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/runtime/JSString.h

    r92706 r93378  
    268268            , m_fiberCount(s_maxInternalRopeLength)
    269269        {
     270            constructorBody(exec, v1, v2, v3);
     271        }
     272
     273        // This constructor constructs a new string by concatenating u1 & u2.
     274        JSString(JSGlobalData& globalData, const UString& u1, const UString& u2)
     275            : JSCell(globalData, globalData.stringStructure.get())
     276            , m_length(u1.length() + u2.length())
     277            , m_fiberCount(2)
     278        {
     279            unsigned index = 0;
     280            appendStringInConstruct(index, u1);
     281            appendStringInConstruct(index, u2);
     282            ASSERT(index <= s_maxInternalRopeLength);
     283        }
     284
     285        // This constructor constructs a new string by concatenating u1, u2 & u3.
     286        JSString(JSGlobalData& globalData, const UString& u1, const UString& u2, const UString& u3)
     287            : JSCell(globalData, globalData.stringStructure.get())
     288            , m_length(u1.length() + u2.length() + u3.length())
     289            , m_fiberCount(s_maxInternalRopeLength)
     290        {
     291            unsigned index = 0;
     292            appendStringInConstruct(index, u1);
     293            appendStringInConstruct(index, u2);
     294            appendStringInConstruct(index, u3);
     295            ASSERT(index <= s_maxInternalRopeLength);
     296        }
     297
     298    protected:
     299        void constructorBody(ExecState* exec, JSValue v1, JSValue v2, JSValue v3)
     300        {
    270301            unsigned index = 0;
    271302            appendValueInConstructAndIncrementLength(exec, index, v1);
     
    273304            appendValueInConstructAndIncrementLength(exec, index, v3);
    274305            ASSERT(index == s_maxInternalRopeLength);
    275         }
    276 
    277         // This constructor constructs a new string by concatenating u1 & u2.
    278         JSString(JSGlobalData& globalData, const UString& u1, const UString& u2)
    279             : JSCell(globalData, globalData.stringStructure.get())
    280             , m_length(u1.length() + u2.length())
    281             , m_fiberCount(2)
    282         {
    283             unsigned index = 0;
    284             appendStringInConstruct(index, u1);
    285             appendStringInConstruct(index, u2);
    286             ASSERT(index <= s_maxInternalRopeLength);
    287         }
    288 
    289         // This constructor constructs a new string by concatenating u1, u2 & u3.
    290         JSString(JSGlobalData& globalData, const UString& u1, const UString& u2, const UString& u3)
    291             : JSCell(globalData, globalData.stringStructure.get())
    292             , m_length(u1.length() + u2.length() + u3.length())
    293             , m_fiberCount(s_maxInternalRopeLength)
    294         {
    295             unsigned index = 0;
    296             appendStringInConstruct(index, u1);
    297             appendStringInConstruct(index, u2);
    298             appendStringInConstruct(index, u3);
    299             ASSERT(index <= s_maxInternalRopeLength);
    300306        }
    301307
Note: See TracChangeset for help on using the changeset viewer.