Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:92055 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 10127 invoked from network); 31 Mar 2016 22:39:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 31 Mar 2016 22:39:56 -0000 Authentication-Results: pb1.pair.com header.from=rowan.collins@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=rowan.collins@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 74.125.82.48 as permitted sender) X-PHP-List-Original-Sender: rowan.collins@gmail.com X-Host-Fingerprint: 74.125.82.48 mail-wm0-f48.google.com Received: from [74.125.82.48] ([74.125.82.48:33121] helo=mail-wm0-f48.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 86/04-15473-937ADF65 for ; Thu, 31 Mar 2016 17:39:53 -0500 Received: by mail-wm0-f48.google.com with SMTP id f198so3245381wme.0 for ; Thu, 31 Mar 2016 15:39:53 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=subject:to:references:from:message-id:date:user-agent:mime-version :in-reply-to:content-transfer-encoding; bh=2h7JKSATqy/14GmedGcWZNxalacFiRwN00s2X71PXnI=; b=emmaxcbKaPXqHZvQb0OiPT+U0Ona6X7wpDfCkUxx4Y5MJYyjsPSREGZeWueV6Kazvg MxctpGbze5rUBjZ4/dOCfm1YtSR9eoml1tJXJdpdzm3Zx1xtfCVJLPAeanePXMJ+zqy/ mQIKwCZ6lH92W1omFnLwiYQasO63s+JwSM6VaThTjGW6Qn1TIwrSKqlIX+ed1yyV814N rjTfiIJ+e/DoF4XFTk7cH8QfyQkHUsLfr5T9pbU25Q/APKIANnvmt7jSX+5rxHZzkpJK Wrq6Xkb/4IUt9yVIY5UUEvQzV4XR6EHdYofgoKEyUNqmIlTNYDthZB0uKTtDOigxpefI G/3w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:subject:to:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-transfer-encoding; bh=2h7JKSATqy/14GmedGcWZNxalacFiRwN00s2X71PXnI=; b=Jw9txZlBmxtTjidL62MwvnTnkxviCTycaIjc7fCmCrYJF9Wc1EVQvHcLLBXNTCzcVz nqW2tgT8bSBGRP4Q+M4AKMiK+CGD2oH2aqmsIK6nHv/9BRsJTMzfqILjb4pevbbX3jXR uDZW7LNEVG4IXpM6tzRtbRkst5W49EFe5krQzHD/BYhOALPcTxMyzlNf+D9x8uI6x8dG dOjAFLu2OXi6OrleFlopZmPoipLj2R7S/FmTOHhwBU8yqdbkq6CxfwBZv+kqZJRtMQXK OeZERXf9hngoXnymB9JPKZ+gI/haM1uANlM9oUm4j/+12QKxV/f6qGsGBN01IamqNodo RTbA== X-Gm-Message-State: AD7BkJKF/zBByaeHX0lzh2xE/EpopVcIXLeE0U9R8y5ggv96cY1fdrpq1JnQ/3i+n9U38w== X-Received: by 10.28.153.65 with SMTP id b62mr146375wme.36.1459463990846; Thu, 31 Mar 2016 15:39:50 -0700 (PDT) Received: from [192.168.1.189] ([2.27.88.132]) by smtp.googlemail.com with ESMTPSA id w131sm11565639wmd.17.2016.03.31.15.39.49 for (version=TLSv1/SSLv3 cipher=OTHER); Thu, 31 Mar 2016 15:39:50 -0700 (PDT) To: internals@lists.php.net References: <56FD5D14.7020606@gmail.com> Message-ID: <56FDA70B.6020708@gmail.com> Date: Thu, 31 Mar 2016 23:39:07 +0100 User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64; rv:38.0) Gecko/20100101 Thunderbird/38.6.0 MIME-Version: 1.0 In-Reply-To: <56FD5D14.7020606@gmail.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] Copy On Write and Assign By Reference perform different on PHP5 and PHP7 From: rowan.collins@gmail.com (Rowan Collins) On 31/03/2016 18:23, Rowan Collins wrote: > Maybe in PHP 5 the opcodes are the same, but $2 and $3 somehow end up > as references to !0, rather than new zvals So, it turns out, this is exactly what happens. Specifically, there is a call to SEPARATE_ZVAL_IF_NOT_REF(var_ptr); in the definition of the ZEND_PRE_INC opcode [http://lxr.php.net/xref/PHP_5_6/Zend/zend_vm_def.h#814] If the zval *is* a reference, the code just ends up incrementing its reference count, returning a reference to it rather than the calculated value. In PHP 7, references are very different, and integers aren't refcounted, so it's all a different story. I got a bit curious and did some deep investigation, which I've written up on StackOverflow: http://stackoverflow.com/a/36344524/157957 I've about reached my limit now, though, so I'll leave it to others to correct or fill in any further info. :) Regards, -- Rowan Collins [IMSoP]