Skip to content

Commit b5c4ea9

Browse files
committed
x86 JIT support
1 parent f51375b commit b5c4ea9

File tree

4 files changed

+28
-5
lines changed

4 files changed

+28
-5
lines changed

Zend/zend_execute.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -823,7 +823,7 @@ ZEND_COLD zend_never_inline void zend_verify_property_type_error(zend_property_i
823823
zend_string_release(type_str);
824824
}
825825

826-
ZEND_COLD zend_never_inline void zend_readonly_property_modification_error(
826+
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_readonly_property_modification_error(
827827
zend_property_info *info) {
828828
zend_throw_error(NULL, "Cannot modify readonly property %s::$%s",
829829
ZSTR_VAL(info->ce->name), zend_get_unmangled_property_name(info->name));

Zend/zend_execute.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ ZEND_API ZEND_COLD void zend_throw_ref_type_error_type(zend_property_info *prop1
6969
ZEND_API ZEND_COLD zval* ZEND_FASTCALL zend_undefined_offset_write(HashTable *ht, zend_long lval);
7070
ZEND_API ZEND_COLD zval* ZEND_FASTCALL zend_undefined_index_write(HashTable *ht, zend_string *offset);
7171

72-
ZEND_COLD zend_never_inline void zend_readonly_property_modification_error(zend_property_info *info);
72+
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_readonly_property_modification_error(zend_property_info *info);
7373

7474
ZEND_API bool zend_verify_scalar_type_hint(uint32_t type_mask, zval *arg, bool strict, bool is_internal_arg);
7575
ZEND_API ZEND_COLD void zend_verify_arg_error(

ext/opcache/jit/zend_jit_helpers.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2006,6 +2006,14 @@ static void ZEND_FASTCALL zend_jit_assign_to_typed_prop(zval *property_val, zend
20062006
zend_execute_data *execute_data = EG(current_execute_data);
20072007
zval tmp;
20082008

2009+
if (UNEXPECTED(info->flags & ZEND_ACC_READONLY)) {
2010+
zend_readonly_property_modification_error(info);
2011+
if (result) {
2012+
ZVAL_UNDEF(result);
2013+
}
2014+
return;
2015+
}
2016+
20092017
ZVAL_DEREF(value);
20102018
ZVAL_COPY(&tmp, value);
20112019

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12511,7 +12511,6 @@ static int zend_jit_fetch_obj(dasm_State **Dst,
1251112511
| add FCARG1a, r0
1251212512
prop_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FCARG1a, 0);
1251312513
if (opline->opcode == ZEND_FETCH_OBJ_W
12514-
&& (opline->extended_value & ZEND_FETCH_OBJ_FLAGS)
1251512514
&& (!ce || ce_is_instanceof || (ce->ce_flags & ZEND_ACC_HAS_TYPE_HINTS))) {
1251612515
uint32_t flags = opline->extended_value & ZEND_FETCH_OBJ_FLAGS;
1251712516

@@ -12521,6 +12520,13 @@ static int zend_jit_fetch_obj(dasm_State **Dst,
1252112520
| jnz >1
1252212521
|.cold_code
1252312522
|1:
12523+
| test dword [FCARG2a + offsetof(zend_property_info, flags)], ZEND_ACC_READONLY
12524+
| jz >2
12525+
| IF_Z_TYPE FCARG1a, IS_OBJECT, >2
12526+
| mov FCARG1a, FCARG2a
12527+
| EXT_CALL zend_readonly_property_modification_error, r0
12528+
| jmp >9
12529+
|2:
1252412530
if (flags == ZEND_FETCH_DIM_WRITE) {
1252512531
| SET_EX_OPLINE opline, r0
1252612532
| EXT_CALL zend_jit_check_array_promotion, r0
@@ -12538,7 +12544,7 @@ static int zend_jit_fetch_obj(dasm_State **Dst,
1253812544
|.endif
1253912545
| jmp >9
1254012546
} else {
12541-
ZEND_UNREACHABLE();
12547+
ZEND_ASSERT(flags == 0);
1254212548
}
1254312549
|.code
1254412550
}
@@ -12559,6 +12565,15 @@ static int zend_jit_fetch_obj(dasm_State **Dst,
1255912565
} else {
1256012566
| IF_UNDEF dl, >5
1256112567
}
12568+
if (opline->opcode == ZEND_FETCH_OBJ_W && (prop_info->flags & ZEND_ACC_READONLY)) {
12569+
| IF_NOT_TYPE dl, IS_OBJECT, >4
12570+
|.cold_code
12571+
|4:
12572+
| LOAD_ADDR FCARG1a, prop_info
12573+
| EXT_CALL zend_readonly_property_modification_error, r0
12574+
| jmp >9
12575+
|.code
12576+
}
1256212577
if (opline->opcode == ZEND_FETCH_OBJ_W
1256312578
&& (opline->extended_value & ZEND_FETCH_OBJ_FLAGS)
1256412579
&& ZEND_TYPE_IS_SET(prop_info->type)) {
@@ -13677,7 +13692,7 @@ static int zend_jit_assign_obj(dasm_State **Dst,
1367713692
}
1367813693
} else {
1367913694
prop_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FCARG1a, prop_info->offset);
13680-
if (!ce || ce_is_instanceof || !(ce->ce_flags & ZEND_ACC_IMMUTABLE) || ce->__get || ce->__set) {
13695+
if (!ce || ce_is_instanceof || !(ce->ce_flags & ZEND_ACC_IMMUTABLE) || ce->__get || ce->__set || (prop_info->flags & ZEND_ACC_READONLY)) {
1368113696
// Undefined property with magic __get()/__set()
1368213697
if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) {
1368313698
int32_t exit_point = zend_jit_trace_get_exit_point(opline, ZEND_JIT_EXIT_TO_VM);

0 commit comments

Comments
 (0)