Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:93689 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 93623 invoked from network); 1 Jun 2016 19:01:56 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 1 Jun 2016 19:01:56 -0000 Authentication-Results: pb1.pair.com header.from=nikita.ppv@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=nikita.ppv@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.161.182 as permitted sender) X-PHP-List-Original-Sender: nikita.ppv@gmail.com X-Host-Fingerprint: 209.85.161.182 mail-yw0-f182.google.com Received: from [209.85.161.182] ([209.85.161.182:36569] helo=mail-yw0-f182.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id B6/15-63812-3213F475 for ; Wed, 01 Jun 2016 15:01:55 -0400 Received: by mail-yw0-f182.google.com with SMTP id x189so27719289ywe.3 for ; Wed, 01 Jun 2016 12:01:55 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc; bh=UPnKiEE0iMGCxe6ShWsWLpmqvuW2l+fwxNRs2aGMbl4=; b=Pada1FblyyfmdM5r7dHZ2AeR71vHcTzL71PwMn9jY4Pa2F6W3z/lyMG50on5HWBn0O TeZ6OhkIFqtcB5fEHVwFOEigImuTCaZMJe7T2ejLhL4avpy+Cwef2AUaomAvtFvYEUn7 kWAqj0gS0MreZQ6vMpEZeKj49eE5+8jSNhzlvywoF0MyQfxMQzlp9x1p5bbvf+8Ct+xi qN7LGSwDbPFhRCaJ0jZlxM7yJsVqE5mu2x6zIwAvioeYp0t1OoZnVRPZKEEJ+pw663GD QvQ5KHs4YRnM7JBTQLisUY65Uo2NtCqiQIbsDEM1l6HUr+LgB3In43JW7dbtNDKd6ewc kKYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc; bh=UPnKiEE0iMGCxe6ShWsWLpmqvuW2l+fwxNRs2aGMbl4=; b=ldNPkTBRVRrT5D7BflOPYYlz2VZ+pWPcIFtvkuT2Nat4/Yw06fj3+gb3IrK22LPgTT aAlXZ9/q5pNYUbXfFe6m4zOfd5wyd31FN7AcU6uOJq7QycVcA8mY60K9ObpGc4bHDU8c zpwyOH8VJOPguakyR7qL/8Qz4QrdHh87+4FfQ4CyUjDyy0fk06dPL8KDiXDKN7ymh8UX mNcJmOCMlS9zsvLV+xjPy3loT8xcNBxJDmll3vppr4hPQUbxaoSKNeKZ4g9BDqHEsUcb N+IHCA52uRNAqXQE4kTaYFDK6S4FXvwiUJfu0ZT9rW4Qvn+eTo4w92lfchAoKZ4sL7S7 SX2w== X-Gm-Message-State: ALyK8tIsAtLpWl+Pp+xtnbTCJWORkoPtVtsQVFjtYZGJJL6b7V5ad+7J2MuLnhHfMzzszaLA4glX1oGyNV0gXw== MIME-Version: 1.0 X-Received: by 10.37.51.4 with SMTP id z4mr3415048ybz.75.1464807712168; Wed, 01 Jun 2016 12:01:52 -0700 (PDT) Received: by 10.13.239.3 with HTTP; Wed, 1 Jun 2016 12:01:52 -0700 (PDT) In-Reply-To: References: Date: Wed, 1 Jun 2016 21:01:52 +0200 Message-ID: To: Dmitry Stogov Cc: Joe Watkins , PHP internals , Nikita Popov Content-Type: multipart/alternative; boundary=001a114897a059270a05343c1fc3 Subject: Re: [PHP-DEV] [RFC] Replace "Missing argument" warning with "Too few arguments" exception From: nikita.ppv@gmail.com (Nikita Popov) --001a114897a059270a05343c1fc3 Content-Type: text/plain; charset=UTF-8 On Wed, Jun 1, 2016 at 8:24 PM, Dmitry Stogov wrote: > In the SSA optimisation framework (part of opcache), we predict and > propagate types of variables. > > We also may detect situations when some variables may be undefined. > > If variable can't be "undefined", we may avoid unnecessary run-time checks > (e.g .like in ZEND_ADD_LONG handler). > > Local variables almost always initialized before usage, but with exiting > behavior, function arguments always may be uninitialized. > To expand on this a bit... if a variable is potentially undefined, we pretty much have to exclude it from optimization entirely, as nearly any transformation we can make is prone to impact the undefined variable notice in some way (remove, duplicate, reorder). The saving grace here is that (untyped) function parameters don't have any type information, so we typically can't apply transformations anyway (e.g. type specialization is obviously not applicable, but many other transformation require guaranteed warning/notice freedom, which usually requires more specific type information than "any"). However, there are some optimizations that would be applicable if not for the fact that the variable is potentially undefined. One such example is copy propagation. Namely, in function test($param) { $var = $param; // ... use($var); } we wouldn't be able to simply replace all uses of $var with $param and save that assignment, because this might duplicate or reorder "undefined variable" notices. Such "useless" variable-to-variable assignments are typically introduced by inlining. (Note: Both copy propagation and inlining are not currently in php-src, but may well be in the future.) Nikita --001a114897a059270a05343c1fc3--