Skip to content

Commit

Permalink
JIT: Split zend_jit_hash_index_lookup_rw() into zend_jit_hash_index_l…
Browse files Browse the repository at this point in the history
…ookup_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.
  • Loading branch information
dstogov committed Sep 27, 2021
1 parent 9ce388b commit 325865d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions ext/opcache/jit/zend_jit_disasm_x86.c
Original file line number Diff line number Diff line change
Expand Up @@ -411,6 +411,7 @@ static int zend_jit_disasm_init(void)
REGISTER_HELPER(zend_jit_leave_top_func_helper);
REGISTER_HELPER(zend_jit_leave_func_helper);
REGISTER_HELPER(zend_jit_symtable_find);
REGISTER_HELPER(zend_jit_hash_index_lookup_rw_no_packed);
REGISTER_HELPER(zend_jit_hash_index_lookup_rw);
REGISTER_HELPER(zend_jit_hash_index_lookup_w);
REGISTER_HELPER(zend_jit_hash_lookup_rw);
Expand Down
15 changes: 14 additions & 1 deletion ext/opcache/jit/zend_jit_helpers.c
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ static zval* ZEND_FASTCALL zend_jit_symtable_find(HashTable *ht, zend_string *st
return zend_hash_find(ht, str);
}

static zval* ZEND_FASTCALL zend_jit_hash_index_lookup_rw(HashTable *ht, zend_long idx)
static zval* ZEND_FASTCALL zend_jit_hash_index_lookup_rw_no_packed(HashTable *ht, zend_long idx)
{
zval *retval = _zend_hash_index_find(ht, idx);

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

static zval* ZEND_FASTCALL zend_jit_hash_index_lookup_rw(HashTable *ht, zend_long idx)
{
zval *retval = zend_hash_index_find(ht, idx);

if (!retval) {
if (UNEXPECTED(zend_undefined_offset_write(ht, idx) == FAILURE)) {
return NULL;
}
retval = zend_hash_index_add_new(ht, idx, &EG(uninitialized_zval));
}
return retval;
}

static zval* ZEND_FASTCALL zend_jit_hash_index_lookup_w(HashTable *ht, zend_long idx)
{
zval *retval = _zend_hash_index_find(ht, idx);
Expand Down
6 changes: 5 additions & 1 deletion ext/opcache/jit/zend_jit_x86.dasc
Original file line number Diff line number Diff line change
Expand Up @@ -5569,7 +5569,11 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o
| GET_ZVAL_LVAL ZREG_FCARG2a, op2_addr
}
| SET_EX_OPLINE opline, r0
| EXT_CALL zend_jit_hash_index_lookup_rw, r0
if (packed_loaded) {
| EXT_CALL zend_jit_hash_index_lookup_rw_no_packed, r0
} else {
| EXT_CALL zend_jit_hash_index_lookup_rw, r0
}
| test r0, r0
| jz >9
break;
Expand Down

0 comments on commit 325865d

Please sign in to comment.