summaryrefslogtreecommitdiff
path: root/ext
diff options
context:
space:
mode:
authorNikita Popov <nikita.ppv@gmail.com>2020-07-07 15:09:12 +0200
committerNikita Popov <nikita.ppv@gmail.com>2020-07-07 15:13:03 +0200
commitcdc4ea2a5c1dbcdf8e8c885152b783d039e01b53 (patch)
treeae098ef0bb691547bb54647604ff6d22a8251651 /ext
parentf497b699448ba16c63903c75d4eee9682ff0099a (diff)
downloadphp-git-cdc4ea2a5c1dbcdf8e8c885152b783d039e01b53.tar.gz
JIT support for undefined index/offset handling
Diffstat (limited to 'ext')
-rw-r--r--ext/opcache/jit/zend_jit_helpers.c46
-rw-r--r--ext/opcache/jit/zend_jit_x86.dasc4
2 files changed, 36 insertions, 14 deletions
diff --git a/ext/opcache/jit/zend_jit_helpers.c b/ext/opcache/jit/zend_jit_helpers.c
index 3d40e745d1..c0fa257ed9 100644
--- a/ext/opcache/jit/zend_jit_helpers.c
+++ b/ext/opcache/jit/zend_jit_helpers.c
@@ -129,8 +129,10 @@ static zval* ZEND_FASTCALL zend_jit_hash_index_lookup_rw(HashTable *ht, zend_lon
zval *retval = _zend_hash_index_find(ht, idx);
if (!retval) {
- zend_error(E_NOTICE,"Undefined offset: " ZEND_LONG_FMT, idx);
- retval = zend_hash_index_update(ht, idx, &EG(uninitialized_zval));
+ if (UNEXPECTED(zend_undefined_offset_write(ht, idx) == FAILURE)) {
+ return NULL;
+ }
+ retval = zend_hash_index_add_new(ht, idx, &EG(uninitialized_zval));
}
return retval;
}
@@ -153,12 +155,16 @@ static zval* ZEND_FASTCALL zend_jit_hash_lookup_rw(HashTable *ht, zend_string *s
if (UNEXPECTED(Z_TYPE_P(retval) == IS_INDIRECT)) {
retval = Z_INDIRECT_P(retval);
if (UNEXPECTED(Z_TYPE_P(retval) == IS_UNDEF)) {
- zend_error(E_NOTICE,"Undefined index: %s", ZSTR_VAL(str));
+ if (UNEXPECTED(zend_undefined_index_write(ht, str) == FAILURE)) {
+ return NULL;
+ }
ZVAL_NULL(retval);
}
}
} else {
- zend_error(E_NOTICE,"Undefined index: %s", ZSTR_VAL(str));
+ if (UNEXPECTED(zend_undefined_index_write(ht, str) == FAILURE)) {
+ return NULL;
+ }
retval = zend_hash_update(ht, str, &EG(uninitialized_zval));
}
return retval;
@@ -202,8 +208,10 @@ static zval* ZEND_FASTCALL zend_jit_symtable_lookup_rw(HashTable *ht, zend_strin
if (_zend_handle_numeric_str_ex(str->val, str->len, &idx)) {
retval = zend_hash_index_find(ht, idx);
if (!retval) {
- zend_error(E_NOTICE,"Undefined index: %s", ZSTR_VAL(str));
- retval = zend_hash_index_update(ht, idx, &EG(uninitialized_zval));
+ if (UNEXPECTED(zend_undefined_index_write(ht, str) == FAILURE)) {
+ return NULL;
+ }
+ retval = zend_hash_index_add_new(ht, idx, &EG(uninitialized_zval));
}
return retval;
}
@@ -214,13 +222,17 @@ static zval* ZEND_FASTCALL zend_jit_symtable_lookup_rw(HashTable *ht, zend_strin
if (UNEXPECTED(Z_TYPE_P(retval) == IS_INDIRECT)) {
retval = Z_INDIRECT_P(retval);
if (UNEXPECTED(Z_TYPE_P(retval) == IS_UNDEF)) {
- zend_error(E_NOTICE,"Undefined index: %s", ZSTR_VAL(str));
+ if (UNEXPECTED(zend_undefined_index_write(ht, str) == FAILURE)) {
+ return NULL;
+ }
ZVAL_NULL(retval);
}
}
} else {
- zend_error(E_NOTICE,"Undefined index: %s", ZSTR_VAL(str));
- retval = zend_hash_update(ht, str, &EG(uninitialized_zval));
+ if (UNEXPECTED(zend_undefined_index_write(ht, str) == FAILURE)) {
+ return NULL;
+ }
+ retval = zend_hash_add_new(ht, str, &EG(uninitialized_zval));
}
return retval;
}
@@ -531,13 +543,17 @@ str_index:
if (UNEXPECTED(Z_TYPE_P(retval) == IS_INDIRECT)) {
retval = Z_INDIRECT_P(retval);
if (UNEXPECTED(Z_TYPE_P(retval) == IS_UNDEF)) {
- zend_error(E_NOTICE, "Undefined index: %s", ZSTR_VAL(offset_key));
+ if (UNEXPECTED(zend_undefined_index_write(ht, offset_key) == FAILURE)) {
+ return NULL;
+ }
ZVAL_NULL(retval);
}
}
} else {
- zend_error(E_NOTICE, "Undefined index: %s", ZSTR_VAL(offset_key));
- retval = zend_hash_update(ht, offset_key, &EG(uninitialized_zval));
+ if (UNEXPECTED(zend_undefined_index_write(ht, offset_key) == FAILURE)) {
+ return NULL;
+ }
+ retval = zend_hash_add_new(ht, offset_key, &EG(uninitialized_zval));
}
return retval;
@@ -546,8 +562,10 @@ num_index:
return retval;
num_undef:
- zend_error(E_NOTICE,"Undefined offset: " ZEND_LONG_FMT, hval);
- retval = zend_hash_index_update(ht, hval, &EG(uninitialized_zval));
+ if (UNEXPECTED(zend_undefined_offset_write(ht, hval) == FAILURE)) {
+ return NULL;
+ }
+ retval = zend_hash_index_add_new(ht, hval, &EG(uninitialized_zval));
return retval;
}
diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc
index feabefba4d..b9066f465d 100644
--- a/ext/opcache/jit/zend_jit_x86.dasc
+++ b/ext/opcache/jit/zend_jit_x86.dasc
@@ -4976,6 +4976,8 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o
|4:
| SAVE_VALID_OPLINE opline, r0
| EXT_CALL zend_jit_hash_index_lookup_rw, r0
+ | test r0, r0
+ | jz >9
}
break;
case BP_VAR_W:
@@ -5099,6 +5101,8 @@ static int zend_jit_fetch_dimension_address_inner(dasm_State **Dst, const zend_o
} else {
| EXT_CALL zend_jit_hash_lookup_rw, r0
}
+ | test r0, r0
+ | jz >9
break;
case BP_VAR_W:
if (opline->op2_type != IS_CONST) {