namespace JSC {
class JSCallbackConstructor : public JSObjectWithGlobalObject {
-public:
+protected:
JSCallbackConstructor(JSGlobalObject*, Structure*, JSClassRef, JSObjectCallAsConstructorCallback);
+public:
+ static JSCallbackConstructor* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, JSClassRef classRef, JSObjectCallAsConstructorCallback callback)
+ {
+ return new (allocateCell<JSCallbackConstructor>(*exec->heap())) JSCallbackConstructor(globalObject, structure, classRef, callback);
+ }
+
virtual ~JSCallbackConstructor();
JSClassRef classRef() const { return m_class; }
JSObjectCallAsConstructorCallback callback() const { return m_callback; }
namespace JSC {
class JSCallbackFunction : public InternalFunction {
-public:
+protected:
JSCallbackFunction(ExecState*, JSGlobalObject*, JSObjectCallAsFunctionCallback, const Identifier& name);
+public:
+ static JSCallbackFunction* create(ExecState* exec, JSGlobalObject* globalObject, JSObjectCallAsFunctionCallback callback, const Identifier& name)
+ {
+ return new (allocateCell<JSCallbackFunction>(*exec->heap())) JSCallbackFunction(exec, globalObject, callback, name);
+ }
+
static const ClassInfo s_info;
// InternalFunction mish-mashes constructor and function behavior -- we should
template <class Base>
class JSCallbackObject : public Base {
-public:
+protected:
JSCallbackObject(ExecState*, JSGlobalObject*, Structure*, JSClassRef, void* data);
JSCallbackObject(JSGlobalData&, JSClassRef, Structure*);
+ // We'd like to use the placement version of operator new defined in JSCell, but
+ // we can't because Base is a template argument, so we just duplicate the same
+ // functionality here.
+ void* operator new(size_t, void* ptr) { return ptr; }
+
+public:
+ static JSCallbackObject* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, JSClassRef classRef, void* data)
+ {
+ return new (allocateCell<JSCallbackObject>(*exec->heap())) JSCallbackObject(exec, globalObject, structure, classRef, data);
+ }
+ static JSCallbackObject* create(JSGlobalData& globalData, JSClassRef classRef, Structure* structure)
+ {
+ return new (allocateCell<JSCallbackObject>(globalData.heap)) JSCallbackObject(globalData, classRef, structure);
+ }
void setPrivate(void* data);
void* getPrivate();
if (StaticFunctionEntry* entry = staticFunctions->get(propertyName.impl())) {
if (JSObjectCallAsFunctionCallback callAsFunction = entry->callAsFunction) {
- JSObject* o = new (exec) JSCallbackFunction(exec, asGlobalObject(thisObj->getAnonymousValue(0)), callAsFunction, propertyName);
+ JSObject* o = JSCallbackFunction::create(exec, asGlobalObject(thisObj->getAnonymousValue(0)), callAsFunction, propertyName);
thisObj->putDirect(exec->globalData(), propertyName, o, entry->attributes);
return o;
}
if (!jsClassData.cachedPrototype) {
// Recursive, but should be good enough for our purposes
- jsClassData.cachedPrototype.set(exec->globalData(), new (exec) JSCallbackObject<JSObjectWithGlobalObject>(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->callbackObjectStructure(), prototypeClass, &jsClassData), 0); // set jsClassData as the object's private data, so it can clear our reference on destruction
+ jsClassData.cachedPrototype.set(exec->globalData(), JSCallbackObject<JSObjectWithGlobalObject>::create(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->callbackObjectStructure(), prototypeClass, &jsClassData), 0); // set jsClassData as the object's private data, so it can clear our reference on destruction
if (parentClass) {
if (JSObject* prototype = parentClass->prototype(exec))
jsClassData.cachedPrototype->setPrototype(exec->globalData(), prototype);
return JSGlobalContextRetain(toGlobalRef(globalObject->globalExec()));
}
- JSGlobalObject* globalObject = new (globalData.get()) JSCallbackObject<JSGlobalObject>(*globalData, globalObjectClass, JSCallbackObject<JSGlobalObject>::createStructure(*globalData, jsNull()));
+ JSGlobalObject* globalObject = JSCallbackObject<JSGlobalObject>::create(*globalData, globalObjectClass, JSCallbackObject<JSGlobalObject>::createStructure(*globalData, jsNull()));
ExecState* exec = globalObject->globalExec();
JSValue prototype = globalObjectClass->prototype(exec);
if (!prototype)
if (!jsClass)
return toRef(constructEmptyObject(exec));
- JSCallbackObject<JSObjectWithGlobalObject>* object = new (exec) JSCallbackObject<JSObjectWithGlobalObject>(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->callbackObjectStructure(), jsClass, data);
+ JSCallbackObject<JSObjectWithGlobalObject>* object = JSCallbackObject<JSObjectWithGlobalObject>::create(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->callbackObjectStructure(), jsClass, data);
if (JSObject* prototype = jsClass->prototype(exec))
object->setPrototype(exec->globalData(), prototype);
Identifier nameID = name ? name->identifier(&exec->globalData()) : Identifier(exec, "anonymous");
- return toRef(new (exec) JSCallbackFunction(exec, exec->lexicalGlobalObject(), callAsFunction, nameID));
+ return toRef(JSCallbackFunction::create(exec, exec->lexicalGlobalObject(), callAsFunction, nameID));
}
JSObjectRef JSObjectMakeConstructor(JSContextRef ctx, JSClassRef jsClass, JSObjectCallAsConstructorCallback callAsConstructor)
if (!jsPrototype)
jsPrototype = exec->lexicalGlobalObject()->objectPrototype();
- JSCallbackConstructor* constructor = new (exec) JSCallbackConstructor(exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->callbackConstructorStructure(), jsClass, callAsConstructor);
+ JSCallbackConstructor* constructor = JSCallbackConstructor::create(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->callbackConstructorStructure(), jsClass, callAsConstructor);
constructor->putDirect(exec->globalData(), exec->propertyNames().prototype, jsPrototype, DontEnum | DontDelete | ReadOnly);
return toRef(constructor);
}
+2011-07-18 Mark Hahnenberg <mhahnenberg@apple.com>
+
+ Refactor JSC to replace JSCell::operator new with static create method
+ https://bugs.webkit.org/show_bug.cgi?id=64466
+
+ Reviewed by Oliver Hunt (oliver@apple.com) and Darin Adler (darin@apple.com).
+
+ 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):
+
2011-07-17 Ryuan Choi <ryuan.choi@samsung.com>
[EFL] Refactor scheduleDispatchFunctionsOnMainThread to fix crash.
__ZN3JSC14JSGlobalObject4initEPNS_8JSObjectE
__ZN3JSC14JSGlobalObject6s_infoE
__ZN3JSC14JSGlobalObjectD2Ev
-__ZN3JSC14JSGlobalObjectnwEmPNS_12JSGlobalDataE
__ZN3JSC14MachineThreads16addCurrentThreadEv
__ZN3JSC14SamplingThread4stopEv
__ZN3JSC14SamplingThread5startEj
__ZN3JSC6JSLock6unlockENS_14JSLockBehaviorE
__ZN3JSC6JSLock9lockCountEv
__ZN3JSC6JSLockC1EPNS_9ExecStateE
-__ZN3JSC6RegExp6createEPNS_12JSGlobalDataERKNS_7UStringENS_11RegExpFlagsE
__ZN3JSC6RegExpD1Ev
+__ZN3JSC6RegExp6createERNS_12JSGlobalDataERKNS_7UStringENS_11RegExpFlagsE
__ZN3JSC7JSArray13visitChildrenERNS_11SlotVisitorE
__ZN3JSC7JSArray15setSubclassDataEPv
__ZN3JSC7JSArray18getOwnPropertySlotEPNS_9ExecStateEjRNS_12PropertySlotE
??0CString@WTF@@QAE@PBD@Z
??0CString@WTF@@QAE@PBDI@Z
??0Collator@WTF@@QAE@PBD@Z
- ??0DateInstance@JSC@@QAE@PAVExecState@1@PAVStructure@1@N@Z
+ ??0DateInstance@JSC@@IAE@PAVExecState@1@PAVStructure@1@N@Z
??0DefaultGCActivityCallback@JSC@@QAE@PAVHeap@1@@Z
??0DropAllLocks@JSLock@JSC@@QAE@W4JSLockBehavior@2@@Z
??0DynamicGlobalObjectScope@JSC@@QAE@AAVJSGlobalData@1@PAVJSGlobalObject@1@@Z
??0InternalFunction@JSC@@IAE@PAVJSGlobalData@1@PAVJSGlobalObject@1@PAVStructure@1@ABVIdentifier@1@@Z
- ??0JSArray@JSC@@QAE@AAVJSGlobalData@1@PAVStructure@1@@Z
- ??0JSArray@JSC@@QAE@AAVJSGlobalData@1@PAVStructure@1@ABVArgList@1@@Z
+ ??0JSArray@JSC@@IAE@AAVJSGlobalData@1@PAVStructure@1@@Z
+ ??0JSArray@JSC@@IAE@AAVJSGlobalData@1@PAVStructure@1@ABVArgList@1@@Z
??0JSByteArray@JSC@@QAE@PAVExecState@1@PAVStructure@1@PAVByteArray@WTF@@@Z
- ??0JSFunction@JSC@@QAE@PAVExecState@1@PAVJSGlobalObject@1@PAVStructure@1@HABVIdentifier@1@P6I_J0@Z@Z
+ ??0JSFunction@JSC@@AAE@PAVExecState@1@PAVJSGlobalObject@1@PAVStructure@1@HABVIdentifier@1@P6I_J0@Z@Z
??0JSLock@JSC@@QAE@PAVExecState@1@@Z
??0JSObjectWithGlobalObject@JSC@@IAE@AAVJSGlobalData@1@PAVJSGlobalObject@1@PAVStructure@1@@Z
??0JSObjectWithGlobalObject@JSC@@IAE@PAVJSGlobalObject@1@PAVStructure@1@@Z
??0MD5@WTF@@QAE@XZ
??0Mutex@WTF@@QAE@XZ
??0RefCountedLeakCounter@WTF@@QAE@PBD@Z
- ??0RegExpObject@JSC@@QAE@PAVJSGlobalObject@1@PAVStructure@1@PAVRegExp@1@@Z
+ ??0RegExpObject@JSC@@IAE@PAVJSGlobalObject@1@PAVStructure@1@PAVRegExp@1@@Z
??0SHA1@WTF@@QAE@XZ
- ??0StringObject@JSC@@QAE@PAVExecState@1@PAVStructure@1@ABVUString@1@@Z
+ ??0StringObject@JSC@@IAE@PAVExecState@1@PAVStructure@1@ABVUString@1@@Z
??0Structure@JSC@@AAE@AAVJSGlobalData@1@VJSValue@1@ABVTypeInfo@1@IPBUClassInfo@1@@Z
??0ThreadCondition@WTF@@QAE@XZ
??0UString@JSC@@QAE@PBD@Z
??1ThreadCondition@WTF@@QAE@XZ
??1WTFThreadData@WTF@@QAE@XZ
??1WeakHandleOwner@JSC@@UAE@XZ
- ??2JSGlobalObject@JSC@@SAPAXIPAVJSGlobalData@1@@Z
??8JSC@@YA_NABVUString@0@0@Z
??8WTF@@YA_NABVCString@0@0@Z
?absoluteTimeToWaitTimeoutInterval@WTF@@YAKN@Z
?create@ByteArray@WTF@@SA?AV?$PassRefPtr@VByteArray@WTF@@@2@I@Z
?create@JSGlobalData@JSC@@SA?AV?$PassRefPtr@VJSGlobalData@JSC@@@WTF@@W4ThreadStackType@2@@Z
?create@OpaqueJSString@@SA?AV?$PassRefPtr@UOpaqueJSString@@@WTF@@ABVUString@JSC@@@Z
- ?create@RegExp@JSC@@SAPAV12@PAVJSGlobalData@2@ABVUString@2@W4RegExpFlags@2@@Z
+ ?create@RegExp@JSC@@SAPAV12@AAVJSGlobalData@2@ABVUString@2@W4RegExpFlags@2@@Z
?createEmptyString@SmallStrings@JSC@@AAEXPAVJSGlobalData@2@@Z
?createError@JSC@@YAPAVJSObject@1@PAVExecState@1@ABVUString@1@@Z
?createInterruptedExecutionException@JSC@@YAPAVJSObject@1@PAVJSGlobalData@1@@Z
ASSERT(codeType() == FunctionCode);
ASSERT(needsFullScopeChain());
ASSERT(!callFrame->uncheckedR(activationRegister()).jsValue());
- JSActivation* activation = new (callFrame) JSActivation(callFrame, static_cast<FunctionExecutable*>(ownerExecutable()));
+ JSActivation* activation = JSActivation::create(callFrame->globalData(), callFrame, static_cast<FunctionExecutable*>(ownerExecutable()));
callFrame->uncheckedR(activationRegister()) = JSValue(activation);
callFrame->setScopeChain(callFrame->scopeChain()->push(activation));
}
FunctionBodyNode* function = functionStack[i];
globalObject->removeDirect(*m_globalData, function->ident()); // Newly declared functions overwrite existing properties.
- JSValue value = new (exec) JSFunction(exec, makeFunction(exec, function), scopeChain);
+ JSValue value = JSFunction::create(exec, makeFunction(exec, function), scopeChain);
int index = addGlobalVar(function->ident(), false);
globalObject->registerAt(index).set(*m_globalData, globalObject, value);
}
FunctionExecutable* makeFunction(JSGlobalData* globalData, FunctionBodyNode* body)
{
- return FunctionExecutable::create(globalData, body->ident(), body->source(), body->usesArguments(), body->parameters(), body->isStrictMode(), body->lineNo(), body->lastLine());
+ return FunctionExecutable::create(*globalData, body->ident(), body->source(), body->usesArguments(), body->parameters(), body->isStrictMode(), body->lineNo(), body->lastLine());
}
JSString* addStringConstant(const Identifier&);
{
if (dst == generator.ignoredResult())
return 0;
- return generator.emitNewRegExp(generator.finalDestination(dst), RegExp::create(generator.globalData(), m_pattern.ustring(), regExpFlags(m_flags.ustring())));
+ return generator.emitNewRegExp(generator.finalDestination(dst), RegExp::create(*generator.globalData(), m_pattern.ustring(), regExpFlags(m_flags.ustring())));
}
// ------------------------------ ThisNode -------------------------------------
exceptionValue = createSyntaxError(callFrame, "Invalid flags supplied to RegExp constructor.");
goto vm_throw;
}
- callFrame->uncheckedR(dst) = JSValue(new (globalData) RegExpObject(callFrame->lexicalGlobalObject(), callFrame->scopeChain()->globalObject->regExpStructure(), regExp));
+ callFrame->uncheckedR(dst) = JSValue(RegExpObject::create(globalData, callFrame->lexicalGlobalObject(), callFrame->scopeChain()->globalObject->regExpStructure(), regExp));
vPC += OPCODE_LENGTH(op_new_regexp);
NEXT_INSTRUCTION();
NEXT_INSTRUCTION();
}
if (!arguments) {
- Arguments* arguments = new (globalData) Arguments(callFrame);
+ Arguments* arguments = Arguments::create(globalData, callFrame);
callFrame->uncheckedR(argumentsRegister) = JSValue(arguments);
callFrame->uncheckedR(unmodifiedArgumentsRegister(argumentsRegister)) = JSValue(arguments);
}
int activationReg = vPC[1].u.operand;
if (!callFrame->r(activationReg).jsValue()) {
- JSActivation* activation = new (globalData) JSActivation(callFrame, static_cast<FunctionExecutable*>(codeBlock->ownerExecutable()));
+ JSActivation* activation = JSActivation::create(globalData, callFrame, static_cast<FunctionExecutable*>(codeBlock->ownerExecutable()));
callFrame->r(activationReg) = JSValue(activation);
callFrame->setScopeChain(callFrame->scopeChain()->push(activation));
}
int dst = vPC[1].u.operand;
if (!callFrame->r(dst).jsValue()) {
- Arguments* arguments = new (globalData) Arguments(callFrame);
+ Arguments* arguments = Arguments::create(globalData, callFrame);
callFrame->uncheckedR(dst) = JSValue(arguments);
callFrame->uncheckedR(unmodifiedArgumentsRegister(dst)) = JSValue(arguments);
}
int realArgumentsRegister = unmodifiedArgumentsRegister(argumentsRegister);
if (JSValue arguments = functionCallFrame->uncheckedR(argumentsRegister).jsValue())
return arguments;
- JSValue arguments = JSValue(new (callFrame) Arguments(functionCallFrame));
+ JSValue arguments = JSValue(Arguments::create(callFrame->globalData(), functionCallFrame));
functionCallFrame->r(argumentsRegister) = arguments;
functionCallFrame->r(realArgumentsRegister) = arguments;
return arguments;
}
- Arguments* arguments = new (functionCallFrame) Arguments(functionCallFrame);
+ Arguments* arguments = Arguments::create(functionCallFrame->globalData(), functionCallFrame);
arguments->copyRegisters(functionCallFrame->globalData());
return arguments;
}
{
STUB_INIT_STACK_FRAME(stackFrame);
- JSActivation* activation = new (stackFrame.globalData) JSActivation(stackFrame.callFrame, static_cast<FunctionExecutable*>(stackFrame.callFrame->codeBlock()->ownerExecutable()));
+ JSActivation* activation = JSActivation::create(stackFrame.callFrame->globalData(), stackFrame.callFrame, static_cast<FunctionExecutable*>(stackFrame.callFrame->codeBlock()->ownerExecutable()));
stackFrame.callFrame->setScopeChain(stackFrame.callFrame->scopeChain()->push(activation));
return activation;
}
{
STUB_INIT_STACK_FRAME(stackFrame);
- Arguments* arguments = new (stackFrame.globalData) Arguments(stackFrame.callFrame);
+ Arguments* arguments = Arguments::create(*stackFrame.globalData, stackFrame.callFrame);
return JSValue::encode(JSValue(arguments));
}
{
STUB_INIT_STACK_FRAME(stackFrame);
- Arguments* arguments = new (stackFrame.globalData) Arguments(stackFrame.callFrame, Arguments::NoParameters);
+ Arguments* arguments = Arguments::createNoParameters(*stackFrame.globalData, stackFrame.callFrame);
return JSValue::encode(JSValue(arguments));
}
VM_THROW_EXCEPTION();
}
- return new (stackFrame.globalData) RegExpObject(stackFrame.callFrame->lexicalGlobalObject(), stackFrame.callFrame->lexicalGlobalObject()->regExpStructure(), regExp);
+ return RegExpObject::create(*stackFrame.globalData, stackFrame.callFrame->lexicalGlobalObject(), stackFrame.callFrame->lexicalGlobalObject()->regExpStructure(), regExp);
}
DEFINE_STUB_FUNCTION(EncodedJSValue, op_bitor)
}
class GlobalObject : public JSGlobalObject {
-public:
+private:
GlobalObject(JSGlobalData&, Structure*, const Vector<UString>& arguments);
+
+public:
+ static GlobalObject* create(JSGlobalData& globalData, Structure* structure, const Vector<UString>& arguments)
+ {
+ return new (allocateCell<GlobalObject>(globalData.heap)) GlobalObject(globalData, structure, arguments);
+ }
virtual UString className() const { return "global"; }
};
COMPILE_ASSERT(!IsInteger<GlobalObject>::value, WTF_IsInteger_GlobalObject_false);
GlobalObject::GlobalObject(JSGlobalData& globalData, Structure* structure, const Vector<UString>& arguments)
: JSGlobalObject(globalData, structure)
{
- putDirectFunction(globalExec(), new (globalExec()) JSFunction(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "debug"), functionDebug));
- putDirectFunction(globalExec(), new (globalExec()) JSFunction(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "print"), functionPrint));
- putDirectFunction(globalExec(), new (globalExec()) JSFunction(globalExec(), this, functionStructure(), 0, Identifier(globalExec(), "quit"), functionQuit));
- putDirectFunction(globalExec(), new (globalExec()) JSFunction(globalExec(), this, functionStructure(), 0, Identifier(globalExec(), "gc"), functionGC));
+ putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "debug"), functionDebug));
+ putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "print"), functionPrint));
+ putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 0, Identifier(globalExec(), "quit"), functionQuit));
+ putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 0, Identifier(globalExec(), "gc"), functionGC));
#ifndef NDEBUG
- putDirectFunction(globalExec(), new (globalExec()) JSFunction(globalExec(), this, functionStructure(), 0, Identifier(globalExec(), "releaseExecutableMemory"), functionReleaseExecutableMemory));
+ putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 0, Identifier(globalExec(), "releaseExecutableMemory"), functionReleaseExecutableMemory));
#endif
- putDirectFunction(globalExec(), new (globalExec()) JSFunction(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "version"), functionVersion));
- putDirectFunction(globalExec(), new (globalExec()) JSFunction(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "run"), functionRun));
- putDirectFunction(globalExec(), new (globalExec()) JSFunction(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "load"), functionLoad));
- putDirectFunction(globalExec(), new (globalExec()) JSFunction(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "checkSyntax"), functionCheckSyntax));
- putDirectFunction(globalExec(), new (globalExec()) JSFunction(globalExec(), this, functionStructure(), 0, Identifier(globalExec(), "readline"), functionReadline));
+ putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "version"), functionVersion));
+ putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "run"), functionRun));
+ putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "load"), functionLoad));
+ putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "checkSyntax"), functionCheckSyntax));
+ putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 0, Identifier(globalExec(), "readline"), functionReadline));
#if ENABLE(SAMPLING_FLAGS)
- putDirectFunction(globalExec(), new (globalExec()) JSFunction(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "setSamplingFlags"), functionSetSamplingFlags));
- putDirectFunction(globalExec(), new (globalExec()) JSFunction(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "clearSamplingFlags"), functionClearSamplingFlags));
+ putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "setSamplingFlags"), functionSetSamplingFlags));
+ putDirectFunction(globalExec(), JSFunction::create(globalExec(), this, functionStructure(), 1, Identifier(globalExec(), "clearSamplingFlags"), functionClearSamplingFlags));
#endif
JSObject* array = constructEmptyArray(globalExec());
if (!fillBufferWithContentsOfFile(fileName, script))
return JSValue::encode(throwError(exec, createError(exec, "Could not open file.")));
- GlobalObject* globalObject = new (&exec->globalData()) GlobalObject(exec->globalData(), GlobalObject::createStructure(exec->globalData(), jsNull()), Vector<UString>());
+ GlobalObject* globalObject = GlobalObject::create(exec->globalData(), GlobalObject::createStructure(exec->globalData(), jsNull()), Vector<UString>());
StopWatch stopWatch;
stopWatch.start();
Options options;
parseArguments(argc, argv, options, globalData);
- GlobalObject* globalObject = new (globalData) GlobalObject(*globalData, GlobalObject::createStructure(*globalData, jsNull()), options.arguments);
+ GlobalObject* globalObject = GlobalObject::create(*globalData, GlobalObject::createStructure(*globalData, jsNull()), options.arguments);
bool success = runWithScripts(globalObject, options.scripts, options.dump);
if (options.interactive && success)
runInteractive(globalObject);
class Arguments : public JSNonFinalObject {
public:
+ static Arguments* create(JSGlobalData& globalData, CallFrame* callFrame)
+ {
+ return new (allocateCell<Arguments>(globalData.heap)) Arguments(callFrame);
+ }
+
+ static Arguments* createNoParameters(JSGlobalData& globalData, CallFrame* callFrame)
+ {
+ return new (allocateCell<Arguments>(globalData.heap)) Arguments(callFrame, NoParameters);
+ }
+
// Use an enum because otherwise gcc insists on doing a memory
// read.
enum { MaxArguments = 0x10000 };
+ private:
enum NoParametersType { NoParameters };
-
+
Arguments(CallFrame*);
Arguments(CallFrame*, NoParametersType);
+
+ public:
virtual ~Arguments();
static const ClassInfo s_info;
uint32_t n = args.at(0).toUInt32(exec);
if (n != args.at(0).toNumber(exec))
return throwError(exec, createRangeError(exec, "Array size is not a small enough positive integer."));
- return new (exec) JSArray(exec->globalData(), globalObject->arrayStructure(), n, CreateInitialized);
+ return JSArray::create(exec->globalData(), globalObject->arrayStructure(), n, CreateInitialized);
}
// otherwise the array is constructed with the arguments in it
- return new (exec) JSArray(exec->globalData(), globalObject->arrayStructure(), args);
+ return JSArray::create(exec->globalData(), globalObject->arrayStructure(), args);
}
static EncodedJSValue JSC_HOST_CALL constructWithArrayConstructor(ExecState* exec)
class ArrayPrototype;
class ArrayConstructor : public InternalFunction {
- public:
+ private:
ArrayConstructor(ExecState*, JSGlobalObject*, Structure*, ArrayPrototype*);
+
+ public:
+ static ArrayConstructor* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, ArrayPrototype* arrPrototype)
+ {
+ return new (allocateCell<ArrayConstructor>(*exec->heap())) ArrayConstructor(exec, globalObject, structure, arrPrototype);
+ }
static const ClassInfo s_info;
deleteCount = static_cast<unsigned>(deleteDouble);
}
- JSArray* resObj = new (exec) JSArray(exec->globalData(), exec->lexicalGlobalObject()->arrayStructure(), deleteCount, CreateCompact);
+ JSArray* resObj = JSArray::create(exec->globalData(), exec->lexicalGlobalObject()->arrayStructure(), deleteCount, CreateCompact);
JSValue result = resObj;
JSGlobalData& globalData = exec->globalData();
for (unsigned k = 0; k < deleteCount; k++)
namespace JSC {
class ArrayPrototype : public JSArray {
- public:
- explicit ArrayPrototype(JSGlobalObject*, Structure*);
+ private:
+ ArrayPrototype(JSGlobalObject*, Structure*);
+ public:
+ static ArrayPrototype* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure)
+ {
+ return new (allocateCell<ArrayPrototype>(*exec->heap())) ArrayPrototype(globalObject, structure);
+ }
+
bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&);
// ECMA 15.6.2
JSObject* constructBoolean(ExecState* exec, const ArgList& args)
{
- BooleanObject* obj = new (exec) BooleanObject(exec->globalData(), asInternalFunction(exec->callee())->globalObject()->booleanObjectStructure());
+ BooleanObject* obj = BooleanObject::create(exec->globalData(), asInternalFunction(exec->callee())->globalObject()->booleanObjectStructure());
obj->setInternalValue(exec->globalData(), jsBoolean(args.at(0).toBoolean(exec)));
return obj;
}
JSObject* constructBooleanFromImmediateBoolean(ExecState* exec, JSGlobalObject* globalObject, JSValue immediateBooleanValue)
{
- BooleanObject* obj = new (exec) BooleanObject(exec->globalData(), globalObject->booleanObjectStructure());
+ BooleanObject* obj = BooleanObject::create(exec->globalData(), globalObject->booleanObjectStructure());
obj->setInternalValue(exec->globalData(), immediateBooleanValue);
return obj;
}
class BooleanPrototype;
class BooleanConstructor : public InternalFunction {
- public:
+ private:
BooleanConstructor(ExecState*, JSGlobalObject*, Structure*, BooleanPrototype*);
+
+ public:
+ static BooleanConstructor* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, BooleanPrototype* boolPrototype)
+ {
+ return new (allocateCell<BooleanConstructor>(*exec->heap())) BooleanConstructor(exec, globalObject, structure, boolPrototype);
+ }
private:
virtual ConstructType getConstructData(ConstructData&);
namespace JSC {
class BooleanObject : public JSWrapperObject {
- public:
- explicit BooleanObject(JSGlobalData&, Structure*);
+ protected:
+ BooleanObject(JSGlobalData&, Structure*);
+ public:
+ static BooleanObject* create(JSGlobalData& globalData, Structure* structure)
+ {
+ return new (allocateCell<BooleanObject>(globalData.heap)) BooleanObject(globalData, structure);
+ }
+
static const ClassInfo s_info;
static Structure* createStructure(JSGlobalData& globalData, JSValue prototype)
namespace JSC {
class BooleanPrototype : public BooleanObject {
- public:
+ private:
BooleanPrototype(ExecState*, JSGlobalObject*, Structure*);
+ public:
+ static BooleanPrototype* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure)
+ {
+ return new (allocateCell<BooleanPrototype>(*exec->heap())) BooleanPrototype(exec, globalObject, structure);
+ }
+
static const ClassInfo s_info;
static Structure* createStructure(JSGlobalData& globalData, JSValue prototype)
}
}
- return new (exec) DateInstance(exec, globalObject->dateStructure(), value);
+ return DateInstance::create(exec, globalObject->dateStructure(), value);
}
static EncodedJSValue JSC_HOST_CALL constructWithDateConstructor(ExecState* exec)
class DatePrototype;
class DateConstructor : public InternalFunction {
- public:
+ private:
DateConstructor(ExecState*, JSGlobalObject*, Structure*, DatePrototype*);
+
+ public:
+ static DateConstructor* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, DatePrototype* datePrototype)
+ {
+ return new (allocateCell<DateConstructor>(*exec->heap())) DateConstructor(exec, globalObject, structure, datePrototype);
+ }
static const ClassInfo s_info;
namespace JSC {
class DateInstance : public JSWrapperObject {
- public:
+ protected:
DateInstance(ExecState*, Structure*, double);
- explicit DateInstance(ExecState*, Structure*);
-
+ DateInstance(ExecState*, Structure*);
+
+ public:
+ static DateInstance* create(ExecState* exec, Structure* structure, double date)
+ {
+ return new (allocateCell<DateInstance>(*exec->heap())) DateInstance(exec, structure, date);
+ }
+ static DateInstance* create(ExecState* exec, Structure* structure)
+ {
+ return new (allocateCell<DateInstance>(*exec->heap())) DateInstance(exec, structure);
+ }
+
double internalNumber() const { return internalValue().uncheckedGetNumber(); }
static JS_EXPORTDATA const ClassInfo s_info;
class ObjectPrototype;
class DatePrototype : public DateInstance {
- public:
+ private:
DatePrototype(ExecState*, JSGlobalObject*, Structure*);
+ public:
+ static DatePrototype* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure)
+ {
+ return new (allocateCell<DatePrototype>(*exec->heap())) DatePrototype(exec, globalObject, structure);
+ }
virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&);
JSObject* createError(JSGlobalObject* globalObject, const UString& message)
{
ASSERT(!message.isEmpty());
- return ErrorInstance::create(&globalObject->globalData(), globalObject->errorStructure(), message);
+ return ErrorInstance::create(globalObject->globalData(), globalObject->errorStructure(), message);
}
JSObject* createEvalError(JSGlobalObject* globalObject, const UString& message)
{
ASSERT(!message.isEmpty());
- return ErrorInstance::create(&globalObject->globalData(), globalObject->evalErrorConstructor()->errorStructure(), message);
+ return ErrorInstance::create(globalObject->globalData(), globalObject->evalErrorConstructor()->errorStructure(), message);
}
JSObject* createRangeError(JSGlobalObject* globalObject, const UString& message)
{
ASSERT(!message.isEmpty());
- return ErrorInstance::create(&globalObject->globalData(), globalObject->rangeErrorConstructor()->errorStructure(), message);
+ return ErrorInstance::create(globalObject->globalData(), globalObject->rangeErrorConstructor()->errorStructure(), message);
}
JSObject* createReferenceError(JSGlobalObject* globalObject, const UString& message)
{
ASSERT(!message.isEmpty());
- return ErrorInstance::create(&globalObject->globalData(), globalObject->referenceErrorConstructor()->errorStructure(), message);
+ return ErrorInstance::create(globalObject->globalData(), globalObject->referenceErrorConstructor()->errorStructure(), message);
}
JSObject* createSyntaxError(JSGlobalObject* globalObject, const UString& message)
{
ASSERT(!message.isEmpty());
- return ErrorInstance::create(&globalObject->globalData(), globalObject->syntaxErrorConstructor()->errorStructure(), message);
+ return ErrorInstance::create(globalObject->globalData(), globalObject->syntaxErrorConstructor()->errorStructure(), message);
}
JSObject* createTypeError(JSGlobalObject* globalObject, const UString& message)
{
ASSERT(!message.isEmpty());
- return ErrorInstance::create(&globalObject->globalData(), globalObject->typeErrorConstructor()->errorStructure(), message);
+ return ErrorInstance::create(globalObject->globalData(), globalObject->typeErrorConstructor()->errorStructure(), message);
}
JSObject* createURIError(JSGlobalObject* globalObject, const UString& message)
{
ASSERT(!message.isEmpty());
- return ErrorInstance::create(&globalObject->globalData(), globalObject->URIErrorConstructor()->errorStructure(), message);
+ return ErrorInstance::create(globalObject->globalData(), globalObject->URIErrorConstructor()->errorStructure(), message);
}
JSObject* createError(ExecState* exec, const UString& message)
}
class StrictModeTypeErrorFunction : public InternalFunction {
-public:
+private:
StrictModeTypeErrorFunction(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, const UString& message)
: InternalFunction(&exec->globalData(), globalObject, structure, exec->globalData().propertyNames->emptyIdentifier)
, m_message(message)
{
}
+
+public:
+ static StrictModeTypeErrorFunction* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, const UString& message)
+ {
+ return new (allocateCell<StrictModeTypeErrorFunction>(*exec->heap())) StrictModeTypeErrorFunction(exec, globalObject, structure, message);
+ }
static EncodedJSValue JSC_HOST_CALL constructThrowTypeError(ExecState* exec)
{
JSValue createTypeErrorFunction(ExecState* exec, const UString& message)
{
- return new (exec) StrictModeTypeErrorFunction(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->internalFunctionStructure(), message);
+ return StrictModeTypeErrorFunction::create(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->internalFunctionStructure(), message);
}
} // namespace JSC
class ErrorPrototype;
class ErrorConstructor : public InternalFunction {
- public:
+ private:
ErrorConstructor(ExecState*, JSGlobalObject*, Structure*, ErrorPrototype*);
+ public:
+ static ErrorConstructor* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, ErrorPrototype* errPrototype)
+ {
+ return new (allocateCell<ErrorConstructor>(*exec->heap())) ErrorConstructor(exec, globalObject, structure, errPrototype);
+ }
+
private:
virtual ConstructType getConstructData(ConstructData&);
virtual CallType getCallData(CallData&);
const ClassInfo ErrorInstance::s_info = { "Error", &JSNonFinalObject::s_info, 0, 0 };
-ErrorInstance::ErrorInstance(JSGlobalData* globalData, Structure* structure)
- : JSNonFinalObject(*globalData, structure)
+ErrorInstance::ErrorInstance(JSGlobalData& globalData, Structure* structure)
+ : JSNonFinalObject(globalData, structure)
, m_appendSourceToMessage(false)
{
ASSERT(inherits(&s_info));
- putDirect(*globalData, globalData->propertyNames->message, jsString(globalData, ""), DontEnum);
+ putDirect(globalData, globalData.propertyNames->message, jsString(&globalData, ""), DontEnum);
}
-ErrorInstance::ErrorInstance(JSGlobalData* globalData, Structure* structure, const UString& message)
- : JSNonFinalObject(*globalData, structure)
+ErrorInstance::ErrorInstance(JSGlobalData& globalData, Structure* structure, const UString& message)
+ : JSNonFinalObject(globalData, structure)
, m_appendSourceToMessage(false)
{
ASSERT(inherits(&s_info));
- putDirect(*globalData, globalData->propertyNames->message, jsString(globalData, message), DontEnum);
+ putDirect(globalData, globalData.propertyNames->message, jsString(&globalData, message), DontEnum);
}
-ErrorInstance* ErrorInstance::create(JSGlobalData* globalData, Structure* structure, const UString& message)
+ErrorInstance* ErrorInstance::create(JSGlobalData& globalData, Structure* structure, const UString& message)
{
- return new (globalData) ErrorInstance(globalData, structure, message);
+ return new (allocateCell<ErrorInstance>(globalData.heap)) ErrorInstance(globalData, structure, message);
}
ErrorInstance* ErrorInstance::create(ExecState* exec, Structure* structure, JSValue message)
{
if (message.isUndefined())
- return new (exec) ErrorInstance(&exec->globalData(), structure);
- return new (exec) ErrorInstance(&exec->globalData(), structure, message.toString(exec));
+ return new (allocateCell<ErrorInstance>(*exec->heap())) ErrorInstance(exec->globalData(), structure);
+ return new (allocateCell<ErrorInstance>(*exec->heap())) ErrorInstance(exec->globalData(), structure, message.toString(exec));
}
} // namespace JSC
return Structure::create(globalData, prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
}
- static ErrorInstance* create(JSGlobalData*, Structure*, const UString&);
+ static ErrorInstance* create(JSGlobalData&, Structure*, const UString&);
static ErrorInstance* create(ExecState*, Structure*, JSValue message);
virtual bool isErrorInstance() const { return true; }
protected:
- explicit ErrorInstance(JSGlobalData*, Structure*);
- explicit ErrorInstance(JSGlobalData*, Structure*, const UString&);
+ explicit ErrorInstance(JSGlobalData&, Structure*);
+ explicit ErrorInstance(JSGlobalData&, Structure*, const UString&);
bool m_appendSourceToMessage;
};
ASSERT_CLASS_FITS_IN_CELL(ErrorPrototype);
ErrorPrototype::ErrorPrototype(ExecState* exec, JSGlobalObject* globalObject, Structure* structure)
- : ErrorInstance(&exec->globalData(), structure)
+ : ErrorInstance(exec->globalData(), structure)
{
putDirect(exec->globalData(), exec->propertyNames().name, jsNontrivialString(exec, "Error"), DontEnum);
class ObjectPrototype;
class ErrorPrototype : public ErrorInstance {
- public:
+ protected:
ErrorPrototype(ExecState*, JSGlobalObject*, Structure*);
+ public:
+ static ErrorPrototype* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure)
+ {
+ return new (allocateCell<ErrorPrototype>(*exec->heap())) ErrorPrototype(exec, globalObject, structure);
+ }
+
static const ClassInfo s_info;
static Structure* createStructure(JSGlobalData& globalData, JSValue prototype)
namespace JSC {
class InterruptedExecutionError : public JSNonFinalObject {
+private:
+ InterruptedExecutionError(JSGlobalData& globalData)
+ : JSNonFinalObject(globalData, globalData.interruptedExecutionErrorStructure.get())
+ {
+ }
+
public:
- InterruptedExecutionError(JSGlobalData* globalData)
- : JSNonFinalObject(*globalData, globalData->interruptedExecutionErrorStructure.get())
+ static InterruptedExecutionError* create(JSGlobalData& globalData)
{
+ return new (allocateCell<InterruptedExecutionError>(globalData.heap)) InterruptedExecutionError(globalData);
}
virtual ComplType exceptionType() const { return Interrupted; }
JSObject* createInterruptedExecutionException(JSGlobalData* globalData)
{
- return new (globalData) InterruptedExecutionError(globalData);
+ return InterruptedExecutionError::create(*globalData);
}
class TerminatedExecutionError : public JSNonFinalObject {
+private:
+ TerminatedExecutionError(JSGlobalData& globalData)
+ : JSNonFinalObject(globalData, globalData.terminatedExecutionErrorStructure.get())
+ {
+ }
+
public:
- TerminatedExecutionError(JSGlobalData* globalData)
- : JSNonFinalObject(*globalData, globalData->terminatedExecutionErrorStructure.get())
+ static TerminatedExecutionError* create(JSGlobalData& globalData)
{
+ return new (allocateCell<TerminatedExecutionError>(globalData.heap)) TerminatedExecutionError(globalData);
}
virtual ComplType exceptionType() const { return Terminated; }
JSObject* createTerminatedExecutionException(JSGlobalData* globalData)
{
- return new (globalData) TerminatedExecutionError(globalData);
+ return TerminatedExecutionError::create(*globalData);
}
JSObject* createStackOverflowError(ExecState* exec)
const ClassInfo FunctionExecutable::s_info = { "FunctionExecutable", &ScriptExecutable::s_info, 0, 0 };
-FunctionExecutable::FunctionExecutable(JSGlobalData* globalData, const Identifier& name, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, bool inStrictContext, int firstLine, int lastLine)
- : ScriptExecutable(globalData->functionExecutableStructure.get(), globalData, source, inStrictContext)
+FunctionExecutable::FunctionExecutable(JSGlobalData& globalData, const Identifier& name, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, bool inStrictContext, int firstLine, int lastLine)
+ : ScriptExecutable(globalData.functionExecutableStructure.get(), globalData, source, inStrictContext)
, m_numCapturedVariables(0)
, m_forceUsesArguments(forceUsesArguments)
, m_parameters(parameters)
FunctionBodyNode* body = static_cast<FuncExprNode*>(funcExpr)->body();
ASSERT(body);
- return FunctionExecutable::create(&exec->globalData(), functionName, body->source(), body->usesArguments(), body->parameters(), body->isStrictMode(), body->lineNo(), body->lastLine());
+ return FunctionExecutable::create(exec->globalData(), functionName, body->source(), body->usesArguments(), body->parameters(), body->isStrictMode(), body->lineNo(), body->lastLine());
}
UString FunctionExecutable::paramString() const
protected:
static const int NUM_PARAMETERS_IS_HOST = 0;
static const int NUM_PARAMETERS_NOT_COMPILED = -1;
-
- public:
+
+ protected:
ExecutableBase(JSGlobalData& globalData, Structure* structure, int numParameters)
: JSCell(globalData, structure)
, m_numParametersForCall(numParameters)
finalizer.leakHandle();
#endif
}
+
+ public:
+ static ExecutableBase* create(JSGlobalData& globalData, Structure* structure, int numParameters)
+ {
+ return new (allocateCell<ExecutableBase>(globalData.heap)) ExecutableBase(globalData, structure, numParameters);
+ }
bool isHostFunction() const
{
static NativeExecutable* create(JSGlobalData& globalData, MacroAssemblerCodePtr callThunk, NativeFunction function, MacroAssemblerCodePtr constructThunk, NativeFunction constructor)
{
if (!callThunk)
- return new (&globalData) NativeExecutable(globalData, JITCode(), function, JITCode(), constructor);
- return new (&globalData) NativeExecutable(globalData, JITCode::HostFunction(callThunk), function, JITCode::HostFunction(constructThunk), constructor);
+ return new (allocateCell<NativeExecutable>(globalData.heap)) NativeExecutable(globalData, JITCode(), function, JITCode(), constructor);
+ return new (allocateCell<NativeExecutable>(globalData.heap)) NativeExecutable(globalData, JITCode::HostFunction(callThunk), function, JITCode::HostFunction(constructThunk), constructor);
}
#else
static NativeExecutable* create(JSGlobalData& globalData, NativeFunction function, NativeFunction constructor)
{
- return new (&globalData) NativeExecutable(globalData, function, constructor);
+ return new (allocateCell<NativeExecutable>(globalData.heap)) NativeExecutable(globalData, function, constructor);
}
#endif
class ScriptExecutable : public ExecutableBase {
public:
- ScriptExecutable(Structure* structure, JSGlobalData* globalData, const SourceCode& source, bool isInStrictContext)
- : ExecutableBase(*globalData, structure, NUM_PARAMETERS_NOT_COMPILED)
+ ScriptExecutable(Structure* structure, JSGlobalData& globalData, const SourceCode& source, bool isInStrictContext)
+ : ExecutableBase(globalData, structure, NUM_PARAMETERS_NOT_COMPILED)
, m_source(source)
, m_features(isInStrictContext ? StrictModeFeature : 0)
{
#if ENABLE(CODEBLOCK_SAMPLING)
- if (SamplingTool* sampler = globalData->interpreter->sampler())
+ if (SamplingTool* sampler = globalData.interpreter->sampler())
sampler->notifyOfScope(*globalData, this);
#else
UNUSED_PARAM(globalData);
return *m_evalCodeBlock;
}
- static EvalExecutable* create(ExecState* exec, const SourceCode& source, bool isInStrictContext) { return new (exec) EvalExecutable(exec, source, isInStrictContext); }
+ static EvalExecutable* create(ExecState* exec, const SourceCode& source, bool isInStrictContext)
+ {
+ return new (allocateCell<EvalExecutable>(*exec->heap())) EvalExecutable(exec, source, isInStrictContext);
+ }
#if ENABLE(JIT)
JITCode& generatedJITCode()
public:
static ProgramExecutable* create(ExecState* exec, const SourceCode& source)
{
- return new (exec) ProgramExecutable(exec, source);
+ return new (allocateCell<ProgramExecutable>(*exec->heap())) ProgramExecutable(exec, source);
}
~ProgramExecutable();
public:
static FunctionExecutable* create(ExecState* exec, const Identifier& name, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, bool isInStrictContext, int firstLine, int lastLine)
{
- return new (exec) FunctionExecutable(exec, name, source, forceUsesArguments, parameters, isInStrictContext, firstLine, lastLine);
+ return new (allocateCell<FunctionExecutable>(*exec->heap())) FunctionExecutable(exec, name, source, forceUsesArguments, parameters, isInStrictContext, firstLine, lastLine);
}
- static FunctionExecutable* create(JSGlobalData* globalData, const Identifier& name, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, bool isInStrictContext, int firstLine, int lastLine)
+ static FunctionExecutable* create(JSGlobalData& globalData, const Identifier& name, const SourceCode& source, bool forceUsesArguments, FunctionParameters* parameters, bool isInStrictContext, int firstLine, int lastLine)
{
- return new (globalData) FunctionExecutable(globalData, name, source, forceUsesArguments, parameters, isInStrictContext, firstLine, lastLine);
+ return new (allocateCell<FunctionExecutable>(globalData.heap)) FunctionExecutable(globalData, name, source, forceUsesArguments, parameters, isInStrictContext, firstLine, lastLine);
}
JSFunction* make(ExecState* exec, ScopeChainNode* scopeChain)
{
- return new (exec) JSFunction(exec, this, scopeChain);
+ return JSFunction::create(exec, this, scopeChain);
}
// Returns either call or construct bytecode. This can be appropriate
static const ClassInfo s_info;
private:
- FunctionExecutable(JSGlobalData*, const Identifier& name, const SourceCode&, bool forceUsesArguments, FunctionParameters*, bool, int firstLine, int lastLine);
+ FunctionExecutable(JSGlobalData&, const Identifier& name, const SourceCode&, bool forceUsesArguments, FunctionParameters*, bool, int firstLine, int lastLine);
FunctionExecutable(ExecState*, const Identifier& name, const SourceCode&, bool forceUsesArguments, FunctionParameters*, bool, int firstLine, int lastLine);
JSObject* compileForCallInternal(ExecState*, ScopeChainNode*);
return throwError(exec, exception);
}
- ScopeChainNode* scopeChain = new (exec) ScopeChainNode(0, globalObject, &globalData, globalObject, exec->globalThisValue());
- return new (exec) JSFunction(exec, function, scopeChain);
+ ScopeChainNode* scopeChain = ScopeChainNode::create(exec, 0, globalObject, &globalData, globalObject, exec->globalThisValue());
+ return JSFunction::create(exec, function, scopeChain);
}
// ECMA 15.3.2 The Function Constructor
class FunctionPrototype;
class FunctionConstructor : public InternalFunction {
- public:
+ private:
FunctionConstructor(ExecState*, JSGlobalObject*, Structure*, FunctionPrototype*);
+
+ public:
+ static FunctionConstructor* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, FunctionPrototype* funcPrototype)
+ {
+ return new (allocateCell<FunctionConstructor>(*exec->heap())) FunctionConstructor(exec, globalObject, structure, funcPrototype);
+ }
private:
virtual ConstructType getConstructData(ConstructData&);
void FunctionPrototype::addFunctionProperties(ExecState* exec, JSGlobalObject* globalObject, Structure* functionStructure, JSFunction** callFunction, JSFunction** applyFunction)
{
- putDirectFunctionWithoutTransition(exec, new (exec) JSFunction(exec, globalObject, functionStructure, 0, exec->propertyNames().toString, functionProtoFuncToString), DontEnum);
- *applyFunction = new (exec) JSFunction(exec, globalObject, functionStructure, 2, exec->propertyNames().apply, functionProtoFuncApply);
+ putDirectFunctionWithoutTransition(exec, JSFunction::create(exec, globalObject, functionStructure, 0, exec->propertyNames().toString, functionProtoFuncToString), DontEnum);
+ *applyFunction = JSFunction::create(exec, globalObject, functionStructure, 2, exec->propertyNames().apply, functionProtoFuncApply);
putDirectFunctionWithoutTransition(exec, *applyFunction, DontEnum);
- *callFunction = new (exec) JSFunction(exec, globalObject, functionStructure, 1, exec->propertyNames().call, functionProtoFuncCall);
+ *callFunction = JSFunction::create(exec, globalObject, functionStructure, 1, exec->propertyNames().call, functionProtoFuncCall);
putDirectFunctionWithoutTransition(exec, *callFunction, DontEnum);
}
namespace JSC {
class FunctionPrototype : public InternalFunction {
- public:
+ private:
FunctionPrototype(ExecState*, JSGlobalObject*, Structure*);
- void addFunctionProperties(ExecState*, JSGlobalObject*, Structure* functionStructure, JSFunction** callFunction, JSFunction** applyFunction);
+ public:
+ static FunctionPrototype* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure)
+ {
+ return new (allocateCell<FunctionPrototype>(*exec->heap())) FunctionPrototype(exec, globalObject, structure);
+ }
+
+ void addFunctionProperties(ExecState*, JSGlobalObject*, Structure* functionStructure, JSFunction** callFunction, JSFunction** applyFunction);
+
static Structure* createStructure(JSGlobalData& globalData, JSValue proto)
{
return Structure::create(globalData, proto, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
// for a property.
class GetterSetter : public JSCell {
friend class JIT;
- public:
+
+ private:
GetterSetter(ExecState* exec)
: JSCell(exec->globalData(), exec->globalData().getterSetterStructure.get())
{
}
+ public:
+ static GetterSetter* create(ExecState* exec)
+ {
+ return new (allocateCell<GetterSetter>(*exec->heap())) GetterSetter(exec);
+ }
+
virtual void visitChildren(SlotVisitor&);
JSObject* getter() const { return m_getter.get(); }
}
static const ClassInfo s_info;
+
+ static JSAPIValueWrapper* create(ExecState* exec, JSValue value)
+ {
+ return new (allocateCell<JSAPIValueWrapper>(*exec->heap())) JSAPIValueWrapper(exec, value);
+ }
private:
JSAPIValueWrapper(ExecState* exec, JSValue value)
inline JSValue jsAPIValueWrapper(ExecState* exec, JSValue value)
{
- return new (exec) JSAPIValueWrapper(exec, value);
+ return JSAPIValueWrapper::create(exec, value);
}
} // namespace JSC
return arguments;
int realArgumentsRegister = unmodifiedArgumentsRegister(argumentsRegister);
- JSValue arguments = JSValue(new (callFrame) Arguments(callFrame));
+ JSValue arguments = JSValue(Arguments::create(callFrame->globalData(), callFrame));
callFrame->uncheckedR(argumentsRegister) = arguments;
callFrame->uncheckedR(realArgumentsRegister) = arguments;
class Register;
class JSActivation : public JSVariableObject {
+ private:
typedef JSVariableObject Base;
- public:
JSActivation(CallFrame*, FunctionExecutable*);
+
+ public:
+ static JSActivation* create(JSGlobalData& globalData, CallFrame* callFrame, FunctionExecutable* funcExec)
+ {
+ return new (allocateCell<JSActivation>(globalData.heap)) JSActivation(callFrame, funcExec);
+ }
+
virtual ~JSActivation();
virtual void visitChildren(SlotVisitor&);
class JSArray : public JSNonFinalObject {
friend class Walker;
- public:
- JSArray(VPtrStealingHackType);
-
+ protected:
explicit JSArray(JSGlobalData&, Structure*);
JSArray(JSGlobalData&, Structure*, unsigned initialLength, ArrayCreationMode);
JSArray(JSGlobalData&, Structure*, const ArgList& initialValues);
+
+ public:
+ JSArray(VPtrStealingHackType);
virtual ~JSArray();
+ static JSArray* create(JSGlobalData& globalData, Structure* structure)
+ {
+ return new (allocateCell<JSArray>(globalData.heap)) JSArray(globalData, structure);
+ }
+
+ static JSArray* create(JSGlobalData& globalData, Structure* structure, unsigned initialLength, ArrayCreationMode createMode)
+ {
+ return new (allocateCell<JSArray>(globalData.heap)) JSArray(globalData, structure, initialLength, createMode);
+ }
+
+ static JSArray* create(JSGlobalData& globalData, Structure* structure, const ArgList& initialValues)
+ {
+ return new (allocateCell<JSArray>(globalData.heap)) JSArray(globalData, structure, initialValues);
+ }
+
virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&);
virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&);
cell->~JSCell();
}
+ template <typename T> void* allocateCell(Heap& heap)
+ {
+ return heap.allocate(sizeof(T));
+ }
+
} // namespace JSC
#endif // JSCell_h
typedef JSObjectWithGlobalObject Base;
- public:
JSFunction(ExecState*, JSGlobalObject*, Structure*, int length, const Identifier&, NativeFunction);
JSFunction(ExecState*, JSGlobalObject*, Structure*, int length, const Identifier&, NativeExecutable*);
JSFunction(ExecState*, FunctionExecutable*, ScopeChainNode*);
+
+ public:
+ static JSFunction* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, int length, const Identifier& ident, NativeFunction nativeFunc)
+ {
+ return new (allocateCell<JSFunction>(*exec->heap())) JSFunction(exec, globalObject, structure, length, ident, nativeFunc);
+ }
+ static JSFunction* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, int length, const Identifier& ident, NativeExecutable* nativeExec)
+ {
+ return new (allocateCell<JSFunction>(*exec->heap())) JSFunction(exec, globalObject, structure, length, ident, nativeExec);
+ }
+ static JSFunction* create(ExecState* exec, FunctionExecutable* funcExec, ScopeChainNode* scopeChain)
+ {
+ return new (allocateCell<JSFunction>(*exec->heap())) JSFunction(exec, funcExec, scopeChain);
+ }
+
virtual ~JSFunction();
const UString& name(ExecState*);
structure()->disableSpecificFunctionTracking();
m_globalData = Heap::heap(this)->globalData();
- m_globalScopeChain.set(*m_globalData, this, new (m_globalData.get()) ScopeChainNode(0, this, m_globalData.get(), this, thisValue));
+ m_globalScopeChain.set(*m_globalData, this, ScopeChainNode::create(0, this, m_globalData.get(), this, thisValue));
JSGlobalObject::globalExec()->init(0, 0, m_globalScopeChain.get(), CallFrame::noCaller(), 0, 0);
{
ExecState* exec = JSGlobalObject::globalExec();
- m_functionPrototype.set(exec->globalData(), this, new (exec) FunctionPrototype(exec, this, FunctionPrototype::createStructure(exec->globalData(), jsNull()))); // The real prototype will be set once ObjectPrototype is created.
+ m_functionPrototype.set(exec->globalData(), this, FunctionPrototype::create(exec, this, FunctionPrototype::createStructure(exec->globalData(), jsNull()))); // The real prototype will be set once ObjectPrototype is created.
m_functionStructure.set(exec->globalData(), this, JSFunction::createStructure(exec->globalData(), m_functionPrototype.get()));
m_internalFunctionStructure.set(exec->globalData(), this, InternalFunction::createStructure(exec->globalData(), m_functionPrototype.get()));
JSFunction* callFunction = 0;
m_functionPrototype->addFunctionProperties(exec, this, m_functionStructure.get(), &callFunction, &applyFunction);
m_callFunction.set(exec->globalData(), this, callFunction);
m_applyFunction.set(exec->globalData(), this, applyFunction);
- m_objectPrototype.set(exec->globalData(), this, new (exec) ObjectPrototype(exec, this, ObjectPrototype::createStructure(exec->globalData(), jsNull())));
+ m_objectPrototype.set(exec->globalData(), this, ObjectPrototype::create(exec, this, ObjectPrototype::createStructure(exec->globalData(), jsNull())));
m_functionPrototype->structure()->setPrototypeWithoutTransition(exec->globalData(), m_objectPrototype.get());
m_emptyObjectStructure.set(exec->globalData(), this, m_objectPrototype->inheritorID(exec->globalData()));
m_callbackConstructorStructure.set(exec->globalData(), this, JSCallbackConstructor::createStructure(exec->globalData(), m_objectPrototype.get()));
m_callbackObjectStructure.set(exec->globalData(), this, JSCallbackObject<JSObjectWithGlobalObject>::createStructure(exec->globalData(), m_objectPrototype.get()));
- m_arrayPrototype.set(exec->globalData(), this, new (exec) ArrayPrototype(this, ArrayPrototype::createStructure(exec->globalData(), m_objectPrototype.get())));
+ m_arrayPrototype.set(exec->globalData(), this, ArrayPrototype::create(exec, this, ArrayPrototype::createStructure(exec->globalData(), m_objectPrototype.get())));
m_arrayStructure.set(exec->globalData(), this, JSArray::createStructure(exec->globalData(), m_arrayPrototype.get()));
m_regExpMatchesArrayStructure.set(exec->globalData(), this, RegExpMatchesArray::createStructure(exec->globalData(), m_arrayPrototype.get()));
- m_stringPrototype.set(exec->globalData(), this, new (exec) StringPrototype(exec, this, StringPrototype::createStructure(exec->globalData(), m_objectPrototype.get())));
+ m_stringPrototype.set(exec->globalData(), this, StringPrototype::create(exec, this, StringPrototype::createStructure(exec->globalData(), m_objectPrototype.get())));
m_stringObjectStructure.set(exec->globalData(), this, StringObject::createStructure(exec->globalData(), m_stringPrototype.get()));
- m_booleanPrototype.set(exec->globalData(), this, new (exec) BooleanPrototype(exec, this, BooleanPrototype::createStructure(exec->globalData(), m_objectPrototype.get())));
+ m_booleanPrototype.set(exec->globalData(), this, BooleanPrototype::create(exec, this, BooleanPrototype::createStructure(exec->globalData(), m_objectPrototype.get())));
m_booleanObjectStructure.set(exec->globalData(), this, BooleanObject::createStructure(exec->globalData(), m_booleanPrototype.get()));
- m_numberPrototype.set(exec->globalData(), this, new (exec) NumberPrototype(exec, this, NumberPrototype::createStructure(exec->globalData(), m_objectPrototype.get())));
+ m_numberPrototype.set(exec->globalData(), this, NumberPrototype::create(exec, this, NumberPrototype::createStructure(exec->globalData(), m_objectPrototype.get())));
m_numberObjectStructure.set(exec->globalData(), this, NumberObject::createStructure(exec->globalData(), m_numberPrototype.get()));
- m_datePrototype.set(exec->globalData(), this, new (exec) DatePrototype(exec, this, DatePrototype::createStructure(exec->globalData(), m_objectPrototype.get())));
+ m_datePrototype.set(exec->globalData(), this, DatePrototype::create(exec, this, DatePrototype::createStructure(exec->globalData(), m_objectPrototype.get())));
m_dateStructure.set(exec->globalData(), this, DateInstance::createStructure(exec->globalData(), m_datePrototype.get()));
- RegExp* emptyRegex = RegExp::create(&exec->globalData(), "", NoFlags);
+ RegExp* emptyRegex = RegExp::create(exec->globalData(), "", NoFlags);
- m_regExpPrototype.set(exec->globalData(), this, new (exec) RegExpPrototype(exec, this, RegExpPrototype::createStructure(exec->globalData(), m_objectPrototype.get()), emptyRegex));
+ m_regExpPrototype.set(exec->globalData(), this, RegExpPrototype::create(exec, this, RegExpPrototype::createStructure(exec->globalData(), m_objectPrototype.get()), emptyRegex));
m_regExpStructure.set(exec->globalData(), this, RegExpObject::createStructure(exec->globalData(), m_regExpPrototype.get()));
m_methodCallDummy.set(exec->globalData(), this, constructEmptyObject(exec));
- ErrorPrototype* errorPrototype = new (exec) ErrorPrototype(exec, this, ErrorPrototype::createStructure(exec->globalData(), m_objectPrototype.get()));
+ ErrorPrototype* errorPrototype = ErrorPrototype::create(exec, this, ErrorPrototype::createStructure(exec->globalData(), m_objectPrototype.get()));
m_errorStructure.set(exec->globalData(), this, ErrorInstance::createStructure(exec->globalData(), errorPrototype));
// Constructors
- JSCell* objectConstructor = new (exec) ObjectConstructor(exec, this, ObjectConstructor::createStructure(exec->globalData(), m_functionPrototype.get()), m_objectPrototype.get());
- JSCell* functionConstructor = new (exec) FunctionConstructor(exec, this, FunctionConstructor::createStructure(exec->globalData(), m_functionPrototype.get()), m_functionPrototype.get());
- JSCell* arrayConstructor = new (exec) ArrayConstructor(exec, this, ArrayConstructor::createStructure(exec->globalData(), m_functionPrototype.get()), m_arrayPrototype.get());
- JSCell* stringConstructor = new (exec) StringConstructor(exec, this, StringConstructor::createStructure(exec->globalData(), m_functionPrototype.get()), m_stringPrototype.get());
- JSCell* booleanConstructor = new (exec) BooleanConstructor(exec, this, BooleanConstructor::createStructure(exec->globalData(), m_functionPrototype.get()), m_booleanPrototype.get());
- JSCell* numberConstructor = new (exec) NumberConstructor(exec, this, NumberConstructor::createStructure(exec->globalData(), m_functionPrototype.get()), m_numberPrototype.get());
- JSCell* dateConstructor = new (exec) DateConstructor(exec, this, DateConstructor::createStructure(exec->globalData(), m_functionPrototype.get()), m_datePrototype.get());
+ JSCell* objectConstructor = ObjectConstructor::create(exec, this, ObjectConstructor::createStructure(exec->globalData(), m_functionPrototype.get()), m_objectPrototype.get());
+ JSCell* functionConstructor = FunctionConstructor::create(exec, this, FunctionConstructor::createStructure(exec->globalData(), m_functionPrototype.get()), m_functionPrototype.get());
+ JSCell* arrayConstructor = ArrayConstructor::create(exec, this, ArrayConstructor::createStructure(exec->globalData(), m_functionPrototype.get()), m_arrayPrototype.get());
+ JSCell* stringConstructor = StringConstructor::create(exec, this, StringConstructor::createStructure(exec->globalData(), m_functionPrototype.get()), m_stringPrototype.get());
+ JSCell* booleanConstructor = BooleanConstructor::create(exec, this, BooleanConstructor::createStructure(exec->globalData(), m_functionPrototype.get()), m_booleanPrototype.get());
+ JSCell* numberConstructor = NumberConstructor::create(exec, this, NumberConstructor::createStructure(exec->globalData(), m_functionPrototype.get()), m_numberPrototype.get());
+ JSCell* dateConstructor = DateConstructor::create(exec, this, DateConstructor::createStructure(exec->globalData(), m_functionPrototype.get()), m_datePrototype.get());
- m_regExpConstructor.set(exec->globalData(), this, new (exec) RegExpConstructor(exec, this, RegExpConstructor::createStructure(exec->globalData(), m_functionPrototype.get()), m_regExpPrototype.get()));
+ m_regExpConstructor.set(exec->globalData(), this, RegExpConstructor::create(exec, this, RegExpConstructor::createStructure(exec->globalData(), m_functionPrototype.get()), m_regExpPrototype.get()));
- m_errorConstructor.set(exec->globalData(), this, new (exec) ErrorConstructor(exec, this, ErrorConstructor::createStructure(exec->globalData(), m_functionPrototype.get()), errorPrototype));
+ m_errorConstructor.set(exec->globalData(), this, ErrorConstructor::create(exec, this, ErrorConstructor::createStructure(exec->globalData(), m_functionPrototype.get()), errorPrototype));
Structure* nativeErrorPrototypeStructure = NativeErrorPrototype::createStructure(exec->globalData(), errorPrototype);
Structure* nativeErrorStructure = NativeErrorConstructor::createStructure(exec->globalData(), m_functionPrototype.get());
- m_evalErrorConstructor.set(exec->globalData(), this, new (exec) NativeErrorConstructor(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, "EvalError"));
- m_rangeErrorConstructor.set(exec->globalData(), this, new (exec) NativeErrorConstructor(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, "RangeError"));
- m_referenceErrorConstructor.set(exec->globalData(), this, new (exec) NativeErrorConstructor(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, "ReferenceError"));
- m_syntaxErrorConstructor.set(exec->globalData(), this, new (exec) NativeErrorConstructor(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, "SyntaxError"));
- m_typeErrorConstructor.set(exec->globalData(), this, new (exec) NativeErrorConstructor(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, "TypeError"));
- m_URIErrorConstructor.set(exec->globalData(), this, new (exec) NativeErrorConstructor(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, "URIError"));
+ m_evalErrorConstructor.set(exec->globalData(), this, NativeErrorConstructor::create(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, "EvalError"));
+ m_rangeErrorConstructor.set(exec->globalData(), this, NativeErrorConstructor::create(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, "RangeError"));
+ m_referenceErrorConstructor.set(exec->globalData(), this, NativeErrorConstructor::create(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, "ReferenceError"));
+ m_syntaxErrorConstructor.set(exec->globalData(), this, NativeErrorConstructor::create(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, "SyntaxError"));
+ m_typeErrorConstructor.set(exec->globalData(), this, NativeErrorConstructor::create(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, "TypeError"));
+ m_URIErrorConstructor.set(exec->globalData(), this, NativeErrorConstructor::create(exec, this, nativeErrorStructure, nativeErrorPrototypeStructure, "URIError"));
m_objectPrototype->putDirectFunctionWithoutTransition(exec->globalData(), exec->propertyNames().constructor, objectConstructor, DontEnum);
m_functionPrototype->putDirectFunctionWithoutTransition(exec->globalData(), exec->propertyNames().constructor, functionConstructor, DontEnum);
putDirectFunctionWithoutTransition(exec->globalData(), Identifier(exec, "TypeError"), m_typeErrorConstructor.get(), DontEnum);
putDirectFunctionWithoutTransition(exec->globalData(), Identifier(exec, "URIError"), m_URIErrorConstructor.get(), DontEnum);
- m_evalFunction.set(exec->globalData(), this, new (exec) JSFunction(exec, this, m_functionStructure.get(), 1, exec->propertyNames().eval, globalFuncEval));
+ m_evalFunction.set(exec->globalData(), this, JSFunction::create(exec, this, m_functionStructure.get(), 1, exec->propertyNames().eval, globalFuncEval));
putDirectFunctionWithoutTransition(exec, m_evalFunction.get(), DontEnum);
GlobalPropertyInfo staticGlobals[] = {
- GlobalPropertyInfo(Identifier(exec, "Math"), new (exec) MathObject(exec, this, MathObject::createStructure(exec->globalData(), m_objectPrototype.get())), DontEnum | DontDelete),
+ GlobalPropertyInfo(Identifier(exec, "Math"), MathObject::create(exec, this, MathObject::createStructure(exec->globalData(), m_objectPrototype.get())), DontEnum | DontDelete),
GlobalPropertyInfo(Identifier(exec, "NaN"), jsNaN(), DontEnum | DontDelete | ReadOnly),
GlobalPropertyInfo(Identifier(exec, "Infinity"), jsNumber(std::numeric_limits<double>::infinity()), DontEnum | DontDelete | ReadOnly),
GlobalPropertyInfo(Identifier(exec, "undefined"), jsUndefined(), DontEnum | DontDelete | ReadOnly),
- GlobalPropertyInfo(Identifier(exec, "JSON"), new (exec) JSONObject(this, JSONObject::createStructure(exec->globalData(), m_objectPrototype.get())), DontEnum | DontDelete)
+ GlobalPropertyInfo(Identifier(exec, "JSON"), JSONObject::create(exec, this, JSONObject::createStructure(exec->globalData(), m_objectPrototype.get())), DontEnum | DontDelete)
};
addStaticGlobals(staticGlobals, WTF_ARRAY_LENGTH(staticGlobals));
setRegisters(registers, registerArray.release(), newSize);
}
-void* JSGlobalObject::operator new(size_t size, JSGlobalData* globalData)
-{
- return globalData->heap.allocate(size);
-}
-
void JSGlobalObject::addStaticGlobals(GlobalPropertyInfo* globals, int count)
{
resizeRegisters(symbolTable().size() + count);
bool m_evalEnabled;
public:
- void* operator new(size_t, JSGlobalData*);
-
explicit JSGlobalObject(JSGlobalData& globalData, Structure* structure)
: JSVariableObject(globalData, structure, &m_symbolTable, 0)
, m_registerArraySize(0)
void reset(JSValue prototype);
void setRegisters(WriteBarrier<Unknown>* registers, PassOwnArrayPtr<WriteBarrier<Unknown> > registerArray, size_t count);
-
- void* operator new(size_t); // can only be allocated with JSGlobalData
};
JSGlobalObject* asGlobalObject(JSValue);
inline JSArray* constructEmptyArray(ExecState* exec, JSGlobalObject* globalObject)
{
- return new (exec) JSArray(exec->globalData(), globalObject->arrayStructure());
+ return JSArray::create(exec->globalData(), globalObject->arrayStructure());
}
inline JSArray* constructEmptyArray(ExecState* exec)
inline JSArray* constructEmptyArray(ExecState* exec, JSGlobalObject* globalObject, unsigned initialLength)
{
- return new (exec) JSArray(exec->globalData(), globalObject->arrayStructure(), initialLength, CreateInitialized);
+ return JSArray::create(exec->globalData(), globalObject->arrayStructure(), initialLength, CreateInitialized);
}
inline JSArray* constructEmptyArray(ExecState* exec, unsigned initialLength)
{
MarkedArgumentBuffer values;
values.append(singleItemValue);
- return new (exec) JSArray(exec->globalData(), globalObject->arrayStructure(), values);
+ return JSArray::create(exec->globalData(), globalObject->arrayStructure(), values);
}
inline JSArray* constructArray(ExecState* exec, JSValue singleItemValue)
inline JSArray* constructArray(ExecState* exec, JSGlobalObject* globalObject, const ArgList& values)
{
- return new (exec) JSArray(exec->globalData(), globalObject->arrayStructure(), values);
+ return JSArray::create(exec->globalData(), globalObject->arrayStructure(), values);
}
inline JSArray* constructArray(ExecState* exec, const ArgList& values)
// in certain SquirrelFish bytecodes -- effectively it just silently consumes
// any operations performed on the result of a failed toObject call.
class JSNotAnObject : public JSNonFinalObject {
- public:
+ private:
JSNotAnObject(ExecState* exec)
: JSNonFinalObject(exec->globalData(), exec->globalData().notAnObjectStructure.get())
{
}
+
+ public:
+ static JSNotAnObject* create(ExecState* exec)
+ {
+ return new (allocateCell<JSNotAnObject>(*exec->heap())) JSNotAnObject(exec);
+ }
static Structure* createStructure(JSGlobalData& globalData, JSValue prototype)
{
class Stringifier;
class JSONObject : public JSObjectWithGlobalObject {
- public:
+ private:
JSONObject(JSGlobalObject*, Structure*);
+ public:
+ static JSONObject* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure)
+ {
+ return new (allocateCell<JSONObject>(*exec->heap())) JSONObject(globalObject, structure);
+ }
+
static Structure* createStructure(JSGlobalData& globalData, JSValue prototype)
{
return Structure::create(globalData, prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
JSGlobalData& globalData = exec->globalData();
PutPropertySlot slot;
- GetterSetter* getterSetter = new (exec) GetterSetter(exec);
+ GetterSetter* getterSetter = GetterSetter::create(exec);
putDirectInternal(globalData, propertyName, getterSetter, attributes | Getter, true, slot);
// putDirect will change our Structure if we add a new property. For
}
PutPropertySlot slot;
- GetterSetter* getterSetter = new (exec) GetterSetter(exec);
+ GetterSetter* getterSetter = GetterSetter::create(exec);
putDirectInternal(exec->globalData(), propertyName, getterSetter, attributes | Setter, true, slot);
// putDirect will change our Structure if we add a new property. For
{
if (descriptor.isGenericDescriptor() || descriptor.isDataDescriptor()) {
if (descriptor.isGenericDescriptor() && oldDescriptor.isAccessorDescriptor()) {
- GetterSetter* accessor = new (exec) GetterSetter(exec);
+ GetterSetter* accessor = GetterSetter::create(exec);
if (oldDescriptor.getter()) {
attributes |= Getter;
accessor->setGetter(exec->globalData(), asObject(oldDescriptor.getter()));
public:
static JSFinalObject* create(ExecState* exec, Structure* structure)
{
- return new (exec) JSFinalObject(exec->globalData(), structure);
+ return new (allocateCell<JSFinalObject>(*exec->heap())) JSFinalObject(exec->globalData(), structure);
}
static Structure* createStructure(JSGlobalData& globalData, JSValue prototype)
!o->structure()->hasGetterSetterProperties() && !o->structure()->isUncacheableDictionary() &&
!o->structure()->typeInfo().overridesGetPropertyNames())
numCacheableSlots = o->structure()->propertyStorageSize();
-
- JSPropertyNameIterator* jsPropertyNameIterator = new (exec) JSPropertyNameIterator(exec, propertyNames.data(), numCacheableSlots);
+
+ JSPropertyNameIterator* jsPropertyNameIterator = new (allocateCell<JSPropertyNameIterator>(*exec->heap())) JSPropertyNameIterator(exec, propertyNames.data(), numCacheableSlots);
if (o->structure()->isDictionary())
return jsPropertyNameIterator;
public:
static JSPropertyNameIterator* create(ExecState*, JSObject*);
+ static JSPropertyNameIterator* create(ExecState* exec, PropertyNameArrayData* propertyNameArrayData, size_t numCacheableSlot)
+ {
+ return new (allocateCell<JSPropertyNameIterator>(*exec->heap())) JSPropertyNameIterator(exec, propertyNameArrayData, numCacheableSlot);
+ }
static Structure* createStructure(JSGlobalData& globalData, JSValue prototype)
{
return globalData->smallStrings.singleCharacterString(globalData, c);
}
if (substringFiberCount == 1)
- return new (globalData) JSString(globalData, substringFibers[0]);
+ return JSString::create(*globalData, substringFibers[0]);
if (substringFiberCount == 2)
- return new (globalData) JSString(globalData, substringFibers[0], substringFibers[1]);
- return new (globalData) JSString(globalData, substringFibers[0], substringFibers[1], substringFibers[2]);
+ return JSString::create(*globalData, substringFibers[0], substringFibers[1]);
+ return JSString::create(*globalData, substringFibers[0], substringFibers[1], substringFibers[2]);
}
JSValue JSString::replaceCharacter(ExecState* exec, UChar character, const UString& replacement)
}
JSGlobalData* globalData = &exec->globalData();
- return JSValue(new (globalData) JSString(globalData, builder.release()));
+ return JSValue(JSString::create(*globalData, builder.release()));
}
JSString* JSString::getIndexSlowCase(ExecState* exec, unsigned i)
inline StringObject* StringObject::create(ExecState* exec, JSGlobalObject* globalObject, JSString* string)
{
- return new (exec) StringObject(exec->globalData(), globalObject->stringObjectStructure(), string);
+ return new (allocateCell<StringObject>(*exec->heap())) StringObject(exec->globalData(), globalObject->stringObjectStructure(), string);
}
JSObject* JSString::toObject(ExecState* exec, JSGlobalObject* globalObject) const
Vector<WorkItem, 16> m_workQueue;
};
-
- ALWAYS_INLINE JSString(JSGlobalData* globalData, const UString& value)
- : JSCell(*globalData, globalData->stringStructure.get())
+
+ private:
+ ALWAYS_INLINE JSString(JSGlobalData& globalData, const UString& value)
+ : JSCell(globalData, globalData.stringStructure.get())
, m_length(value.length())
, m_value(value)
, m_fiberCount(0)
}
enum HasOtherOwnerType { HasOtherOwner };
- JSString(JSGlobalData* globalData, const UString& value, HasOtherOwnerType)
- : JSCell(*globalData, globalData->stringStructure.get())
+ JSString(JSGlobalData& globalData, const UString& value, HasOtherOwnerType)
+ : JSCell(globalData, globalData.stringStructure.get())
, m_length(value.length())
, m_value(value)
, m_fiberCount(0)
{
ASSERT(!m_value.isNull());
}
- JSString(JSGlobalData* globalData, PassRefPtr<StringImpl> value, HasOtherOwnerType)
- : JSCell(*globalData, globalData->stringStructure.get())
+ JSString(JSGlobalData& globalData, PassRefPtr<StringImpl> value, HasOtherOwnerType)
+ : JSCell(globalData, globalData.stringStructure.get())
, m_length(value->length())
, m_value(value)
, m_fiberCount(0)
{
ASSERT(!m_value.isNull());
}
- JSString(JSGlobalData* globalData, PassRefPtr<RopeImpl> rope)
- : JSCell(*globalData, globalData->stringStructure.get())
+ JSString(JSGlobalData& globalData, PassRefPtr<RopeImpl> rope)
+ : JSCell(globalData, globalData.stringStructure.get())
, m_length(rope->length())
, m_fiberCount(1)
{
}
// This constructor constructs a new string by concatenating s1 & s2.
// This should only be called with fiberCount <= 3.
- JSString(JSGlobalData* globalData, unsigned fiberCount, JSString* s1, JSString* s2)
- : JSCell(*globalData, globalData->stringStructure.get())
+ JSString(JSGlobalData& globalData, unsigned fiberCount, JSString* s1, JSString* s2)
+ : JSCell(globalData, globalData.stringStructure.get())
, m_length(s1->length() + s2->length())
, m_fiberCount(fiberCount)
{
}
// This constructor constructs a new string by concatenating s1 & s2.
// This should only be called with fiberCount <= 3.
- JSString(JSGlobalData* globalData, unsigned fiberCount, JSString* s1, const UString& u2)
- : JSCell(*globalData, globalData->stringStructure.get())
+ JSString(JSGlobalData& globalData, unsigned fiberCount, JSString* s1, const UString& u2)
+ : JSCell(globalData, globalData.stringStructure.get())
, m_length(s1->length() + u2.length())
, m_fiberCount(fiberCount)
{
}
// This constructor constructs a new string by concatenating s1 & s2.
// This should only be called with fiberCount <= 3.
- JSString(JSGlobalData* globalData, unsigned fiberCount, const UString& u1, JSString* s2)
- : JSCell(*globalData, globalData->stringStructure.get())
+ JSString(JSGlobalData& globalData, unsigned fiberCount, const UString& u1, JSString* s2)
+ : JSCell(globalData, globalData.stringStructure.get())
, m_length(u1.length() + s2->length())
, m_fiberCount(fiberCount)
{
}
// This constructor constructs a new string by concatenating u1 & u2.
- JSString(JSGlobalData* globalData, const UString& u1, const UString& u2)
- : JSCell(*globalData, globalData->stringStructure.get())
+ JSString(JSGlobalData& globalData, const UString& u1, const UString& u2)
+ : JSCell(globalData, globalData.stringStructure.get())
, m_length(u1.length() + u2.length())
, m_fiberCount(2)
{
}
// This constructor constructs a new string by concatenating u1, u2 & u3.
- JSString(JSGlobalData* globalData, const UString& u1, const UString& u2, const UString& u3)
- : JSCell(*globalData, globalData->stringStructure.get())
+ JSString(JSGlobalData& globalData, const UString& u1, const UString& u2, const UString& u3)
+ : JSCell(globalData, globalData.stringStructure.get())
, m_length(u1.length() + u2.length() + u3.length())
, m_fiberCount(s_maxInternalRopeLength)
{
ASSERT(index <= s_maxInternalRopeLength);
}
+ public:
+ static JSString* create(JSGlobalData& globalData, const UString& value)
+ {
+ return new (allocateCell<JSString>(globalData.heap)) JSString(globalData, value);
+ }
+ static JSString* createHasOtherOwner(JSGlobalData& globalData, const UString& value)
+ {
+ return new (allocateCell<JSString>(globalData.heap)) JSString(globalData, value, HasOtherOwner);
+ }
+ static JSString* createHasOtherOwner(JSGlobalData& globalData, PassRefPtr<StringImpl> value)
+ {
+ return new (allocateCell<JSString>(globalData.heap)) JSString(globalData, value, HasOtherOwner);
+ }
+ static JSString* create(JSGlobalData& globalData, PassRefPtr<RopeImpl> rope)
+ {
+ return new (allocateCell<JSString>(globalData.heap)) JSString(globalData, rope);
+ }
+ static JSString* create(JSGlobalData& globalData, unsigned fiberCount, JSString* s1, JSString* s2)
+ {
+ return new (allocateCell<JSString>(globalData.heap)) JSString(globalData, fiberCount, s1, s2);
+ }
+ static JSString* create(JSGlobalData& globalData, unsigned fiberCount, JSString* s1, const UString& u2)
+ {
+ return new (allocateCell<JSString>(globalData.heap)) JSString(globalData, fiberCount, s1, u2);
+ }
+ static JSString* create(JSGlobalData& globalData, unsigned fiberCount, const UString& u1, JSString* s2)
+ {
+ return new (allocateCell<JSString>(globalData.heap)) JSString(globalData, fiberCount, u1, s2);
+ }
+ static JSString* create(ExecState* exec, JSValue v1, JSValue v2, JSValue v3)
+ {
+ return new (allocateCell<JSString>(*exec->heap())) JSString(exec, v1, v2, v3);
+ }
+ static JSString* create(JSGlobalData& globalData, const UString& u1, const UString& u2)
+ {
+ return new (allocateCell<JSString>(globalData.heap)) JSString(globalData, u1, u2);
+ }
+ static JSString* create(JSGlobalData& globalData, const UString& u1, const UString& u2, const UString& u3)
+ {
+ return new (allocateCell<JSString>(globalData.heap)) JSString(globalData, u1, u2, u3);
+ }
+
~JSString()
{
ASSERT(vptr() == JSGlobalData::jsStringVPtr);
{
if (c <= maxSingleCharacterString)
return globalData->smallStrings.singleCharacterString(globalData, c);
- return fixupVPtr(globalData, new (globalData) JSString(globalData, UString(&c, 1)));
+ return fixupVPtr(globalData, JSString::create(*globalData, UString(&c, 1)));
}
inline JSString* jsSingleCharacterSubstring(ExecState* exec, const UString& s, unsigned offset)
UChar c = s.characters()[offset];
if (c <= maxSingleCharacterString)
return globalData->smallStrings.singleCharacterString(globalData, c);
- return fixupVPtr(globalData, new (globalData) JSString(globalData, UString(StringImpl::create(s.impl(), offset, 1))));
+ return fixupVPtr(globalData, JSString::create(*globalData, UString(StringImpl::create(s.impl(), offset, 1))));
}
inline JSString* jsNontrivialString(JSGlobalData* globalData, const char* s)
ASSERT(s);
ASSERT(s[0]);
ASSERT(s[1]);
- return fixupVPtr(globalData, new (globalData) JSString(globalData, s));
+ return fixupVPtr(globalData, JSString::create(*globalData, s));
}
inline JSString* jsNontrivialString(JSGlobalData* globalData, const UString& s)
{
ASSERT(s.length() > 1);
- return fixupVPtr(globalData, new (globalData) JSString(globalData, s));
+ return fixupVPtr(globalData, JSString::create(*globalData, s));
}
inline JSString* JSString::getIndex(ExecState* exec, unsigned i)
if (c <= maxSingleCharacterString)
return globalData->smallStrings.singleCharacterString(globalData, c);
}
- return fixupVPtr(globalData, new (globalData) JSString(globalData, s));
+ return fixupVPtr(globalData, JSString::create(*globalData, s));
}
inline JSString* jsSubstring(ExecState* exec, JSString* s, unsigned offset, unsigned length)
if (c <= maxSingleCharacterString)
return globalData->smallStrings.singleCharacterString(globalData, c);
}
- return fixupVPtr(globalData, new (globalData) JSString(globalData, UString(StringImpl::create(s.impl(), offset, length)), JSString::HasOtherOwner));
+ return fixupVPtr(globalData, JSString::createHasOtherOwner(*globalData, UString(StringImpl::create(s.impl(), offset, length))));
}
inline JSString* jsOwnedString(JSGlobalData* globalData, const UString& s)
if (c <= maxSingleCharacterString)
return globalData->smallStrings.singleCharacterString(globalData, c);
}
- return fixupVPtr(globalData, new (globalData) JSString(globalData, s, JSString::HasOtherOwner));
+ return fixupVPtr(globalData, JSString::createHasOtherOwner(*globalData, s));
}
inline JSString* jsEmptyString(ExecState* exec) { return jsEmptyString(&exec->globalData()); }
ASSERT(isUndefinedOrNull());
throwError(exec, createNotAnObjectError(exec, *this));
- return new (exec) JSNotAnObject(exec);
+ return JSNotAnObject::create(exec);
}
JSObject* JSValue::toThisObjectSlowCase(ExecState* exec) const
ASSERT(isUndefinedOrNull());
throwError(exec, createNotAnObjectError(exec, *this));
- return new (exec) JSNotAnObject(exec);
+ return JSNotAnObject::create(exec);
}
JSObject* JSValue::synthesizePrototype(ExecState* exec) const
ASSERT(isUndefinedOrNull());
throwError(exec, createNotAnObjectError(exec, *this));
- return new (exec) JSNotAnObject(exec);
+ return JSNotAnObject::create(exec);
}
#ifndef NDEBUG
JSGlobalObject* globalObject = asGlobalObject(thisObj->getAnonymousValue(0).asCell());
#if ENABLE(JIT)
if (entry->generator())
- function = new (exec) JSFunction(exec, globalObject, globalObject->functionStructure(), entry->functionLength(), propertyName, exec->globalData().getHostFunction(entry->function(), entry->generator()));
+ function = JSFunction::create(exec, globalObject, globalObject->functionStructure(), entry->functionLength(), propertyName, exec->globalData().getHostFunction(entry->function(), entry->generator()));
else
#endif
- function = new (exec) JSFunction(exec, globalObject, globalObject->functionStructure(), entry->functionLength(), propertyName, entry->function());
+ function = JSFunction::create(exec, globalObject, globalObject->functionStructure(), entry->functionLength(), propertyName, entry->function());
thisObj->putDirectFunction(exec->globalData(), propertyName, function, entry->attributes());
location = thisObj->getDirectLocation(exec->globalData(), propertyName);
namespace JSC {
class MathObject : public JSObjectWithGlobalObject {
- public:
+ private:
MathObject(ExecState*, JSGlobalObject*, Structure*);
+ public:
+ static MathObject* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure)
+ {
+ return new (allocateCell<MathObject>(*exec->heap())) MathObject(exec, globalObject, structure);
+ }
virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&);
{
ASSERT(inherits(&s_info));
- NativeErrorPrototype* prototype = new (exec) NativeErrorPrototype(exec, globalObject, prototypeStructure, nameAndMessage, this);
+ NativeErrorPrototype* prototype = NativeErrorPrototype::create(exec, globalObject, prototypeStructure, nameAndMessage, this);
putDirect(exec->globalData(), exec->propertyNames().length, jsNumber(1), DontDelete | ReadOnly | DontEnum); // ECMA 15.11.7.5
putDirect(exec->globalData(), exec->propertyNames().prototype, prototype, DontDelete | ReadOnly | DontEnum);
class NativeErrorPrototype;
class NativeErrorConstructor : public InternalFunction {
- public:
+ private:
NativeErrorConstructor(ExecState*, JSGlobalObject*, Structure*, Structure* prototypeStructure, const UString&);
+ public:
+ static NativeErrorConstructor* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, Structure* prototypeStructure, const UString& nameAndMessage)
+ {
+ return new (allocateCell<NativeErrorConstructor>(*exec->heap())) NativeErrorConstructor(exec, globalObject, structure, prototypeStructure, nameAndMessage);
+ }
+
static const ClassInfo s_info;
static Structure* createStructure(JSGlobalData& globalData, JSValue prototype)
class NativeErrorConstructor;
class NativeErrorPrototype : public ErrorPrototype {
- public:
+ private:
NativeErrorPrototype(ExecState*, JSGlobalObject*, Structure*, const UString&, NativeErrorConstructor*);
+
+ public:
+ static NativeErrorPrototype* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, const UString& nameAndMessage, NativeErrorConstructor* constructor)
+ {
+ return new (allocateCell<NativeErrorPrototype>(*exec->heap())) NativeErrorPrototype(exec, globalObject, structure, nameAndMessage, constructor);
+ }
};
} // namespace JSC
// ECMA 15.7.1
static EncodedJSValue JSC_HOST_CALL constructWithNumberConstructor(ExecState* exec)
{
- NumberObject* object = new (exec) NumberObject(exec->globalData(), asInternalFunction(exec->callee())->globalObject()->numberObjectStructure());
+ NumberObject* object = NumberObject::create(exec->globalData(), asInternalFunction(exec->callee())->globalObject()->numberObjectStructure());
double n = exec->argumentCount() ? exec->argument(0).toNumber(exec) : 0;
object->setInternalValue(exec->globalData(), jsNumber(n));
return JSValue::encode(object);
class NumberPrototype;
class NumberConstructor : public InternalFunction {
- public:
+ private:
NumberConstructor(ExecState*, JSGlobalObject*, Structure*, NumberPrototype*);
+
+ public:
+ static NumberConstructor* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, NumberPrototype* numPrototype)
+ {
+ return new (allocateCell<NumberConstructor>(*exec->heap())) NumberConstructor(exec, globalObject, structure, numPrototype);
+ }
virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&);
NumberObject* constructNumber(ExecState* exec, JSGlobalObject* globalObject, JSValue number)
{
- NumberObject* object = new (exec) NumberObject(exec->globalData(), globalObject->numberObjectStructure());
+ NumberObject* object = NumberObject::create(exec->globalData(), globalObject->numberObjectStructure());
object->setInternalValue(exec->globalData(), number);
return object;
}
namespace JSC {
class NumberObject : public JSWrapperObject {
+ protected:
+ NumberObject(JSGlobalData&, Structure*);
+
public:
- explicit NumberObject(JSGlobalData&, Structure*);
+ static NumberObject* create(JSGlobalData& globalData, Structure* structure)
+ {
+ return new (allocateCell<NumberObject>(globalData.heap)) NumberObject(globalData, structure);
+ }
static const ClassInfo s_info;
namespace JSC {
class NumberPrototype : public NumberObject {
- public:
+ private:
NumberPrototype(ExecState*, JSGlobalObject*, Structure*);
+ public:
+ static NumberPrototype* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure)
+ {
+ return new (allocateCell<NumberPrototype>(*exec->heap())) NumberPrototype(exec, globalObject, structure);
+ }
+
static const ClassInfo s_info;
static Structure* createStructure(JSGlobalData& globalData, JSValue prototype)
class ObjectPrototype;
class ObjectConstructor : public InternalFunction {
- public:
+ private:
ObjectConstructor(ExecState*, JSGlobalObject*, Structure*, ObjectPrototype*);
+
+ public:
+ static ObjectConstructor* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, ObjectPrototype* objPrototype)
+ {
+ return new (allocateCell<ObjectConstructor>(*exec->heap())) ObjectConstructor(exec, globalObject, structure, objPrototype);
+ }
virtual bool getOwnPropertySlot(ExecState*, const Identifier&, PropertySlot&);
virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&);
namespace JSC {
class ObjectPrototype : public JSNonFinalObject {
- public:
+ private:
ObjectPrototype(ExecState*, JSGlobalObject*, Structure*);
+ public:
+ static ObjectPrototype* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure)
+ {
+ return new (allocateCell<ObjectPrototype>(*exec->heap())) ObjectPrototype(exec, globalObject, structure);
+ }
+
static const ClassInfo s_info;
static Structure* createStructure(JSGlobalData& globalData, JSValue prototype)
JSGlobalData* globalData = &exec->globalData();
if (fiberCount <= JSString::s_maxInternalRopeLength)
- return new (globalData) JSString(globalData, fiberCount, s1, s2);
+ return JSString::create(*globalData, fiberCount, s1, s2);
JSString::RopeBuilder ropeBuilder(fiberCount);
if (UNLIKELY(ropeBuilder.isOutOfMemory()))
return throwOutOfMemoryError(exec);
ropeBuilder.append(s1);
ropeBuilder.append(s2);
- return new (globalData) JSString(globalData, ropeBuilder.release());
+ return JSString::create(*globalData, ropeBuilder.release());
}
ALWAYS_INLINE JSValue jsString(ExecState* exec, const UString& u1, JSString* s2)
JSGlobalData* globalData = &exec->globalData();
if (fiberCount <= JSString::s_maxInternalRopeLength)
- return new (globalData) JSString(globalData, fiberCount, u1, s2);
+ return JSString::create(*globalData, fiberCount, u1, s2);
JSString::RopeBuilder ropeBuilder(fiberCount);
if (UNLIKELY(ropeBuilder.isOutOfMemory()))
return throwOutOfMemoryError(exec);
ropeBuilder.append(u1);
ropeBuilder.append(s2);
- return new (globalData) JSString(globalData, ropeBuilder.release());
+ return JSString::create(*globalData, ropeBuilder.release());
}
ALWAYS_INLINE JSValue jsString(ExecState* exec, JSString* s1, const UString& u2)
JSGlobalData* globalData = &exec->globalData();
if (fiberCount <= JSString::s_maxInternalRopeLength)
- return new (globalData) JSString(globalData, fiberCount, s1, u2);
+ return JSString::create(*globalData, fiberCount, s1, u2);
JSString::RopeBuilder ropeBuilder(fiberCount);
if (UNLIKELY(ropeBuilder.isOutOfMemory()))
return throwOutOfMemoryError(exec);
ropeBuilder.append(s1);
ropeBuilder.append(u2);
- return new (globalData) JSString(globalData, ropeBuilder.release());
+ return JSString::create(*globalData, ropeBuilder.release());
}
ALWAYS_INLINE JSValue jsString(ExecState* exec, const UString& u1, const UString& u2)
return throwOutOfMemoryError(exec);
JSGlobalData* globalData = &exec->globalData();
- return new (globalData) JSString(globalData, u1, u2);
+ return JSString::create(*globalData, u1, u2);
}
ALWAYS_INLINE JSValue jsString(ExecState* exec, const UString& u1, const UString& u2, const UString& u3)
return throwOutOfMemoryError(exec);
JSGlobalData* globalData = &exec->globalData();
- return new (globalData) JSString(globalData, u1, u2, u3);
+ return JSString::create(*globalData, u1, u2, u3);
}
ALWAYS_INLINE JSValue jsString(ExecState* exec, Register* strings, unsigned count)
JSGlobalData* globalData = &exec->globalData();
if (fiberCount == 3)
- return new (globalData) JSString(exec, strings[0].jsValue(), strings[1].jsValue(), strings[2].jsValue());
+ return JSString::create(exec, strings[0].jsValue(), strings[1].jsValue(), strings[2].jsValue());
JSString::RopeBuilder ropeBuilder(fiberCount);
if (UNLIKELY(ropeBuilder.isOutOfMemory()))
if (overflow)
return throwOutOfMemoryError(exec);
- return new (globalData) JSString(globalData, ropeBuilder.release());
+ return JSString::create(*globalData, ropeBuilder.release());
}
ALWAYS_INLINE JSValue jsString(ExecState* exec, JSValue thisValue)
return throwOutOfMemoryError(exec);
JSGlobalData* globalData = &exec->globalData();
- return new (globalData) JSString(globalData, ropeBuilder.release());
+ return JSString::create(*globalData, ropeBuilder.release());
}
// ECMA 11.9.3
OwnPtr<Yarr::BytecodePattern> m_regExpBytecode;
};
-RegExp::RegExp(JSGlobalData* globalData, const UString& patternString, RegExpFlags flags)
- : JSCell(*globalData, globalData->regExpStructure.get())
+RegExp::RegExp(JSGlobalData& globalData, const UString& patternString, RegExpFlags flags)
+ : JSCell(globalData, globalData.regExpStructure.get())
, m_state(NotCompiled)
, m_patternString(patternString)
, m_flags(flags)
{
}
-RegExp* RegExp::create(JSGlobalData* globalData, const UString& patternString, RegExpFlags flags)
+RegExp* RegExp::createWithoutCaching(JSGlobalData& globalData, const UString& patternString, RegExpFlags flags)
{
- return globalData->regExpCache()->lookupOrCreate(patternString, flags);
+ return new (allocateCell<RegExp>(globalData.heap)) RegExp(globalData, patternString, flags);
+}
+
+RegExp* RegExp::create(JSGlobalData& globalData, const UString& patternString, RegExpFlags flags)
+{
+ return globalData.regExpCache()->lookupOrCreate(patternString, flags);
}
void RegExp::compile(JSGlobalData* globalData)
class RegExp : public JSCell {
public:
- static RegExp* create(JSGlobalData*, const UString& pattern, RegExpFlags);
+ static RegExp* create(JSGlobalData&, const UString& pattern, RegExpFlags);
~RegExp();
bool global() const { return m_flags & FlagGlobal; }
private:
friend class RegExpCache;
- RegExp(JSGlobalData* globalData, const UString& pattern, RegExpFlags);
+ RegExp(JSGlobalData&, const UString&, RegExpFlags);
+
+ static RegExp* createWithoutCaching(JSGlobalData&, const UString&, RegExpFlags);
enum RegExpState {
ParseError,
RegExpCacheMap::iterator result = m_weakCache.find(key);
if (result != m_weakCache.end())
return result->second.get();
- RegExp* regExp = new (m_globalData) RegExp(m_globalData, patternString, flags);
+ RegExp* regExp = RegExp::createWithoutCaching(*m_globalData, patternString, flags);
#if ENABLE(REGEXP_TRACING)
m_globalData->addRegExpToTrace(regExp);
#endif
JSObject* RegExpConstructor::arrayOfMatches(ExecState* exec) const
{
- return new (exec) RegExpMatchesArray(exec, d.get());
+ return RegExpMatchesArray::create(exec, d.get());
}
JSValue RegExpConstructor::getBackref(ExecState* exec, unsigned i) const
// If called as a function, this just returns the first argument (see 15.10.3.1).
if (callAsConstructor) {
RegExp* regExp = static_cast<RegExpObject*>(asObject(arg0))->regExp();
- return new (exec) RegExpObject(globalObject, globalObject->regExpStructure(), regExp);
+ return RegExpObject::create(exec, globalObject, globalObject->regExpStructure(), regExp);
}
return asObject(arg0);
}
return throwError(exec, createSyntaxError(exec, "Invalid flags supplied to RegExp constructor."));
}
- RegExp* regExp = RegExp::create(&exec->globalData(), pattern, flags);
+ RegExp* regExp = RegExp::create(exec->globalData(), pattern, flags);
if (!regExp->isValid())
return throwError(exec, createSyntaxError(exec, regExp->errorMessage()));
- return new (exec) RegExpObject(exec->lexicalGlobalObject(), globalObject->regExpStructure(), regExp);
+ return RegExpObject::create(exec, exec->lexicalGlobalObject(), globalObject->regExpStructure(), regExp);
}
static EncodedJSValue JSC_HOST_CALL constructWithRegExpConstructor(ExecState* exec)
};
class RegExpConstructor : public InternalFunction {
- public:
+ private:
RegExpConstructor(ExecState*, JSGlobalObject*, Structure*, RegExpPrototype*);
+ public:
+ static RegExpConstructor* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, RegExpPrototype* regExpPrototype)
+ {
+ return new (allocateCell<RegExpConstructor>(*exec->heap())) RegExpConstructor(exec, globalObject, structure, regExpPrototype);
+ }
+
static Structure* createStructure(JSGlobalData& globalData, JSValue prototype)
{
return Structure::create(globalData, prototype, TypeInfo(ObjectType, StructureFlags), AnonymousSlotCount, &s_info);
namespace JSC {
class RegExpMatchesArray : public JSArray {
- public:
+ private:
RegExpMatchesArray(ExecState*, RegExpConstructorPrivate*);
+
+ public:
+ static RegExpMatchesArray* create(ExecState* exec, RegExpConstructorPrivate* ctorPrivate)
+ {
+ return new (allocateCell<RegExpMatchesArray>(*exec->heap())) RegExpMatchesArray(exec, ctorPrivate);
+ }
virtual ~RegExpMatchesArray();
private:
namespace JSC {
class RegExpObject : public JSObjectWithGlobalObject {
+ protected:
+ RegExpObject(JSGlobalObject*, Structure*, RegExp*);
+
public:
+ static RegExpObject* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, RegExp* regExp)
+ {
+ return new (allocateCell<RegExpObject>(*exec->heap())) RegExpObject(globalObject, structure, regExp);
+ }
+
+ static RegExpObject* create(JSGlobalData& globalData, JSGlobalObject* globalObject, Structure* structure, RegExp* regExp)
+ {
+ return new (allocateCell<RegExpObject>(globalData.heap)) RegExpObject(globalObject, structure, regExp);
+ }
+
typedef JSObjectWithGlobalObject Base;
- RegExpObject(JSGlobalObject*, Structure*, RegExp*);
virtual ~RegExpObject();
void setRegExp(JSGlobalData& globalData, RegExp* r) { d->regExp.set(globalData, this, r); }
if (flags == InvalidFlags)
return throwVMError(exec, createSyntaxError(exec, "Invalid flags supplied to RegExp constructor."));
}
- regExp = RegExp::create(&exec->globalData(), pattern, flags);
+ regExp = RegExp::create(exec->globalData(), pattern, flags);
}
if (!regExp->isValid())
namespace JSC {
class RegExpPrototype : public RegExpObject {
- public:
+ protected:
RegExpPrototype(ExecState*, JSGlobalObject*, Structure*, RegExp*);
+ public:
+ static RegExpPrototype* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, RegExp* regExp)
+ {
+ return new (allocateCell<RegExpPrototype>(*exec->heap())) RegExpPrototype(exec, globalObject, structure, regExp);
+ }
+
static const ClassInfo s_info;
static Structure* createStructure(JSGlobalData& globalData, JSValue prototype)
class SlotVisitor;
class ScopeChainNode : public JSCell {
- public:
+ private:
ScopeChainNode(ScopeChainNode* next, JSObject* object, JSGlobalData* globalData, JSGlobalObject* globalObject, JSObject* globalThis)
: JSCell(*globalData, globalData->scopeChainNodeStructure.get())
, globalData(globalData)
ASSERT(globalObject);
}
+ public:
+ static ScopeChainNode* create(ExecState* exec, ScopeChainNode* next, JSObject* object, JSGlobalData* globalData, JSGlobalObject* globalObject, JSObject* globalThis)
+ {
+ return new (allocateCell<ScopeChainNode>(*exec->heap())) ScopeChainNode(next, object, globalData, globalObject, globalThis);
+ }
+ static ScopeChainNode* create(ScopeChainNode* next, JSObject* object, JSGlobalData* globalData, JSGlobalObject* globalObject, JSObject* globalThis)
+ {
+ return new (allocateCell<ScopeChainNode>(globalData->heap)) ScopeChainNode(next, object, globalData, globalObject, globalThis);
+ }
+
JSGlobalData* globalData;
WriteBarrier<ScopeChainNode> next;
WriteBarrier<JSObject> object;
inline ScopeChainNode* ScopeChainNode::push(JSObject* o)
{
ASSERT(o);
- return new (globalData) ScopeChainNode(this, o, globalData, globalObject.get(), globalThis.get());
+ return ScopeChainNode::create(this, o, globalData, globalObject.get(), globalThis.get());
}
inline ScopeChainNode* ScopeChainNode::pop()
void SmallStrings::createEmptyString(JSGlobalData* globalData)
{
ASSERT(!m_emptyString);
- m_emptyString = new (globalData) JSString(globalData, "", JSString::HasOtherOwner);
+ m_emptyString = JSString::createHasOtherOwner(*globalData, "");
}
void SmallStrings::createSingleCharacterString(JSGlobalData* globalData, unsigned char character)
if (!m_storage)
m_storage = adoptPtr(new SmallStringsStorage);
ASSERT(!m_singleCharacterStrings[character]);
- m_singleCharacterStrings[character] = new (globalData) JSString(globalData, PassRefPtr<StringImpl>(m_storage->rep(character)), JSString::HasOtherOwner);
+ m_singleCharacterStrings[character] = JSString::createHasOtherOwner(*globalData, PassRefPtr<StringImpl>(m_storage->rep(character)));
}
StringImpl* SmallStrings::singleCharacterStringRep(unsigned char character)
{
JSGlobalObject* globalObject = asInternalFunction(exec->callee())->globalObject();
if (!exec->argumentCount())
- return JSValue::encode(new (exec) StringObject(exec, globalObject->stringObjectStructure()));
- return JSValue::encode(new (exec) StringObject(exec, globalObject->stringObjectStructure(), exec->argument(0).toString(exec)));
+ return JSValue::encode(StringObject::create(exec, globalObject->stringObjectStructure()));
+ return JSValue::encode(StringObject::create(exec, globalObject->stringObjectStructure(), exec->argument(0).toString(exec)));
}
ConstructType StringConstructor::getConstructData(ConstructData& constructData)
class StringPrototype;
class StringConstructor : public InternalFunction {
- public:
+ private:
StringConstructor(ExecState*, JSGlobalObject*, Structure*, StringPrototype*);
+
+ public:
+ static StringConstructor* create(ExecState* exec, JSGlobalObject* globalObject , Structure* structure, StringPrototype* strPrototype)
+ {
+ return new (allocateCell<StringConstructor>(*exec->heap())) StringConstructor(exec, globalObject, structure, strPrototype);
+ }
static const ClassInfo s_info;
namespace JSC {
class StringObject : public JSWrapperObject {
- public:
+ protected:
StringObject(ExecState*, Structure*);
StringObject(ExecState*, Structure*, const UString&);
-
+
+ public:
+ static StringObject* create(ExecState* exec, Structure* structure)
+ {
+ return new (allocateCell<StringObject>(*exec->heap())) StringObject(exec, structure);
+ }
+ static StringObject* create(ExecState* exec, Structure* structure, const UString& str)
+ {
+ return new (allocateCell<StringObject>(*exec->heap())) StringObject(exec, structure, str);
+ }
static StringObject* create(ExecState*, JSGlobalObject*, JSString*);
+
virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
virtual bool getOwnPropertySlot(ExecState*, unsigned propertyName, PropertySlot&);
public:
static StringObjectThatMasqueradesAsUndefined* create(ExecState* exec, const UString& string)
{
- return new (exec) StringObjectThatMasqueradesAsUndefined(exec,
+ return new (allocateCell<StringObjectThatMasqueradesAsUndefined>(*exec->heap())) StringObjectThatMasqueradesAsUndefined(exec,
createStructure(exec->globalData(), exec->lexicalGlobalObject()->stringPrototype()), string);
}
* If regexp is not an object whose [[Class]] property is "RegExp", it is
* replaced with the result of the expression new RegExp(regexp).
*/
- reg = RegExp::create(&exec->globalData(), a0.toString(exec), NoFlags);
+ reg = RegExp::create(exec->globalData(), a0.toString(exec), NoFlags);
}
RegExpConstructor* regExpConstructor = exec->lexicalGlobalObject()->regExpConstructor();
int pos;
* If regexp is not an object whose [[Class]] property is "RegExp", it is
* replaced with the result of the expression new RegExp(regexp).
*/
- reg = RegExp::create(&exec->globalData(), a0.toString(exec), NoFlags);
+ reg = RegExp::create(exec->globalData(), a0.toString(exec), NoFlags);
}
RegExpConstructor* regExpConstructor = exec->lexicalGlobalObject()->regExpConstructor();
int pos;
class ObjectPrototype;
class StringPrototype : public StringObject {
- public:
+ private:
StringPrototype(ExecState*, JSGlobalObject*, Structure*);
+ public:
+ static StringPrototype* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure)
+ {
+ return new (allocateCell<StringPrototype>(*exec->heap())) StringPrototype(exec, globalObject, structure);
+ }
+
virtual bool getOwnPropertySlot(ExecState*, const Identifier& propertyName, PropertySlot&);
virtual bool getOwnPropertyDescriptor(ExecState*, const Identifier&, PropertyDescriptor&);
{
ASSERT(globalData.structureStructure);
ASSERT(classInfo);
- return new (&globalData) Structure(globalData, prototype, typeInfo, anonymousSlotCount, classInfo);
+ return new (allocateCell<Structure>(globalData.heap)) Structure(globalData, prototype, typeInfo, anonymousSlotCount, classInfo);
}
static void dumpStatistics();
static Structure* createStructure(JSGlobalData& globalData)
{
ASSERT(!globalData.structureStructure);
- return new (&globalData) Structure(globalData);
+ return new (allocateCell<Structure>(globalData.heap)) Structure(globalData);
}
static JS_EXPORTDATA const ClassInfo s_info;
static Structure* create(JSGlobalData& globalData, const Structure* structure)
{
ASSERT(globalData.structureStructure);
- return new (&globalData) Structure(globalData, structure);
+ return new (allocateCell<Structure>(globalData.heap)) Structure(globalData, structure);
}
typedef enum {
friend class JIT;
public:
- static StructureChain* create(JSGlobalData& globalData, Structure* head) { return new (&globalData) StructureChain(globalData, globalData.structureChainStructure.get(), head); }
+ static StructureChain* create(JSGlobalData& globalData, Structure* head) { return new (allocateCell<StructureChain>(globalData.heap)) StructureChain(globalData, globalData.structureChainStructure.get(), head); }
WriteBarrier<Structure>* head() { return m_vector.get(); }
void visitChildren(SlotVisitor&);
+2011-07-18 Mark Hahnenberg <mhahnenberg@apple.com>
+
+ Refactor JSC to replace JSCell::operator new with static create method
+ https://bugs.webkit.org/show_bug.cgi?id=64466
+
+ Reviewed by Oliver Hunt (oliver@apple.com) and Darin Adler (darin@apple.com).
+
+ 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.
+
+ * bindings/js/JSDOMBinding.cpp:
+ (WebCore::jsDateOrNull):
+ (WebCore::objectToStringFunctionGetter):
+ * bindings/js/JSDOMWindowCustom.cpp:
+ (WebCore::nonCachingStaticFunctionGetter):
+ * bindings/js/JSHistoryCustom.cpp:
+ (WebCore::nonCachingStaticBackFunctionGetter):
+ (WebCore::nonCachingStaticForwardFunctionGetter):
+ (WebCore::nonCachingStaticGoFunctionGetter):
+ * bindings/js/JSLocationCustom.cpp:
+ (WebCore::nonCachingStaticReplaceFunctionGetter):
+ (WebCore::nonCachingStaticReloadFunctionGetter):
+ (WebCore::nonCachingStaticAssignFunctionGetter):
+ * bindings/js/SerializedScriptValue.cpp:
+ (WebCore::CloneDeserializer::readTerminal):
+ * bridge/qt/qt_runtime.cpp:
+ (JSC::Bindings::convertQVariantToValue):
+
2011-07-18 Viatcheslav Ostapenko <ostapenko.viatcheslav@nokia.com>
[Texmap] [Qt] [WK2] Unsync in TextureMapperNode between parent and child lists cause crashes on WK2.
{
if (!isfinite(value))
return jsNull();
- return new (exec) DateInstance(exec, exec->lexicalGlobalObject()->dateStructure(), value);
+ return DateInstance::create(exec, exec->lexicalGlobalObject()->dateStructure(), value);
}
double valueToDate(ExecState* exec, JSValue value)
JSValue objectToStringFunctionGetter(ExecState* exec, JSValue, const Identifier& propertyName)
{
- return new (exec) JSFunction(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->functionStructure(), 0, propertyName, objectProtoFuncToString);
+ return JSFunction::create(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->functionStructure(), 0, propertyName, objectProtoFuncToString);
}
Structure* getCachedDOMStructure(JSDOMGlobalObject* globalObject, const ClassInfo* classInfo)
template<NativeFunction nativeFunction, int length>
JSValue nonCachingStaticFunctionGetter(ExecState* exec, JSValue, const Identifier& propertyName)
{
- return new (exec) JSFunction(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->functionStructure(), length, propertyName, nativeFunction);
+ return JSFunction::create(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->functionStructure(), length, propertyName, nativeFunction);
}
static JSValue childFrameGetter(ExecState* exec, JSValue slotBase, const Identifier& propertyName)
static JSValue nonCachingStaticBackFunctionGetter(ExecState* exec, JSValue, const Identifier& propertyName)
{
- return new (exec) JSFunction(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->functionStructure(), 0, propertyName, jsHistoryPrototypeFunctionBack);
+ return JSFunction::create(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->functionStructure(), 0, propertyName, jsHistoryPrototypeFunctionBack);
}
static JSValue nonCachingStaticForwardFunctionGetter(ExecState* exec, JSValue, const Identifier& propertyName)
{
- return new (exec) JSFunction(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->functionStructure(), 0, propertyName, jsHistoryPrototypeFunctionForward);
+ return JSFunction::create(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->functionStructure(), 0, propertyName, jsHistoryPrototypeFunctionForward);
}
static JSValue nonCachingStaticGoFunctionGetter(ExecState* exec, JSValue, const Identifier& propertyName)
{
- return new (exec) JSFunction(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->functionStructure(), 1, propertyName, jsHistoryPrototypeFunctionGo);
+ return JSFunction::create(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->functionStructure(), 1, propertyName, jsHistoryPrototypeFunctionGo);
}
bool JSHistory::getOwnPropertySlotDelegate(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
static JSValue nonCachingStaticReplaceFunctionGetter(ExecState* exec, JSValue, const Identifier& propertyName)
{
- return new (exec) JSFunction(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->functionStructure(), 1, propertyName, jsLocationPrototypeFunctionReplace);
+ return JSFunction::create(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->functionStructure(), 1, propertyName, jsLocationPrototypeFunctionReplace);
}
static JSValue nonCachingStaticReloadFunctionGetter(ExecState* exec, JSValue, const Identifier& propertyName)
{
- return new (exec) JSFunction(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->functionStructure(), 0, propertyName, jsLocationPrototypeFunctionReload);
+ return JSFunction::create(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->functionStructure(), 0, propertyName, jsLocationPrototypeFunctionReload);
}
static JSValue nonCachingStaticAssignFunctionGetter(ExecState* exec, JSValue, const Identifier& propertyName)
{
- return new (exec) JSFunction(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->functionStructure(), 1, propertyName, jsLocationPrototypeFunctionAssign);
+ return JSFunction::create(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->functionStructure(), 1, propertyName, jsLocationPrototypeFunctionAssign);
}
bool JSLocation::getOwnPropertySlotDelegate(ExecState* exec, const Identifier& propertyName, PropertySlot& slot)
double d;
if (!read(d))
return JSValue();
- return new (m_exec) DateInstance(m_exec, m_globalObject->dateStructure(), d);
+ return DateInstance::create(m_exec, m_globalObject->dateStructure(), d);
}
case FileTag: {
RefPtr<File> file;
return JSValue();
RegExpFlags reFlags = regExpFlags(flags->ustring());
ASSERT(reFlags != InvalidFlags);
- RegExp* regExp = RegExp::create(&m_exec->globalData(), pattern->ustring(), reFlags);
- return new (m_exec) RegExpObject(m_exec->lexicalGlobalObject(), m_globalObject->regExpStructure(), regExp);
+ RegExp* regExp = RegExp::create(m_exec->globalData(), pattern->ustring(), reFlags);
+ return RegExpObject::create(m_exec, m_exec->lexicalGlobalObject(), m_globalObject->regExpStructure(), regExp);
}
case ObjectReferenceTag: {
unsigned index = 0;
UString pattern((UChar*)re.pattern().utf16(), re.pattern().length());
RegExpFlags flags = (re.caseSensitivity() == Qt::CaseInsensitive) ? FlagIgnoreCase : NoFlags;
- JSC::RegExp* regExp = JSC::RegExp::create(&exec->globalData(), pattern, flags);
+ JSC::RegExp* regExp = JSC::RegExp::create(exec->globalData(), pattern, flags);
if (regExp->isValid())
- return new (exec) RegExpObject(exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->regExpStructure(), regExp);
+ return RegExpObject::create(exec, exec->lexicalGlobalObject(), exec->lexicalGlobalObject()->regExpStructure(), regExp);
return jsNull();
}
}
dt.isDST = -1;
double ms = gregorianDateTimeToMS(exec, dt, time.msec(), /*inputIsUTC*/ false);
- return new (exec) DateInstance(exec, exec->lexicalGlobalObject()->dateStructure(), trunc(ms));
+ return DateInstance::create(exec, exec->lexicalGlobalObject()->dateStructure(), trunc(ms));
}
if (type == QMetaType::QByteArray) {