Ignore:
Timestamp:
Jul 18, 2011, 10:47:13 AM (14 years ago)
Author:
[email protected]
Message:

2011-07-18 Mark Hahnenberg <[email protected]>

Refactor JSC to replace JSCell::operator new with static create method
https://bugs.webkit.org/show_bug.cgi?id=64466

Reviewed by Oliver Hunt ([email protected]) and Darin Adler (Darin Adler).

First step in a longer refactoring process to remove the use of
operator new overloading in order to allocate GC objects and to replace
this method with static create methods for each individual type of heap-allocated
JS object. This particular patch only deals with replacing uses of
operator new within JSC proper. Future patches will remove it from the
parts that interface with the DOM. Due to the DOM's continued dependence
on it, operator new has not actually been removed from JSCell.

  • API/JSCallbackConstructor.h: (JSC::JSCallbackConstructor::create):
  • API/JSCallbackFunction.h: (JSC::JSCallbackFunction::create):
  • API/JSCallbackObject.h: (JSC::JSCallbackObject::operator new): (JSC::JSCallbackObject::create):
  • API/JSCallbackObjectFunctions.h: (JSC::::staticFunctionGetter):
  • API/JSClassRef.cpp: (OpaqueJSClass::prototype):
  • API/JSContextRef.cpp:
  • API/JSObjectRef.cpp: (JSObjectMake): (JSObjectMakeFunctionWithCallback): (JSObjectMakeConstructor):
  • JavaScriptCore.exp:
  • JavaScriptCore.vcproj/JavaScriptCore/JavaScriptCore.def:
  • bytecode/CodeBlock.cpp: (JSC::CodeBlock::createActivation):
  • bytecompiler/BytecodeGenerator.cpp: (JSC::BytecodeGenerator::BytecodeGenerator):
  • bytecompiler/BytecodeGenerator.h: (JSC::BytecodeGenerator::makeFunction):
  • bytecompiler/NodesCodegen.cpp: (JSC::RegExpNode::emitBytecode):
  • interpreter/Interpreter.cpp: (JSC::Interpreter::privateExecute): (JSC::Interpreter::retrieveArguments):
  • jit/JITStubs.cpp: (JSC::DEFINE_STUB_FUNCTION):
  • jsc.cpp: (GlobalObject::create): (GlobalObject::GlobalObject): (functionRun): (jscmain):
  • runtime/Arguments.h: (JSC::Arguments::create): (JSC::Arguments::createNoParameters):
  • runtime/ArrayConstructor.cpp: (JSC::constructArrayWithSizeQuirk):
  • runtime/ArrayConstructor.h: (JSC::ArrayConstructor::create):
  • runtime/ArrayPrototype.cpp: (JSC::arrayProtoFuncSplice):
  • runtime/ArrayPrototype.h: (JSC::ArrayPrototype::create):
  • runtime/BooleanConstructor.cpp: (JSC::constructBoolean): (JSC::constructBooleanFromImmediateBoolean):
  • runtime/BooleanConstructor.h: (JSC::BooleanConstructor::create):
  • runtime/BooleanObject.h: (JSC::BooleanObject::create):
  • runtime/BooleanPrototype.h: (JSC::BooleanPrototype::create):
  • runtime/DateConstructor.cpp: (JSC::constructDate):
  • runtime/DateConstructor.h: (JSC::DateConstructor::create):
  • runtime/DateInstance.h: (JSC::DateInstance::create):
  • runtime/DatePrototype.h: (JSC::DatePrototype::create):
  • runtime/Error.cpp: (JSC::createError): (JSC::createEvalError): (JSC::createRangeError): (JSC::createReferenceError): (JSC::createSyntaxError): (JSC::createTypeError): (JSC::createURIError): (JSC::StrictModeTypeErrorFunction::create): (JSC::createTypeErrorFunction):
  • runtime/ErrorConstructor.h: (JSC::ErrorConstructor::create):
  • runtime/ErrorInstance.cpp: (JSC::ErrorInstance::ErrorInstance): (JSC::ErrorInstance::create):
  • runtime/ErrorInstance.h:
  • runtime/ErrorPrototype.cpp: (JSC::ErrorPrototype::ErrorPrototype):
  • runtime/ErrorPrototype.h: (JSC::ErrorPrototype::create):
  • runtime/ExceptionHelpers.cpp: (JSC::InterruptedExecutionError::InterruptedExecutionError): (JSC::InterruptedExecutionError::create): (JSC::createInterruptedExecutionException): (JSC::TerminatedExecutionError::TerminatedExecutionError): (JSC::TerminatedExecutionError::create): (JSC::createTerminatedExecutionException):
  • runtime/Executable.cpp: (JSC::FunctionExecutable::FunctionExecutable): (JSC::FunctionExecutable::fromGlobalCode):
  • runtime/Executable.h: (JSC::ExecutableBase::create): (JSC::NativeExecutable::create): (JSC::ScriptExecutable::ScriptExecutable): (JSC::EvalExecutable::create): (JSC::ProgramExecutable::create): (JSC::FunctionExecutable::create): (JSC::FunctionExecutable::make):
  • runtime/FunctionConstructor.cpp: (JSC::constructFunctionSkippingEvalEnabledCheck):
  • runtime/FunctionConstructor.h: (JSC::FunctionConstructor::create):
  • runtime/FunctionPrototype.cpp: (JSC::FunctionPrototype::addFunctionProperties):
  • runtime/FunctionPrototype.h: (JSC::FunctionPrototype::create):
  • runtime/GetterSetter.h: (JSC::GetterSetter::create):
  • runtime/JSAPIValueWrapper.h: (JSC::JSAPIValueWrapper::create): (JSC::jsAPIValueWrapper):
  • runtime/JSActivation.cpp: (JSC::JSActivation::argumentsGetter):
  • runtime/JSActivation.h: (JSC::JSActivation::create):
  • runtime/JSArray.h: (JSC::JSArray::create):
  • runtime/JSCell.h: (JSC::JSCell::allocateCell):
  • runtime/JSFunction.h: (JSC::JSFunction::create):
  • runtime/JSGlobalObject.cpp: (JSC::JSGlobalObject::init): (JSC::JSGlobalObject::reset):
  • runtime/JSGlobalObject.h: (JSC::constructEmptyArray): (JSC::constructArray):
  • runtime/JSNotAnObject.h: (JSC::JSNotAnObject::create):
  • runtime/JSONObject.h: (JSC::JSONObject::create):
  • runtime/JSObject.cpp: (JSC::JSObject::defineGetter): (JSC::JSObject::defineSetter): (JSC::putDescriptor):
  • runtime/JSObject.h: (JSC::JSFinalObject::create):
  • runtime/JSPropertyNameIterator.cpp: (JSC::JSPropertyNameIterator::create):
  • runtime/JSPropertyNameIterator.h: (JSC::JSPropertyNameIterator::create):
  • runtime/JSString.cpp: (JSC::JSString::substringFromRope): (JSC::JSString::replaceCharacter): (JSC::StringObject::create):
  • runtime/JSString.h: (JSC::RopeBuilder::JSString): (JSC::RopeBuilder::create): (JSC::RopeBuilder::createHasOtherOwner): (JSC::jsSingleCharacterString): (JSC::jsSingleCharacterSubstring): (JSC::jsNontrivialString): (JSC::jsString): (JSC::jsSubstring): (JSC::jsOwnedString):
  • runtime/JSValue.cpp: (JSC::JSValue::toObjectSlowCase): (JSC::JSValue::synthesizeObject): (JSC::JSValue::synthesizePrototype):
  • runtime/Lookup.cpp: (JSC::setUpStaticFunctionSlot):
  • runtime/MathObject.h: (JSC::MathObject::create):
  • runtime/NativeErrorConstructor.cpp: (JSC::NativeErrorConstructor::NativeErrorConstructor):
  • runtime/NativeErrorConstructor.h: (JSC::NativeErrorConstructor::create):
  • runtime/NativeErrorPrototype.h: (JSC::NativeErrorPrototype::create):
  • runtime/NumberConstructor.cpp: (JSC::constructWithNumberConstructor):
  • runtime/NumberConstructor.h: (JSC::NumberConstructor::create):
  • runtime/NumberObject.cpp: (JSC::constructNumber):
  • runtime/NumberObject.h: (JSC::NumberObject::create):
  • runtime/NumberPrototype.h: (JSC::NumberPrototype::create):
  • runtime/ObjectConstructor.h: (JSC::ObjectConstructor::create):
  • runtime/ObjectPrototype.h: (JSC::ObjectPrototype::create):
  • runtime/Operations.h: (JSC::jsString):
  • runtime/RegExp.cpp: (JSC::RegExp::RegExp): (JSC::RegExp::createWithoutCaching): (JSC::RegExp::create):
  • runtime/RegExp.h:
  • runtime/RegExpCache.cpp: (JSC::RegExpCache::lookupOrCreate):
  • runtime/RegExpConstructor.cpp: (JSC::RegExpConstructor::arrayOfMatches): (JSC::constructRegExp):
  • runtime/RegExpConstructor.h: (JSC::RegExpConstructor::create):
  • runtime/RegExpMatchesArray.h: (JSC::RegExpMatchesArray::create):
  • runtime/RegExpObject.h: (JSC::RegExpObject::create):
  • runtime/RegExpPrototype.cpp: (JSC::regExpProtoFuncCompile):
  • runtime/RegExpPrototype.h: (JSC::RegExpPrototype::create):
  • runtime/ScopeChain.h: (JSC::ScopeChainNode::create): (JSC::ScopeChainNode::push):
  • runtime/SmallStrings.cpp: (JSC::SmallStrings::createEmptyString): (JSC::SmallStrings::createSingleCharacterString):
  • runtime/StringConstructor.cpp: (JSC::constructWithStringConstructor):
  • runtime/StringConstructor.h: (JSC::StringConstructor::create):
  • runtime/StringObject.h: (JSC::StringObject::create):
  • runtime/StringObjectThatMasqueradesAsUndefined.h: (JSC::StringObjectThatMasqueradesAsUndefined::create):
  • runtime/StringPrototype.cpp: (JSC::stringProtoFuncMatch): (JSC::stringProtoFuncSearch):
  • runtime/StringPrototype.h: (JSC::StringPrototype::create):
  • runtime/Structure.h: (JSC::Structure::create): (JSC::Structure::createStructure):
  • runtime/StructureChain.h: (JSC::StructureChain::create):
File:
1 edited

Legend:

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

    r90938 r91194  
    5353        static const int NUM_PARAMETERS_IS_HOST = 0;
    5454        static const int NUM_PARAMETERS_NOT_COMPILED = -1;
    55    
    56     public:
     55
     56    protected:
    5757        ExecutableBase(JSGlobalData& globalData, Structure* structure, int numParameters)
    5858            : JSCell(globalData, structure)
     
    6464            finalizer.leakHandle();
    6565#endif
     66        }
     67       
     68    public:
     69        static ExecutableBase* create(JSGlobalData& globalData, Structure* structure, int numParameters)
     70        {
     71            return new (allocateCell<ExecutableBase>(globalData.heap)) ExecutableBase(globalData, structure, numParameters);
    6672        }
    6773
     
    167173        {
    168174            if (!callThunk)
    169                 return new (&globalData) NativeExecutable(globalData, JITCode(), function, JITCode(), constructor);
    170             return new (&globalData) NativeExecutable(globalData, JITCode::HostFunction(callThunk), function, JITCode::HostFunction(constructThunk), constructor);
     175                return new (allocateCell<NativeExecutable>(globalData.heap)) NativeExecutable(globalData, JITCode(), function, JITCode(), constructor);
     176            return new (allocateCell<NativeExecutable>(globalData.heap)) NativeExecutable(globalData, JITCode::HostFunction(callThunk), function, JITCode::HostFunction(constructThunk), constructor);
    171177        }
    172178#else
    173179        static NativeExecutable* create(JSGlobalData& globalData, NativeFunction function, NativeFunction constructor)
    174180        {
    175             return new (&globalData) NativeExecutable(globalData, function, constructor);
     181            return new (allocateCell<NativeExecutable>(globalData.heap)) NativeExecutable(globalData, function, constructor);
    176182        }
    177183#endif
     
    214220    class ScriptExecutable : public ExecutableBase {
    215221    public:
    216         ScriptExecutable(Structure* structure, JSGlobalData* globalData, const SourceCode& source, bool isInStrictContext)
    217             : ExecutableBase(*globalData, structure, NUM_PARAMETERS_NOT_COMPILED)
     222        ScriptExecutable(Structure* structure, JSGlobalData& globalData, const SourceCode& source, bool isInStrictContext)
     223            : ExecutableBase(globalData, structure, NUM_PARAMETERS_NOT_COMPILED)
    218224            , m_source(source)
    219225            , m_features(isInStrictContext ? StrictModeFeature : 0)
    220226        {
    221227#if ENABLE(CODEBLOCK_SAMPLING)
    222             if (SamplingTool* sampler = globalData->interpreter->sampler())
     228            if (SamplingTool* sampler = globalData.interpreter->sampler())
    223229                sampler->notifyOfScope(*globalData, this);
    224230#else
     
    291297        }
    292298
    293         static EvalExecutable* create(ExecState* exec, const SourceCode& source, bool isInStrictContext) { return new (exec) EvalExecutable(exec, source, isInStrictContext); }
     299        static EvalExecutable* create(ExecState* exec, const SourceCode& source, bool isInStrictContext)
     300        {
     301            return new (allocateCell<EvalExecutable>(*exec->heap())) EvalExecutable(exec, source, isInStrictContext);
     302        }
    294303
    295304#if ENABLE(JIT)
     
    320329        static ProgramExecutable* create(ExecState* exec, const SourceCode& source)
    321330        {
    322             return new (exec) ProgramExecutable(exec, source);
     331            return new (allocateCell<ProgramExecutable>(*exec->heap())) ProgramExecutable(exec, source);
    323332        }
    324333
     
    373382        static FunctionExecutable* create(ExecState* exec, const Identifier& name, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, bool isInStrictContext, int firstLine, int lastLine)
    374383        {
    375             return new (exec) FunctionExecutable(exec, name, source, forceUsesArguments, parameters, isInStrictContext, firstLine, lastLine);
    376         }
    377 
    378         static FunctionExecutable* create(JSGlobalData* globalData, const Identifier& name, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, bool isInStrictContext, int firstLine, int lastLine)
    379         {
    380             return new (globalData) FunctionExecutable(globalData, name, source, forceUsesArguments, parameters, isInStrictContext, firstLine, lastLine);
     384            return new (allocateCell<FunctionExecutable>(*exec->heap())) FunctionExecutable(exec, name, source, forceUsesArguments, parameters, isInStrictContext, firstLine, lastLine);
     385        }
     386
     387        static FunctionExecutable* create(JSGlobalData& globalData, const Identifier& name, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, bool isInStrictContext, int firstLine, int lastLine)
     388        {
     389            return new (allocateCell<FunctionExecutable>(globalData.heap)) FunctionExecutable(globalData, name, source, forceUsesArguments, parameters, isInStrictContext, firstLine, lastLine);
    381390        }
    382391
    383392        JSFunction* make(ExecState* exec, ScopeChainNode* scopeChain)
    384393        {
    385             return new (exec) JSFunction(exec, this, scopeChain);
     394            return JSFunction::create(exec, this, scopeChain);
    386395        }
    387396       
     
    480489
    481490    private:
    482         FunctionExecutable(JSGlobalData*, const Identifier& name, const SourceCode&, bool forceUsesArguments, FunctionParameters*, bool, int firstLine, int lastLine);
     491        FunctionExecutable(JSGlobalData&, const Identifier& name, const SourceCode&, bool forceUsesArguments, FunctionParameters*, bool, int firstLine, int lastLine);
    483492        FunctionExecutable(ExecState*, const Identifier& name, const SourceCode&, bool forceUsesArguments, FunctionParameters*, bool, int firstLine, int lastLine);
    484493
Note: See TracChangeset for help on using the changeset viewer.