Skip to content

Commit e0924e6

Browse files
committed
Minor improvements to names and comments.
1 parent 130a7ed commit e0924e6

File tree

1 file changed

+16
-13
lines changed

1 file changed

+16
-13
lines changed

Objects/obmalloc.c

Lines changed: 16 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1272,7 +1272,7 @@ _Py_GetAllocatedBlocks(void)
12721272
bit allocation for keys
12731273
12741274
64-bit pointers and 2^20 arena size:
1275-
16 -> ignored (BITS - PHYSICAL_BITS)
1275+
16 -> ignored (POINTER_BITS - ADDRESS_BITS)
12761276
10 -> MAP_TOP
12771277
10 -> MAP_MID
12781278
8 -> MAP_BOT
@@ -1291,21 +1291,21 @@ _Py_GetAllocatedBlocks(void)
12911291
#if SIZEOF_VOID_P == 8
12921292

12931293
/* number of bits in a pointer */
1294-
#define BITS 64
1294+
#define POINTER_BITS 64
12951295

12961296
/* Current 64-bit processors are limited to 48-bit physical addresses. For
12971297
* now, the top 17 bits of addresses will all be equal to bit 2**47. If that
12981298
* changes in the future, this must be adjusted upwards.
12991299
*/
1300-
#define PHYSICAL_BITS 48
1300+
#define ADDRESS_BITS 48
13011301

13021302
/* use the top and mid layers of the radix tree */
13031303
#define USE_INTERIOR_NODES
13041304

13051305
#elif SIZEOF_VOID_P == 4
13061306

1307-
#define BITS 32
1308-
#define PHYSICAL_BITS 32
1307+
#define POINTER_BITS 32
1308+
#define ADDRESS_BITS 32
13091309

13101310
#else
13111311

@@ -1321,7 +1321,7 @@ _Py_GetAllocatedBlocks(void)
13211321

13221322
#ifdef USE_INTERIOR_NODES
13231323
/* number of bits used for MAP_TOP and MAP_MID nodes */
1324-
#define INTERIOR_BITS ((PHYSICAL_BITS - ARENA_BITS + 2) / 3)
1324+
#define INTERIOR_BITS ((ADDRESS_BITS - ARENA_BITS + 2) / 3)
13251325
#else
13261326
#define INTERIOR_BITS 0
13271327
#endif
@@ -1334,7 +1334,7 @@ _Py_GetAllocatedBlocks(void)
13341334
#define MAP_MID_LENGTH (1 << MAP_MID_BITS)
13351335
#define MAP_MID_MASK (MAP_MID_LENGTH - 1)
13361336

1337-
#define MAP_BOT_BITS (PHYSICAL_BITS - ARENA_BITS - 2*INTERIOR_BITS)
1337+
#define MAP_BOT_BITS (ADDRESS_BITS - ARENA_BITS - 2*INTERIOR_BITS)
13381338
#define MAP_BOT_LENGTH (1 << MAP_BOT_BITS)
13391339
#define MAP_BOT_MASK (MAP_BOT_LENGTH - 1)
13401340

@@ -1347,10 +1347,13 @@ _Py_GetAllocatedBlocks(void)
13471347
#define MAP_MID_INDEX(p) ((AS_UINT(p) >> MAP_MID_SHIFT) & MAP_MID_MASK)
13481348
#define MAP_TOP_INDEX(p) ((AS_UINT(p) >> MAP_TOP_SHIFT) & MAP_TOP_MASK)
13491349

1350-
#if PHYSICAL_BITS > BITS
1351-
/* Return non-physical bits of pointer. Should be same for all valid
1352-
* pointers if PHYSICAL_BITS set correctly. */
1353-
#define HIGH_BITS(p) (AS_UINT(p) >> PHYSICAL_BITS)
1350+
#if ADDRESS_BITS > POINTER_BITS
1351+
/* Return non-physical address bits of a pointer. Those bits should be same
1352+
* for all valid pointers if ADDRESS_BITS set correctly. Linux has support for
1353+
* 57-bit address space (Intel 5-level paging) but will not currently give
1354+
* those addresses to user space.
1355+
*/
1356+
#define HIGH_BITS(p) (AS_UINT(p) >> ADDRESS_BITS)
13541357
#else
13551358
#define HIGH_BITS(p) 0
13561359
#endif
@@ -1400,7 +1403,7 @@ static arena_map_bot_t *
14001403
arena_map_get(block *p, int create)
14011404
{
14021405
#ifdef USE_INTERIOR_NODES
1403-
/* sanity check that PHYSICAL_BITS is correct */
1406+
/* sanity check that ADDRESS_BITS is correct */
14041407
assert(HIGH_BITS(p) == HIGH_BITS(&arena_map_root));
14051408
int i1 = MAP_TOP_INDEX(p);
14061409
if (arena_map_root.ptrs[i1] == NULL) {
@@ -1460,7 +1463,7 @@ arena_map_get(block *p, int create)
14601463
static int
14611464
arena_map_mark_used(uintptr_t arena_base, int is_used)
14621465
{
1463-
/* sanity check that PHYSICAL_BITS is correct */
1466+
/* sanity check that ADDRESS_BITS is correct */
14641467
assert(HIGH_BITS(arena_base) == HIGH_BITS(&arena_map_root));
14651468
arena_map_bot_t *n_hi = arena_map_get((block *)arena_base, is_used);
14661469
if (n_hi == NULL) {

0 commit comments

Comments
 (0)