Oop, re-reading that, I realize that was unclear --- The compiler deopts 
because operations in those rare branches haven't been run yet, so there is no 
type feedback and the compiler doesn't know what to do with them. So, v8 
deopts, and resumes execution from the slow path, which collects that 
information --- so that next time the function is evaluated, that same deopt 
won't happen (but, you have a number of branches like that, so there are many 
opportunities for this to happen). But that's sort of the nature of this kind 
of state machine, so I'm not sure you can do much about it.

> On Sep 26, 2018, at 1:11 AM, ca...@igalia.com wrote:
> 
> Sounds like a cool project :)
> 
> So, I think these deopts are all expected, and I don't think you're in a 
> deopt loop (but I could be wrong about that). Basically what's happening is, 
> your `tick()` function is called frequently, you increment counters (dot 
> count, scanline count, instruction cycle count, etc), and there are a number 
> of branches in your functions which depend on those variables --- so they 
> aren't reached every time. Because of that, the compiler decides to deopt 
> when it sees them, so that the slow case can run them and collect information 
> that the optimizer can make use of next time to speed them up.
> 
> Is the 30% measure of performance only measuring time spent in the tick's 
> frame, or does it also include functions invoked by tick()?
> 
>> On Sep 25, 2018, at 11:24 PM, Taylor Dondich <tay...@dondich.com> wrote:
>> 
>> I'm building a NES emulator in Javascript and there's a certain function of 
>> code that when gathering performance metrics in google chrome, shows that 
>> the self time for this method is over 30% of overall execution time. That's 
>> pretty excessive to what looks like a tree of if/else statements. I was 
>> wondering if anyone can look at it to see if there's something to this 
>> structure that would have the v8 engine choke on it.  I've also gathered a 
>> collection of v8's opt and deopt messages regarding this method and so far 
>> I'm having a very hard time finding documentation online to understand the 
>> deopt reasons and how to potentially code to safeguard against the constant 
>> deopts.
>> 
>> I've attached the code in the method as well as the opt/deopt log.  Would 
>> love any feedback!
>> 
>> 
>> 
>> --
>> --
>> 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.
>> <onlyppudeopt.txt><tickmethod.txt>
> 
> --
> --
> 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.

Attachment: signature.asc
Description: Message signed with OpenPGP

Reply via email to