Skip to content
  • benjamin@webkit.org's avatar
    Do not abuse ArrayStorage's m_length for testing array consistency · 83c15267
    benjamin@webkit.org authored
    https://bugs.webkit.org/show_bug.cgi?id=83403
    
    Patch by Benjamin Poulain <bpoulain@apple.com> on 2012-04-06
    Reviewed by Geoffrey Garen.
    
    Array creation from a list of values is a 3 steps process:
    -JSArray::tryCreateUninitialized()
    -JSArray::initializeIndex() for each values
    -JSArray::completeInitialization()
    
    Previously, the attribute m_length was not set to the final size
    JSArray::tryCreateUninitialized() because it was used to test the array
    consistency JSArray::initializeIndex().
    
    This caused the initialization loop using JSArray::initializeIndex() maintain
    two counters:
    -index of the loop
    -storage->m_length++
    
    This patch fixes this by using the index of the initialization loop for the indinces of
    JSArray::initializeIndex(). For testing consistency, the variable m_initializationIndex
    is introduced if CHECK_ARRAY_CONSISTENCY is defined.
    
    The patch also fixes minor unrelated build issue when CHECK_ARRAY_CONSISTENCY is defined.
    
    This improves the performance of JSArray creation from literals by 8%.
    
    * runtime/JSArray.cpp:
    (JSC::JSArray::tryFinishCreationUninitialized):
    (JSC::JSArray::checkConsistency):
    * runtime/JSArray.h:
    (ArrayStorage):
    (JSC::JSArray::initializeIndex):
    (JSC::JSArray::completeInitialization):
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@113530 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    83c15267