Ignore:
Timestamp:
Oct 3, 2009, 10:01:14 AM (16 years ago)
Author:
[email protected]
Message:

Removed the concept of a "fast access cutoff" in arrays, because it
punished some patterns of array access too much, and made things too
complex for inlining in some cases.

Patch by Geoffrey Garen <[email protected]> on 2009-10-02
Reviewed by Sam Weinig.

1.3% speedup on SunSpider.

  • jit/JITOpcodes.cpp:

(JSC::JIT::emitSlow_op_get_by_val):
(JSC::JIT::emitSlow_op_put_by_val):

  • jit/JITPropertyAccess.cpp:

(JSC::JIT::emit_op_get_by_val):
(JSC::JIT::emitSlow_op_get_by_val):
(JSC::JIT::emit_op_put_by_val):
(JSC::JIT::emitSlow_op_put_by_val):

  • jit/JITStubs.cpp:
  • jit/JITStubs.h:

(JSC::): Check m_vectorLength instead of m_fastAccessCutoff when
getting / putting from / to an array. Inline putting past the end of
the array.

  • runtime/JSArray.cpp:

(JSC::JSArray::JSArray):
(JSC::JSArray::getOwnPropertySlot):
(JSC::JSArray::getOwnPropertyDescriptor):
(JSC::JSArray::put):
(JSC::JSArray::putSlowCase):
(JSC::JSArray::deleteProperty):
(JSC::JSArray::getOwnPropertyNames):
(JSC::JSArray::increaseVectorLength):
(JSC::JSArray::setLength):
(JSC::JSArray::pop):
(JSC::JSArray::push):
(JSC::JSArray::sort):
(JSC::JSArray::fillArgList):
(JSC::JSArray::copyToRegisters):
(JSC::JSArray::compactForSorting):
(JSC::JSArray::checkConsistency):

  • runtime/JSArray.h:

(JSC::JSArray::canGetIndex):
(JSC::JSArray::canSetIndex):
(JSC::JSArray::setIndex):
(JSC::JSArray::markChildrenDirect): Removed m_fastAccessCutoff, and
replaced with checks for JSValue() to detect reads and writes from / to
uninitialized parts of the array.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/runtime/JSArray.h

    r48836 r49065  
    3030    struct ArrayStorage {
    3131        unsigned m_length;
    32         unsigned m_vectorLength;
    3332        unsigned m_numValuesInVector;
    3433        SparseArrayValueMap* m_sparseValueMap;
     
    6463        JSValue pop();
    6564
    66         bool canGetIndex(unsigned i) { return i < m_fastAccessCutoff; }
     65        bool canGetIndex(unsigned i) { return i < m_vectorLength && m_storage->m_vector[i]; }
    6766        JSValue getIndex(unsigned i)
    6867        {
     
    7170        }
    7271
    73         bool canSetIndex(unsigned i) { return i < m_fastAccessCutoff; }
    74         JSValue setIndex(unsigned i, JSValue v)
     72        bool canSetIndex(unsigned i) { return i < m_vectorLength; }
     73        void setIndex(unsigned i, JSValue v)
    7574        {
    7675            ASSERT(canSetIndex(i));
    77             return m_storage->m_vector[i] = v;
     76            JSValue& x = m_storage->m_vector[i];
     77            if (!x) {
     78                ++m_storage->m_numValuesInVector;
     79                if (i >= m_storage->m_length)
     80                    m_storage->m_length = i + 1;
     81            }
     82            x = v;
    7883        }
    7984
     
    111116        void checkConsistency(ConsistencyCheckType = NormalConsistencyCheck);
    112117
    113         unsigned m_fastAccessCutoff;
     118        unsigned m_vectorLength;
    114119        ArrayStorage* m_storage;
    115120    };
     
    140145        ArrayStorage* storage = m_storage;
    141146
    142         unsigned usedVectorLength = std::min(storage->m_length, storage->m_vectorLength);
     147        unsigned usedVectorLength = std::min(storage->m_length, m_vectorLength);
    143148        markStack.appendValues(storage->m_vector, usedVectorLength, MayContainNullValues);
    144149
Note: See TracChangeset for help on using the changeset viewer.