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/JSONObject.cpp

    r77151 r79132  
    135135        return value;
    136136    JSObject* object = asObject(value);
    137     if (object->inherits(&NumberObject::info))
     137    if (object->inherits(&NumberObject::s_info))
    138138        return jsNumber(object->toNumber(exec));
    139     if (object->inherits(&StringObject::info))
     139    if (object->inherits(&StringObject::s_info))
    140140        return jsString(exec, object->toString(exec));
    141     if (object->inherits(&BooleanObject::info))
     141    if (object->inherits(&BooleanObject::s_info))
    142142        return object->toPrimitive(exec);
    143143    return value;
     
    213213        return;
    214214
    215     if (asObject(m_replacer)->inherits(&JSArray::info)) {
     215    if (asObject(m_replacer)->inherits(&JSArray::s_info)) {
    216216        m_usingArrayReplacer = true;
    217217        JSObject* array = asObject(m_replacer);
     
    235235
    236236            if (name.isObject()) {
    237                 if (!asObject(name)->inherits(&NumberObject::info) && !asObject(name)->inherits(&StringObject::info))
     237                if (!asObject(name)->inherits(&NumberObject::s_info) && !asObject(name)->inherits(&StringObject::s_info))
    238238                    continue;
    239239                propertyName = name.toString(exec);
     
    377377    }
    378378
    379     if (value.isUndefined() && !holder->inherits(&JSArray::info))
     379    if (value.isUndefined() && !holder->inherits(&JSArray::s_info))
    380380        return StringifyFailedDueToUndefinedValue;
    381381
     
    417417    CallData callData;
    418418    if (object->getCallData(callData) != CallTypeNone) {
    419         if (holder->inherits(&JSArray::info)) {
     419        if (holder->inherits(&JSArray::s_info)) {
    420420            builder.append("null");
    421421            return StringifySucceeded;
     
    487487inline Stringifier::Holder::Holder(JSObject* object)
    488488    : m_object(object)
    489     , m_isArray(object->inherits(&JSArray::info))
     489    , m_isArray(object->inherits(&JSArray::s_info))
    490490    , m_index(0)
    491491{
     
    602602// ------------------------------ JSONObject --------------------------------
    603603
    604 const ClassInfo JSONObject::info = { "JSON", 0, 0, ExecState::jsonTable };
     604const ClassInfo JSONObject::s_info = { "JSON", &JSObjectWithGlobalObject::s_info, 0, ExecState::jsonTable };
    605605
    606606/* Source for JSONObject.lut.h
     
    679679            case ArrayStartState: {
    680680                ASSERT(inValue.isObject());
    681                 ASSERT(isJSArray(&m_exec->globalData(), asObject(inValue)) || asObject(inValue)->inherits(&JSArray::info));
     681                ASSERT(isJSArray(&m_exec->globalData(), asObject(inValue)) || asObject(inValue)->inherits(&JSArray::s_info));
    682682                if (objectStack.size() + arrayStack.size() > maximumFilterRecursion)
    683683                    return throwError(m_exec, createStackOverflowError(m_exec));
     
    740740            case ObjectStartState: {
    741741                ASSERT(inValue.isObject());
    742                 ASSERT(!isJSArray(&m_exec->globalData(), asObject(inValue)) && !asObject(inValue)->inherits(&JSArray::info));
     742                ASSERT(!isJSArray(&m_exec->globalData(), asObject(inValue)) && !asObject(inValue)->inherits(&JSArray::s_info));
    743743                if (objectStack.size() + arrayStack.size() > maximumFilterRecursion)
    744744                    return throwError(m_exec, createStackOverflowError(m_exec));
     
    807807                }
    808808                JSObject* object = asObject(inValue);
    809                 if (isJSArray(&m_exec->globalData(), object) || object->inherits(&JSArray::info))
     809                if (isJSArray(&m_exec->globalData(), object) || object->inherits(&JSArray::s_info))
    810810                    goto arrayStartState;
    811811                goto objectStartState;
Note: See TracChangeset for help on using the changeset viewer.