summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry Stogov <dmitry@zend.com>2020-09-14 22:26:34 +0300
committerDmitry Stogov <dmitry@zend.com>2020-09-14 22:26:34 +0300
commita351da55bf4cb000c267775c631534b5d513fbcd (patch)
tree3391e4dc578f6ea08d10b92ce7222122357b963a
parentad61e141dd60087f566c4e9ccb0f529988526608 (diff)
downloadphp-git-a351da55bf4cb000c267775c631534b5d513fbcd.tar.gz
Simplify zend_jit_pre/post_inc/dec_typed_ref() helpers
-rw-r--r--ext/opcache/jit/zend_jit_helpers.c20
-rw-r--r--ext/opcache/jit/zend_jit_x86.dasc70
2 files changed, 34 insertions, 56 deletions
diff --git a/ext/opcache/jit/zend_jit_helpers.c b/ext/opcache/jit/zend_jit_helpers.c
index c1886b0266..89f55b9644 100644
--- a/ext/opcache/jit/zend_jit_helpers.c
+++ b/ext/opcache/jit/zend_jit_helpers.c
@@ -1748,8 +1748,9 @@ static ZEND_COLD void zend_jit_throw_incdec_ref_error(zend_reference *ref, zend_
inc ? "max" : "min");
}
-static void ZEND_FASTCALL zend_jit_pre_inc_typed_ref(zval *var_ptr, zend_reference *ref, zval *ret)
+static void ZEND_FASTCALL zend_jit_pre_inc_typed_ref(zend_reference *ref, zval *ret)
{
+ zval *var_ptr = &ref->val;
zval tmp;
ZVAL_COPY(&tmp, var_ptr);
@@ -1770,8 +1771,9 @@ static void ZEND_FASTCALL zend_jit_pre_inc_typed_ref(zval *var_ptr, zend_referen
}
}
-static void ZEND_FASTCALL zend_jit_pre_dec_typed_ref(zval *var_ptr, zend_reference *ref, zval *ret)
+static void ZEND_FASTCALL zend_jit_pre_dec_typed_ref(zend_reference *ref, zval *ret)
{
+ zval *var_ptr = &ref->val;
zval tmp;
ZVAL_COPY(&tmp, var_ptr);
@@ -1792,8 +1794,9 @@ static void ZEND_FASTCALL zend_jit_pre_dec_typed_ref(zval *var_ptr, zend_referen
}
}
-static void ZEND_FASTCALL zend_jit_post_inc_typed_ref(zval *var_ptr, zend_reference *ref, zval *ret)
+static void ZEND_FASTCALL zend_jit_post_inc_typed_ref(zend_reference *ref, zval *ret)
{
+ zval *var_ptr = &ref->val;
ZVAL_COPY(ret, var_ptr);
increment_function(var_ptr);
@@ -1807,8 +1810,9 @@ static void ZEND_FASTCALL zend_jit_post_inc_typed_ref(zval *var_ptr, zend_refere
}
}
-static void ZEND_FASTCALL zend_jit_post_dec_typed_ref(zval *var_ptr, zend_reference *ref, zval *ret)
+static void ZEND_FASTCALL zend_jit_post_dec_typed_ref(zend_reference *ref, zval *ret)
{
+ zval *var_ptr = &ref->val;
ZVAL_COPY(ret, var_ptr);
decrement_function(var_ptr);
@@ -2259,7 +2263,7 @@ static void ZEND_FASTCALL zend_jit_pre_inc_obj_helper(zend_object *zobj, zend_st
zend_reference *ref = Z_REF_P(prop);
prop = Z_REFVAL_P(prop);
if (UNEXPECTED(ZEND_REF_HAS_TYPE_SOURCES(ref))) {
- zend_jit_pre_inc_typed_ref(&ref->val, ref, result);
+ zend_jit_pre_inc_typed_ref(ref, result);
break;
}
}
@@ -2328,7 +2332,7 @@ static void ZEND_FASTCALL zend_jit_pre_dec_obj_helper(zend_object *zobj, zend_st
zend_reference *ref = Z_REF_P(prop);
prop = Z_REFVAL_P(prop);
if (UNEXPECTED(ZEND_REF_HAS_TYPE_SOURCES(ref))) {
- zend_jit_pre_dec_typed_ref(&ref->val, ref, result);
+ zend_jit_pre_dec_typed_ref(ref, result);
break;
}
}
@@ -2395,7 +2399,7 @@ static void ZEND_FASTCALL zend_jit_post_inc_obj_helper(zend_object *zobj, zend_s
zend_reference *ref = Z_REF_P(prop);
prop = Z_REFVAL_P(prop);
if (ZEND_REF_HAS_TYPE_SOURCES(ref)) {
- zend_jit_post_inc_typed_ref(&ref->val, ref, result);
+ zend_jit_post_inc_typed_ref(ref, result);
return;
}
}
@@ -2454,7 +2458,7 @@ static void ZEND_FASTCALL zend_jit_post_dec_obj_helper(zend_object *zobj, zend_s
zend_reference *ref = Z_REF_P(prop);
prop = Z_REFVAL_P(prop);
if (ZEND_REF_HAS_TYPE_SOURCES(ref)) {
- zend_jit_post_dec_typed_ref(&ref->val, ref, result);
+ zend_jit_post_dec_typed_ref(ref, result);
return;
}
}
diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc
index cfbbec04e2..cb23f44d0c 100644
--- a/ext/opcache/jit/zend_jit_x86.dasc
+++ b/ext/opcache/jit/zend_jit_x86.dasc
@@ -4064,24 +4064,14 @@ static int zend_jit_inc_dec(dasm_State **Dst, const zend_op *opline, uint32_t op
| // ZVAL_DEREF(var_ptr);
if (op1_info & MAY_BE_REF) {
| IF_NOT_Z_TYPE, FCARG1a, IS_REFERENCE, >2
- | GET_Z_PTR FCARG2a, FCARG1a
- | cmp aword [FCARG2a + offsetof(zend_reference, sources.ptr)], 0
- | lea FCARG1a, [FCARG2a + offsetof(zend_reference, val)]
- | jz >2
- |.if X64
- if (RETURN_VALUE_USED(opline)) {
- | LOAD_ZVAL_ADDR CARG3, res_addr
- } else {
- | mov CARG3, 0
- }
- |.else
- | sub r4, 12
- if (RETURN_VALUE_USED(opline)) {
- | PUSH_ZVAL_ADDR res_addr, r0
- } else {
- | push 0
- }
- |.endif
+ | GET_Z_PTR FCARG1a, FCARG1a
+ | cmp aword [FCARG1a + offsetof(zend_reference, sources.ptr)], 0
+ | jz >1
+ if (RETURN_VALUE_USED(opline)) {
+ | LOAD_ZVAL_ADDR FCARG2a, res_addr
+ } else {
+ | xor FCARG2a, FCARG2a
+ }
if (opline->opcode == ZEND_PRE_INC) {
| EXT_CALL zend_jit_pre_inc_typed_ref, r0
} else if (opline->opcode == ZEND_PRE_DEC) {
@@ -4093,11 +4083,10 @@ static int zend_jit_inc_dec(dasm_State **Dst, const zend_op *opline, uint32_t op
} else {
ZEND_UNREACHABLE();
}
- |.if not(X64)
- | add r4, 12
- |.endif
zend_jit_check_exception(Dst);
| jmp >3
+ |1:
+ | lea FCARG1a, [FCARG1a + offsetof(zend_reference, val)]
|2:
}
@@ -12516,33 +12505,24 @@ static int zend_jit_incdec_obj(dasm_State **Dst,
if (!prop_info || !ZEND_TYPE_IS_SET(prop_info->type)) {
zend_jit_addr var_addr = prop_addr;
- var_addr = ZEND_ADDR_MEM_ZVAL(ZREG_R0, 0);
- | LOAD_ZVAL_ADDR r0, prop_addr
+ var_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FCARG1a, 0);
+ | LOAD_ZVAL_ADDR FCARG1a, prop_addr
| IF_NOT_ZVAL_TYPE var_addr, IS_REFERENCE, >2
- | GET_ZVAL_PTR FCARG2a, var_addr
- | cmp aword [FCARG2a + offsetof(zend_reference, sources.ptr)], 0
+ | GET_ZVAL_PTR FCARG1a, var_addr
+ | cmp aword [FCARG1a + offsetof(zend_reference, sources.ptr)], 0
| jnz >1
- | lea r0, aword [FCARG2a + offsetof(zend_reference, val)]
+ | lea FCARG1a, aword [FCARG1a + offsetof(zend_reference, val)]
|.cold_code
|1:
- | lea FCARG1a, [FCARG2a + offsetof(zend_reference, val)]
if (opline) {
| SET_EX_OPLINE opline, r0
}
- |.if X64
- if (opline->result_type == IS_UNUSED) {
- | xor CARG3, CARG3
- } else {
- | LOAD_ZVAL_ADDR CARG3, res_addr
- }
- |.else
- if (opline->result_type == IS_UNUSED) {
- | push 0
- } else {
- | PUSH_ZVAL_ADDR res_addr, r0
- }
- |.endif
+ if (opline->result_type == IS_UNUSED) {
+ | xor FCARG2a, FCARG2a
+ } else {
+ | LOAD_ZVAL_ADDR FCARG2a, res_addr
+ }
switch (opline->opcode) {
case ZEND_PRE_INC_OBJ:
| EXT_CALL zend_jit_pre_inc_typed_ref, r0
@@ -12559,9 +12539,6 @@ static int zend_jit_incdec_obj(dasm_State **Dst,
default:
ZEND_UNREACHABLE();
}
- |.if not(X64)
- | add r4, 12
- |.endif
| jmp >9
|.code
@@ -12580,16 +12557,13 @@ static int zend_jit_incdec_obj(dasm_State **Dst,
| jo >3
if (opline->opcode == ZEND_PRE_INC_OBJ || opline->opcode == ZEND_PRE_DEC_OBJ) {
if (opline->result_type != IS_UNUSED) {
- | ZVAL_COPY_VALUE res_addr, -1, var_addr, MAY_BE_LONG, ZREG_R1, ZREG_R2
+ | ZVAL_COPY_VALUE res_addr, -1, var_addr, MAY_BE_LONG, ZREG_R0, ZREG_R2
}
}
|.cold_code
|2:
- | LOAD_ZVAL_ADDR FCARG1a, var_addr
if (opline->opcode == ZEND_POST_INC_OBJ || opline->opcode == ZEND_POST_DEC_OBJ) {
- zend_jit_addr val_addr = ZEND_ADDR_MEM_ZVAL(ZREG_FCARG1a, 0);
-
- | ZVAL_COPY_VALUE res_addr, -1, val_addr, MAY_BE_ANY, ZREG_R0, ZREG_R2
+ | ZVAL_COPY_VALUE res_addr, -1, var_addr, MAY_BE_ANY, ZREG_R0, ZREG_R2
| TRY_ADDREF MAY_BE_ANY, ah, r2
}
if (opline->opcode == ZEND_PRE_INC_OBJ || opline->opcode == ZEND_POST_INC_OBJ) {