Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83523 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 17187 invoked from network); 23 Feb 2015 01:21:04 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 23 Feb 2015 01:21:04 -0000 Authentication-Results: pb1.pair.com header.from=ircmaxell@gmail.com; sender-id=pass Authentication-Results: pb1.pair.com smtp.mail=ircmaxell@gmail.com; spf=pass; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.217.175 as permitted sender) X-PHP-List-Original-Sender: ircmaxell@gmail.com X-Host-Fingerprint: 209.85.217.175 mail-lb0-f175.google.com Received: from [209.85.217.175] ([209.85.217.175:45419] helo=mail-lb0-f175.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id 01/C3-33016-E708AE45 for ; Sun, 22 Feb 2015 20:21:03 -0500 Received: by lbjb6 with SMTP id b6so15585896lbj.12 for ; Sun, 22 Feb 2015 17:20:59 -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=wN4nZUKMslTWjZmmZlp6RRBUM3qD+ffjMOpSMiQ6t4A=; b=erTHzC0/YJdjnE49Tgb+7wHuRUIAbYKPJhODk7SFHxoH3uVT9K8HwbjjAyfWU/WKvs wWz7dH1mC0hkVlYn9EMSBXwr1lc5gJ3M7nY+VF8aRySld5IeY1dGzWoHEc6r7SxFXFgW mBR5xYBuELtMmZbYlglc5Xg5NM5+cYQ7lAJt9DLfEu6uJYSLkyT8sokt2GJnbl2hHnQO PZhPnQdUNugw0uCKTV6FI572+HDfq0384I9oVQb6UUpeMNGn848Xnixa2MpdXIP+TycP 8VFCvvPuq6ySKfw3wNvHeDsvcjjOUfuLsrwoEUMOrZw0VtDAAgDma1E8d+qHUkrWMU9r isXw== MIME-Version: 1.0 X-Received: by 10.112.170.72 with SMTP id ak8mr7294745lbc.95.1424654459067; Sun, 22 Feb 2015 17:20:59 -0800 (PST) Received: by 10.25.43.9 with HTTP; Sun, 22 Feb 2015 17:20:58 -0800 (PST) In-Reply-To: <7d58f9b893c257c7289166b31bbdd9ac@mail.gmail.com> References: <2e4694f9805ee81ea0b2c79eab06c2d6@mail.gmail.com> <83921f861c3378dfc6ea34b6681f2edd@mail.gmail.com> <26a5bb62bd37a3f610b2a6c10f84d855@mail.gmail.com> <6d317b6cce0cc1aaded1dae11218234d@mail.gmail.com> <7d58f9b893c257c7289166b31bbdd9ac@mail.gmail.com> Date: Sun, 22 Feb 2015 20:20:58 -0500 Message-ID: To: Zeev Suraski Cc: PHP internals Content-Type: text/plain; charset=UTF-8 Subject: Re: [PHP-DEV] JIT (was RE: [PHP-DEV] Coercive Scalar Type Hints RFC) From: ircmaxell@gmail.com (Anthony Ferrara) Zeev, >> Partially. >> >> The static analysis and compilation would be pure AOT. So the errors would >> be told to the user when they try to analyze the program, not run it. >> Similar >> to HHVM's hh_client. > > How about that then: > > 1. The developers runs a static analyzer on the program. > 2. It fails because the static analyzer detects float being fed to an int. > 3. The user changes the code to convert the input to int. > 4. You can now optimize the whole flow better, since you know for a fact > it's an int. > > Is that an accurate flow? Yes. At least for what I was talking about in this thread. >> However, there could be a "runtime compiler" which compiles in PHP's >> compile flow (leveraging opcache, etc). In that case, if the type >> assertion >> isn't stable, the function wouldn't be compiled (the external analyzer >> would >> error, here it just doesn't compile). Then the code would be run under the >> Zend engine (and error when called). > > Got you. Is it fair to say that if we got to that case, it no longer > matters what type of type hints we have? Once you get to the end, no. Recki-CT proves that. The difference though is the journey. The static analyzer can reason about far more code with strict types than it can without (due to the limited number of possibilities presented at each call). So this leaves the dilema: compiled code that behaves slightly differently (what Recki does) or whether it always behaves the same. >> So think of it as a graph. When you start the type analysis, there's one >> edge >> between $input and foo() with type mixed. Looking at foo's argument, you >> can say that the type of that graph edge must be int. >> Therefore it becomes an int. Then, when you look at $input, you see that >> it >> can be other things, and therefore there are unstable states which can >> error >> at runtime. > > So when you say it 'must be an int', what you mean is that you assume it > needs to be an int, and attempt to either prove that or refute that. Is > that correct? > If you manage to prove it - you can generate optimal code. > If you manage to refute that - the static analyzer will emit an error. > If you can't determine - you defer to runtime. > > Is that correct? Basically yes. Anthony