Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:18327 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 89446 invoked by uid 1010); 23 Aug 2005 23:18:36 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 89431 invoked from network); 23 Aug 2005 23:18:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Aug 2005 23:18:36 -0000 X-Host-Fingerprint: 80.74.107.235 mail.zend.com Linux 2.5 (sometimes 2.4) (4) Received: from ([80.74.107.235:39404] helo=mail.zend.com) by pb1.pair.com (ecelerity 2.0 beta r(6323M)) with SMTP id A7/17-28235-CCEAB034 for ; Tue, 23 Aug 2005 19:18:36 -0400 Received: (qmail 12566 invoked from network); 23 Aug 2005 23:18:32 -0000 Received: from localhost (HELO ANDI-NOTEBOOK.zend.com) (127.0.0.1) by localhost with SMTP; 23 Aug 2005 23:18:32 -0000 Message-ID: <6.2.3.4.2.20050823161755.03bffe20@localhost> X-Mailer: QUALCOMM Windows Eudora Version 6.2.3.4 Date: Tue, 23 Aug 2005 16:18:25 -0700 To: "Sara Golemon" , In-Reply-To: <004501c5a813$1691dc30$5c8be5a9@ohr.berkeley.edu> References: <004501c5a813$1691dc30$5c8be5a9@ohr.berkeley.edu> Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii"; format=flowed Subject: Re: [PHP-DEV] Returning References from Internal Functions From: andi@zend.com (Andi Gutmans) We'll take a look at it as this should actually work today. As to back porting, I don't think we should touch the stable branches. Andi At 11:47 AM 8/23/2005, Sara Golemon wrote: >I've got a one-line fix to allow internal functions to return by reference. > >What happens currently is if (*return_value_ptr)->refcount <= 2 at the end >of an internal function, then the _get_zval_ptr_ptr_var delrefs it down to >refcount==1 (removing is_ref in the process). With userspace functions >ASSIGN_REF can handle this since >EX_T(opline->result.u.var).var.fcall_returned_reference is set appropriately >in fcall_common_helper. With internal functions, this value is never set. > >The following one-liner change to Zend/zend_vm_def.h sets this value if the >function has declared itself to return reference (based on arg_info data), >and the value in return_value_ptr is in fact set to is_ref. > >Two question: (1) Is it okay for me to just commit this (Andi? Zeev?), (2) >Should this fix be applied to 5.1 and 5.0 branches as well? Note: It >doesn't directly apply to 4.x branches since they have no return_value_ptr, >nor arg_info hinting. I havn't actually looked at the PHP_4_4 branch to see >if it has a similar problem. > >-Sara > >Index: zend_vm_def.h >=================================================================== >RCS file: /repository/ZendEngine2/zend_vm_def.h,v >retrieving revision 1.68 >diff -u -r1.68 zend_vm_def.h >--- zend_vm_def.h 19 Aug 2005 13:20:14 -0000 1.68 >+++ zend_vm_def.h 23 Aug 2005 18:38:28 -0000 >@@ -1883,6 +1883,8 @@ > EX_T(opline->result.u.var).var.ptr->refcount = 1; > } > */ >+ EX_T(opline->result.u.var).var.fcall_returned_reference = >EX(function_state).function->common.return_reference && >EX_T(opline->result.u.var).var.ptr->is_ref; >+ > if (!return_value_used) { > zval_ptr_dtor(&EX_T(opline->result.u.var).var.ptr); > } > >-- >PHP Internals - PHP Runtime Development Mailing List >To unsubscribe, visit: http://www.php.net/unsub.php