Bug 169030

Summary: [JSC] Optimize generators and iterators with op_next
Product: WebKit Reporter: Yusuke Suzuki <ysuzuki>
Component: JavaScriptCoreAssignee: Nobody <webkit-unassigned>
Status: NEW ---    
Severity: Normal CC: fpizlo, ggaren, jfbastien, joepeck, keith_miller, mark.lam, msaboff, saam
Priority: P2    
Version: WebKit Nightly Build   
Hardware: Unspecified   
OS: Unspecified   

Description Yusuke Suzuki 2017-03-01 04:19:10 PST
Simple idea: we have op_next for for-of statement. And op_next usually works as similar to `call` to the next() function.
But it records the iterator/generator (IC).

In DFG / FTL tiers, if we can ensure that this op_next still calls the same generator functions,
we can skip Generator.prototype.next() function. Generator.prototype.next() is costly because all the generators use this one function.
It is inherently polymorphic. But if we can skip this and if the IC tells DFG which generator function is called, we can inline
the generator function in the call site! If it is done in FTL layer, we have a chance to drop the lexical environment creation for the generators by using object allocation sinking.
Comment 1 Saam Barati 2017-03-04 17:28:34 PST
This would be sweet. It'd make iterating Map/Set really fast
Comment 2 Saam Barati 2017-03-07 10:42:50 PST
Let's make sure this also speeds up array destructuring. See Joe's example program in:
https://bugs.webkit.org/show_bug.cgi?id=155146
Comment 3 Saam Barati 2017-03-07 10:43:07 PST
*** Bug 155146 has been marked as a duplicate of this bug. ***