From bdac60d2c0fc6d534e5679f165dd1b4273864e59 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Tue, 23 Jun 2020 13:46:56 +0300 Subject: [PATCH] Improve JIT for SEPARATE_ARRAY --- ext/opcache/jit/zend_jit_helpers.c | 4 ++- ext/opcache/jit/zend_jit_x86.dasc | 47 +++++++++++++++--------------- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/ext/opcache/jit/zend_jit_helpers.c b/ext/opcache/jit/zend_jit_helpers.c index adbcc9004d..a394c4af0f 100644 --- a/ext/opcache/jit/zend_jit_helpers.c +++ b/ext/opcache/jit/zend_jit_helpers.c @@ -1755,8 +1755,10 @@ static void ZEND_FASTCALL zend_jit_array_free(HashTable *ht) static HashTable *ZEND_FASTCALL zend_jit_zval_array_dup(zval *arr) { - HashTable *ht = Z_ARRVAL_P(arr); + HashTable *ht; + Z_TRY_DELREF_P(arr); + ht = Z_ARRVAL_P(arr); ht = zend_array_dup(ht); ZVAL_ARR(arr, ht); return ht; diff --git a/ext/opcache/jit/zend_jit_x86.dasc b/ext/opcache/jit/zend_jit_x86.dasc index 73e6514ad6..dd6b075d2e 100644 --- a/ext/opcache/jit/zend_jit_x86.dasc +++ b/ext/opcache/jit/zend_jit_x86.dasc @@ -1411,40 +1411,41 @@ static void* dasm_labels[zend_lb_MAX]; |.macro SEPARATE_ARRAY, addr, op_info, cold || if (RC_MAY_BE_N(op_info)) { -|| zend_reg tmp_reg; -|| -|| tmp_reg = (Z_REG(addr) == ZREG_FCARG1a) ? ZREG_R0 : ZREG_FCARG1a; -| GET_ZVAL_LVAL tmp_reg, addr -|| if (RC_MAY_BE_1(op_info)) { -| cmp dword [Ra(tmp_reg)], 1 // if (GC_REFCOUNT() > 1) -|| if (cold) { -| ja >1 +|| if (Z_REG(addr) == ZREG_FCARG1a) { +| GET_ZVAL_LVAL ZREG_R0, addr +|| if (RC_MAY_BE_1(op_info)) { +| cmp dword [r0], 1 // if (GC_REFCOUNT() > 1) +| jbe >2 +|| } +| EXT_CALL zend_jit_zval_array_dup, r0 +|2: +| mov FCARG1a, r0 +|| } else { +| GET_ZVAL_LVAL ZREG_FCARG1a, addr +|| if (RC_MAY_BE_1(op_info)) { +| cmp dword [FCARG1a], 1 // if (GC_REFCOUNT() > 1) +|| if (cold) { +| ja >1 |.cold_code |1: -|| } else { -| jbe >2 +|| } else { +| jbe >2 +|| } || } -|| } -| IF_NOT_ZVAL_REFCOUNTED addr, >1 -| GC_DELREF Ra(tmp_reg) +| IF_NOT_ZVAL_REFCOUNTED addr, >1 +| GC_DELREF FCARG1a |1: -|| if (Z_REG(addr) == ZREG_FCARG1a) { -| EXT_CALL zend_jit_zval_array_dup, r0 -|| } else { | EXT_CALL zend_array_dup, r0 | SET_ZVAL_PTR addr, r0 | SET_ZVAL_TYPE_INFO addr, IS_ARRAY_EX | mov FCARG1a, r0 -|| } -|| if (RC_MAY_BE_1(op_info)) { -|| if (cold) { -| jmp >2 +|| if (RC_MAY_BE_1(op_info)) { +|| if (cold) { +| jmp >2 |.code +|| } || } -|| } |2: -|| if (Z_REG(addr) == ZREG_FCARG1a) { -| mov FCARG1a, r0 || } || } else { | GET_ZVAL_LVAL ZREG_FCARG1a, addr -- 2.50.1