[Git][ghc/ghc][wip/libffi-3.4.7] 3 commits: compiler: use fromAscList when applicable

Cheng Shao (@TerrorJack) gitlab at gitlab.haskell.org
Sat Feb 22 03:01:39 UTC 2025



Cheng Shao pushed to branch wip/libffi-3.4.7 at Glasgow Haskell Compiler / GHC


Commits:
1c8e608a by Cheng Shao at 2025-02-21T20:18:41-05:00
compiler: use fromAscList when applicable

This patch uses fromAscList (with O(n) complexity) instead of fromList
(with O(nlogn) complexity) in certain Binary instances. It's safe to
do so since the corresponding serialization logic is based on toList
(same as toAscList).

- - - - -
549e0aff by Ben Gamari at 2025-02-21T20:19:18-05:00
rts/linker/MachO: Mark internal symbols as static

There is no reason why these should have external linkage.

- - - - -
d5756e13 by Cheng Shao at 2025-02-22T03:01:28+00:00
libffi: update to 3.4.7

Bumps libffi submodule.

- - - - -


3 changed files:

- compiler/GHC/Utils/Binary.hs
- libffi-tarballs
- rts/linker/MachO.c


Changes:

=====================================
compiler/GHC/Utils/Binary.hs
=====================================
@@ -940,8 +940,8 @@ instance Binary a => Binary [a] where
 -- | This instance doesn't rely on the determinism of the keys' 'Ord' instance,
 -- so it works e.g. for 'Name's too.
 instance (Binary a, Ord a) => Binary (Set a) where
-  put_ bh s = put_ bh (Set.toList s)
-  get bh = Set.fromList <$> get bh
+  put_ bh s = put_ bh (Set.toAscList s)
+  get bh = Set.fromAscList <$> get bh
 
 instance Binary a => Binary (NonEmpty a) where
     put_ bh = put_ bh . NonEmpty.toList
@@ -2086,5 +2086,5 @@ source location as part of a larger structure.
 --------------------------------------------------------------------------------
 
 instance (Binary v) => Binary (IntMap v) where
-  put_ bh m = put_ bh (IntMap.toList m)
-  get bh = IntMap.fromList <$> get bh
+  put_ bh m = put_ bh (IntMap.toAscList m)
+  get bh = IntMap.fromAscList <$> get bh


=====================================
libffi-tarballs
=====================================
@@ -1 +1 @@
-Subproject commit 89a9b01c5647c8f0d3899435b99df690f582e9f1
+Subproject commit cb280851187d7b509d341be7b50c9a239810feb0


=====================================
rts/linker/MachO.c
=====================================
@@ -51,7 +51,7 @@
 /* often times we need to extend some value of certain number of bits
  * int an int64_t for e.g. relative offsets.
  */
-int64_t signExtend(uint64_t val, uint8_t bits);
+static int64_t signExtend(uint64_t val, uint8_t bits);
 /* Helper functions to check some instruction properties */
 static bool isVectorOp(uint32_t *p);
 static bool isLoadStore(uint32_t *p);
@@ -60,17 +60,17 @@ static bool isLoadStore(uint32_t *p);
  * where we want to write the address offset to. Thus decoding as well
  * as encoding is needed.
  */
-bool fitsBits(size_t bits, int64_t value);
-int64_t decodeAddend(ObjectCode * oc, Section * section,
+static bool fitsBits(size_t bits, int64_t value);
+static int64_t decodeAddend(ObjectCode * oc, Section * section,
                      MachORelocationInfo * ri);
-void encodeAddend(ObjectCode * oc, Section * section,
+static void encodeAddend(ObjectCode * oc, Section * section,
                   MachORelocationInfo * ri, int64_t addend);
 
 /* Global Offset Table logic */
-bool isGotLoad(MachORelocationInfo * ri);
-bool needGotSlot(MachONList * symbol);
-bool makeGot(ObjectCode * oc);
-void freeGot(ObjectCode * oc);
+static bool isGotLoad(MachORelocationInfo * ri);
+static bool needGotSlot(MachONList * symbol);
+static bool makeGot(ObjectCode * oc);
+static void freeGot(ObjectCode * oc);
 #endif /* aarch64_HOST_ARCH */
 
 /*
@@ -265,7 +265,7 @@ resolveImports(
 #if defined(aarch64_HOST_ARCH)
 /* aarch64 linker by moritz angermann <moritz at lichtzwerge.de> */
 
-int64_t
+static int64_t
 signExtend(uint64_t val, uint8_t bits) {
     return (int64_t)(val << (64-bits)) >> (64-bits);
 }
@@ -280,7 +280,7 @@ isLoadStore(uint32_t *p) {
     return (*p & 0x3B000000) == 0x39000000;
 }
 
-int64_t
+static int64_t
 decodeAddend(ObjectCode * oc, Section * section, MachORelocationInfo * ri) {
 
     /* the instruction. It is 32bit wide */
@@ -350,7 +350,7 @@ decodeAddend(ObjectCode * oc, Section * section, MachORelocationInfo * ri) {
     barf("unsupported relocation type: %d\n", ri->r_type);
 }
 
-inline bool
+inline static bool
 fitsBits(size_t bits, int64_t value) {
     if(bits == 64) return true;
     if(bits > 64) barf("fits_bits with %zu bits and an 64bit integer!", bits);
@@ -358,7 +358,7 @@ fitsBits(size_t bits, int64_t value) {
         || -1 == (value >> bits);  // All bits on: -1
 }
 
-void
+static void
 encodeAddend(ObjectCode * oc, Section * section,
              MachORelocationInfo * ri, int64_t addend) {
     uint32_t * p = (uint32_t*)((uint8_t*)section->start + ri->r_address);
@@ -440,7 +440,7 @@ encodeAddend(ObjectCode * oc, Section * section,
     barf("unsupported relocation type: %d\n", ri->r_type);
 }
 
-bool
+static bool
 isGotLoad(struct relocation_info * ri) {
     return ri->r_type == ARM64_RELOC_GOT_LOAD_PAGE21
     ||  ri->r_type == ARM64_RELOC_GOT_LOAD_PAGEOFF12;
@@ -450,7 +450,7 @@ isGotLoad(struct relocation_info * ri) {
  * Check if we need a global offset table slot for a
  * given symbol
  */
-bool
+static bool
 needGotSlot(MachONList * symbol) {
     return (symbol->n_type & N_EXT)             /* is an external symbol      */
         && (N_UNDF == (symbol->n_type & N_TYPE) /* and is undefined           */
@@ -458,7 +458,7 @@ needGotSlot(MachONList * symbol) {
                                                  *        different section   */
 }
 
-bool
+static bool
 makeGot(ObjectCode * oc) {
     size_t got_slots = 0;
 
@@ -484,7 +484,7 @@ makeGot(ObjectCode * oc) {
     return EXIT_SUCCESS;
 }
 
-void
+static void
 freeGot(ObjectCode * oc) {
     /* sanity check */
     if(NULL != oc->info->got_start && oc->info->got_size > 0) {



View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9c66011edd4d8dd86baa79c1a38e40a75674987d...d5756e1309477bef1b52ab6ec8c0696bb5e52cee

-- 
View it on GitLab: https://gitlab.haskell.org/ghc/ghc/-/compare/9c66011edd4d8dd86baa79c1a38e40a75674987d...d5756e1309477bef1b52ab6ec8c0696bb5e52cee
You're receiving this email because of your account on gitlab.haskell.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.haskell.org/pipermail/ghc-commits/attachments/20250221/9ded1d42/attachment-0001.html>


More information about the ghc-commits mailing list