Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83532 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 32642 invoked from network); 23 Feb 2015 02:31:06 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Feb 2015 02:31:06 -0000 Authentication-Results: pb1.pair.com header.from=zeev@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=zeev@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.213.177 as permitted sender) X-PHP-List-Original-Sender: zeev@zend.com X-Host-Fingerprint: 209.85.213.177 mail-ig0-f177.google.com Received: from [209.85.213.177] ([209.85.213.177:50065] helo=mail-ig0-f177.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F2/E6-33016-9E09AE45 for ; Sun, 22 Feb 2015 21:31:06 -0500 Received: by mail-ig0-f177.google.com with SMTP id z20so15125740igj.4 for ; Sun, 22 Feb 2015 18:31:03 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:references:in-reply-to:mime-version :thread-index:date:message-id:subject:to:cc:content-type; bh=eQ9H3haqbyXcfd2VTnbV2doOWNfjMJmjIm9oSuJnq58=; b=Gcuo8CkiEdzF09FXMa8u5ivBbNtRRO2yNLKrn8rf1mHCFkkPO8ee9McScXgB49Tqno iHo/HPylzgadk86aMYDCBuKu/XWh0ptI66939BpLSBwunlrfm0ahinJTK9TopCvW/KHY lb7kzqb0MscDmmCXYVn/fNPNWEuK3Buvn63i3Jquv3C9cHykz0klQKF4HTduRhCDDIcg YtiVf9KNsgIMKuQzdTT4XzjqslybM+QsBuVxicDbl3AOnxQbX7n0W3+Xdt2xGuI/FrNQ GOPFxjO0QqCci43as8ldPgjWNaofYvN0ZJu3E3hFmFTZFRWAzb6tVbDEbXXOIa0nTJG0 9l+w== X-Gm-Message-State: ALoCoQmb30nmvXRPhnm4T+Kbp/640kqTd337XyHswzgks1u98ms04KZHODw+j0xrvFKKSyTk1he8ZbHyS7yinn2xBfMXtJb9nnfqAQdboS6yOyHAEWhL67fPA68gSnZWXRArIK0HS4dE2JjpNKNWD4s72+6rEqPamg== X-Received: by 10.50.39.112 with SMTP id o16mr10279065igk.0.1424658663099; Sun, 22 Feb 2015 18:31:03 -0800 (PST) References: <2e4694f9805ee81ea0b2c79eab06c2d6@mail.gmail.com> <54EA5EDA.8010605@gmail.com> <54EA6A99.5010609@gmail.com> <54EA7F15.9030606@gmail.com> In-Reply-To: MIME-Version: 1.0 X-Mailer: Microsoft Outlook 14.0 Thread-Index: AQIDXD7ehmaYKzbAddTs7O1sB4MzmgIw+OLdAe4e2iYCibfnDQEmdWqtAiDZcfAB4cR2SQLEF8I9nCKybTA= Date: Mon, 23 Feb 2015 04:31:02 +0200 Message-ID: <90e29a09812f8b8f8f6917d4aa4ea936@mail.gmail.com> To: Anthony Ferrara , smalyshev@gmail.com Cc: Jefferson Gonzalez , PHP internals Content-Type: text/plain; charset=UTF-8 Subject: RE: [PHP-DEV] JIT (was RE: [PHP-DEV] Coercive Scalar Type Hints RFC) From: zeev@zend.com (Zeev Suraski) > -----Original Message----- > From: Anthony Ferrara [mailto:ircmaxell@gmail.com] > Sent: Monday, February 23, 2015 3:43 AM > To: Stanislav Malyshev > Cc: Zeev Suraski; Jefferson Gonzalez; PHP internals > Subject: Re: [PHP-DEV] JIT (was RE: [PHP-DEV] Coercive Scalar Type Hints > RFC) > > Stas, > > >> It is still a performance advantage, because since we know the types > >> are stable at compile time, we can generate far more optimized code > >> (no variant types, native function calls, etc). > > > > I don't see where it comes from. So far you said that your compiler > > would reject some code. That doesn't generate any code, optimized or > > otherwise. For the code your compiler does not reject, still no > > advantage over dynamic model. > > It rejects code because doing code generation on the dynamic case is > significantly harder and more resource intensive. Could that be built in? > Sure. > But it's a very significant difference from generating the static code. I hope I demonstrated in the other email that lists how two use cases would look with coercive type hints, the strategies and implementation of doing the optimizations for those cases where we can infer the type in compile time, would be similar in cost, complexity and resource consumption to the optimizations you're talking about. Even if we keep the handling of all other types as AOTless/JITless, it would still have performance equivalent to the strict case, given inputs that the strict case accepts. Either way, I'm happy we all agree that equally-efficient code can be generated for the dynamic case, which is the point I was making in the Coercive typing RFC. We still have the gap on whether it's truly a lot harder and resource intensive - I don't think it is as we can do the very same things in compile-time - but that's a smaller gap that I personally care less about. I wanted it to be clear to everyone that we can reach the same level of optimizations for Coercive type hints as we can for Strict. > And even if we generated native code for the dynamic code, it would still > need variants, and hence ZPP at runtime. Hence the static code has a > significant performance benefit in that we can indeed bypass type checks > as > shown in the PECL example a few messages up (more than a few). We can only eliminate the ZPP structure during compile time if we know with certainty what the type is. If we do, we know that for both strict type hints and coercive type hints (i.e. we either managed to prove it's an int in the static analyzer in the strict case, or we managed to deduce what the type is in the coercive case). If we don't - we the ZPP structure it in exactly the same way. Thanks, Zeev