Newsgroups: php.internals Path: news.php.net Xref: news.php.net php.internals:83502 Return-Path: Mailing-List: contact internals-help@lists.php.net; run by ezmlm Delivered-To: mailing list internals@lists.php.net Received: (qmail 78993 invoked from network); 22 Feb 2015 22:57:36 -0000 Received: from unknown (HELO lists.php.net) (127.0.0.1) by localhost with SMTP; 22 Feb 2015 22:57:36 -0000 Authentication-Results: pb1.pair.com smtp.mail=smalyshev@gmail.com; spf=pass; sender-id=pass Authentication-Results: pb1.pair.com header.from=smalyshev@gmail.com; sender-id=pass Received-SPF: pass (pb1.pair.com: domain gmail.com designates 209.85.220.49 as permitted sender) X-PHP-List-Original-Sender: smalyshev@gmail.com X-Host-Fingerprint: 209.85.220.49 mail-pa0-f49.google.com Received: from [209.85.220.49] ([209.85.220.49:40296] helo=mail-pa0-f49.google.com) by pb1.pair.com (ecelerity 2.1.1.9-wez r(12769M)) with ESMTP id A0/1B-18531-EDE5AE45 for ; Sun, 22 Feb 2015 17:57:35 -0500 Received: by paceu11 with SMTP id eu11so22761852pac.7 for ; Sun, 22 Feb 2015 14:57:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=message-id:date:from:user-agent:mime-version:to:cc:subject :references:in-reply-to:content-type:content-transfer-encoding; bh=v6pEhqDs8q1wky7kKKQu+1j0/7zLDv6qWtuaa5yBxPk=; b=LtT9b4Kz8WeOe4eVcPoZs0hj6l/de7RrpGJXzjR0x0aUT9ywBb8ikpwCyR7WVV05iy 4h0z58D3jv17XnWtnyNeYyG5yRovOGWwDtBXl0Tw0AfXlLGmagfhkCCFhDzqY/zCtfAd s/H951ofck1fGcqJWFa+FGFxcpS8CHLqBrLuaHGHUgQWOcoOKYayPzuiucVPbQORVFrA l4Pln82SHBw42TEaxtduvzspkQIi1SJBioa0Hs2L+W7A+N+6B0CZwDv1sAAsOuz70zV/ fV2HXtx+AM3Y+VdxN47j4ePf3e0AVm2kKszUzhbNhqnZGsoGR90+YqaIzPWKqsf7CbTH NYXQ== X-Received: by 10.69.25.9 with SMTP id im9mr14403760pbd.2.1424645851582; Sun, 22 Feb 2015 14:57:31 -0800 (PST) Received: from [192.168.2.145] (108-66-6-48.lightspeed.sntcca.sbcglobal.net. [108.66.6.48]) by mx.google.com with ESMTPSA id z10sm8812415pas.18.2015.02.22.14.57.30 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Sun, 22 Feb 2015 14:57:31 -0800 (PST) Message-ID: <54EA5EDA.8010605@gmail.com> Date: Sun, 22 Feb 2015 14:57:30 -0800 User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.9; rv:31.0) Gecko/20100101 Thunderbird/31.4.0 MIME-Version: 1.0 To: Anthony Ferrara , Zeev Suraski CC: Jefferson Gonzalez , PHP internals References: <2e4694f9805ee81ea0b2c79eab06c2d6@mail.gmail.com> In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Subject: Re: [PHP-DEV] JIT (was RE: [PHP-DEV] Coercive Scalar Type Hints RFC) From: smalyshev@gmail.com (Stanislav Malyshev) Hi! >> -- Can the code generated for a strict type hint can somehow be optimized significantly better than the code generated for a dynamic/coercive type hint. > And me, who wrote an AOT compiler that does **exactly** this, claim Sorry, did exactly what? Here a bit more explanation would help. > However, since test_strict() is compiled, there's no reason to > dispatch back up to PHP functions for strict_foo(). In fact, that > would be exceedingly slow. So instead, we'd compile strict_foo() as a > C function, and do a native function call to it. Never having to check > types because they are passed on the C stack. Doesn't that assume strict_foo() is always called with the right type of arguments? What exactly ensures that it does in fact happen? Shouldn't you have the type check _somewhere_ to be able to claim this happens? test_foo() doesn't do any checks, so what ensures $x is of the right type for C? And if the check is there, how is it better? > And note that this can only work with strict types since you can do > the necessary type inference and reconstruction (both forward from a > function call, and backwards before it). I don't get the backwards part - I think you claimed it last time we discussed it but I haven't seen your answer explaining why it's OK to just ignore cases when the variable is of the wrong type. Right now, it looks like you claim that if somebody has a call strict_foo($x) and strict_foo() accepts integers, that magically makes $x integer and you can generate code everywhere (not only inside strict_foo but outside) assuming $x is integer without actually needing a check. I don't see how this can work. -- Stas Malyshev smalyshev@gmail.com