com php-src: Use DECLARE_CONST instruction instead of call to internal define() function when poss ible: ext/opcache/Optimizer/pass1_5.c

From: Date: Thu, 30 Oct 2014 23:42:39 +0000
Subject: com php-src: Use DECLARE_CONST instruction instead of call to internal define() function when poss ible: ext/opcache/Optimizer/pass1_5.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-82910@lists.php.net to get a copy of this message
Commit: 10107db61ec1ac695bb7167cae49d0e1b7271b11 Author: Dmitry Stogov <dmitry@zend.com> Thu, 30 Oct 2014 16:42:39 -0700 Parents: 7f61dc7d3500f177c79b5381749efcc528f6fe51 Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=10107db61ec1ac695bb7167cae49d0e1b7271b11 Log: Use DECLARE_CONST instruction instead of call to internal define() function when possible Changed paths: M ext/opcache/Optimizer/pass1_5.c Diff: diff --git a/ext/opcache/Optimizer/pass1_5.c b/ext/opcache/Optimizer/pass1_5.c index 180482f..15bca2a 100644 --- a/ext/opcache/Optimizer/pass1_5.c +++ b/ext/opcache/Optimizer/pass1_5.c @@ -381,15 +381,33 @@ void zend_optimizer_pass1(zend_op_array *op_array, zend_optimizer_ctx *ctx TSRML } /* define("name", scalar); */ - if (collect_constants && - Z_STRLEN(ZEND_OP2_LITERAL(init_opline)) == sizeof("define")-1 && + if (Z_STRLEN(ZEND_OP2_LITERAL(init_opline)) == sizeof("define")-1 && zend_binary_strcasecmp(Z_STRVAL(ZEND_OP2_LITERAL(init_opline)), Z_STRLEN(ZEND_OP2_LITERAL(init_opline)), "define", sizeof("define")-1) == 0) { if (Z_TYPE(ZEND_OP1_LITERAL(send1_opline)) == IS_STRING && send2_opline && Z_TYPE(ZEND_OP1_LITERAL(send2_opline)) <= IS_STRING) { - zend_optimizer_collect_constant(ctx, &ZEND_OP1_LITERAL(send1_opline), &ZEND_OP1_LITERAL(send2_opline)); + if (collect_constants) { + zend_optimizer_collect_constant(ctx, &ZEND_OP1_LITERAL(send1_opline), &ZEND_OP1_LITERAL(send2_opline)); + } + + if (RESULT_UNUSED(opline) && + !zend_memnstr(Z_STRVAL(ZEND_OP1_LITERAL(send1_opline)), "::", sizeof("::") - 1, Z_STRVAL(ZEND_OP1_LITERAL(send1_opline)) + Z_STRLEN(ZEND_OP1_LITERAL(send1_opline)))) { + + opline->opcode = ZEND_DECLARE_CONST; + opline->op1_type = IS_CONST; + opline->op2_type = IS_CONST; + opline->result_type = IS_UNUSED; + opline->op1.constant = send1_opline->op1.constant; + opline->op2.constant = send2_opline->op1.constant; + opline->result.zv = NULL; + + literal_dtor(&ZEND_OP2_LITERAL(init_opline)); + MAKE_NOP(init_opline); + MAKE_NOP(send1_opline); + MAKE_NOP(send2_opline); + } break; } }

« previous php.cvs (#82910) next »