Skip to content

Commit baaa731

Browse files
committed
x86 JIT support
1 parent c34eb6c commit baaa731

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
@@ -68,7 +68,7 @@ ZEND_API ZEND_COLD void zend_throw_ref_type_error_type(zend_property_info *prop1
6868
ZEND_API ZEND_COLD zval* ZEND_FASTCALL zend_undefined_offset_write(HashTable *ht, zend_long lval);
6969
ZEND_API ZEND_COLD zval* ZEND_FASTCALL zend_undefined_index_write(HashTable *ht, zend_string *offset);
7070

71-
ZEND_COLD zend_never_inline void zend_readonly_property_modification_error(zend_property_info *info);
71+
ZEND_API ZEND_COLD void ZEND_FASTCALL zend_readonly_property_modification_error(zend_property_info *info);
7272

7373
ZEND_API bool zend_verify_scalar_type_hint(uint32_t type_mask, zval *arg, bool strict, bool is_internal_arg);
7474
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
@@ -1968,6 +1968,14 @@ static void ZEND_FASTCALL zend_jit_assign_to_typed_prop(zval *property_val, zend
19681968
zend_execute_data *execute_data = EG(current_execute_data);
19691969
zval tmp;
19701970

1971+
if (UNEXPECTED(info->flags & ZEND_ACC_READONLY)) {
1972+
zend_readonly_property_modification_error(info);
1973+
if (result) {
1974+
ZVAL_UNDEF(result);
1975+
}
1976+
return;
1977+
}
1978+
19711979
ZVAL_DEREF(value);
19721980
ZVAL_COPY(&tmp, value);
19731981

ext/opcache/jit/zend_jit_x86.dasc

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12508,7 +12508,6 @@ static int zend_jit_fetch_obj(dasm_State **Dst,
1250812508
| add FCARG1a, r0
1250912509
prop_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FCARG1a, 0);
1251012510
if (opline->opcode == ZEND_FETCH_OBJ_W
12511-
&& (opline->extended_value & ZEND_FETCH_OBJ_FLAGS)
1251212511
&& (!ce || ce_is_instanceof || (ce->ce_flags & ZEND_ACC_HAS_TYPE_HINTS))) {
1251312512
uint32_t flags = opline->extended_value & ZEND_FETCH_OBJ_FLAGS;
1251412513

@@ -12518,6 +12517,13 @@ static int zend_jit_fetch_obj(dasm_State **Dst,
1251812517
| jnz >1
1251912518
|.cold_code
1252012519
|1:
12520+
| test dword [FCARG2a + offsetof(zend_property_info, flags)], ZEND_ACC_READONLY
12521+
| jz >2
12522+
| IF_Z_TYPE FCARG1a, IS_OBJECT, >2
12523+
| mov FCARG1a, FCARG2a
12524+
| EXT_CALL zend_readonly_property_modification_error, r0
12525+
| jmp >9
12526+
|2:
1252112527
if (flags == ZEND_FETCH_DIM_WRITE) {
1252212528
| SET_EX_OPLINE opline, r0
1252312529
| EXT_CALL zend_jit_check_array_promotion, r0
@@ -12535,7 +12541,7 @@ static int zend_jit_fetch_obj(dasm_State **Dst,
1253512541
|.endif
1253612542
| jmp >9
1253712543
} else {
12538-
ZEND_UNREACHABLE();
12544+
ZEND_ASSERT(flags == 0);
1253912545
}
1254012546
|.code
1254112547
}
@@ -12556,6 +12562,15 @@ static int zend_jit_fetch_obj(dasm_State **Dst,
1255612562
} else {
1255712563
| IF_UNDEF dl, >5
1255812564
}
12565+
if (opline->opcode == ZEND_FETCH_OBJ_W && (prop_info->flags & ZEND_ACC_READONLY)) {
12566+
| IF_NOT_TYPE dl, IS_OBJECT, >4
12567+
|.cold_code
12568+
|4:
12569+
| LOAD_ADDR FCARG1a, prop_info
12570+
| EXT_CALL zend_readonly_property_modification_error, r0
12571+
| jmp >9
12572+
|.code
12573+
}
1255912574
if (opline->opcode == ZEND_FETCH_OBJ_W
1256012575
&& (opline->extended_value & ZEND_FETCH_OBJ_FLAGS)
1256112576
&& ZEND_TYPE_IS_SET(prop_info->type)) {
@@ -13674,7 +13689,7 @@ static int zend_jit_assign_obj(dasm_State **Dst,
1367413689
}
1367513690
} else {
1367613691
prop_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FCARG1a, prop_info->offset);
13677-
if (!ce || ce_is_instanceof || !(ce->ce_flags & ZEND_ACC_IMMUTABLE) || ce->__get || ce->__set) {
13692+
if (!ce || ce_is_instanceof || !(ce->ce_flags & ZEND_ACC_IMMUTABLE) || ce->__get || ce->__set || (prop_info->flags & ZEND_ACC_READONLY)) {
1367813693
// Undefined property with magic __get()/__set()
1367913694
if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) {
1368013695
int32_t exit_point = zend_jit_trace_get_exit_point(opline, ZEND_JIT_EXIT_TO_VM);

0 commit comments

Comments
 (0)