Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:82752 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 14018 invoked from network); 15 Feb 2015 21:45:21 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 15 Feb 2015 21:45:21 -0000 Authentication-Results: pb1.pair.com smtp.mail=ircmaxell@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=ircmaxell@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.215.42 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 209.85.215.42 mail-la0-f42.google.com Received: from [209.85.215.42] ([209.85.215.42:43712] helo=mail-la0-f42.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 70/00-13857-F6311E45 for ; Sun, 15 Feb 2015 16:45:20 -0500 Received: by labms9 with SMTP id ms9so19224000lab.10 for ; Sun, 15 Feb 2015 13:45:16 -0800 (PST) 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:content-type; bh=MmI67YD8Q1qIyjR0d+xbzUQvOuYABqjH7QYuxMpjufc=; b=KuNkkcrsJO6fMlCB+t130XH5iXB1VKvcb8AZc6+oXZLPZB11YKiDnZmSswZ4ZgB2IW RAq6Ltzjn7MoF6TowEeXAyh5VHUJeAJm3ISXPMzsX+Hws9BzO09mUWHtZaZMQIZDeaTR 8SSdfmSLn/ci74T30uOlYrMtSpZAI0+Y8VQZo1bysKCTAvHUjIBi6hrIZnTGNZ8Y7is/ +eZVh0GCtnV13MIpOZRg6HA7PmAYDhng5awuWqUb82xt/WmB7j2dnXLX9a+tHnjmtKVO Ueusr9O0hAxmQpjJtdJFemJ2xkvZGEHsGbvHxAoWYB/Pi1YuvxlrnAx5/UlPSNacVZie jrwQ== MIME-Version: 1.0 X-Received: by 10.112.171.65 with SMTP id as1mr12656314lbc.45.1424036716589; Sun, 15 Feb 2015 13:45:16 -0800 (PST) Received: by 10.25.43.9 with HTTP; Sun, 15 Feb 2015 13:45:16 -0800 (PST) In-Reply-To: References: <93453174-E6A8-47C6-8AB6-A08858A7FC05@zend.com> Date: Sun, 15 Feb 2015 16:45:16 -0500 Message-ID: To: Dmitry Stogov Cc: Zeev Suraski , Andrea Faulds , Patrick ALLAERT , PHP Internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] [VOTE] Scalar Type Hints From: ircmaxell@gmail.com (Anthony Ferrara) Dmitry, On Sun, Feb 15, 2015 at 1:43 PM, Dmitry Stogov wrote: > Hi Anthony, > > If you are working on JIT, you should understand that declare() switch to > strict typing can't improve anything, because it works on caller side and in > each function you now will have to generate code for both weak and strict > checks. Well, if you know the destination function at compile time, you don't need to generate generic code. you can generate a direct dispatch (asm-level function call). In this case, strict lets you push type checks back to compile time, where in non-strict mode you still need to generation runtime conversion logic. That runtime conversion logic then requires the ability to hook into Zend's error handling mechanism, vastly complicating the generated code (and the generating code). In fact, the research I have been doing is precisely around that (where I know for a fact that all remaining function calls are going to be typed, and compile the entire block at one time with direct calls). So that way I never need to actually do even as much as a FCC to call a userland function. Which then lets me avoid generating typing code (since I know the types). Which is why I'm advocating for strict, since that way we can treat an entire graph of function calls as strict and compile them all in one go (no need to even JIT at runtime, just compile AOT). If your research has shown something different, care to share? > According to mandel() and integer to float conversion in the loop, it's > possible to perform a backward data-propagation pass to catch this case and > replace integer by float in first place. We did it in our old JIT prototypes > without any type hinting. Also, don't use "fild", use SSE2 and/or AVX. I did wind up doing a few passes to back-propagate the cast (among other optimizations). But it's still a point that the conversions aren't exactly cheap. But as I said before, that was a side-note and not really an argument for/against strict typing. So worth mentioning, but shouldn't affect anyone's decision. Re fild vs SSE/AVX: that was up to the backend code generator we were using (libjit). It may be an open req against that lib to generate the different instruction, or perhaps it just failed a heuristic. We were working a level higher than the generated ASM, so not really 100% sure why it made that decision. Anthony