com php-src: Fcall optimization: Avoid FETCH_DIM_R with UNUSED op2: ext/opcache/Optimizer/optimize_func_ calls.c
ext/opcache/tests/optimize_func_calls_00 1.phpt

From: Date: Thu, 10 Nov 2016 20:36:46 +0000
Subject: com php-src: Fcall optimization: Avoid FETCH_DIM_R with UNUSED op2: ext/opcache/Optimizer/optimize_func_ calls.c
ext/opcache/tests/optimize_func_calls_00 1.phpt
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-95702@lists.php.net to get a copy of this message
Commit: bb3d0c0e17a614f2bcb2a257f8146affced86341 Author: Nikita Popov <nikic@php.net> Thu, 10 Nov 2016 21:36:46 +0100 Parents: 15ac4904727d22acdb9722871ef8f4acb7ddccae Branches: PHP-7.0 PHP-7.1 master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=bb3d0c0e17a614f2bcb2a257f8146affced86341 Log: Fcall optimization: Avoid FETCH_DIM_R with UNUSED op2 Changed paths: M ext/opcache/Optimizer/optimize_func_calls.c A ext/opcache/tests/optimize_func_calls_001.phpt Diff: diff --git a/ext/opcache/Optimizer/optimize_func_calls..c b/ext/opcache/Optimizer/optimize_func_calls.c index 5804a5f..ccac5b9 100644 --- a/ext/opcache/Optimizer/optimize_func_calls.c +++ b/ext/opcache/Optimizer/optimize_func_calls.c @@ -112,6 +112,13 @@ void optimize_func_calls(zend_op_array *op_array, zend_optimizer_ctx *ctx) opline->extended_value &= ZEND_FETCH_TYPE_MASK; opline->opcode -= 9; } else { + if (opline->opcode == ZEND_FETCH_DIM_FUNC_ARG + && opline->op2_type == IS_UNUSED) { + /* FETCH_DIM_FUNC_ARG supports UNUSED op2, while FETCH_DIM_R does not. + * Performing the replacement would create an invalid opcode. */ + break; + } + opline->extended_value &= ZEND_FETCH_TYPE_MASK; opline->opcode -= 12; } diff --git a/ext/opcache/tests/optimize_func_calls_001.phpt b/ext/opcache/tests/optimize_func_calls_001.phpt new file mode 100644 index 0000000..5745b3f --- /dev/null +++ b/ext/opcache/tests/optimize_func_calls_001.phpt @@ -0,0 +1,15 @@ +--TEST-- +Don't create FETCH_DIM_R with UNUSED op2 +--FILE-- +<?php + +// Order matters +test($arr[]); +function test($arg) {} + +?> +--EXPECTF-- +Fatal error: Uncaught Error: Cannot use [] for reading in %s:%d +Stack trace: +#0 {main} + thrown in %s on line %d

« previous php.cvs (#95702) next »