Changeset 93378 in webkit for trunk/Source/JavaScriptCore/jsc.cpp


Ignore:
Timestamp:
Aug 18, 2011, 5:58:34 PM (14 years ago)
Author:
[email protected]
Message:

Move allocation in constructors into separate constructorBody() methods
https://bugs.webkit.org/show_bug.cgi?id=66265

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

Source/JavaScriptCore:

Refactoring to put all allocations that need to be done after the object's
initialization list has executed but before the object is ready for use
into a separate constructorBody() method. This method is still called by the constructor,
so the patch doesn't resolve any potential issues, it's just to set up the code for further refactoring.

(GlobalObject::constructorBody):
(GlobalObject::GlobalObject):

  • runtime/ErrorInstance.cpp:

(JSC::ErrorInstance::ErrorInstance):

  • runtime/ErrorInstance.h:

(JSC::ErrorInstance::constructorBody):

  • runtime/ErrorPrototype.cpp:

(JSC::ErrorPrototype::ErrorPrototype):
(JSC::ErrorPrototype::constructorBody):

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

(JSC::FunctionExecutable::FunctionExecutable):

  • runtime/Executable.h:

(JSC::FunctionExecutable::constructorBody):

  • runtime/InternalFunction.cpp:

(JSC::InternalFunction::InternalFunction):

  • runtime/InternalFunction.h:

(JSC::InternalFunction::constructorBody):

  • runtime/JSByteArray.cpp:

(JSC::JSByteArray::JSByteArray):

  • runtime/JSByteArray.h:

(JSC::JSByteArray::constructorBody):

  • runtime/JSFunction.cpp:

(JSC::JSFunction::JSFunction):
(JSC::JSFunction::constructorBody):

  • runtime/JSFunction.h:
  • runtime/JSGlobalObject.h:

(JSC::JSGlobalObject::JSGlobalObject):
(JSC::JSGlobalObject::constructorBody):

  • runtime/JSPropertyNameIterator.cpp:

(JSC::JSPropertyNameIterator::JSPropertyNameIterator):

  • runtime/JSPropertyNameIterator.h:

(JSC::JSPropertyNameIterator::constructorBody):

  • runtime/JSString.h:

(JSC::RopeBuilder::JSString):
(JSC::RopeBuilder::constructorBody):

  • runtime/NativeErrorConstructor.cpp:

(JSC::NativeErrorConstructor::NativeErrorConstructor):

  • runtime/NativeErrorConstructor.h:

(JSC::NativeErrorConstructor::constructorBody):

  • runtime/NativeErrorPrototype.cpp:

(JSC::NativeErrorPrototype::NativeErrorPrototype):
(JSC::NativeErrorPrototype::constructorBody):

  • runtime/NativeErrorPrototype.h:
  • runtime/StringObject.cpp:
  • runtime/StringObject.h:

(JSC::StringObject::create):

  • runtime/StringObjectThatMasqueradesAsUndefined.h:

(JSC::StringObjectThatMasqueradesAsUndefined::create):
(JSC::StringObjectThatMasqueradesAsUndefined::StringObjectThatMasqueradesAsUndefined):

  • runtime/StringPrototype.cpp:

(JSC::StringPrototype::StringPrototype):

  • runtime/StringPrototype.h:

(JSC::StringPrototype::create):

Source/WebCore:

No new tests.

Refactoring to put all allocations that need to be done after the object's
initialization list has executed but before the object is ready for use
into a separate constructorBody() method. This method is still called by the constructor,
so the patch doesn't resolve any potential issues, it's just to set up the code for further refactoring.

  • bridge/objc/ObjCRuntimeObject.h:

(JSC::Bindings::ObjCRuntimeObject::create):

  • bridge/objc/ObjCRuntimeObject.mm:
  • bridge/objc/objc_instance.mm:

(ObjCRuntimeMethod::create):
(ObjCRuntimeMethod::ObjCRuntimeMethod):

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

(JSC::RuntimeArray::create):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/jsc.cpp

    r92706 r93378  
    156156    }
    157157    virtual UString className() const { return "global"; }
     158
     159protected:
     160    void constructorBody(const Vector<UString>& arguments)
     161    {
     162        putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "debug"), functionDebug));
     163        putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "print"), functionPrint));
     164        putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 0, Identifier(globalExec(), "quit"), functionQuit));
     165        putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 0, Identifier(globalExec(), "gc"), functionGC));
     166#ifndef NDEBUG
     167        putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 0, Identifier(globalExec(), "releaseExecutableMemory"), functionReleaseExecutableMemory));
     168#endif
     169        putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "version"), functionVersion));
     170        putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "run"), functionRun));
     171        putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "load"), functionLoad));
     172        putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "checkSyntax"), functionCheckSyntax));
     173        putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 0, Identifier(globalExec(), "readline"), functionReadline));
     174        putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 0, Identifier(globalExec(), "preciseTime"), functionPreciseTime));
     175
     176#if ENABLE(SAMPLING_FLAGS)
     177        putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "setSamplingFlags"), functionSetSamplingFlags));
     178        putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "clearSamplingFlags"), functionClearSamplingFlags));
     179#endif
     180
     181        JSObject* array = constructEmptyArray(globalExec());
     182        for (size_t i = 0; i < arguments.size(); ++i)
     183            array->put(globalExec(), i, jsString(globalExec(), arguments[i]));
     184        putDirect(globalExec()->globalData(), Identifier(globalExec(), "arguments"), array);
     185    }
    158186};
    159187COMPILE_ASSERT(!IsInteger<GlobalObject>::value, WTF_IsInteger_GlobalObject_false);
     
    163191    : JSGlobalObject(globalData, structure)
    164192{
    165     putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "debug"), functionDebug));
    166     putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "print"), functionPrint));
    167     putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 0, Identifier(globalExec(), "quit"), functionQuit));
    168     putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 0, Identifier(globalExec(), "gc"), functionGC));
    169 #ifndef NDEBUG
    170     putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 0, Identifier(globalExec(), "releaseExecutableMemory"), functionReleaseExecutableMemory));
    171 #endif
    172     putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "version"), functionVersion));
    173     putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "run"), functionRun));
    174     putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "load"), functionLoad));
    175     putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "checkSyntax"), functionCheckSyntax));
    176     putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 0, Identifier(globalExec(), "readline"), functionReadline));
    177     putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 0, Identifier(globalExec(), "preciseTime"), functionPreciseTime));
    178 
    179 #if ENABLE(SAMPLING_FLAGS)
    180     putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "setSamplingFlags"), functionSetSamplingFlags));
    181     putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "clearSamplingFlags"), functionClearSamplingFlags));
    182 #endif
    183 
    184     JSObject* array = constructEmptyArray(globalExec());
    185     for (size_t i = 0; i < arguments.size(); ++i)
    186         array->put(globalExec(), i, jsString(globalExec(), arguments[i]));
    187     putDirect(globalExec()->globalData(), Identifier(globalExec(), "arguments"), array);
     193    constructorBody(arguments);
    188194}
    189195
Note: See TracChangeset for help on using the changeset viewer.