Skip to content

Commit 52c670f

Browse files
committed
Move static map ptr number to pointer computation into macro
Signed-off-by: Bob Weinand <bobwei9@hotmail.com>
1 parent 4e110f2 commit 52c670f

File tree

2 files changed

+4
-3
lines changed

2 files changed

+4
-3
lines changed

Zend/zend_map_ptr.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,9 @@ typedef struct _zend_string zend_string;
7070
} while (0)
7171
# define ZEND_MAP_PTR_BIASED_BASE(real_base) \
7272
((void*)(((uintptr_t)(real_base)) + zend_map_ptr_static_size * sizeof(void *) - 1))
73+
// Note: chunked like: [8192..12287][4096..8191][0..4095]
74+
#define ZEND_MAP_PTR_STATIC_NUM_TO_PTR(num) \
75+
((void **)CG(map_ptr_real_base) + zend_map_ptr_static_size - ZEND_MM_ALIGNED_SIZE_EX((num) + 1, 4096) + ((num) & 4095))
7376
#else
7477
# error "Unknown ZEND_MAP_PTR_KIND"
7578
#endif

ext/opcache/ZendAccelerator.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4389,9 +4389,7 @@ static void preload_load(size_t orig_map_ptr_static_last)
43894389
ZCG(preloaded_internal_run_time_cache) = cache;
43904390

43914391
for (size_t cur_static_map_ptr = orig_map_ptr_static_last; cur_static_map_ptr < zend_map_ptr_static_last; ++cur_static_map_ptr) {
4392-
// Note: chunked like: [8192..12287][4096..8191][0..4095]
4393-
void **ptr = (void **) CG(map_ptr_real_base) + zend_map_ptr_static_size - ZEND_MM_ALIGNED_SIZE_EX(cur_static_map_ptr + 1, 4096) + (cur_static_map_ptr & 4095);
4394-
*ptr = cache;
4392+
*ZEND_MAP_PTR_STATIC_NUM_TO_PTR(cur_static_map_ptr) = cache;
43954393
cache += runtime_cache_size;
43964394
}
43974395
}

0 commit comments

Comments
 (0)