diff options
author | Sverker Eriksson <[email protected]> | 2012-11-15 20:24:16 +0100 |
---|---|---|
committer | Sverker Eriksson <[email protected]> | 2012-11-15 20:24:16 +0100 |
commit | 8f1bd655d8bbfc80efb082daca495c19aff02f3d (patch) | |
tree | 89f727c2102c4fd09dbb870c0003cef266ad0946 /erts/emulator | |
parent | 379fc29e02f91193a9bc41454f9bf288ca4a7989 (diff) | |
download | otp-8f1bd655d8bbfc80efb082daca495c19aff02f3d.tar.gz otp-8f1bd655d8bbfc80efb082daca495c19aff02f3d.tar.bz2 otp-8f1bd655d8bbfc80efb082daca495c19aff02f3d.zip |
erts: Enable new header scheme without super alignment on 64-bit
Diffstat (limited to 'erts/emulator')
-rw-r--r-- | erts/emulator/beam/erl_alloc_util.c | 28 | ||||
-rw-r--r-- | erts/emulator/beam/erl_alloc_util.h | 22 |
2 files changed, 29 insertions, 21 deletions
diff --git a/erts/emulator/beam/erl_alloc_util.c b/erts/emulator/beam/erl_alloc_util.c index c0884c0013..cef30d95a2 100644 --- a/erts/emulator/beam/erl_alloc_util.c +++ b/erts/emulator/beam/erl_alloc_util.c @@ -153,7 +153,11 @@ MBC after deallocating first block: #define UNUSED1_BLK_FTR_FLG (((UWord) 1) << 1) #define UNUSED2_BLK_FTR_FLG (((UWord) 1) << 2) -#define ABLK_HDR_SZ (offsetof(Block_t,u)) +#if MBC_ABLK_OFFSET_BITS +# define ABLK_HDR_SZ (offsetof(Block_t,u)) +#else +# define ABLK_HDR_SZ (sizeof(Block_t)) +#endif #define FBLK_FTR_SZ (sizeof(FreeBlkFtr_t)) #define UMEMSZ2BLKSZ(AP, SZ) \ @@ -202,16 +206,16 @@ MBC after deallocating first block: #define SBH_LAST_BLK LAST_BLK_HDR_FLG -#if HAVE_SUPER_ALIGNED_MB_CARRIERS +#if MBC_ABLK_OFFSET_BITS -# define MBC_SZ_MAX_LIMIT ((((UWord)1 << CARRIER_OFFSET_BITS) - 1) << MSEG_ALIGN_BITS) +# define MBC_SZ_MAX_LIMIT ((((UWord)1 << MBC_ABLK_OFFSET_BITS) - 1) << MSEG_ALIGN_BITS) # define BLK_CARRIER_OFFSET(B, C) (((char*)(B) - (char*)(C)) >> MSEG_UNIT_SHIFT) # define SET_MBC_ABLK_HDR(B, Sz, F, C) \ (ASSERT(((Sz) & ~MBC_ABLK_SZ_MASK) == 0), \ ASSERT(!((UWord)(F) & (~FLG_MASK|THIS_FREE_BLK_HDR_FLG))), \ - (B)->bhdr = ((Sz) | (F) | (BLK_CARRIER_OFFSET(B,C) << CARRIER_OFFSET_SHIFT))) + (B)->bhdr = ((Sz) | (F) | (BLK_CARRIER_OFFSET(B,C) << MBC_ABLK_OFFSET_SHIFT))) # define SET_MBC_FBLK_HDR(B, Sz, F, C) \ (ASSERT(((Sz) & ~MBC_FBLK_SZ_MASK) == 0), \ @@ -222,7 +226,7 @@ MBC after deallocating first block: # define ABLK_TO_MBC(B) \ (ASSERT(IS_MBC_BLK(B) && IS_ALLOCED_BLK(B)), \ (Carrier_t*)((MSEG_UNIT_FLOOR((UWord)(B)) - \ - (((B)->bhdr >> CARRIER_OFFSET_SHIFT) << MSEG_UNIT_SHIFT)))) + (((B)->bhdr >> MBC_ABLK_OFFSET_SHIFT) << MSEG_UNIT_SHIFT)))) # define FBLK_TO_MBC(B) \ (ASSERT(IS_MBC_BLK(B) && IS_FREE_BLK(B)), \ @@ -232,7 +236,7 @@ MBC after deallocating first block: # define IS_MBC_FIRST_ABLK(AP,B) \ ((((UWord)(B) & ~MSEG_UNIT_MASK) == (AP)->mbc_header_size) \ - && ((B)->bhdr & CARRIER_OFFSET_MASK) == 0) + && ((B)->bhdr & MBC_ABLK_OFFSET_MASK) == 0) # define IS_MBC_FIRST_FBLK(AP,B) \ ((char*)(B) == (char*)((B)->u.carrier) + (AP)->mbc_header_size) @@ -247,11 +251,11 @@ MBC after deallocating first block: (B)->bhdr &= (MBC_ABLK_SZ_MASK|FLG_MASK)) # define SET_BLK_ALLOCED(B) \ - (ASSERT(((B)->bhdr & (CARRIER_OFFSET_MASK|THIS_FREE_BLK_HDR_FLG)) == THIS_FREE_BLK_HDR_FLG), \ + (ASSERT(((B)->bhdr & (MBC_ABLK_OFFSET_MASK|THIS_FREE_BLK_HDR_FLG)) == THIS_FREE_BLK_HDR_FLG), \ (B)->bhdr &= ~THIS_FREE_BLK_HDR_FLG, \ - (B)->bhdr |= (BLK_CARRIER_OFFSET(B,(B)->u.carrier) << CARRIER_OFFSET_SHIFT)) + (B)->bhdr |= (BLK_CARRIER_OFFSET(B,(B)->u.carrier) << MBC_ABLK_OFFSET_SHIFT)) -#else /* !HAVE_SUPER_ALIGNED_MB_CARRIERS */ +#else /* !MBC_ABLK_OFFSET_BITS */ # define MBC_SZ_MAX_LIMIT ((UWord)~0) @@ -284,7 +288,7 @@ MBC after deallocating first block: # define SET_BLK_ALLOCED(B) \ ((B)->bhdr &= ~THIS_FREE_BLK_HDR_FLG) -#endif /* !HAVE_SUPER_ALIGNED_MB_CARRIERS */ +#endif /* !MBC_ABLK_OFFSET_BITS */ #define SET_SBC_BLK_HDR(B, Sz) \ (ASSERT(((Sz) & FLG_MASK) == 0), (B)->bhdr = ((Sz) | (SBC_BLK_HDR_FLG))) @@ -4158,11 +4162,9 @@ erts_alcu_start(Allctr_t *allctr, AllctrInit_t *init) allctr->ramv = init->ramv; allctr->main_carrier_size = init->mmbcs; allctr->sbc_threshold = init->sbct; -#if HAVE_SUPER_ALIGNED_MB_CARRIERS if (allctr->sbc_threshold > MBC_ABLK_SZ_MASK - ABLK_HDR_SZ) { allctr->sbc_threshold = MBC_ABLK_SZ_MASK - ABLK_HDR_SZ + 1; } -#endif #if HAVE_ERTS_MSEG allctr->mseg_opt.abs_shrink_th = init->asbcst; @@ -4180,11 +4182,9 @@ erts_alcu_start(Allctr_t *allctr, AllctrInit_t *init) #endif allctr->largest_mbc_size = MAX(init->lmbcs, init->smbcs); -#if HAVE_SUPER_ALIGNED_MB_CARRIERS if (allctr->largest_mbc_size > MBC_SZ_MAX_LIMIT) { allctr->largest_mbc_size = MBC_SZ_MAX_LIMIT; } -#endif allctr->smallest_mbc_size = init->smbcs; allctr->mbc_growth_stages = MAX(1, init->mbcgs); diff --git a/erts/emulator/beam/erl_alloc_util.h b/erts/emulator/beam/erl_alloc_util.h index 06a5a5a346..e3dde2d54c 100644 --- a/erts/emulator/beam/erl_alloc_util.h +++ b/erts/emulator/beam/erl_alloc_util.h @@ -222,11 +222,18 @@ erts_aint32_t erts_alcu_fix_alloc_shrink(Allctr_t *, erts_aint32_t); #define CARRIER_SZ_MASK UNIT_MASK -#if HAVE_SUPER_ALIGNED_MB_CARRIERS -# define CARRIER_OFFSET_BITS 13 -# define CARRIER_OFFSET_SHIFT (sizeof(UWord)*8 - CARRIER_OFFSET_BITS) -# define CARRIER_OFFSET_MASK (~((UWord)0) << CARRIER_OFFSET_SHIFT) -# define MBC_ABLK_SZ_MASK (~CARRIER_OFFSET_MASK & ~FLG_MASK) +#ifdef ARCH_64 +# define MBC_ABLK_OFFSET_BITS 24 +#elif HAVE_SUPER_ALIGNED_MB_CARRIERS +# define MBC_ABLK_OFFSET_BITS 13 +#else +# define MBC_ABLK_OFFSET_BITS 0 /* no carrier offset in block header */ +#endif + +#if MBC_ABLK_OFFSET_BITS +# define MBC_ABLK_OFFSET_SHIFT (sizeof(UWord)*8 - MBC_ABLK_OFFSET_BITS) +# define MBC_ABLK_OFFSET_MASK (~((UWord)0) << MBC_ABLK_OFFSET_SHIFT) +# define MBC_ABLK_SZ_MASK (~MBC_ABLK_OFFSET_MASK & ~FLG_MASK) #else # define MBC_ABLK_SZ_MASK (~FLG_MASK) #endif @@ -257,13 +264,14 @@ typedef struct { typedef struct { UWord bhdr; -#if !HAVE_SUPER_ALIGNED_MB_CARRIERS +#if !MBC_ABLK_OFFSET_BITS Carrier_t *carrier; -#endif +#else union { Carrier_t *carrier; /* if free */ char udata__[1]; /* if allocated */ }u; +#endif } Block_t; typedef UWord FreeBlkFtr_t; /* Footer of a free block */ |