Skip to content

Instantly share code, notes, and snippets.

@laruence
Created August 20, 2017 15:46
Show Gist options
  • Save laruence/33c538838821564947f473d86e49264f to your computer and use it in GitHub Desktop.
Save laruence/33c538838821564947f473d86e49264f to your computer and use it in GitHub Desktop.
RC_MAY_BE_RC.diff
diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c
index 3737125..6d40260 100644
--- a/ext/opcache/jit/zend_jit.c
+++ b/ext/opcache/jit/zend_jit.c
@@ -44,10 +44,12 @@
# define ZEND_SSA_RC_INFERENCE_FLAG ZEND_SSA_RC_INFERENCE
# define RC_MAY_BE_1(info) (((info) & (MAY_BE_RC1|MAY_BE_REF)) != 0)
# define RC_MAY_BE_N(info) (((info) & (MAY_BE_RCN|MAY_BE_REF)) != 0)
+# define RC_MAY_BE_RC(info) (RC_MAY_BE_1(info)||RC_MAY_BE_N(info))
#else
# define ZEND_SSA_RC_INFERENCE_FLAG 0
# define RC_MAY_BE_1(info) 1
# define RC_MAY_BE_N(info) 1
+# define RC_MAY_BE_RC(info) 1
#endif
#define JIT_PREFIX "JIT$"
diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc
index d2aedf0..7e7d9c8 100644
--- a/ext/opcache/jit/zend_jit_x86.dasc
+++ b/ext/opcache/jit/zend_jit_x86.dasc
@@ -1273,9 +1273,9 @@ static void* dasm_labels[zend_lb_MAX];
|.endmacro
|.macro ZVAL_PTR_DTOR, addr, op_info, gc, cold, safe, filename, opline
-|| if ((op_info) & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)) {
+|| if (((op_info) & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)) && RC_MAY_BE_RC(op_info)) {
|| if ((op_info) & ((MAY_BE_ANY|MAY_BE_UNDEF)-(MAY_BE_OBJECT|MAY_BE_RESOURCE))) {
-| // if (Z_REFCOUNTED_P(cv)) {
+| // if (Z_REFCOUNTED_P(cv))
|| if (cold) {
| IF_ZVAL_REFCOUNTED addr, >1
|.cold_code
@@ -4248,11 +4248,11 @@ static int zend_jit_assign_to_variable(dasm_State **Dst,
/* Labels: 1,2,3,4,5 */
{
ZEND_ASSERT(Z_MODE(var_addr) == IS_MEM_ZVAL);
- if (var_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) {
+ if ((var_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) && RC_MAY_BE_RC(var_info)) {
int in_cold = 0;
ZEND_ASSERT(Z_REG(var_addr) != ZREG_R0);
- if (var_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-(MAY_BE_OBJECT|MAY_BE_RESOURCE))) {
+ if ((var_info & ((MAY_BE_ANY|MAY_BE_UNDEF)-(MAY_BE_OBJECT|MAY_BE_RESOURCE)))) {
| IF_ZVAL_REFCOUNTED var_addr, >1
|.cold_code
|1:
@@ -4302,9 +4302,7 @@ static int zend_jit_assign_to_variable(dasm_State **Dst,
|.code
}
} else if (in_cold) {
- if (!RC_MAY_BE_1(var_info)) {
- | jmp >5
- }
+ ZEND_ASSERT(RC_MAY_BE_1(var_info));
|.code
}
|5:
@@ -7982,7 +7980,7 @@ static int zend_jit_type_check(dasm_State **Dst, const zend_op *opline, int b, i
if (opline->extended_value == _IS_BOOL) {
if (smart_branch &&
(opline->op1_type & (IS_VAR|IS_TMP_VAR)) &&
- (op1_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE))) {
+ (op1_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) && RC_MAY_BE_RC(op1_info)) {
if ((op1_info) & (MAY_BE_ANY-(MAY_BE_OBJECT|MAY_BE_RESOURCE))) {
| // if (Z_REFCOUNTED_P(cv)) {
| IF_ZVAL_REFCOUNTED op1_addr, >1
@@ -8061,8 +8059,8 @@ static int zend_jit_type_check(dasm_State **Dst, const zend_op *opline, int b, i
} else {
if (smart_branch &&
(opline->op1_type & (IS_VAR|IS_TMP_VAR)) &&
- (op1_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE))) {
- if ((op1_info) & (MAY_BE_ANY-(MAY_BE_OBJECT|MAY_BE_RESOURCE))) {
+ (op1_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)) && RC_MAY_BE_RC(op1_info)) {
+ if (((op1_info) & (MAY_BE_ANY-(MAY_BE_OBJECT|MAY_BE_RESOURCE)))) {
| // if (Z_REFCOUNTED_P(cv)) {
| IF_ZVAL_REFCOUNTED op1_addr, >1
|.cold_code
@@ -8086,7 +8084,7 @@ static int zend_jit_type_check(dasm_State **Dst, const zend_op *opline, int b, i
| mov cl, byte [r4] // restore
|jmp >2
}
- if ((op1_info) & (MAY_BE_ANY-(MAY_BE_OBJECT|MAY_BE_RESOURCE))) {
+ if (((op1_info) & (MAY_BE_ANY-(MAY_BE_OBJECT|MAY_BE_RESOURCE)))) {
if (!RC_MAY_BE_1(op1_info)) {
| jmp >3
}
@@ -8829,8 +8827,8 @@ static int zend_jit_bind_global(dasm_State **Dst, const zend_op *opline, zend_op
| GET_Z_PTR r0, r0
| GC_ADDREF r0
//if (UNEXPECTED(Z_REFCOUNTED_P(variable_ptr)))
- if (op1_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)) {
- if (op1_info & (MAY_BE_ANY - (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE))) {
+ if ((op1_info & (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE|MAY_BE_REF)) && RC_MAY_BE_RC(op1_info)) {
+ if ((op1_info & (MAY_BE_ANY - (MAY_BE_STRING|MAY_BE_ARRAY|MAY_BE_OBJECT|MAY_BE_RESOURCE)))) {
| IF_ZVAL_REFCOUNTED op1_addr, >2
}
|.cold_code
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment