Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83269 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 14270 invoked from network); 20 Feb 2015 07:13:44 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 20 Feb 2015 07:13:44 -0000 Authentication-Results: pb1.pair.com header.from=dmitry@zend.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=dmitry@zend.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain zend.com designates 209.85.220.171 as permitted sender) X-PHP-List-Original-Sender: dmitry@zend.com X-Host-Fingerprint: 209.85.220.171 mail-vc0-f171.google.com Received: from [209.85.220.171] ([209.85.220.171:62393] helo=mail-vc0-f171.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id F3/A4-25547-5AED6E45 for ; Fri, 20 Feb 2015 02:13:42 -0500 Received: by mail-vc0-f171.google.com with SMTP id kv19so2922827vcb.2 for ; Thu, 19 Feb 2015 23:13:38 -0800 (PST) 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:content-type; bh=aQRhbNJUAl013KLQmw+v+xKHxQzeI2AOS9ERae5IDas=; b=e4/+gSU3cE8IXfK/YCFMN9xUuf1b6UKFm3f9xblP5p4iIeHPMv36gauweGZVL67TAq RCZiNxEyXvqP6tQQlypRfoerI0H/Fc63wXFgStP/Z5eQykNNsArmEx9tKZ49Ad4GOXME FdmPXbfO7P9RTmaUQgLjv1HisybaVDTHNb5jjy2mRn7etr43jgYbZb9875Ous/Kp3rAQ Kp2uuHv9CGHeBTn576/EH5GxfhjU9sG/+zAEO9fz7Js5vFDbTaIDAzK9uIJGGqhdtG4U 8MIQ6DtY2OTfqZs9dP2OR6zKbA/NVjPr7COwzcgIhH/YjrzSIPeZB/Ay6vVgfkp6Hoxw RmoA== X-Gm-Message-State: ALoCoQntZfzrz/GXCoVJqVkGwaq/l2ww6ycKOuqmkccnocTiUCMP6S+ufy5HBnAa0nlbN03BZHUoh38OME559YaFTVeylK7c7wroMW/nECq+cuHsAuOX7FnXJ7FA32icN7Iknf40pplhn8a3dq673qDglms7geA3Yw== MIME-Version: 1.0 X-Received: by 10.52.25.11 with SMTP id y11mr5338611vdf.51.1424416418300; Thu, 19 Feb 2015 23:13:38 -0800 (PST) Received: by 10.52.74.73 with HTTP; Thu, 19 Feb 2015 23:13:38 -0800 (PST) In-Reply-To: References: <011801d04a07$83ab1c00$8b015400$@php.net> <016f01d04a3a$e9183220$bb489660$@php.net> <022801d04ab1$4a0c47d0$de24d770$@php.net> <1913e09d7f52541901d8574d2080a63f@mail.gmail.com> <7a5d96b34b98ec1f3ee17be7fa6a1e81@mail.gmail.com> <2CBDEB67-3DE3-437D-9AF3-0E6A92027244@zend.com> <4cc0c81c7199a452534bb8edcdb19914@mail.gmail.com> <54E589F6.9030002@garfieldtech.com> <54E66569.8000709@garfieldtech.com> Date: Fri, 20 Feb 2015 11:13:38 +0400 Message-ID: To: Anthony Ferrara Cc: Larry Garfield , "internals@lists.php.net" Content-Type: multipart/alternative; boundary=001a1133e5f2a01d5e050f7fca00 Subject: Re: [PHP-DEV] Reviving scalar type hints From: dmitry@zend.com (Dmitry Stogov) --001a1133e5f2a01d5e050f7fca00 Content-Type: text/plain; charset=UTF-8 On Fri, Feb 20, 2015 at 4:57 AM, Anthony Ferrara wrote: > Larry, > > > Anthony, can you expand here at all about the practical benefits of > > strong-typing for variable passing for the compiler? That seems to be > the > > main point of contention: Whether or not there are real, practical > benefits > > to be had in the compiler of knowing that a call will be in "strict > mode". > > (If there are, then the split-mode makes sense If there are not, then > > there's little benefit to it.) > > For the normal compiler & engine there will be no benefit for the > foreseeable future. > > For a tracing JIT compiler, there will be no advantage. > > For a local JIT compiler, there can be some optimizations around > reduced conversion logic generated (and hence potentially better cache > efficiency, etc). A guard would still be generated, but that's a > single branch rather than the full cast logic. This would likely be a > small gain (likely less than 1%, possibly significantly less). > > For a AOT compiler (optimizing compiler), more optimizations and > therefore gains can be had. The big difference here is that type > assertions can be done at compile time. AOT compiler that know type of passed argument and expected parameter type, may eliminate guard check independently on hint semantic (strong or week). If you don't know first or second you'll have to generate guard code anyway independently from hint semantic (strong or week). Is this wrong? We may introduce strong type hints because of your mistake. > So that means one less branch > (no guard) per argument per function call. In addition, native calls > can be used in a lot of cases, which means the compiled code doesn't > even need to know about a zval (significant memory and access > reduction). This has potential to be significant. Not to mention the > other optimizations that are possible. > This already worked for as without type hinting. > However, I think making this decision based on performance is the > incorrect way of doing it. For the Zend engine, there will be no > discernible difference between the proposals. It's a red herring. The > difference I would focus on is the ability to statically analyze the > code (with the benefits that comes with). > Completely agree, changing language for compiler is not fair. It's clear that statically typed languages are more suitable but we won't make PHP statically typed. Also, modern JS engines showed - what they may do without typing. In my opinion strict type hints may be useful for program verification, but again, I wouldn't like to change the whole language semantic just to get few unit tests out of the box. Thanks. Dmitry. > > Anthony > > -- > PHP Internals - PHP Runtime Development Mailing List > To unsubscribe, visit: http://www.php.net/unsub.php > > --001a1133e5f2a01d5e050f7fca00--