Skip to content

Instantly share code, notes, and snippets.

View dstogov's full-sized avatar

Dmitry Stogov dstogov

  • Zend by Perforce
  • Russia
View GitHub Profile
<?php
class A {
public $prop = "x";
function foo() {
var_dump("A");
return $this->prop;
}
function bar() {
$x = $this->foo();
var_dump(str_repeat($x,5));
@dstogov
dstogov / fix.diff
Last active September 21, 2021 10:31
diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc
index 40efcef2b9..9d15aadcf5 100644
--- a/ext/opcache/jit/zend_jit_x86.dasc
+++ b/ext/opcache/jit/zend_jit_x86.dasc
@@ -9866,7 +9866,7 @@ static int zend_jit_do_fcall(dasm_State **Dst, const zend_op *opline, const zend
}
}
- if (!trace && op_array == &func->op_array
+ if (GCC_GLOBAL_REGS && !trace && op_array == &func->op_array
diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc
index 175e063639..0447858e48 100644
--- a/ext/opcache/jit/zend_jit_x86.dasc
+++ b/ext/opcache/jit/zend_jit_x86.dasc
@@ -6018,6 +6018,27 @@ static int zend_jit_assign_to_variable_call(dasm_State **Dst,
zend_jit_addr __res_addr,
bool __check_exception)
{
+ if (val_info & MAY_BE_UNDEF) {
+ if (JIT_G(trigger) == ZEND_JIT_ON_HOT_TRACE) {
diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc
index 205d1bccb8..1c94e1a8e1 100644
--- a/ext/opcache/jit/zend_jit_x86.dasc
+++ b/ext/opcache/jit/zend_jit_x86.dasc
@@ -8271,7 +8271,7 @@ static int zend_jit_bool_jmpznz(dasm_State **Dst, const zend_op *opline, uint32_
return 1;
}
- if (op1_info & MAY_BE_REF) {
+ if (opline->op1_type == IS_CV && (op1_info & MAY_BE_REF)) {
diff --git a/ext/opcache/jit/zend_jit.c b/ext/opcache/jit/zend_jit.c
index 93c79bdce2..eceeed2733 100644
--- a/ext/opcache/jit/zend_jit.c
+++ b/ext/opcache/jit/zend_jit.c
@@ -292,7 +292,7 @@ static int zend_jit_is_constant_cmp_long_long(const zend_op *opline,
return 0;
}
-static int zend_jit_needs_call_chain(zend_call_info *call_info, uint32_t b, const zend_op_array *op_array, zend_ssa *ssa, const zend_ssa_op *ssa_op, const zend_op *opline, zend_jit_trace_rec *trace)
+static int zend_jit_needs_call_chain(zend_call_info *call_info, uint32_t b, const zend_op_array *op_array, zend_ssa *ssa, const zend_ssa_op *ssa_op, const zend_op *opline, int call_level, zend_jit_trace_rec *trace)
diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc
index 7941b396f5..8e81627007 100644
--- a/ext/opcache/jit/zend_jit_x86.dasc
+++ b/ext/opcache/jit/zend_jit_x86.dasc
@@ -4831,7 +4831,11 @@ static int zend_jit_math_helper(dasm_State **Dst,
| FREE_OP op1_type, op1, op1_info, 0, opline
| FREE_OP op2_type, op2, op2_info, 0, opline
if (may_throw) {
- zend_jit_check_exception(Dst);
+ if (Z_MODE(res_addr) == IS_MEM_ZVAL && Z_REG(res_addr) == ZREG_RX) {
diff --git a/Zend/zend_closures.c b/Zend/zend_closures.c
index d388e8184a..d089677287 100644
--- a/Zend/zend_closures.c
+++ b/Zend/zend_closures.c
@@ -478,6 +478,7 @@ static void zend_closure_free_storage(zend_object *object) /* {{{ */
/* We don't own the static variables of fake closures. */
if (!(closure->func.op_array.fn_flags & ZEND_ACC_FAKE_CLOSURE)) {
zend_destroy_static_vars(&closure->func.op_array);
+ closure->func.op_array.static_variables = NULL;
}
diff --git a/ext/opcache/ZendAccelerator.c b/ext/opcache/ZendAccelerator.c
index 797d83258c..a3ed78e410 100644
--- a/ext/opcache/ZendAccelerator.c
+++ b/ext/opcache/ZendAccelerator.c
@@ -4086,6 +4086,7 @@ static void preload_link(void)
zend_op_array *op_array = &script->script.main_op_array;
zend_op *opline = op_array->opcodes;
zend_op *end = opline + op_array->last;
+ uint32_t skip_dynamic_func_count = 0;
diff --git a/Zend/Optimizer/zend_inference.c b/Zend/Optimizer/zend_inference.c
index bee54586fc..d8f82e87b2 100644
--- a/Zend/Optimizer/zend_inference.c
+++ b/Zend/Optimizer/zend_inference.c
@@ -2393,13 +2393,13 @@ static zend_always_inline int _zend_update_type_info(
if (!(t1 & (MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_CLASS))
|| !(t2 & (MAY_BE_ANY|MAY_BE_UNDEF|MAY_BE_CLASS))) {
tmp = 0;
- if (ssa_op->result_def >= 0) {
+ if (ssa_op->result_def >= 0 && !(ssa_var_info[ssa_op->result_def].type & MAY_BE_REF)) {
diff --git a/ext/opcache/jit/dynasm/dasm_arm64.h b/ext/opcache/jit/dynasm/dasm_arm64.h
index 909b51f808..fdb22435e8 100644
--- a/ext/opcache/jit/dynasm/dasm_arm64.h
+++ b/ext/opcache/jit/dynasm/dasm_arm64.h
@@ -482,7 +482,12 @@ int dasm_encode(Dst_DECL, void *buffer)
}
break;
case DASM_REL_A: {
- ptrdiff_t na = (((ptrdiff_t)(*b++) << 32) | (unsigned int)n) - (ptrdiff_t)cp + 4;
+ ptrdiff_t na;