From e9f4d822b0c794cceaf71b68b37977bb3b6212a3 Mon Sep 17 00:00:00 2001 From: Dmitry Stogov Date: Mon, 21 Apr 2014 13:19:52 +0400 Subject: [PATCH] Avoid useles copy ctor --- Zend/zend_vm_def.h | 11 ++++++----- Zend/zend_vm_execute.h | 44 +++++++++++++++++++++++------------------- 2 files changed, 30 insertions(+), 25 deletions(-) diff --git a/Zend/zend_vm_def.h b/Zend/zend_vm_def.h index e3b58bcea88..81f000dc6e2 100644 --- a/Zend/zend_vm_def.h +++ b/Zend/zend_vm_def.h @@ -2863,13 +2863,14 @@ ZEND_VM_HANDLER(108, ZEND_THROW, CONST|TMP|VAR|CV, ANY) } zend_exception_save(TSRMLS_C); - /* Not sure if a complete copy is what we want here */ - ZVAL_COPY_VALUE(&exception, value); - if (!IS_OP1_TMP_FREE()) { - zval_opt_copy_ctor(&exception); + if (OP1_TYPE == IS_CONST) { + ZVAL_DUP(&exception, value); + value = &exception; + } else if (OP1_TYPE != IS_TMP_VAR) { + if (Z_REFCOUNTED_P(value)) Z_ADDREF_P(value); } - zend_throw_exception_object(&exception TSRMLS_CC); + zend_throw_exception_object(value TSRMLS_CC); zend_exception_restore(TSRMLS_C); FREE_OP1_IF_VAR(); HANDLE_EXCEPTION(); diff --git a/Zend/zend_vm_execute.h b/Zend/zend_vm_execute.h index 482ea3109de..29a9821bf51 100644 --- a/Zend/zend_vm_execute.h +++ b/Zend/zend_vm_execute.h @@ -2638,13 +2638,14 @@ static int ZEND_FASTCALL ZEND_THROW_SPEC_CONST_HANDLER(ZEND_OPCODE_HANDLER_ARGS } zend_exception_save(TSRMLS_C); - /* Not sure if a complete copy is what we want here */ - ZVAL_COPY_VALUE(&exception, value); - if (!0) { - zval_opt_copy_ctor(&exception); + if (IS_CONST == IS_CONST) { + ZVAL_DUP(&exception, value); + value = &exception; + } else if (IS_CONST != IS_TMP_VAR) { + if (Z_REFCOUNTED_P(value)) Z_ADDREF_P(value); } - zend_throw_exception_object(&exception TSRMLS_CC); + zend_throw_exception_object(value TSRMLS_CC); zend_exception_restore(TSRMLS_C); HANDLE_EXCEPTION(); @@ -7585,13 +7586,14 @@ static int ZEND_FASTCALL ZEND_THROW_SPEC_TMP_HANDLER(ZEND_OPCODE_HANDLER_ARGS) } zend_exception_save(TSRMLS_C); - /* Not sure if a complete copy is what we want here */ - ZVAL_COPY_VALUE(&exception, value); - if (!1) { - zval_opt_copy_ctor(&exception); + if (IS_TMP_VAR == IS_CONST) { + ZVAL_DUP(&exception, value); + value = &exception; + } else if (IS_TMP_VAR != IS_TMP_VAR) { + if (Z_REFCOUNTED_P(value)) Z_ADDREF_P(value); } - zend_throw_exception_object(&exception TSRMLS_CC); + zend_throw_exception_object(value TSRMLS_CC); zend_exception_restore(TSRMLS_C); HANDLE_EXCEPTION(); @@ -12454,13 +12456,14 @@ static int ZEND_FASTCALL ZEND_THROW_SPEC_VAR_HANDLER(ZEND_OPCODE_HANDLER_ARGS) } zend_exception_save(TSRMLS_C); - /* Not sure if a complete copy is what we want here */ - ZVAL_COPY_VALUE(&exception, value); - if (!0) { - zval_opt_copy_ctor(&exception); + if (IS_VAR == IS_CONST) { + ZVAL_DUP(&exception, value); + value = &exception; + } else if (IS_VAR != IS_TMP_VAR) { + if (Z_REFCOUNTED_P(value)) Z_ADDREF_P(value); } - zend_throw_exception_object(&exception TSRMLS_CC); + zend_throw_exception_object(value TSRMLS_CC); zend_exception_restore(TSRMLS_C); zval_ptr_dtor_nogc(free_op1.var); HANDLE_EXCEPTION(); @@ -28986,13 +28989,14 @@ static int ZEND_FASTCALL ZEND_THROW_SPEC_CV_HANDLER(ZEND_OPCODE_HANDLER_ARGS) } zend_exception_save(TSRMLS_C); - /* Not sure if a complete copy is what we want here */ - ZVAL_COPY_VALUE(&exception, value); - if (!0) { - zval_opt_copy_ctor(&exception); + if (IS_CV == IS_CONST) { + ZVAL_DUP(&exception, value); + value = &exception; + } else if (IS_CV != IS_TMP_VAR) { + if (Z_REFCOUNTED_P(value)) Z_ADDREF_P(value); } - zend_throw_exception_object(&exception TSRMLS_CC); + zend_throw_exception_object(value TSRMLS_CC); zend_exception_restore(TSRMLS_C); HANDLE_EXCEPTION();