Ignore:
Timestamp:
Feb 19, 2011, 1:55:44 PM (14 years ago)
Author:
[email protected]
Message:

Bug 54786 - Devirtualize JSCell::classInfo()

Reviewed by Sam Weinig.

Instead of making a virtual function call, add a pointer to the ClassInfo
onto Structure.

This removes a virtual function call, and paves the way towards removing all
the createStructure methods, and StructureFlags/AnonymousSlotCount properties
(these should be able to move onto ClassInfo).

Calls to Structure::create must now pass a pointer to the ClassInfo for the
structure. All objects now have a ClassInfo pointer, non-object cell types
still do not.

Changes are most mechanical, involving three steps:

  • Remove virtual classInfo() methods.
  • Add &s_info parameter to calls to Structure::create.
  • Rename ClassInfo static members on classes from 'info' to 's_info', for consistency.

Source/JavaScriptCore:

  • API/JSCallbackConstructor.cpp:
  • API/JSCallbackConstructor.h:
  • API/JSCallbackFunction.cpp:
  • API/JSCallbackFunction.h:
  • API/JSCallbackObject.cpp:
  • API/JSCallbackObject.h:
  • API/JSCallbackObjectFunctions.h:
  • API/JSObjectRef.cpp:
  • API/JSValueRef.cpp:
  • API/JSWeakObjectMapRefPrivate.cpp:
  • JavaScriptCore.exp:
  • debugger/Debugger.cpp:
  • debugger/DebuggerActivation.h:
  • debugger/DebuggerCallFrame.cpp:
  • interpreter/Interpreter.cpp:
  • jit/JITCall32_64.cpp:
  • jit/JITOpcodes.cpp:
  • jit/JITStubs.cpp:
  • profiler/Profiler.cpp:
  • runtime/Arguments.cpp:
  • runtime/Arguments.h:
  • runtime/ArrayConstructor.cpp:
  • runtime/ArrayPrototype.cpp:
  • runtime/ArrayPrototype.h:
  • runtime/BooleanObject.cpp:
  • runtime/BooleanObject.h:
  • runtime/BooleanPrototype.cpp:
  • runtime/DateConstructor.cpp:
  • runtime/DateInstance.cpp:
  • runtime/DateInstance.h:
  • runtime/DatePrototype.cpp:
  • runtime/DatePrototype.h:
  • runtime/ErrorInstance.cpp:
  • runtime/ErrorInstance.h:
  • runtime/ErrorPrototype.cpp:
  • runtime/FunctionPrototype.cpp:
  • runtime/FunctionPrototype.h:
  • runtime/GetterSetter.h:
  • runtime/GlobalEvalFunction.h:
  • runtime/InternalFunction.cpp:
  • runtime/InternalFunction.h:
  • runtime/JSAPIValueWrapper.h:
  • runtime/JSActivation.cpp:
  • runtime/JSActivation.h:
  • runtime/JSArray.cpp:
  • runtime/JSArray.h:
  • runtime/JSByteArray.cpp:
  • runtime/JSByteArray.h:
  • runtime/JSCell.cpp:
  • runtime/JSCell.h:
  • runtime/JSFunction.cpp:
  • runtime/JSFunction.h:
  • runtime/JSGlobalData.cpp:
  • runtime/JSGlobalObject.cpp:
  • runtime/JSGlobalObject.h:
  • runtime/JSNotAnObject.h:
  • runtime/JSONObject.cpp:
  • runtime/JSONObject.h:
  • runtime/JSObject.cpp:
  • runtime/JSObject.h:
  • runtime/JSObjectWithGlobalObject.h:
  • runtime/JSPropertyNameIterator.h:
  • runtime/JSStaticScopeObject.h:
  • runtime/JSString.h:
  • runtime/JSVariableObject.h:
  • runtime/JSWrapperObject.h:
  • runtime/JSZombie.cpp:
  • runtime/JSZombie.h:
  • runtime/Lookup.cpp:
  • runtime/MathObject.cpp:
  • runtime/MathObject.h:
  • runtime/NativeErrorConstructor.cpp:
  • runtime/NativeErrorConstructor.h:
  • runtime/NumberConstructor.cpp:
  • runtime/NumberConstructor.h:
  • runtime/NumberObject.cpp:
  • runtime/NumberObject.h:
  • runtime/NumberPrototype.cpp:
  • runtime/ObjectConstructor.cpp:
  • runtime/ObjectPrototype.cpp:
  • runtime/RegExpConstructor.cpp:
  • runtime/RegExpConstructor.h:
  • runtime/RegExpObject.cpp:
  • runtime/RegExpObject.h:
  • runtime/RegExpPrototype.cpp:
  • runtime/ScopeChain.cpp:
  • runtime/StringConstructor.cpp:
  • runtime/StringObject.cpp:
  • runtime/StringObject.h:
  • runtime/StringObjectThatMasqueradesAsUndefined.h:
  • runtime/StringPrototype.cpp:
  • runtime/StringPrototype.h:
  • runtime/Structure.cpp:
  • runtime/Structure.h:

Source/JavaScriptGlue:

  • JSUtils.cpp:

(KJSValueToJSObject):
(KJSValueToCFTypeInternal):

  • UserObjectImp.cpp:
  • UserObjectImp.h:

(UserObjectImp::createStructure):

Source/WebCore:

  • WebCore.exp.in:
  • bindings/js/JSAudioConstructor.cpp:
  • bindings/js/JSAudioConstructor.h:
  • bindings/js/JSDOMBinding.cpp:
  • bindings/js/JSDOMBinding.h:
  • bindings/js/JSDOMGlobalObject.cpp:
  • bindings/js/JSDOMGlobalObject.h:
  • bindings/js/JSDOMWindowBase.cpp:
  • bindings/js/JSDOMWindowBase.h:
  • bindings/js/JSDOMWindowShell.cpp:
  • bindings/js/JSDOMWindowShell.h:
  • bindings/js/JSGeolocationCustom.cpp:
  • bindings/js/JSImageConstructor.cpp:
  • bindings/js/JSImageConstructor.h:
  • bindings/js/JSImageDataCustom.cpp:
  • bindings/js/JSOptionConstructor.cpp:
  • bindings/js/JSOptionConstructor.h:
  • bindings/js/JSWorkerContextBase.cpp:
  • bindings/js/JSWorkerContextBase.h:
  • bindings/js/SerializedScriptValue.cpp:
  • bindings/scripts/CodeGeneratorJS.pm:
  • bridge/c/CRuntimeObject.cpp:
  • bridge/c/CRuntimeObject.h:
  • bridge/c/c_instance.cpp:
  • bridge/jni/jsc/JNIUtilityPrivate.cpp:
  • bridge/jni/jsc/JavaInstanceJSC.cpp:
  • bridge/jni/jsc/JavaRuntimeObject.cpp:
  • bridge/jni/jsc/JavaRuntimeObject.h:
  • bridge/jsc/BridgeJSC.cpp:
  • bridge/objc/ObjCRuntimeObject.h:
  • bridge/objc/ObjCRuntimeObject.mm:
  • bridge/objc/objc_instance.mm:
  • bridge/objc/objc_runtime.h:
  • bridge/objc/objc_runtime.mm:
  • bridge/runtime_array.cpp:
  • bridge/runtime_array.h:
  • bridge/runtime_method.cpp:
  • bridge/runtime_method.h:
  • bridge/runtime_object.cpp:
  • bridge/runtime_object.h:

Source/WebKit/mac:

  • Plugins/Hosted/ProxyInstance.mm:

(WebKit::ProxyRuntimeMethod::ProxyRuntimeMethod):
(WebKit::ProxyRuntimeMethod::createStructure):

  • Plugins/Hosted/ProxyRuntimeObject.h:

(WebKit::ProxyRuntimeObject::createStructure):

  • Plugins/Hosted/ProxyRuntimeObject.mm:

(WebKit::ProxyRuntimeObject::ProxyRuntimeObject):

  • WebView/WebView.mm:

(aeDescFromJSValue):

Source/WebKit2:

  • WebProcess/Plugins/Netscape/JSNPMethod.cpp:

(WebKit::JSNPMethod::JSNPMethod):

  • WebProcess/Plugins/Netscape/JSNPMethod.h:

(WebKit::JSNPMethod::createStructure):

  • WebProcess/Plugins/Netscape/JSNPObject.cpp:

(WebKit::JSNPObject::JSNPObject):

  • WebProcess/Plugins/Netscape/JSNPObject.h:

(WebKit::JSNPObject::createStructure):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/Structure.cpp

    r78732 r79132  
    224224}
    225225
    226 Structure::Structure(JSValue prototype, const TypeInfo& typeInfo, unsigned anonymousSlotCount)
     226Structure::Structure(JSValue prototype, const TypeInfo& typeInfo, unsigned anonymousSlotCount, const ClassInfo* classInfo)
    227227    : m_typeInfo(typeInfo)
    228228    , m_prototype(prototype)
    229229    , m_specificValueInPrevious(0)
     230    , m_classInfo(classInfo)
    230231    , m_propertyTable(0)
    231232    , m_propertyStorageCapacity(typeInfo.isFinal() ? JSFinalObject_inlineStorageCapacity : JSNonFinalObject_inlineStorageCapacity)
     
    260261}
    261262
     263Structure::Structure(const Structure* previous)
     264    : m_typeInfo(previous->typeInfo())
     265    , m_prototype(previous->storedPrototype())
     266    , m_specificValueInPrevious(0)
     267    , m_classInfo(previous->m_classInfo)
     268    , m_propertyTable(0)
     269    , m_propertyStorageCapacity(previous->m_propertyStorageCapacity)
     270    , m_offset(noOffset)
     271    , m_dictionaryKind(NoneDictionaryKind)
     272    , m_isPinnedPropertyTable(false)
     273    , m_hasGetterSetterProperties(previous->m_hasGetterSetterProperties)
     274    , m_hasNonEnumerableProperties(previous->m_hasNonEnumerableProperties)
     275    , m_attributesInPrevious(0)
     276    , m_specificFunctionThrashCount(previous->m_specificFunctionThrashCount)
     277    , m_anonymousSlotCount(previous->anonymousSlotCount())
     278    , m_isUsingSingleSlot(true)
     279{
     280    m_transitions.m_singleTransition = 0;
     281
     282    ASSERT(m_prototype);
     283    ASSERT(m_prototype->isObject() || m_prototype->isNull());
     284
     285#ifndef NDEBUG
     286#if ENABLE(JSC_MULTIPLE_THREADS)
     287    MutexLocker protect(ignoreSetMutex);
     288#endif
     289    if (shouldIgnoreLeaks)
     290        ignoreSet.add(this);
     291    else
     292        structureCounter.increment();
     293#endif
     294
     295#if DUMP_STRUCTURE_ID_STATISTICS
     296    liveStructureSet.add(this);
     297#endif
     298}
     299
    262300Structure::~Structure()
    263301{
     
    476514    }
    477515
    478     RefPtr<Structure> transition = create(structure->m_prototype.get(), structure->typeInfo(), structure->anonymousSlotCount());
     516    RefPtr<Structure> transition = create(structure);
    479517
    480518    transition->m_cachedPrototypeChain = structure->m_cachedPrototypeChain;
     
    483521    transition->m_attributesInPrevious = attributes;
    484522    transition->m_specificValueInPrevious = specificValue;
    485     transition->m_propertyStorageCapacity = structure->m_propertyStorageCapacity;
    486     transition->m_hasGetterSetterProperties = structure->m_hasGetterSetterProperties;
    487     transition->m_hasNonEnumerableProperties = structure->m_hasNonEnumerableProperties;
    488     transition->m_specificFunctionThrashCount = structure->m_specificFunctionThrashCount;
    489523
    490524    if (structure->m_propertyTable) {
     
    529563PassRefPtr<Structure> Structure::changePrototypeTransition(Structure* structure, JSValue prototype)
    530564{
    531     RefPtr<Structure> transition = create(prototype, structure->typeInfo(), structure->anonymousSlotCount());
    532 
    533     transition->m_propertyStorageCapacity = structure->m_propertyStorageCapacity;
    534     transition->m_hasGetterSetterProperties = structure->m_hasGetterSetterProperties;
    535     transition->m_hasNonEnumerableProperties = structure->m_hasNonEnumerableProperties;
    536     transition->m_specificFunctionThrashCount = structure->m_specificFunctionThrashCount;
     565    RefPtr<Structure> transition = create(structure);
     566
     567    transition->m_prototype = prototype;
    537568
    538569    // Don't set m_offset, as one can not transition to this.
     
    549580{
    550581    ASSERT(structure->m_specificFunctionThrashCount < maxSpecificFunctionThrashCount);
    551     RefPtr<Structure> transition = create(structure->storedPrototype(), structure->typeInfo(), structure->anonymousSlotCount());
    552 
    553     transition->m_propertyStorageCapacity = structure->m_propertyStorageCapacity;
    554     transition->m_hasGetterSetterProperties = structure->m_hasGetterSetterProperties;
    555     transition->m_hasNonEnumerableProperties = structure->m_hasNonEnumerableProperties;
    556     transition->m_specificFunctionThrashCount = structure->m_specificFunctionThrashCount + 1;
     582    RefPtr<Structure> transition = create(structure);
     583
     584    ++transition->m_specificFunctionThrashCount;
    557585
    558586    // Don't set m_offset, as one can not transition to this.
     
    575603PassRefPtr<Structure> Structure::getterSetterTransition(Structure* structure)
    576604{
    577     RefPtr<Structure> transition = create(structure->storedPrototype(), structure->typeInfo(), structure->anonymousSlotCount());
    578     transition->m_propertyStorageCapacity = structure->m_propertyStorageCapacity;
    579     transition->m_hasGetterSetterProperties = transition->m_hasGetterSetterProperties;
    580     transition->m_hasNonEnumerableProperties = structure->m_hasNonEnumerableProperties;
    581     transition->m_specificFunctionThrashCount = structure->m_specificFunctionThrashCount;
     605    RefPtr<Structure> transition = create(structure);
    582606
    583607    // Don't set m_offset, as one can not transition to this.
     
    595619    ASSERT(!structure->isUncacheableDictionary());
    596620   
    597     RefPtr<Structure> transition = create(structure->m_prototype.get(), structure->typeInfo(), structure->anonymousSlotCount());
    598     transition->m_dictionaryKind = kind;
    599     transition->m_propertyStorageCapacity = structure->m_propertyStorageCapacity;
    600     transition->m_hasGetterSetterProperties = structure->m_hasGetterSetterProperties;
    601     transition->m_hasNonEnumerableProperties = structure->m_hasNonEnumerableProperties;
    602     transition->m_specificFunctionThrashCount = structure->m_specificFunctionThrashCount;
    603    
     621    RefPtr<Structure> transition = create(structure);
     622
    604623    structure->materializePropertyMapIfNecessary();
    605624    transition->m_propertyTable = structure->copyPropertyTable();
    606625    transition->m_isPinnedPropertyTable = true;
     626    transition->m_dictionaryKind = kind;
    607627   
    608628    ASSERT(structure->anonymousSlotCount() == transition->anonymousSlotCount());
Note: See TracChangeset for help on using the changeset viewer.