Re: JIT (was RE: [PHP-DEV] Coercive Scalar Type Hints RFC)

From: Date: Mon, 23 Feb 2015 09:48:46 +0000
Subject: Re: JIT (was RE: [PHP-DEV] Coercive Scalar Type Hints RFC)
References: 1 2 3 4 5 6 7 8 9 10 11 12 13  Groups: php.internals 
Request: Send a blank email to internals+get-83557@lists.php.net to get a copy of this message
On Mon, Feb 23, 2015 at 10:28 AM, Joe Watkins <pthreads@pthreads.org> wrote: > Zeev, > >> If you can infer the type with confidence, you can do away with coercion > code altogether. > > Maybe I'm ignorant of something, but isn't the only way you can begin to > infer the type with real confidence is by having strict typed parameters ? > > This sounds like the kind of strict mode we're talking about, where no > coercion is necessary because inference is so reliable given a good > starting place (function entry with strictly typed parameters). > >> If you can't, then you're not obligated to generate optimized paths for > every possible input - you can just defer to the relevant coerce() function. > > If the parameters aren't strict but are typed then you need to travel > coercion code paths somewhere, optimized inline, calling an API function, > it makes no real difference. > > I guess we are hedging our bets that having to travel those paths will suck > away so much performance, that it will make all of the effort required to > make any of this a reality seem, somehow ... wasted. > >> JIT might end up being about making PHP viable for more CPU-bound use > cases ... > > This is probably quite realistic. > > In case anyone is reading and thinks I'm using any of this to justify dual > mode, I'm not doing that. The original RFC justified it well enough, I just > happen to disagree with some of the assertions made in this thread and or > RFC. > Hello, if I understand the issue correctly, not even strongly typed parameters won't help you infer types of variables with real confidence? Imagine this piece of code: function foo(int $x) { $x = fnThatReturnsRandomScalarType(); return $x; } Regards Pavel Kouril

« previous php.internals (#83557) next »