cvs: ZendEngine2 / zend_compile.c zend_compile.h zend_vm_handlers.h

From: Date: Tue, 05 Oct 2004 18:36:46 +0000
Subject: cvs: ZendEngine2 / zend_compile.c zend_compile.h zend_vm_handlers.h
Groups: php.zend-engine.cvs 
Request: Send a blank email to php-zend-engine-cvs+get-3080@lists.php.net to get a copy of this message
helly Tue Oct 5 14:36:46 2004 EDT Modified files: /ZendEngine2 zend_compile.c zend_compile.h zend_vm_handlers.h Log: - Add arginfo ZEND_ARG_SEND_AUTOMATIC which lets the compiler automatically determine whether pass by ref is possible or pass by value is needed. # This is usefull when functions take array or string parameters as # expressions. In such a case force by ref is not applicable and the # executor would copy the variable unnecessarily as soon as it is at least # once referenced. http://cvs.php.net/diff.php/ZendEngine2/zend_compile.c?r1=1.593&r2=1.594&ty=u Index: ZendEngine2/zend_compile.c diff -u ZendEngine2/zend_compile.c:1.593 ZendEngine2/zend_compile.c:1.594 --- ZendEngine2/zend_compile.c:1.593 Mon Oct 4 15:54:34 2004 +++ ZendEngine2/zend_compile.c Tue Oct 5 14:36:46 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.c,v 1.593 2004/10/04 19:54:34 andi Exp $ */ +/* $Id: zend_compile.c,v 1.594 2004/10/05 18:36:46 helly Exp $ */ #include "zend_language_parser.h" #include "zend.h" @@ -1454,7 +1454,7 @@ } if (function_ptr) { - send_by_reference = ARG_SHOULD_BE_SENT_BY_REF(function_ptr, (zend_uint) offset) ? ZEND_ARG_SEND_BY_REF : 0; + send_by_reference = ARG_SEND_TYPE(function_ptr, (zend_uint) offset); } else { send_by_reference = 0; } @@ -1466,7 +1466,7 @@ op = ZEND_SEND_VAR_NO_REF; } - if (op!=ZEND_SEND_VAR_NO_REF && send_by_reference==ZEND_ARG_SEND_BY_REF) { + if (op!=ZEND_SEND_VAR_NO_REF && send_by_reference!=0) { /* change to passing by reference */ switch (param->op_type) { case IS_VAR: @@ -1474,7 +1474,9 @@ op = ZEND_SEND_REF; break; default: - zend_error(E_COMPILE_ERROR, "Only variables can be passed by reference"); + if (send_by_reference==ZEND_ARG_SEND_BY_REF) { + zend_error(E_COMPILE_ERROR, "Only variables can be passed by reference"); + } break; } } http://cvs.php.net/diff.php/ZendEngine2/zend_compile.h?r1=1.294&r2=1.295&ty=u Index: ZendEngine2/zend_compile.h diff -u ZendEngine2/zend_compile.h:1.294 ZendEngine2/zend_compile.h:1.295 --- ZendEngine2/zend_compile.h:1.294 Mon Oct 4 15:54:34 2004 +++ ZendEngine2/zend_compile.h Tue Oct 5 14:36:46 2004 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: zend_compile.h,v 1.294 2004/10/04 19:54:34 andi Exp $ */ +/* $Id: zend_compile.h,v 1.295 2004/10/05 18:36:46 helly Exp $ */ #ifndef ZEND_COMPILE_H #define ZEND_COMPILE_H @@ -812,6 +812,7 @@ #define ZEND_ARG_SEND_BY_REF (1<<0) #define ZEND_ARG_COMPILE_TIME_BOUND (1<<1) +#define ZEND_ARG_SEND_AUTOMATIC (1<<2) /* Lost In Stupid Parentheses */ #define ARG_SHOULD_BE_SENT_BY_REF(zf, arg_num) \ @@ -822,15 +823,24 @@ ( \ ( \ arg_num<=((zend_function *) zf)->common.num_args \ - && ((zend_function *) zf)->common.arg_info[arg_num-1].pass_by_reference \ + && ((zend_function *) zf)->common.arg_info[arg_num-1].pass_by_reference == ZEND_ARG_SEND_BY_REF \ ) \ || ( \ arg_num>((zend_function *) zf)->common.num_args \ - && ((zend_function *) zf)->common.pass_rest_by_reference \ + && ((zend_function *) zf)->common.pass_rest_by_reference == ZEND_ARG_SEND_BY_REF \ ) \ ) \ ) +#define ARG_SEND_TYPE(zf, arg_num) \ + ( \ + !zf || !((zend_function *) zf)->common.arg_info \ + ? 0 \ + : ( arg_num<=((zend_function *) zf)->common.num_args \ + ? ((zend_function *) zf)->common.arg_info[arg_num-1].pass_by_reference \ + : ((zend_function *) zf)->common.pass_rest_by_reference \ + ) \ + ) #define ZEND_RETURN_VAL 0 #define ZEND_RETURN_REF 1 http://cvs.php.net/diff.php/ZendEngine2/zend_vm_handlers.h?r1=1.5&r2=1.6&ty=u Index: ZendEngine2/zend_vm_handlers.h diff -u ZendEngine2/zend_vm_handlers.h:1.5 ZendEngine2/zend_vm_handlers.h:1.6 --- ZendEngine2/zend_vm_handlers.h:1.5 Tue Oct 5 05:09:16 2004 +++ ZendEngine2/zend_vm_handlers.h Tue Oct 5 14:36:46 2004 @@ -2550,7 +2550,7 @@ { zend_op *opline = EX(opline); if (opline->extended_value & ZEND_ARG_COMPILE_TIME_BOUND) { /* Had function_ptr at compile_time */ - if (!(opline->extended_value & ZEND_ARG_SEND_BY_REF)) { + if (!(opline->extended_value & ZEND_ARG_SEND_BY_REF) && !(opline->extended_value & ZEND_ARG_SEND_AUTOMATIC)) { ZEND_VM_DISPATCH_TO_HELPER(zend_send_by_var_helper); } } else if (!ARG_SHOULD_BE_SENT_BY_REF(EX(fbc), opline->op2.u.opline_num)) {

« previous php.zend-engine.cvs (#3080) next »