Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:34668 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 53086 invoked by uid 1010); 10 Jan 2008 23:35:46 -0000 Delivered-To: ezmlm-scan-internals@lists.php.net Delivered-To: ezmlm-internals@lists.php.net Received: (qmail 53070 invoked from network); 10 Jan 2008 23:35:46 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 10 Jan 2008 23:35:46 -0000 Authentication-Results: pb1.pair.com header.from=Kannan@facebook.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=Kannan@facebook.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain facebook.com designates 204.15.23.140 as permitted sender) X-PHP-List-Original-Sender: Kannan@facebook.com X-Host-Fingerprint: 204.15.23.140 fw-sf2p.facebook.com Windows 2000 SP4, XP SP1 Received: from [204.15.23.140] ([204.15.23.140:14056] helo=SF2PMXF01.TheFacebook.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id C5/10-51656-1DBA6874 for ; Thu, 10 Jan 2008 18:35:46 -0500 Received: from SF2PMXB01.TheFacebook.com ([192.168.16.15]) by SF2PMXF01.TheFacebook.com with Microsoft SMTPSVC(6.0.3790.3959); Thu, 10 Jan 2008 15:36:28 -0800 X-MimeOLE: Produced By Microsoft Exchange V6.5 Content-class: urn:content-classes:message MIME-Version: 1.0 Content-Type: multipart/alternative; boundary="----_=_NextPart_001_01C853E1.9F2E73DF" Date: Thu, 10 Jan 2008 15:36:18 -0800 Message-ID: <300A9932AE9C0145A146B5A4E5CCE96901921EDC@sf2pmxb01.thefacebook.com> X-MS-Has-Attach: X-MS-TNEF-Correlator: Thread-Topic: php-5.2.3: zend_opcode.c: pass_two() question Thread-Index: AchT4ZmYy5CpBNS3T8GcO9WScZ6tFA== To: X-OriginalArrivalTime: 10 Jan 2008 23:36:28.0501 (UTC) FILETIME=[9F469850:01C853E1] Subject: php-5.2.3: zend_opcode.c: pass_two() question From: Kannan@facebook.com ("Kannan Muthukkaruppan") ------_=_NextPart_001_01C853E1.9F2E73DF Content-Type: text/plain; charset="US-ASCII" Content-Transfer-Encoding: quoted-printable An example assignment such as:=20 $x =3D 10; doesn't seem to get handled as a simple ref-count incrementing assignment (in zend_assign_to_variable()). Instead, $x ends up getting a new "zval" into which a=20 copy of the RHS (10) is made. =20 This seems to be because the zval/znode corresponding to the literal 10 is an IS_CONST operand of the assignment opcode. And, during the end of compilation of a function, the IS_CONST operands in the function's op_array are patched up as "references" (is_ref is set to 1). =20 zend_opcode.c:pass_two()=20 ... while (opline < end) { if (opline->op1.op_type =3D=3D IS_CONST) { opline->op1.u.constant.is_ref =3D 1; opline->op1.u.constant.refcount =3D 2; /* Make sure is_ref won't be reset */ } if (opline->op2.op_type =3D=3D IS_CONST) { opline->op2.u.constant.is_ref =3D 1; opline->op2.u.constant.refcount =3D 2; } ...=20 =20 And zend_assign_to_variable(), when it sees the RHS to be a reference ("is_ref =3D=3D 1") ends up doing a copy rather than a ref-count incrementing assignment.=20 =20 It seems like performance would be better if we didn't mark constant operands as "references" in pass_two(). But presumably it is required to handle some cases that'll otherwise break? I am trying to understand what those cases are. If someone can shed further light on this issue, it is much appreciated... =20 regards, Kannan Muthukkaruppan ------_=_NextPart_001_01C853E1.9F2E73DF--