Skip to content

Commit 325865d

Browse files
committed
JIT: Split zend_jit_hash_index_lookup_rw() into zend_jit_hash_index_lookup_rw() and zend_jit_hash_index_lookup_rw_no_packed().
The previous version might fail if zend_jit_hash_index_lookup_rw() was called for packed array.
1 parent 9ce388b commit 325865d

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

ext/opcache/jit/zend_jit_disasm_x86.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,7 @@ static int zend_jit_disasm_init(void)
411411
REGISTER_HELPER(zend_jit_leave_top_func_helper);
412412
REGISTER_HELPER(zend_jit_leave_func_helper);
413413
REGISTER_HELPER(zend_jit_symtable_find);
414+
REGISTER_HELPER(zend_jit_hash_index_lookup_rw_no_packed);
414415
REGISTER_HELPER(zend_jit_hash_index_lookup_rw);
415416
REGISTER_HELPER(zend_jit_hash_index_lookup_w);
416417
REGISTER_HELPER(zend_jit_hash_lookup_rw);

ext/opcache/jit/zend_jit_helpers.c

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ static zval* ZEND_FASTCALL zend_jit_symtable_find(HashTable *ht, zend_string *st
246246
return zend_hash_find(ht, str);
247247
}
248248

249-
static zval* ZEND_FASTCALL zend_jit_hash_index_lookup_rw(HashTable *ht, zend_long idx)
249+
static zval* ZEND_FASTCALL zend_jit_hash_index_lookup_rw_no_packed(HashTable *ht, zend_long idx)
250250
{
251251
zval *retval = _zend_hash_index_find(ht, idx);
252252

@@ -259,6 +259,19 @@ static zval* ZEND_FASTCALL zend_jit_hash_index_lookup_rw(HashTable *ht, zend_lon
259259
return retval;
260260
}
261261

262+
static zval* ZEND_FASTCALL zend_jit_hash_index_lookup_rw(HashTable *ht, zend_long idx)
263+
{
264+
zval *retval = zend_hash_index_find(ht, idx);
265+
266+
if (!retval) {
267+
if (UNEXPECTED(zend_undefined_offset_write(ht, idx) == FAILURE)) {
268+
return NULL;
269+
}
270+
retval = zend_hash_index_add_new(ht, idx, &EG(uninitialized_zval));
271+
}
272+
return retval;
273+
}
274+
262275
static zval* ZEND_FASTCALL zend_jit_hash_index_lookup_w(HashTable *ht, zend_long idx)
263276
{
264277
zval *retval = _zend_hash_index_find(ht, idx);

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5569,7 +5569,11 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o
55695569
| GET_ZVAL_LVAL ZREG_FCARG2a, op2_addr
55705570
}
55715571
| SET_EX_OPLINE opline, r0
5572-
| EXT_CALL zend_jit_hash_index_lookup_rw, r0
5572+
if (packed_loaded) {
5573+
| EXT_CALL zend_jit_hash_index_lookup_rw_no_packed, r0
5574+
} else {
5575+
| EXT_CALL zend_jit_hash_index_lookup_rw, r0
5576+
}
55735577
| test r0, r0
55745578
| jz >9
55755579
break;

0 commit comments

Comments
 (0)