Skip to content

Commit daee985

Browse files
committed
Fixed JIT for BIND_GLOBAL
1 parent fe7761b commit daee985

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

ext/opcache/jit/zend_jit_helpers.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1118,11 +1118,11 @@ static zval* ZEND_FASTCALL zend_jit_fetch_global_helper(zend_execute_data *execu
11181118

11191119
if (UNEXPECTED(value == NULL)) {
11201120
value = zend_hash_add_new(&EG(symbol_table), Z_STR_P(varname), &EG(uninitialized_zval));
1121-
idx = ((char*)value - (char*)EG(symbol_table).arData) / sizeof(Bucket);
1121+
idx = (char*)value - (char*)EG(symbol_table).arData;
11221122
/* Store "hash slot index" + 1 (NULL is a mark of uninitialized cache slot) */
11231123
CACHE_PTR(cache_slot, (void*)(uintptr_t)(idx + 1));
11241124
} else {
1125-
idx = ((char*)value - (char*)EG(symbol_table).arData) / sizeof(Bucket);
1125+
idx = (char*)value - (char*)EG(symbol_table).arData;
11261126
/* Store "hash slot index" + 1 (NULL is a mark of uninitialized cache slot) */
11271127
CACHE_PTR(cache_slot, (void*)(uintptr_t)(idx + 1));
11281128
/* GLOBAL variable may be an INDIRECT pointer to CV */

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8462,15 +8462,17 @@ static int zend_jit_bind_global(dasm_State **Dst, const zend_op *opline, const z
84628462
| mov r0, EX->run_time_cache
84638463
| mov r0, aword [r0 + opline->extended_value]
84648464
| sub r0, 1
8465-
//if (EXPECTED(idx < EG(symbol_table).nNumUsed))
8466-
| MEM_OP2_2_ZTS cmp, eax, dword, executor_globals, symbol_table.nNumUsed, r1
8467-
| jae >9
8468-
//Bucket *p = EG(symbol_table).arData + idx;
8465+
//if (EXPECTED(idx < EG(symbol_table).nNumUsed * sizeof(Bucket)))
84698466
|.if X64
8470-
| shl r0, 5
8467+
| MEM_OP2_2_ZTS movsxd, r1, dword, executor_globals, symbol_table.nNumUsed, r1
8468+
| shl r1, 5
84718469
|.else
8472-
| imul r0, sizeof(Bucket)
8470+
| MEM_OP2_2_ZTS mov, r1, dword, executor_globals, symbol_table.nNumUsed, r1
8471+
| imul r1, sizeof(Bucket)
84738472
|.endif
8473+
| cmp r0, r1
8474+
| jae >9
8475+
//Bucket *p = (Bucket*)((char*)EG(symbol_table).arData + idx);
84748476
| MEM_OP2_2_ZTS add, r0, aword, executor_globals, symbol_table.arData, r1
84758477
| IF_Z_TYPE r0, IS_UNDEF, >9
84768478
// (EXPECTED(p->key == Z_STR_P(varname))

0 commit comments

Comments
 (0)