Ignore:
Timestamp:
Sep 1, 2011, 4:49:23 PM (14 years ago)
Author:
[email protected]
Message:

Unzip initialization lists and constructors in JSCell hierarchy (4/7)
https://bugs.webkit.org/show_bug.cgi?id=67174

Patch by Mark Hahnenberg <[email protected]> on 2011-09-01
Reviewed by Oliver Hunt.

Source/JavaScriptCore:

Completed the fourth level of the refactoring to add finishCreation()
methods to all classes within the JSCell hierarchy with non-trivial
constructor bodies.

This primarily consists of pushing the calls to finishCreation() down
into the constructors of the subclasses of the second level of the hierarchy
as well as pulling the finishCreation() calls out into the class's corresponding
create() method if it has one. Doing both simultaneously allows us to
maintain the invariant that the finishCreation() method chain is called exactly
once during the creation of an object, since calling it any other number of
times (0, 2, or more) will cause an assertion failure.

  • API/JSCallbackConstructor.cpp:

(JSC::JSCallbackConstructor::JSCallbackConstructor):
(JSC::JSCallbackConstructor::finishCreation):

  • API/JSCallbackConstructor.h:
  • API/JSCallbackObject.h:

(JSC::JSCallbackObject::create):

  • API/JSCallbackObjectFunctions.h:

(JSC::::JSCallbackObject):
(JSC::::finishCreation):

(JSC::DebuggerActivation::DebuggerActivation):
(JSC::DebuggerActivation::create):

  • debugger/DebuggerActivation.h:
  • runtime/Arguments.h:

(JSC::Arguments::create):
(JSC::Arguments::createNoParameters):
(JSC::Arguments::Arguments):

  • runtime/ArrayPrototype.cpp:

(JSC::ArrayPrototype::ArrayPrototype):
(JSC::ArrayPrototype::finishCreation):

  • runtime/ArrayPrototype.h:
  • runtime/BooleanObject.cpp:

(JSC::BooleanObject::BooleanObject):
(JSC::BooleanObject::finishCreation):

  • runtime/BooleanObject.h:
  • runtime/DateInstance.cpp:

(JSC::DateInstance::DateInstance):
(JSC::DateInstance::finishCreation):

  • runtime/DateInstance.h:
  • runtime/ErrorInstance.cpp:

(JSC::ErrorInstance::ErrorInstance):

  • runtime/ErrorInstance.h:

(JSC::ErrorInstance::create):

  • runtime/ErrorPrototype.cpp:

(JSC::ErrorPrototype::ErrorPrototype):
(JSC::ErrorPrototype::finishCreation):

  • runtime/ErrorPrototype.h:
  • runtime/ExceptionHelpers.cpp:

(JSC::InterruptedExecutionError::InterruptedExecutionError):
(JSC::InterruptedExecutionError::create):
(JSC::TerminatedExecutionError::TerminatedExecutionError):
(JSC::TerminatedExecutionError::create):

  • runtime/Executable.cpp:

(JSC::EvalExecutable::EvalExecutable):
(JSC::ProgramExecutable::ProgramExecutable):
(JSC::FunctionExecutable::FunctionExecutable):

  • runtime/Executable.h:

(JSC::NativeExecutable::create):
(JSC::NativeExecutable::NativeExecutable):
(JSC::EvalExecutable::create):
(JSC::ProgramExecutable::create):
(JSC::FunctionExecutable::create):

  • runtime/InternalFunction.cpp:

(JSC::InternalFunction::InternalFunction):
(JSC::InternalFunction::finishCreation):

  • runtime/InternalFunction.h:
  • runtime/JSActivation.cpp:

(JSC::JSActivation::JSActivation):
(JSC::JSActivation::finishCreation):

  • runtime/JSActivation.h:
  • runtime/JSArray.cpp:

(JSC::JSArray::JSArray):

  • runtime/JSArray.h:

(JSC::JSArray::create):

  • runtime/JSByteArray.cpp:

(JSC::JSByteArray::JSByteArray):

  • runtime/JSByteArray.h:

(JSC::JSByteArray::create):

  • runtime/JSFunction.cpp:

(JSC::JSFunction::JSFunction):
(JSC::JSFunction::finishCreation):

  • runtime/JSFunction.h:

(JSC::JSFunction::create):

  • runtime/JSGlobalObject.h:

(JSC::JSGlobalObject::JSGlobalObject):
(JSC::JSGlobalObject::finishCreation):

  • runtime/JSNotAnObject.h:

(JSC::JSNotAnObject::JSNotAnObject):
(JSC::JSNotAnObject::create):

  • runtime/JSONObject.cpp:

(JSC::JSONObject::JSONObject):
(JSC::JSONObject::finishCreation):

  • runtime/JSONObject.h:
  • runtime/JSObjectWithGlobalObject.cpp:

(JSC::JSObjectWithGlobalObject::JSObjectWithGlobalObject):

  • runtime/JSObjectWithGlobalObject.h:
  • runtime/JSStaticScopeObject.h:

(JSC::JSStaticScopeObject::create):
(JSC::JSStaticScopeObject::finishCreation):
(JSC::JSStaticScopeObject::JSStaticScopeObject):

  • runtime/JSVariableObject.h:

(JSC::JSVariableObject::JSVariableObject):

  • runtime/JSWrapperObject.h:

(JSC::JSWrapperObject::JSWrapperObject):

  • runtime/MathObject.cpp:

(JSC::MathObject::MathObject):
(JSC::MathObject::finishCreation):

  • runtime/MathObject.h:
  • runtime/NumberObject.cpp:

(JSC::NumberObject::NumberObject):
(JSC::NumberObject::finishCreation):

  • runtime/NumberObject.h:
  • runtime/ObjectPrototype.cpp:

(JSC::ObjectPrototype::ObjectPrototype):

  • runtime/ObjectPrototype.h:

(JSC::ObjectPrototype::create):

  • runtime/RegExpConstructor.cpp:

(JSC::RegExpMatchesArray::RegExpMatchesArray):
(JSC::RegExpMatchesArray::finishCreation):

  • runtime/RegExpMatchesArray.h:
  • runtime/RegExpObject.cpp:

(JSC::RegExpObject::RegExpObject):
(JSC::RegExpObject::finishCreation):

  • runtime/RegExpObject.h:
  • runtime/StrictEvalActivation.cpp:

(JSC::StrictEvalActivation::StrictEvalActivation):

  • runtime/StrictEvalActivation.h:

(JSC::StrictEvalActivation::create):

  • runtime/StringObject.cpp:

(JSC::StringObject::StringObject):
(JSC::StringObject::finishCreation):

  • runtime/StringObject.h:

Source/JavaScriptGlue:

Completed the fourth level of the refactoring to add finishCreation()
methods to all classes within the JSCell hierarchy with non-trivial
constructor bodies.

This primarily consists of pushing the calls to finishCreation() down
into the constructors of the subclasses of the second level of the hierarchy
as well as pulling the finishCreation() calls out into the class's corresponding
create() method if it has one. Doing both simultaneously allows us to
maintain the invariant that the finishCreation() method chain is called exactly
once during the creation of an object, since calling it any other number of
times (0, 2, or more) will cause an assertion failure.

  • UserObjectImp.cpp:

(UserObjectImp::UserObjectImp):

  • UserObjectImp.h:

(UserObjectImp::create):

Source/WebCore:

No new tests.

Completed the fourth level of the refactoring to add finishCreation()
methods to all classes within the JSCell hierarchy with non-trivial
constructor bodies.

This primarily consists of pushing the calls to finishCreation() down
into the constructors of the subclasses of the second level of the hierarchy
as well as pulling the finishCreation() calls out into the class's corresponding
create() method if it has one. Doing both simultaneously allows us to
maintain the invariant that the finishCreation() method chain is called exactly
once during the creation of an object, since calling it any other number of
times (0, 2, or more) will cause an assertion failure.

  • bindings/js/JSDOMWindowShell.cpp:

(WebCore::JSDOMWindowShell::JSDOMWindowShell):
(WebCore::JSDOMWindowShell::create):

  • bindings/js/JSDOMWindowShell.h:
  • bindings/js/JSDOMWrapper.h:

(WebCore::JSDOMWrapper::JSDOMWrapper):

  • bindings/js/ScriptController.cpp:

(WebCore::ScriptController::createWindowShell):

  • bindings/scripts/CodeGeneratorJS.pm:

(GenerateHeader):

  • bindings/scripts/test/JS/JSTestInterface.h:

(WebCore::JSTestInterfacePrototype::JSTestInterfacePrototype):

  • bindings/scripts/test/JS/JSTestMediaQueryListListener.h:

(WebCore::JSTestMediaQueryListListenerPrototype::JSTestMediaQueryListListenerPrototype):

  • bindings/scripts/test/JS/JSTestObj.h:

(WebCore::JSTestObjPrototype::JSTestObjPrototype):

  • bindings/scripts/test/JS/JSTestSerializedScriptValueInterface.h:

(WebCore::JSTestSerializedScriptValueInterfacePrototype::JSTestSerializedScriptValueInterfacePrototype):

  • bridge/objc/objc_runtime.h:
  • bridge/objc/objc_runtime.mm:

(JSC::Bindings::ObjcFallbackObjectImp::ObjcFallbackObjectImp):
(JSC::Bindings::ObjcFallbackObjectImp::finishCreation):

  • bridge/runtime_array.cpp:

(JSC::RuntimeArray::RuntimeArray):
(JSC::RuntimeArray::finishCreation):

  • bridge/runtime_array.h:
  • bridge/runtime_object.cpp:

(JSC::Bindings::RuntimeObject::RuntimeObject):
(JSC::Bindings::RuntimeObject::finishCreation):

  • bridge/runtime_object.h:

Source/WebKit2:

Completed the fourth level of the refactoring to add finishCreation()
methods to all classes within the JSCell hierarchy with non-trivial
constructor bodies.

This primarily consists of pushing the calls to finishCreation() down
into the constructors of the subclasses of the second level of the hierarchy
as well as pulling the finishCreation() calls out into the class's corresponding
create() method if it has one. Doing both simultaneously allows us to
maintain the invariant that the finishCreation() method chain is called exactly
once during the creation of an object, since calling it any other number of
times (0, 2, or more) will cause an assertion failure.

  • WebProcess/Plugins/Netscape/JSNPObject.cpp:

(WebKit::JSNPObject::JSNPObject):
(WebKit::JSNPObject::finishCreation):

  • WebProcess/Plugins/Netscape/JSNPObject.h:
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/Executable.h

    r94035 r94364  
    177177        {
    178178            NativeExecutable* executable;
    179             if (!callThunk)
    180                 executable = new (allocateCell<NativeExecutable>(globalData.heap)) NativeExecutable(globalData, JITCode(), function, JITCode(), constructor);
    181             else
    182                 executable = new (allocateCell<NativeExecutable>(globalData.heap)) NativeExecutable(globalData, JITCode::HostFunction(callThunk), function, JITCode::HostFunction(constructThunk), constructor);
     179            if (!callThunk) {
     180                executable = new (allocateCell<NativeExecutable>(globalData.heap)) NativeExecutable(globalData, function, constructor);
     181                executable->finishCreation(globalData, JITCode(), JITCode());
     182            } else {
     183                executable = new (allocateCell<NativeExecutable>(globalData.heap)) NativeExecutable(globalData, function, constructor);
     184                executable->finishCreation(globalData, JITCode::HostFunction(callThunk), JITCode::HostFunction(constructThunk));
     185            }
    183186            return executable;
    184187        }
     
    186189        static NativeExecutable* create(JSGlobalData& globalData, NativeFunction function, NativeFunction constructor)
    187190        {
    188             return new (allocateCell<NativeExecutable>(globalData.heap)) NativeExecutable(globalData, function, constructor);
     191            NativeExecutable* executable = new (allocateCell<NativeExecutable>(globalData.heap)) NativeExecutable(globalData, function, constructor);
     192            executable->finishCreation(globalData);
     193            return executable;
    189194        }
    190195#endif
     
    212217    private:
    213218#if ENABLE(JIT)
    214         NativeExecutable(JSGlobalData& globalData, JITCode callThunk, NativeFunction function, JITCode constructThunk, NativeFunction constructor)
     219        NativeExecutable(JSGlobalData& globalData, NativeFunction function, NativeFunction constructor)
    215220            : ExecutableBase(globalData, globalData.nativeExecutableStructure.get(), NUM_PARAMETERS_IS_HOST)
    216221            , m_function(function)
    217222            , m_constructor(constructor)
    218223        {
    219             finishCreation(globalData, callThunk, constructThunk);
    220224        }
    221225#else
     
    225229            , m_constructor(constructor)
    226230        {
    227             finishCreation(globalData);
    228231        }
    229232#endif
     
    318321        {
    319322            EvalExecutable* executable = new (allocateCell<EvalExecutable>(*exec->heap())) EvalExecutable(exec, source, isInStrictContext);
     323            executable->finishCreation(exec->globalData());
    320324            return executable;
    321325        }
     
    355359        {
    356360            ProgramExecutable* executable = new (allocateCell<ProgramExecutable>(*exec->heap())) ProgramExecutable(exec, source);
     361            executable->finishCreation(exec->globalData());
    357362            return executable;
    358363        }
     
    413418        static FunctionExecutable* create(ExecState* exec, const Identifier& name, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, bool isInStrictContext, int firstLine, int lastLine)
    414419        {
    415             FunctionExecutable* executable = new (allocateCell<FunctionExecutable>(*exec->heap())) FunctionExecutable(exec, name, source, forceUsesArguments, parameters, isInStrictContext, firstLine, lastLine);
     420            FunctionExecutable* executable = new (allocateCell<FunctionExecutable>(*exec->heap())) FunctionExecutable(exec, name, source, forceUsesArguments, parameters, isInStrictContext);
     421            executable->finishCreation(exec->globalData(), name, firstLine, lastLine);
    416422            return executable;
    417423        }
     
    419425        static FunctionExecutable* create(JSGlobalData& globalData, const Identifier& name, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, bool isInStrictContext, int firstLine, int lastLine)
    420426        {
    421             FunctionExecutable* executable = new (allocateCell<FunctionExecutable>(globalData.heap)) FunctionExecutable(globalData, name, source, forceUsesArguments, parameters, isInStrictContext, firstLine, lastLine);
     427            FunctionExecutable* executable = new (allocateCell<FunctionExecutable>(globalData.heap)) FunctionExecutable(globalData, name, source, forceUsesArguments, parameters, isInStrictContext);
     428            executable->finishCreation(globalData, name, firstLine, lastLine);
    422429            return executable;
    423430        }
     
    540547
    541548    private:
    542         FunctionExecutable(JSGlobalData&, const Identifier& name, const SourceCode&, bool forceUsesArguments, FunctionParameters*, bool, int firstLine, int lastLine);
    543         FunctionExecutable(ExecState*, const Identifier& name, const SourceCode&, bool forceUsesArguments, FunctionParameters*, bool, int firstLine, int lastLine);
     549        FunctionExecutable(JSGlobalData&, const Identifier& name, const SourceCode&, bool forceUsesArguments, FunctionParameters*, bool);
     550        FunctionExecutable(ExecState*, const Identifier& name, const SourceCode&, bool forceUsesArguments, FunctionParameters*, bool);
    544551
    545552        JSObject* compileForCallInternal(ExecState*, ScopeChainNode*, ExecState* calleeArgsExec);
Note: See TracChangeset for help on using the changeset viewer.