Changeset 128680 in webkit for trunk/Source/JavaScriptCore


Ignore:
Timestamp:
Sep 14, 2012, 8:29:04 PM (13 years ago)
Author:
[email protected]
Message:

All of the things in SparseArrayValueMap should be out-of-line
https://bugs.webkit.org/show_bug.cgi?id=96854

Reviewed by Andy Estes.

Those inline methods were buying us nothing.

  • GNUmakefile.list.am:
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
  • JavaScriptCore.xcodeproj/project.pbxproj:
  • runtime/JSArray.cpp:
  • runtime/JSGlobalData.cpp:
  • runtime/JSObject.cpp:
  • runtime/RegExpMatchesArray.cpp:
  • runtime/SparseArrayValueMap.cpp:

(JSC::SparseArrayValueMap::SparseArrayValueMap):
(JSC):
(JSC::SparseArrayValueMap::~SparseArrayValueMap):
(JSC::SparseArrayValueMap::finishCreation):
(JSC::SparseArrayValueMap::create):
(JSC::SparseArrayValueMap::destroy):
(JSC::SparseArrayValueMap::createStructure):
(JSC::SparseArrayValueMap::add):
(JSC::SparseArrayValueMap::putEntry):
(JSC::SparseArrayValueMap::putDirect):
(JSC::SparseArrayEntry::get):
(JSC::SparseArrayEntry::getNonSparseMode):
(JSC::SparseArrayValueMap::visitChildren):

  • runtime/SparseArrayValueMapInlineMethods.h: Removed.
Location:
trunk/Source/JavaScriptCore
Files:
1 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r128670 r128680  
     12012-09-14  Filip Pizlo  <[email protected]>
     2
     3        All of the things in SparseArrayValueMap should be out-of-line
     4        https://bugs.webkit.org/show_bug.cgi?id=96854
     5
     6        Reviewed by Andy Estes.
     7
     8        Those inline methods were buying us nothing.
     9
     10        * GNUmakefile.list.am:
     11        * JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj:
     12        * JavaScriptCore.xcodeproj/project.pbxproj:
     13        * runtime/JSArray.cpp:
     14        * runtime/JSGlobalData.cpp:
     15        * runtime/JSObject.cpp:
     16        * runtime/RegExpMatchesArray.cpp:
     17        * runtime/SparseArrayValueMap.cpp:
     18        (JSC::SparseArrayValueMap::SparseArrayValueMap):
     19        (JSC):
     20        (JSC::SparseArrayValueMap::~SparseArrayValueMap):
     21        (JSC::SparseArrayValueMap::finishCreation):
     22        (JSC::SparseArrayValueMap::create):
     23        (JSC::SparseArrayValueMap::destroy):
     24        (JSC::SparseArrayValueMap::createStructure):
     25        (JSC::SparseArrayValueMap::add):
     26        (JSC::SparseArrayValueMap::putEntry):
     27        (JSC::SparseArrayValueMap::putDirect):
     28        (JSC::SparseArrayEntry::get):
     29        (JSC::SparseArrayEntry::getNonSparseMode):
     30        (JSC::SparseArrayValueMap::visitChildren):
     31        * runtime/SparseArrayValueMapInlineMethods.h: Removed.
     32
    1332012-09-14  Mike West  <[email protected]>
    234
  • trunk/Source/JavaScriptCore/GNUmakefile.list.am

    r128400 r128680  
    648648        Source/JavaScriptCore/runtime/SmallStrings.cpp \
    649649        Source/JavaScriptCore/runtime/SmallStrings.h \
    650         Source/JavaScriptCore/runtime/SparseArrayValueMapInlineMethods.h \
    651650        Source/JavaScriptCore/runtime/SparseArrayValueMap.cpp \
    652651        Source/JavaScriptCore/runtime/SparseArrayValueMap.h \
  • trunk/Source/JavaScriptCore/JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.vcproj

    r128400 r128680  
    519519                        </File>
    520520                        <File
    521                                 RelativePath="..\..\runtime\SparseArrayValueMapInlineMethods.h"
    522                                 >
    523                         </File>
    524                         <File
    525521                                RelativePath="..\..\runtime\ArrayStorage.h"
    526522                                >
  • trunk/Source/JavaScriptCore/JavaScriptCore.xcodeproj/project.pbxproj

    r128400 r128680  
    201201                0FB7F39D15ED8E4600F167B2 /* Reject.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FB7F39115ED8E3800F167B2 /* Reject.h */; settings = {ATTRIBUTES = (Private, ); }; };
    202202                0FB7F39E15ED8E4600F167B2 /* SparseArrayValueMap.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FB7F39215ED8E3800F167B2 /* SparseArrayValueMap.h */; settings = {ATTRIBUTES = (Private, ); }; };
    203                 0FB7F39F15ED8E4600F167B2 /* SparseArrayValueMapInlineMethods.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FB7F39315ED8E3800F167B2 /* SparseArrayValueMapInlineMethods.h */; settings = {ATTRIBUTES = (Private, ); }; };
    204203                0FBC0AE71496C7C400D4FBDD /* DFGExitProfile.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 0FBC0AE41496C7C100D4FBDD /* DFGExitProfile.cpp */; };
    205204                0FBC0AE81496C7C700D4FBDD /* DFGExitProfile.h in Headers */ = {isa = PBXBuildFile; fileRef = 0FBC0AE51496C7C100D4FBDD /* DFGExitProfile.h */; settings = {ATTRIBUTES = (Private, ); }; };
     
    972971                0FB7F39115ED8E3800F167B2 /* Reject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Reject.h; sourceTree = "<group>"; };
    973972                0FB7F39215ED8E3800F167B2 /* SparseArrayValueMap.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SparseArrayValueMap.h; sourceTree = "<group>"; };
    974                 0FB7F39315ED8E3800F167B2 /* SparseArrayValueMapInlineMethods.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SparseArrayValueMapInlineMethods.h; sourceTree = "<group>"; };
    975973                0FBC0AE41496C7C100D4FBDD /* DFGExitProfile.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = DFGExitProfile.cpp; sourceTree = "<group>"; };
    976974                0FBC0AE51496C7C100D4FBDD /* DFGExitProfile.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = DFGExitProfile.h; sourceTree = "<group>"; };
     
    20582056                                0FB7F39115ED8E3800F167B2 /* Reject.h */,
    20592057                                0FB7F39215ED8E3800F167B2 /* SparseArrayValueMap.h */,
    2060                                 0FB7F39315ED8E3800F167B2 /* SparseArrayValueMapInlineMethods.h */,
    20612058                                C2D58C3315912FEE0021A844 /* GCActivityCallback.cpp */,
    20622059                                BCF605110E203EF800B9A64D /* ArgList.cpp */,
     
    29532950                                0FB7F39D15ED8E4600F167B2 /* Reject.h in Headers */,
    29542951                                0FB7F39E15ED8E4600F167B2 /* SparseArrayValueMap.h in Headers */,
    2955                                 0FB7F39F15ED8E4600F167B2 /* SparseArrayValueMapInlineMethods.h in Headers */,
    29562952                                0F0CD4C215F1A6070032F1C0 /* PutDirectIndexMode.h in Headers */,
    29572953                        );
  • trunk/Source/JavaScriptCore/runtime/JSArray.cpp

    r128667 r128680  
    3535#include "PropertyNameArray.h"
    3636#include "Reject.h"
    37 #include "SparseArrayValueMapInlineMethods.h"
    3837#include <wtf/AVLTree.h>
    3938#include <wtf/Assertions.h>
  • trunk/Source/JavaScriptCore/runtime/JSGlobalData.cpp

    r128498 r128680  
    5656#include "RegExpCache.h"
    5757#include "RegExpObject.h"
    58 #include "SparseArrayValueMapInlineMethods.h"
    5958#include "StrictEvalActivation.h"
    6059#include "StrongInlines.h"
  • trunk/Source/JavaScriptCore/runtime/JSObject.cpp

    r128428 r128680  
    4343#include "Reject.h"
    4444#include "SlotVisitorInlineMethods.h"
    45 #include "SparseArrayValueMapInlineMethods.h"
    4645#include <math.h>
    4746#include <wtf/Assertions.h>
  • trunk/Source/JavaScriptCore/runtime/RegExpMatchesArray.cpp

    r128400 r128680  
    2828
    2929#include "ButterflyInlineMethods.h"
    30 #include "SparseArrayValueMapInlineMethods.h"
    3130
    3231namespace JSC {
  • trunk/Source/JavaScriptCore/runtime/SparseArrayValueMap.cpp

    r128400 r128680  
    2828
    2929#include "ClassInfo.h"
    30 #include "SparseArrayValueMapInlineMethods.h"
     30#include "GetterSetter.h"
     31#include "JSObject.h"
     32#include "PropertySlot.h"
     33#include "Reject.h"
     34#include "SlotVisitor.h"
     35#include "Structure.h"
    3136
    3237namespace JSC {
     
    3439const ClassInfo SparseArrayValueMap::s_info = { "SparseArrayValueMap", 0, 0, 0, CREATE_METHOD_TABLE(SparseArrayValueMap) };
    3540
     41SparseArrayValueMap::SparseArrayValueMap(JSGlobalData& globalData)
     42    : Base(globalData, globalData.sparseArrayValueMapStructure.get())
     43    , m_flags(Normal)
     44    , m_reportedCapacity(0)
     45{
     46}
     47
     48SparseArrayValueMap::~SparseArrayValueMap()
     49{
     50}
     51
     52void SparseArrayValueMap::finishCreation(JSGlobalData& globalData)
     53{
     54    Base::finishCreation(globalData);
     55}
     56
     57SparseArrayValueMap* SparseArrayValueMap::create(JSGlobalData& globalData)
     58{
     59    SparseArrayValueMap* result = new (NotNull, allocateCell<SparseArrayValueMap>(globalData.heap)) SparseArrayValueMap(globalData);
     60    result->finishCreation(globalData);
     61    return result;
     62}
     63
     64void SparseArrayValueMap::destroy(JSCell* cell)
     65{
     66    static_cast<SparseArrayValueMap*>(cell)->SparseArrayValueMap::~SparseArrayValueMap();
     67}
     68
     69Structure* SparseArrayValueMap::createStructure(JSGlobalData& globalData, JSGlobalObject* globalObject, JSValue prototype)
     70{
     71    return Structure::create(globalData, globalObject, prototype, TypeInfo(CompoundType, StructureFlags), &s_info);
     72}
     73
     74SparseArrayValueMap::AddResult SparseArrayValueMap::add(JSObject* array, unsigned i)
     75{
     76    SparseArrayEntry entry;
     77    entry.setWithoutWriteBarrier(jsUndefined());
     78
     79    AddResult result = m_map.add(i, entry);
     80    size_t capacity = m_map.capacity();
     81    if (capacity != m_reportedCapacity) {
     82        Heap::heap(array)->reportExtraMemoryCost((capacity - m_reportedCapacity) * (sizeof(unsigned) + sizeof(WriteBarrier<Unknown>)));
     83        m_reportedCapacity = capacity;
     84    }
     85    return result;
     86}
     87
     88void SparseArrayValueMap::putEntry(ExecState* exec, JSObject* array, unsigned i, JSValue value, bool shouldThrow)
     89{
     90    AddResult result = add(array, i);
     91    SparseArrayEntry& entry = result.iterator->second;
     92
     93    // To save a separate find & add, we first always add to the sparse map.
     94    // In the uncommon case that this is a new property, and the array is not
     95    // extensible, this is not the right thing to have done - so remove again.
     96    if (result.isNewEntry && !array->isExtensible()) {
     97        remove(result.iterator);
     98        if (shouldThrow)
     99            throwTypeError(exec, StrictModeReadonlyPropertyWriteError);
     100        return;
     101    }
     102
     103    if (!(entry.attributes & Accessor)) {
     104        if (entry.attributes & ReadOnly) {
     105            if (shouldThrow)
     106                throwTypeError(exec, StrictModeReadonlyPropertyWriteError);
     107            return;
     108        }
     109
     110        entry.set(exec->globalData(), this, value);
     111        return;
     112    }
     113
     114    JSValue accessor = entry.SparseArrayEntry::Base::get();
     115    ASSERT(accessor.isGetterSetter());
     116    JSObject* setter = asGetterSetter(accessor)->setter();
     117   
     118    if (!setter) {
     119        if (shouldThrow)
     120            throwTypeError(exec, StrictModeReadonlyPropertyWriteError);
     121        return;
     122    }
     123
     124    CallData callData;
     125    CallType callType = setter->methodTable()->getCallData(setter, callData);
     126    MarkedArgumentBuffer args;
     127    args.append(value);
     128    call(exec, setter, callType, callData, array, args);
     129}
     130
     131bool SparseArrayValueMap::putDirect(ExecState* exec, JSObject* array, unsigned i, JSValue value, unsigned attributes, PutDirectIndexMode mode)
     132{
     133    AddResult result = add(array, i);
     134    SparseArrayEntry& entry = result.iterator->second;
     135
     136    // To save a separate find & add, we first always add to the sparse map.
     137    // In the uncommon case that this is a new property, and the array is not
     138    // extensible, this is not the right thing to have done - so remove again.
     139    if (mode != PutDirectIndexLikePutDirect && result.isNewEntry && !array->isExtensible()) {
     140        remove(result.iterator);
     141        return reject(exec, mode == PutDirectIndexShouldThrow, "Attempting to define property on object that is not extensible.");
     142    }
     143
     144    entry.attributes = attributes;
     145    entry.set(exec->globalData(), this, value);
     146    return true;
     147}
     148
     149void SparseArrayEntry::get(PropertySlot& slot) const
     150{
     151    JSValue value = Base::get();
     152    ASSERT(value);
     153
     154    if (LIKELY(!value.isGetterSetter())) {
     155        slot.setValue(value);
     156        return;
     157    }
     158
     159    JSObject* getter = asGetterSetter(value)->getter();
     160    if (!getter) {
     161        slot.setUndefined();
     162        return;
     163    }
     164
     165    slot.setGetterSlot(getter);
     166}
     167
     168void SparseArrayEntry::get(PropertyDescriptor& descriptor) const
     169{
     170    descriptor.setDescriptor(Base::get(), attributes);
     171}
     172
     173JSValue SparseArrayEntry::get(ExecState* exec, JSObject* array) const
     174{
     175    JSValue result = Base::get();
     176    ASSERT(result);
     177
     178    if (LIKELY(!result.isGetterSetter()))
     179        return result;
     180
     181    JSObject* getter = asGetterSetter(result)->getter();
     182    if (!getter)
     183        return jsUndefined();
     184
     185    CallData callData;
     186    CallType callType = getter->methodTable()->getCallData(getter, callData);
     187    return call(exec, getter, callType, callData, array, exec->emptyList());
     188}
     189
     190JSValue SparseArrayEntry::getNonSparseMode() const
     191{
     192    ASSERT(!attributes);
     193    return Base::get();
     194}
     195
     196void SparseArrayValueMap::visitChildren(JSCell* thisObject, SlotVisitor& visitor)
     197{
     198    Base::visitChildren(thisObject, visitor);
     199   
     200    SparseArrayValueMap* thisMap = jsCast<SparseArrayValueMap*>(thisObject);
     201    iterator end = thisMap->m_map.end();
     202    for (iterator it = thisMap->m_map.begin(); it != end; ++it)
     203        visitor.append(&it->second);
     204}
     205
    36206} // namespace JSC
    37207
Note: See TracChangeset for help on using the changeset viewer.