com php-src: Proper optmisation of "goto" into the middle of "try" block.: Zend/tests/jump16.phpt ext/opcache/Optimizer/block_pass.c

From: Date: Thu, 19 Nov 2015 08:19:06 +0000
Subject: com php-src: Proper optmisation of "goto" into the middle of "try" block.: Zend/tests/jump16.phpt ext/opcache/Optimizer/block_pass.c
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-89907@lists.php.net to get a copy of this message
Commit: d6308afce9b74280f8c0085424bdee69accfebd3 Author: Dmitry Stogov <dmitry@zend.com> Thu, 19 Nov 2015 11:19:06 +0300 Parents: 9d7baed8404fb0ab235a9b85ec8ce26a0476707b Branches: master Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=d6308afce9b74280f8c0085424bdee69accfebd3 Log: Proper optmisation of "goto" into the middle of "try" block. Changed paths: A Zend/tests/jump16.phpt M ext/opcache/Optimizer/block_pass.c Diff: diff --git a/Zend/tests/jump16.phpt b/Zend/tests/jump16.phpt new file mode 100644 index 0000000..cc820c4 --- /dev/null +++ b/Zend/tests/jump16.phpt @@ -0,0 +1,27 @@ +--TEST-- +jump 16: goto into try/catch +--FILE-- +<?php +goto a; +try { + echo "1"; +a: + echo "2"; + throw new Exception(); +} catch (Exception $e) { + echo "3"; +} +echo "4"; +goto b; +try { + echo "5"; + throw new Exception(); +} catch (Exception $e) { + echo "6"; +b: + echo "7"; +} +echo "8\n"; +?> +--EXPECT-- +23478 diff --git a/ext/opcache/Optimizer/block_pass.c b/ext/opcache/Optimizer/block_pass.c index 6de5dc6..c674253 100644 --- a/ext/opcache/Optimizer/block_pass.c +++ b/ext/opcache/Optimizer/block_pass.c @@ -730,6 +730,21 @@ static void zend_rebuild_access_path(zend_cfg *cfg, zend_op_array *op_array, int /* Add exception paths */ for (i = 0; i< op_array->last_try_catch; i++) { + /* check for jumps into the middle of try block */ + if (!cfg->try[i]->access) { + if (op_array->try_catch_array[i].catch_op) { + zend_code_block *b = cfg->try[i]; + zend_code_block *end = cfg->catch[i]; + while (b != end) { + if (b->access) { + cfg->try[i] = b; + op_array->try_catch_array[i].try_op = b->start_opline - op_array->opcodes; + break; + } + b = b->next; + } + } + } if (cfg->try[i]->access) { if (op_array->try_catch_array[i].catch_op) { if (!cfg->catch[i]->access) {

« previous php.cvs (#89907) next »