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


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

    r89887 r91194  
    144144
    145145class GlobalObject : public JSGlobalObject {
     146private:
     147    GlobalObject(JSGlobalData&, Structure*, const Vector<UString>& arguments);
     148
    146149public:
    147     GlobalObject(JSGlobalData&, Structure*, const Vector<UString>& arguments);
     150    static GlobalObject* create(JSGlobalData& globalData, Structure* structure, const Vector<UString>& arguments)
     151    {
     152        return new (allocateCell<GlobalObject>(globalData.heap)) GlobalObject(globalData, structure, arguments);
     153    }
    148154    virtual UString className() const { return "global"; }
    149155};
     
    154160    : JSGlobalObject(globalData, structure)
    155161{
    156     putDirectFunction(globalExec(), new (globalExec()) JSFunction(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "debug"), functionDebug));
    157     putDirectFunction(globalExec(), new (globalExec()) JSFunction(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "print"), functionPrint));
    158     putDirectFunction(globalExec(), new (globalExec()) JSFunction(globalExec(), this, functionStructure(), 0, Identifier(globalExec(), "quit"), functionQuit));
    159     putDirectFunction(globalExec(), new (globalExec()) JSFunction(globalExec(), this, functionStructure(), 0, Identifier(globalExec(), "gc"), functionGC));
     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));
    160166#ifndef NDEBUG
    161     putDirectFunction(globalExec(), new (globalExec()) JSFunction(globalExec(), this, functionStructure(), 0, Identifier(globalExec(), "releaseExecutableMemory"), functionReleaseExecutableMemory));
    162 #endif
    163     putDirectFunction(globalExec(), new (globalExec()) JSFunction(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "version"), functionVersion));
    164     putDirectFunction(globalExec(), new (globalExec()) JSFunction(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "run"), functionRun));
    165     putDirectFunction(globalExec(), new (globalExec()) JSFunction(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "load"), functionLoad));
    166     putDirectFunction(globalExec(), new (globalExec()) JSFunction(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "checkSyntax"), functionCheckSyntax));
    167     putDirectFunction(globalExec(), new (globalExec()) JSFunction(globalExec(), this, functionStructure(), 0, Identifier(globalExec(), "readline"), functionReadline));
     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));
    168174
    169175#if ENABLE(SAMPLING_FLAGS)
    170     putDirectFunction(globalExec(), new (globalExec()) JSFunction(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "setSamplingFlags"), functionSetSamplingFlags));
    171     putDirectFunction(globalExec(), new (globalExec()) JSFunction(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "clearSamplingFlags"), functionClearSamplingFlags));
     176    putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "setSamplingFlags"), functionSetSamplingFlags));
     177    putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "clearSamplingFlags"), functionClearSamplingFlags));
    172178#endif
    173179
     
    228234        return JSValue::encode(throwError(exec, createError(exec, "Could not open file.")));
    229235
    230     GlobalObject* globalObject = new (&exec->globalData()) GlobalObject(exec->globalData(), GlobalObject::createStructure(exec->globalData(), jsNull()), Vector<UString>());
     236    GlobalObject* globalObject = GlobalObject::create(exec->globalData(), GlobalObject::createStructure(exec->globalData(), jsNull()), Vector<UString>());
    231237
    232238    StopWatch stopWatch;
     
    553559    parseArguments(argc, argv, options, globalData);
    554560
    555     GlobalObject* globalObject = new (globalData) GlobalObject(*globalData, GlobalObject::createStructure(*globalData, jsNull()), options.arguments);
     561    GlobalObject* globalObject = GlobalObject::create(*globalData, GlobalObject::createStructure(*globalData, jsNull()), options.arguments);
    556562    bool success = runWithScripts(globalObject, options.scripts, options.dump);
    557563    if (options.interactive && success)
Note: See TracChangeset for help on using the changeset viewer.