Skip to content
  • oliver@apple.com's avatar
    Convert for-of iteration to in-band signalling so we can trivially avoid... · 393e9af9
    oliver@apple.com authored
    Convert for-of iteration to in-band signalling so we can trivially avoid unnecessary object allocation
    https://bugs.webkit.org/show_bug.cgi?id=122532
    
    Reviewed by Michael Saboff.
    
    Source/JavaScriptCore:
    
    Switch for-of enumeration to use in band signalling to determine the end
    of iteration.  This allows us to trivially remove an otherwise unnecessary
    object allocation, and paves the way for optimised thunks in future.
    
    We can re-add explicit .next() functions in future that would marshall
    the true iteration functions, but for now we'll ignore them.
    
    This results in a huge improvement in the performance of for-of (in the order
    of 2x) but there's still a long way to go in order to get the performance to
    a satisfactory level.
    
    * bytecompiler/NodesCodegen.cpp:
    (JSC::ForOfNode::emitBytecode):
    * runtime/ArrayIteratorPrototype.cpp:
    (JSC::ArrayIteratorPrototype::finishCreation):
    (JSC::createIteratorResult):
    * runtime/CommonIdentifiers.cpp:
    (JSC::CommonIdentifiers::CommonIdentifiers):
    * runtime/CommonIdentifiers.h:
    * runtime/Identifier.cpp:
    (JSC::Identifier::addSlowCase):
    * runtime/JSObject.h:
    (JSC::JSFinalObject::create):
    * runtime/VM.cpp:
    (JSC::VM::VM):
    * runtime/VM.h:
    
    LayoutTests:
    
    Update tests to reflect our non-exposure of .next()
    
    * js/array-iterators-expected.txt:
    * js/script-tests/array-iterators.js:
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@157150 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    393e9af9