Commit 9e127924 authored by darin@apple.com's avatar darin@apple.com

2008-06-28 Darin Adler <darin@apple.com>

        Reviewed by Cameron.

        - https://bugs.webkit.org/show_bug.cgi?id=19804
          optimize access to arrays without "holes"

        SunSpider says 1.8% faster.

        * kjs/JSArray.cpp:
        (KJS::JSArray::JSArray): Initialize m_fastAccessCutoff when creating
        arrays. Also updated for new location of m_vectorLength.
        (KJS::JSArray::getItem): Updated for new location of m_vectorLength.
        (KJS::JSArray::getSlowCase): Added. Broke out the non-hot parts of
        getOwnPropertySlot to make the hot part faster.
        (KJS::JSArray::getOwnPropertySlot): Added a new faster case for
        indices lower than m_fastAccessCutoff. We can do theese with no
        additional checks or branches.
        (KJS::JSArray::put): Added a new faster case for indices lower than
        m_fastAccessCutoff. We can do theese with no additional checks or
        branches. Moved the maxArrayIndex handling out of this function.
        Added code to set m_fastAccessCutoff when the very last hole in
        an array is filled; this is how the cutoff gets set for most arrays.
        (KJS::JSArray::putSlowCase): Moved the rest of the put function logic
        in here, to make the hot part of the put function faster.
        (KJS::JSArray::deleteProperty): Added code to lower m_fastAccessCutoff
        when a delete makes a new hole in the array.
        (KJS::JSArray::getPropertyNames): Updated for new location of
        m_vectorLength.
        (KJS::JSArray::increaseVectorLength): Ditto.
        (KJS::JSArray::setLength): Added code to lower m_fastAccessCutoff
        when setLength makes the array smaller.
        (KJS::JSArray::mark): Updated for new location of m_vectorLength.
        (KJS::JSArray::sort): Ditto. Set m_fastAccessCutoff after moving
        all the holes to the end of the array.
        (KJS::JSArray::compactForSorting): Ditto.
        (KJS::JSArray::checkConsistency): Added consistency checks fro
        m_fastAccessCutoff and updated for the new location of m_vectorLength.

        * kjs/JSArray.h: Added declarations for slow case functions.
        Replaced m_vectorLength with m_fastAccessCutoff.



git-svn-id: http://svn.webkit.org/repository/webkit/trunk@34867 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 64b5b6cf
2008-06-28 Darin Adler <darin@apple.com>
Reviewed by Cameron.
- https://bugs.webkit.org/show_bug.cgi?id=19804
optimize access to arrays without "holes"
SunSpider says 1.8% faster.
* kjs/JSArray.cpp:
(KJS::JSArray::JSArray): Initialize m_fastAccessCutoff when creating
arrays. Also updated for new location of m_vectorLength.
(KJS::JSArray::getItem): Updated for new location of m_vectorLength.
(KJS::JSArray::getSlowCase): Added. Broke out the non-hot parts of
getOwnPropertySlot to make the hot part faster.
(KJS::JSArray::getOwnPropertySlot): Added a new faster case for
indices lower than m_fastAccessCutoff. We can do theese with no
additional checks or branches.
(KJS::JSArray::put): Added a new faster case for indices lower than
m_fastAccessCutoff. We can do theese with no additional checks or
branches. Moved the maxArrayIndex handling out of this function.
Added code to set m_fastAccessCutoff when the very last hole in
an array is filled; this is how the cutoff gets set for most arrays.
(KJS::JSArray::putSlowCase): Moved the rest of the put function logic
in here, to make the hot part of the put function faster.
(KJS::JSArray::deleteProperty): Added code to lower m_fastAccessCutoff
when a delete makes a new hole in the array.
(KJS::JSArray::getPropertyNames): Updated for new location of
m_vectorLength.
(KJS::JSArray::increaseVectorLength): Ditto.
(KJS::JSArray::setLength): Added code to lower m_fastAccessCutoff
when setLength makes the array smaller.
(KJS::JSArray::mark): Updated for new location of m_vectorLength.
(KJS::JSArray::sort): Ditto. Set m_fastAccessCutoff after moving
all the holes to the end of the array.
(KJS::JSArray::compactForSorting): Ditto.
(KJS::JSArray::checkConsistency): Added consistency checks fro
m_fastAccessCutoff and updated for the new location of m_vectorLength.
* kjs/JSArray.h: Added declarations for slow case functions.
Replaced m_vectorLength with m_fastAccessCutoff.
2008-06-28 Cameron Zwarich <cwzwarich@uwaterloo.ca>
Reviewed by Sam.
......
This diff is collapsed.
......@@ -63,7 +63,9 @@ namespace KJS {
virtual const ClassInfo* classInfo() const { return &info; }
static JSValue* lengthGetter(ExecState*, const Identifier&, const PropertySlot&);
bool inlineGetOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&);
bool getOwnPropertySlotSlowCase(ExecState*, unsigned propertyName, PropertySlot&);
void putSlowCase(ExecState*, unsigned propertyName, JSValue*);
bool increaseVectorLength(unsigned newLength);
......@@ -73,7 +75,7 @@ namespace KJS {
void checkConsistency(ConsistencyCheckType = NormalConsistencyCheck);
unsigned m_length;
unsigned m_vectorLength;
unsigned m_fastAccessCutoff;
ArrayStorage* m_storage;
};
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment