Optimized compilation happens on a per-function basis. A large function
with many branches (if/else or switch), some of which are only executed
rarely, tends to cause repeated deoptimizations (some branches have been
executed enough to make the function hot, it gets optimized, then one of
the as-yet unexecuted branches is hit the first time, causing a deopt;
repeat). *If* you are running into that issue (you'll have to measure),
then moving *every handler* out into its own function *could* indeed help
(you'll have to measure). There's also always a chance that it doesn't
matter in practice (i.e. the difference shows up in a microbenchmark or
with tracing tools, but is not measurable in your real app).

On Tue, Apr 23, 2019 at 12:45 PM Ben Noordhuis <i...@bnoordhuis.nl> wrote:

> On Fri, Apr 19, 2019 at 9:16 AM J Decker <d3c...@gmail.com> wrote:
> >
> > A question came to mind about the resolution of the 'compilation' of
> code.. I have message handlers that receive an object with a standard field
> 'op'.  Then for each 'op' that can be processed I have an if test and a
> small amount of code to handle the message (either inline or calling a
> function).
> >
> > Would it be better to call a function for each message handler, or is
> the code within the if block consider a specific type of message?
> > Given that there is time lost to just calling a function and creating
> its closure too...
>
> V8 emits ICs (inline caches) inside the if block. IOW, the simple
> solution should be best. :-)
>
> --
> --
> v8-users mailing list
> v8-users@googlegroups.com
> http://groups.google.com/group/v8-users
> ---
> You received this message because you are subscribed to the Google Groups
> "v8-users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to v8-users+unsubscr...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
-- 
v8-users mailing list
v8-users@googlegroups.com
http://groups.google.com/group/v8-users
--- 
You received this message because you are subscribed to the Google Groups 
"v8-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to v8-users+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to