Commit 20d6f9c1 authored by akling@apple.com's avatar akling@apple.com

Pass VM instead of ExecState to JSFunction constructors.

<https://webkit.org/b/122014>

Reviewed by Geoffrey Garen.

Source/JavaScriptCore:

JSFunction doesn't need the ExecState for anything during its
construction, so reduce the amount of loads by just passing the
VM around instead.

Factored out putDirectNonIndexAccessor() from the existing
putDirectAccessor() to avoid snowballing the patch (and because
it's kinda neat to avoid the extra branch.)

JSC release binary size -= 9680 bytes.

Source/WebCore:

Updated for new JSFunction::create() signature.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156602 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent d0c71466
2013-09-28 Andreas Kling <akling@apple.com>
Pass VM instead of ExecState to JSFunction constructors.
<https://webkit.org/b/122014>
Reviewed by Geoffrey Garen.
JSFunction doesn't need the ExecState for anything during its
construction, so reduce the amount of loads by just passing the
VM around instead.
Factored out putDirectNonIndexAccessor() from the existing
putDirectAccessor() to avoid snowballing the patch (and because
it's kinda neat to avoid the extra branch.)
JSC release binary size -= 9680 bytes.
2013-09-28 Mark Rowe <mrowe@apple.com>
JavaScriptCore fails to build with newer versions of clang.
......@@ -857,7 +857,7 @@ JSCell* JIT_OPERATION operationNewFunctionNoCheck(ExecState* exec, JSCell* funct
ASSERT(functionExecutable->inherits(FunctionExecutable::info()));
VM& vm = exec->vm();
NativeCallFrameTracer tracer(&vm, exec);
return JSFunction::create(exec, static_cast<FunctionExecutable*>(functionExecutable), exec->scope());
return JSFunction::create(vm, static_cast<FunctionExecutable*>(functionExecutable), exec->scope());
}
EncodedJSValue JIT_OPERATION operationNewFunction(ExecState* exec, JSCell* functionExecutable)
......@@ -865,7 +865,7 @@ EncodedJSValue JIT_OPERATION operationNewFunction(ExecState* exec, JSCell* funct
ASSERT(functionExecutable->inherits(FunctionExecutable::info()));
VM& vm = exec->vm();
NativeCallFrameTracer tracer(&vm, exec);
return JSValue::encode(JSFunction::create(exec, static_cast<FunctionExecutable*>(functionExecutable), exec->scope()));
return JSValue::encode(JSFunction::create(vm, static_cast<FunctionExecutable*>(functionExecutable), exec->scope()));
}
JSCell* JIT_OPERATION operationNewFunctionExpression(ExecState* exec, JSCell* functionExecutableAsCell)
......@@ -877,7 +877,7 @@ JSCell* JIT_OPERATION operationNewFunctionExpression(ExecState* exec, JSCell* fu
FunctionExecutable* functionExecutable =
static_cast<FunctionExecutable*>(functionExecutableAsCell);
return JSFunction::create(exec, functionExecutable, exec->scope());
return JSFunction::create(vm, functionExecutable, exec->scope());
}
size_t JIT_OPERATION operationIsObject(ExecState* exec, EncodedJSValue value)
......
......@@ -1209,7 +1209,7 @@ JSValue Interpreter::execute(EvalExecutable* eval, CallFrame* callFrame, JSValue
for (int i = 0; i < numFunctions; ++i) {
FunctionExecutable* function = codeBlock->functionDecl(i);
PutPropertySlot slot;
variableObject->methodTable()->put(variableObject, callFrame, function->name(), JSFunction::create(callFrame, function, scope), slot);
variableObject->methodTable()->put(variableObject, callFrame, function->name(), JSFunction::create(vm, function, scope), slot);
}
}
......
......@@ -1155,7 +1155,7 @@ DEFINE_STUB_FUNCTION(JSObject*, op_new_func)
STUB_INIT_STACK_FRAME(stackFrame);
ASSERT(stackFrame.callFrame->codeBlock()->codeType() != FunctionCode || !stackFrame.callFrame->codeBlock()->needsFullScopeChain() || stackFrame.callFrame->uncheckedR(stackFrame.callFrame->codeBlock()->activationRegister().offset()).jsValue());
return JSFunction::create(stackFrame.callFrame, stackFrame.args[0].function(), stackFrame.callFrame->scope());
return JSFunction::create(stackFrame.callFrame->vm(), stackFrame.args[0].function(), stackFrame.callFrame->scope());
}
inline void* jitCompileFor(CallFrame* callFrame, CodeSpecializationKind kind)
......@@ -1930,7 +1930,7 @@ DEFINE_STUB_FUNCTION(JSObject*, op_new_func_exp)
CallFrame* callFrame = stackFrame.callFrame;
FunctionExecutable* function = stackFrame.args[0].function();
JSFunction* func = JSFunction::create(callFrame, function, callFrame->scope());
JSFunction* func = JSFunction::create(callFrame->vm(), function, callFrame->scope());
ASSERT(callFrame->codeBlock()->codeType() != FunctionCode || !callFrame->codeBlock()->needsFullScopeChain() || callFrame->uncheckedR(callFrame->codeBlock()->activationRegister().offset()).jsValue());
return func;
......
......@@ -250,14 +250,14 @@ protected:
void addFunction(VM& vm, const char* name, NativeFunction function, unsigned arguments)
{
Identifier identifier(globalExec(), name);
putDirect(vm, identifier, JSFunction::create(globalExec(), this, arguments, identifier.string(), function));
Identifier identifier(&vm, name);
putDirect(vm, identifier, JSFunction::create(vm, this, arguments, identifier.string(), function));
}
void addConstructableFunction(VM& vm, const char* name, NativeFunction function, unsigned arguments)
{
Identifier identifier(globalExec(), name);
putDirect(vm, identifier, JSFunction::create(globalExec(), this, arguments, identifier.string(), function, NoIntrinsic, function));
Identifier identifier(&vm, name);
putDirect(vm, identifier, JSFunction::create(vm, this, arguments, identifier.string(), function, NoIntrinsic, function));
}
};
......
......@@ -921,7 +921,7 @@ LLINT_SLOW_PATH_DECL(slow_path_new_func)
#if LLINT_SLOW_PATH_TRACING
dataLogF("Creating function!\n");
#endif
LLINT_RETURN(JSFunction::create(exec, codeBlock->functionDecl(pc[2].u.operand), exec->scope()));
LLINT_RETURN(JSFunction::create(vm, codeBlock->functionDecl(pc[2].u.operand), exec->scope()));
}
LLINT_SLOW_PATH_DECL(slow_path_new_func_exp)
......@@ -929,7 +929,7 @@ LLINT_SLOW_PATH_DECL(slow_path_new_func_exp)
LLINT_BEGIN();
CodeBlock* codeBlock = exec->codeBlock();
FunctionExecutable* function = codeBlock->functionExpr(pc[2].u.operand);
JSFunction* func = JSFunction::create(exec, function, exec->scope());
JSFunction* func = JSFunction::create(vm, function, exec->scope());
LLINT_RETURN(func);
}
......
......@@ -106,21 +106,23 @@ void Arguments::createStrictModeCallerIfNecessary(ExecState* exec)
if (m_overrodeCaller)
return;
VM& vm = exec->vm();
m_overrodeCaller = true;
PropertyDescriptor descriptor;
descriptor.setAccessorDescriptor(globalObject()->throwTypeErrorGetterSetter(exec), DontEnum | DontDelete | Accessor);
methodTable()->defineOwnProperty(this, exec, exec->propertyNames().caller, descriptor, false);
descriptor.setAccessorDescriptor(globalObject()->throwTypeErrorGetterSetter(vm), DontEnum | DontDelete | Accessor);
methodTable()->defineOwnProperty(this, exec, vm.propertyNames->caller, descriptor, false);
}
void Arguments::createStrictModeCalleeIfNecessary(ExecState* exec)
{
if (m_overrodeCallee)
return;
VM& vm = exec->vm();
m_overrodeCallee = true;
PropertyDescriptor descriptor;
descriptor.setAccessorDescriptor(globalObject()->throwTypeErrorGetterSetter(exec), DontEnum | DontDelete | Accessor);
methodTable()->defineOwnProperty(this, exec, exec->propertyNames().callee, descriptor, false);
descriptor.setAccessorDescriptor(globalObject()->throwTypeErrorGetterSetter(vm), DontEnum | DontDelete | Accessor);
methodTable()->defineOwnProperty(this, exec, vm.propertyNames->callee, descriptor, false);
}
bool Arguments::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyName propertyName, PropertySlot& slot)
......
......@@ -433,11 +433,9 @@ JSObject* ProgramExecutable::initializeGlobalProperties(VM& vm, CallFrame* callF
const UnlinkedProgramCodeBlock::VariableDeclations& variableDeclarations = unlinkedCode->variableDeclarations();
const UnlinkedProgramCodeBlock::FunctionDeclations& functionDeclarations = unlinkedCode->functionDeclarations();
CallFrame* globalExec = globalObject->globalExec();
for (size_t i = 0; i < functionDeclarations.size(); ++i) {
UnlinkedFunctionExecutable* unlinkedFunctionExecutable = functionDeclarations[i].second.get();
JSValue value = JSFunction::create(globalExec, unlinkedFunctionExecutable->link(vm, m_source, lineNo(), 0), scope);
JSValue value = JSFunction::create(vm, unlinkedFunctionExecutable->link(vm, m_source, lineNo(), 0), scope);
globalObject->addFunction(callFrame, functionDeclarations[i].first, value);
}
......
......@@ -118,7 +118,7 @@ JSObject* constructFunctionSkippingEvalEnabledCheck(ExecState* exec, JSGlobalObj
return exec->vm().throwException(exec, exception);
}
return JSFunction::create(exec, function, globalObject);
return JSFunction::create(exec->vm(), function, globalObject);
}
// ECMA 15.3.2 The Function Constructor
......
......@@ -55,17 +55,19 @@ void FunctionPrototype::finishCreation(VM& vm, const String& name)
void FunctionPrototype::addFunctionProperties(ExecState* exec, JSGlobalObject* globalObject, JSFunction** callFunction, JSFunction** applyFunction)
{
JSFunction* toStringFunction = JSFunction::create(exec, globalObject, 0, exec->propertyNames().toString.string(), functionProtoFuncToString);
putDirectWithoutTransition(exec->vm(), exec->propertyNames().toString, toStringFunction, DontEnum);
VM& vm = exec->vm();
*applyFunction = JSFunction::create(exec, globalObject, 2, exec->propertyNames().apply.string(), functionProtoFuncApply);
putDirectWithoutTransition(exec->vm(), exec->propertyNames().apply, *applyFunction, DontEnum);
JSFunction* toStringFunction = JSFunction::create(vm, globalObject, 0, vm.propertyNames->toString.string(), functionProtoFuncToString);
putDirectWithoutTransition(vm, vm.propertyNames->toString, toStringFunction, DontEnum);
*callFunction = JSFunction::create(exec, globalObject, 1, exec->propertyNames().call.string(), functionProtoFuncCall);
putDirectWithoutTransition(exec->vm(), exec->propertyNames().call, *callFunction, DontEnum);
*applyFunction = JSFunction::create(vm, globalObject, 2, vm.propertyNames->apply.string(), functionProtoFuncApply);
putDirectWithoutTransition(vm, vm.propertyNames->apply, *applyFunction, DontEnum);
JSFunction* bindFunction = JSFunction::create(exec, globalObject, 1, exec->propertyNames().bind.string(), functionProtoFuncBind);
putDirectWithoutTransition(exec->vm(), exec->propertyNames().bind, bindFunction, DontEnum);
*callFunction = JSFunction::create(vm, globalObject, 1, vm.propertyNames->call.string(), functionProtoFuncCall);
putDirectWithoutTransition(vm, vm.propertyNames->call, *callFunction, DontEnum);
JSFunction* bindFunction = JSFunction::create(vm, globalObject, 1, vm.propertyNames->bind.string(), functionProtoFuncBind);
putDirectWithoutTransition(vm, vm.propertyNames->bind, bindFunction, DontEnum);
}
static EncodedJSValue JSC_HOST_CALL callFunctionPrototype(ExecState*)
......@@ -184,15 +186,16 @@ EncodedJSValue JSC_HOST_CALL functionProtoFuncBind(ExecState* exec)
// Primitive values are not callable.
ASSERT(target.isObject());
JSObject* targetObject = asObject(target);
VM& vm = exec->vm();
// Let A be a new (possibly empty) internal list of all of the argument values provided after thisArg (arg1, arg2 etc), in order.
size_t numBoundArgs = exec->argumentCount() > 1 ? exec->argumentCount() - 1 : 0;
JSArray* boundArgs = JSArray::tryCreateUninitialized(exec->vm(), globalObject->arrayStructureForIndexingTypeDuringAllocation(ArrayWithUndecided), numBoundArgs);
JSArray* boundArgs = JSArray::tryCreateUninitialized(vm, globalObject->arrayStructureForIndexingTypeDuringAllocation(ArrayWithUndecided), numBoundArgs);
if (!boundArgs)
return JSValue::encode(throwOutOfMemoryError(exec));
for (size_t i = 0; i < numBoundArgs; ++i)
boundArgs->initializeIndex(exec->vm(), i, exec->argument(i + 1));
boundArgs->initializeIndex(vm, i, exec->argument(i + 1));
// If the [[Class]] internal property of Target is "Function", then ...
// Else set the length own property of F to 0.
......@@ -207,7 +210,7 @@ EncodedJSValue JSC_HOST_CALL functionProtoFuncBind(ExecState* exec)
}
JSString* name = target.get(exec, exec->propertyNames().name).toString(exec);
return JSValue::encode(JSBoundFunction::create(exec, globalObject, targetObject, exec->argument(0), boundArgs, length, name->value(exec)));
return JSValue::encode(JSBoundFunction::create(vm, globalObject, targetObject, exec->argument(0), boundArgs, length, name->value(exec)));
}
} // namespace JSC
......@@ -74,16 +74,15 @@ EncodedJSValue JSC_HOST_CALL boundFunctionConstruct(ExecState* exec)
return JSValue::encode(construct(exec, targetFunction, constructType, constructData, args));
}
JSBoundFunction* JSBoundFunction::create(ExecState* exec, JSGlobalObject* globalObject, JSObject* targetFunction, JSValue boundThis, JSValue boundArgs, int length, const String& name)
JSBoundFunction* JSBoundFunction::create(VM& vm, JSGlobalObject* globalObject, JSObject* targetFunction, JSValue boundThis, JSValue boundArgs, int length, const String& name)
{
VM& vm = exec->vm();
ConstructData constructData;
ConstructType constructType = JSC::getConstructData(targetFunction, constructData);
bool canConstruct = constructType != ConstructTypeNone;
NativeExecutable* executable = vm.getHostFunction(boundFunctionCall, canConstruct ? boundFunctionConstruct : callHostFunctionAsConstructor);
JSBoundFunction* function = new (NotNull, allocateCell<JSBoundFunction>(vm.heap)) JSBoundFunction(exec, globalObject, globalObject->boundFunctionStructure(), targetFunction, boundThis, boundArgs);
JSBoundFunction* function = new (NotNull, allocateCell<JSBoundFunction>(vm.heap)) JSBoundFunction(vm, globalObject, globalObject->boundFunctionStructure(), targetFunction, boundThis, boundArgs);
function->finishCreation(exec, executable, length, name);
function->finishCreation(vm, executable, length, name);
return function;
}
......@@ -97,22 +96,21 @@ bool JSBoundFunction::customHasInstance(JSObject* object, ExecState* exec, JSVal
return jsCast<JSBoundFunction*>(object)->m_targetFunction->hasInstance(exec, value);
}
JSBoundFunction::JSBoundFunction(ExecState* exec, JSGlobalObject* globalObject, Structure* structure, JSObject* targetFunction, JSValue boundThis, JSValue boundArgs)
: Base(exec, globalObject, structure)
, m_targetFunction(exec->vm(), this, targetFunction)
, m_boundThis(exec->vm(), this, boundThis)
, m_boundArgs(exec->vm(), this, boundArgs)
JSBoundFunction::JSBoundFunction(VM& vm, JSGlobalObject* globalObject, Structure* structure, JSObject* targetFunction, JSValue boundThis, JSValue boundArgs)
: Base(vm, globalObject, structure)
, m_targetFunction(vm, this, targetFunction)
, m_boundThis(vm, this, boundThis)
, m_boundArgs(vm, this, boundArgs)
{
}
void JSBoundFunction::finishCreation(ExecState* exec, NativeExecutable* executable, int length, const String& name)
void JSBoundFunction::finishCreation(VM& vm, NativeExecutable* executable, int length, const String& name)
{
VM& vm = exec->vm();
Base::finishCreation(vm, executable, length, name);
ASSERT(inherits(info()));
putDirectAccessor(exec, vm.propertyNames->arguments, globalObject()->throwTypeErrorGetterSetter(exec), DontDelete | DontEnum | Accessor);
putDirectAccessor(exec, vm.propertyNames->caller, globalObject()->throwTypeErrorGetterSetter(exec), DontDelete | DontEnum | Accessor);
putDirectNonIndexAccessor(vm, vm.propertyNames->arguments, globalObject()->throwTypeErrorGetterSetter(vm), DontDelete | DontEnum | Accessor);
putDirectNonIndexAccessor(vm, vm.propertyNames->caller, globalObject()->throwTypeErrorGetterSetter(vm), DontDelete | DontEnum | Accessor);
}
void JSBoundFunction::visitChildren(JSCell* cell, SlotVisitor& visitor)
......
......@@ -37,7 +37,7 @@ class JSBoundFunction : public JSFunction {
public:
typedef JSFunction Base;
static JSBoundFunction* create(ExecState*, JSGlobalObject*, JSObject* targetFunction, JSValue boundThis, JSValue boundArgs, int, const String&);
static JSBoundFunction* create(VM&, JSGlobalObject*, JSObject* targetFunction, JSValue boundThis, JSValue boundArgs, int, const String&);
static void destroy(JSCell*);
......@@ -61,9 +61,9 @@ protected:
static void visitChildren(JSCell*, SlotVisitor&);
private:
JSBoundFunction(ExecState*, JSGlobalObject*, Structure*, JSObject* targetFunction, JSValue boundThis, JSValue boundArgs);
JSBoundFunction(VM&, JSGlobalObject*, Structure*, JSObject* targetFunction, JSValue boundThis, JSValue boundArgs);
void finishCreation(ExecState*, NativeExecutable*, int, const String&);
void finishCreation(VM&, NativeExecutable*, int, const String&);
WriteBarrier<JSObject> m_targetFunction;
WriteBarrier<Unknown> m_boundThis;
......
......@@ -61,22 +61,20 @@ bool JSFunction::isHostFunctionNonInline() const
return isHostFunction();
}
JSFunction* JSFunction::create(ExecState* exec, JSGlobalObject* globalObject, int length, const String& name, NativeFunction nativeFunction, Intrinsic intrinsic, NativeFunction nativeConstructor)
JSFunction* JSFunction::create(VM& vm, JSGlobalObject* globalObject, int length, const String& name, NativeFunction nativeFunction, Intrinsic intrinsic, NativeFunction nativeConstructor)
{
VM& vm = exec->vm();
NativeExecutable* executable;
#if !ENABLE(JIT)
UNUSED_PARAM(intrinsic);
#else
if (intrinsic != NoIntrinsic && exec->vm().canUseJIT()) {
if (intrinsic != NoIntrinsic && vm.canUseJIT()) {
ASSERT(nativeConstructor == callHostFunctionAsConstructor);
executable = vm.getHostFunction(nativeFunction, intrinsic);
} else
#endif
executable = vm.getHostFunction(nativeFunction, nativeConstructor);
JSFunction* function = new (NotNull, allocateCell<JSFunction>(vm.heap)) JSFunction(exec, globalObject, globalObject->functionStructure());
JSFunction* function = new (NotNull, allocateCell<JSFunction>(vm.heap)) JSFunction(vm, globalObject, globalObject->functionStructure());
// Can't do this during initialization because getHostFunction might do a GC allocation.
function->finishCreation(vm, executable, length, name);
return function;
......@@ -87,10 +85,10 @@ void JSFunction::destroy(JSCell* cell)
static_cast<JSFunction*>(cell)->JSFunction::~JSFunction();
}
JSFunction::JSFunction(ExecState* exec, JSGlobalObject* globalObject, Structure* structure)
: Base(exec->vm(), structure)
JSFunction::JSFunction(VM& vm, JSGlobalObject* globalObject, Structure* structure)
: Base(vm, structure)
, m_executable()
, m_scope(exec->vm(), this, globalObject)
, m_scope(vm, this, globalObject)
// We initialize blind so that changes to the prototype after function creation but before
// the optimizer kicks in don't disable optimizations. Once the optimizer kicks in, the
// watchpoint will start watching and any changes will both force deoptimization and disable
......@@ -325,7 +323,7 @@ bool JSFunction::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyN
if (thisObject->jsExecutable()->isStrictMode()) {
bool result = Base::getOwnPropertySlot(thisObject, exec, propertyName, slot);
if (!result) {
thisObject->putDirectAccessor(exec, propertyName, thisObject->globalObject()->throwTypeErrorGetterSetter(exec), DontDelete | DontEnum | Accessor);
thisObject->putDirectAccessor(exec, propertyName, thisObject->globalObject()->throwTypeErrorGetterSetter(exec->vm()), DontDelete | DontEnum | Accessor);
result = Base::getOwnPropertySlot(thisObject, exec, propertyName, slot);
ASSERT(result);
}
......@@ -349,7 +347,7 @@ bool JSFunction::getOwnPropertySlot(JSObject* object, ExecState* exec, PropertyN
if (thisObject->jsExecutable()->isStrictMode()) {
bool result = Base::getOwnPropertySlot(thisObject, exec, propertyName, slot);
if (!result) {
thisObject->putDirectAccessor(exec, propertyName, thisObject->globalObject()->throwTypeErrorGetterSetter(exec), DontDelete | DontEnum | Accessor);
thisObject->putDirectAccessor(exec, propertyName, thisObject->globalObject()->throwTypeErrorGetterSetter(exec->vm()), DontDelete | DontEnum | Accessor);
result = Base::getOwnPropertySlot(thisObject, exec, propertyName, slot);
ASSERT(result);
}
......@@ -447,7 +445,7 @@ bool JSFunction::defineOwnProperty(JSObject* object, ExecState* exec, PropertyNa
if (thisObject->jsExecutable()->isStrictMode()) {
PropertySlot slot(thisObject);
if (!Base::getOwnPropertySlot(thisObject, exec, propertyName, slot))
thisObject->putDirectAccessor(exec, propertyName, thisObject->globalObject()->throwTypeErrorGetterSetter(exec), DontDelete | DontEnum | Accessor);
thisObject->putDirectAccessor(exec, propertyName, thisObject->globalObject()->throwTypeErrorGetterSetter(exec->vm()), DontDelete | DontEnum | Accessor);
return Base::defineOwnProperty(object, exec, propertyName, descriptor, throwException);
}
valueCheck = !descriptor.value() || sameValue(exec, descriptor.value(), retrieveArguments(exec, thisObject));
......@@ -455,7 +453,7 @@ bool JSFunction::defineOwnProperty(JSObject* object, ExecState* exec, PropertyNa
if (thisObject->jsExecutable()->isStrictMode()) {
PropertySlot slot(thisObject);
if (!Base::getOwnPropertySlot(thisObject, exec, propertyName, slot))
thisObject->putDirectAccessor(exec, propertyName, thisObject->globalObject()->throwTypeErrorGetterSetter(exec), DontDelete | DontEnum | Accessor);
thisObject->putDirectAccessor(exec, propertyName, thisObject->globalObject()->throwTypeErrorGetterSetter(exec->vm()), DontDelete | DontEnum | Accessor);
return Base::defineOwnProperty(object, exec, propertyName, descriptor, throwException);
}
valueCheck = !descriptor.value() || sameValue(exec, descriptor.value(), retrieveCallerFunction(exec, thisObject));
......
......@@ -58,11 +58,10 @@ namespace JSC {
public:
typedef JSDestructibleObject Base;
JS_EXPORT_PRIVATE static JSFunction* create(ExecState*, JSGlobalObject*, int length, const String& name, NativeFunction, Intrinsic = NoIntrinsic, NativeFunction nativeConstructor = callHostFunctionAsConstructor);
JS_EXPORT_PRIVATE static JSFunction* create(VM&, JSGlobalObject*, int length, const String& name, NativeFunction, Intrinsic = NoIntrinsic, NativeFunction nativeConstructor = callHostFunctionAsConstructor);
static JSFunction* create(ExecState* exec, FunctionExecutable* executable, JSScope* scope)
static JSFunction* create(VM& vm, FunctionExecutable* executable, JSScope* scope)
{
VM& vm = exec->vm();
JSFunction* function = new (NotNull, allocateCell<JSFunction>(vm.heap)) JSFunction(vm, executable, scope);
ASSERT(function->structure()->globalObject());
function->finishCreation(vm);
......@@ -162,7 +161,7 @@ namespace JSC {
protected:
const static unsigned StructureFlags = OverridesGetOwnPropertySlot | ImplementsHasInstance | OverridesVisitChildren | OverridesGetPropertyNames | JSObject::StructureFlags;
JS_EXPORT_PRIVATE JSFunction(ExecState*, JSGlobalObject*, Structure*);
JS_EXPORT_PRIVATE JSFunction(VM&, JSGlobalObject*, Structure*);
JSFunction(VM&, FunctionExecutable*, JSScope*);
void finishCreation(VM&, NativeExecutable*, int length, const String& name);
......
......@@ -240,9 +240,9 @@ void JSGlobalObject::reset(JSValue prototype)
m_applyFunction.set(vm, this, applyFunction);
m_objectPrototype.set(vm, this, ObjectPrototype::create(exec, this, ObjectPrototype::createStructure(vm, this, jsNull())));
GetterSetter* protoAccessor = GetterSetter::create(vm);
protoAccessor->setGetter(vm, JSFunction::create(exec, this, 0, String(), globalFuncProtoGetter));
protoAccessor->setSetter(vm, JSFunction::create(exec, this, 0, String(), globalFuncProtoSetter));
m_objectPrototype->putDirectAccessor(exec, vm.propertyNames->underscoreProto, protoAccessor, Accessor | DontEnum);
protoAccessor->setGetter(vm, JSFunction::create(vm, this, 0, String(), globalFuncProtoGetter));
protoAccessor->setSetter(vm, JSFunction::create(vm, this, 0, String(), globalFuncProtoSetter));
m_objectPrototype->putDirectNonIndexAccessor(vm, vm.propertyNames->underscoreProto, protoAccessor, Accessor | DontEnum);
m_functionPrototype->structure()->setPrototypeWithoutTransition(vm, m_objectPrototype.get());
m_typedArrays[toIndex(TypeInt8)].prototype.set(vm, this, JSInt8ArrayPrototype::create(exec, this, JSInt8ArrayPrototype::createStructure(vm, this, m_objectPrototype.get())));
......@@ -384,7 +384,7 @@ void JSGlobalObject::reset(JSValue prototype)
#undef PUT_CONSTRUCTOR_FOR_SIMPLE_TYPE
m_evalFunction.set(vm, this, JSFunction::create(exec, this, 1, vm.propertyNames->eval.string(), globalFuncEval));
m_evalFunction.set(vm, this, JSFunction::create(vm, this, 1, vm.propertyNames->eval.string(), globalFuncEval));
putDirectWithoutTransition(vm, vm.propertyNames->eval, m_evalFunction.get(), DontEnum);
putDirectWithoutTransition(vm, vm.propertyNames->JSON, JSONObject::create(exec, this, JSONObject::createStructure(vm, this, m_objectPrototype.get())), DontEnum);
......@@ -548,10 +548,9 @@ bool JSGlobalObject::stringPrototypeChainIsSane()
&& objectPrototypeIsSane();
}
void JSGlobalObject::createThrowTypeError(ExecState* exec)
void JSGlobalObject::createThrowTypeError(VM& vm)
{
VM& vm = exec->vm();
JSFunction* thrower = JSFunction::create(exec, this, 0, String(), globalFuncThrowTypeError);
JSFunction* thrower = JSFunction::create(vm, this, 0, String(), globalFuncThrowTypeError);
GetterSetter* getterSetter = GetterSetter::create(vm);
getterSetter->setGetter(vm, thrower);
getterSetter->setSetter(vm, thrower);
......
......@@ -335,10 +335,10 @@ public:
JSFunction* evalFunction() const { return m_evalFunction.get(); }
JSFunction* callFunction() const { return m_callFunction.get(); }
JSFunction* applyFunction() const { return m_applyFunction.get(); }
GetterSetter* throwTypeErrorGetterSetter(ExecState* exec)
GetterSetter* throwTypeErrorGetterSetter(VM& vm)
{
if (!m_throwTypeErrorGetterSetter)
createThrowTypeError(exec);
createThrowTypeError(vm);
return m_throwTypeErrorGetterSetter.get();
}
......@@ -544,7 +544,7 @@ private:
JS_EXPORT_PRIVATE void init(JSObject* thisValue);
void reset(JSValue prototype);
void createThrowTypeError(ExecState*);
void createThrowTypeError(VM&);
JS_EXPORT_PRIVATE static void clearRareData(JSCell*);
};
......
......@@ -1192,8 +1192,11 @@ void JSObject::putDirectAccessor(ExecState* exec, PropertyName propertyName, JSV
return;
}
VM& vm = exec->vm();
putDirectNonIndexAccessor(exec->vm(), propertyName, value, attributes);
}
void JSObject::putDirectNonIndexAccessor(VM& vm, PropertyName propertyName, JSValue value, unsigned attributes)
{
PutPropertySlot slot;
putDirectInternal<PutModeDefineOwnProperty>(vm, propertyName, value, attributes, slot, getCallableObject(value));
......@@ -2202,18 +2205,20 @@ void JSObject::putDirectNativeFunction(ExecState* exec, JSGlobalObject* globalOb
{
StringImpl* name = propertyName.publicName();
ASSERT(name);
JSFunction* function = JSFunction::create(exec, globalObject, functionLength, name, nativeFunction, intrinsic);
putDirect(exec->vm(), propertyName, function, attributes);
VM& vm = exec->vm();
JSFunction* function = JSFunction::create(vm, globalObject, functionLength, name, nativeFunction, intrinsic);
putDirect(vm, propertyName, function, attributes);
}
void JSObject::putDirectNativeFunctionWithoutTransition(ExecState* exec, JSGlobalObject* globalObject, const PropertyName& propertyName, unsigned functionLength, NativeFunction nativeFunction, Intrinsic intrinsic, unsigned attributes)
{
StringImpl* name = propertyName.publicName();
ASSERT(name);
JSFunction* function = JSFunction::create(exec, globalObject, functionLength, name, nativeFunction, intrinsic);
putDirectWithoutTransition(exec->vm(), propertyName, function, attributes);
VM& vm = exec->vm();
JSFunction* function = JSFunction::create(vm, globalObject, functionLength, name, nativeFunction, intrinsic);
putDirectWithoutTransition(vm, propertyName, function, attributes);
}
ALWAYS_INLINE unsigned JSObject::getNewVectorLength(unsigned currentVectorLength, unsigned currentLength, unsigned desiredLength)
......
......@@ -460,6 +460,7 @@ public:
void putDirect(VM&, PropertyName, JSValue, unsigned attributes = 0);
void putDirect(VM&, PropertyName, JSValue, PutPropertySlot&);
void putDirectWithoutTransition(VM&, PropertyName, JSValue, unsigned attributes = 0);
void putDirectNonIndexAccessor(VM&, PropertyName, JSValue, unsigned attributes);
void putDirectAccessor(ExecState*, PropertyName, JSValue, unsigned attributes);
JS_EXPORT_PRIVATE bool hasProperty(ExecState*, PropertyName) const;
......
......@@ -64,9 +64,9 @@ void MapPrototype::finishCreation(ExecState* exec, JSGlobalObject* globalObject)
JSC_NATIVE_FUNCTION(vm.propertyNames->set, mapProtoFuncSet, DontEnum, 2);
GetterSetter* accessor = GetterSetter::create(vm);
JSFunction* function = JSFunction::create(exec, globalObject, 0, vm.propertyNames->size.string(), mapProtoFuncSize);
JSFunction* function = JSFunction::create(vm, globalObject, 0, vm.propertyNames->size.string(), mapProtoFuncSize);
accessor->setGetter(vm, function);
putDirectAccessor(exec, vm.propertyNames->size, accessor, DontEnum | Accessor);
putDirectNonIndexAccessor(vm, vm.propertyNames->size, accessor, DontEnum | Accessor);
}
ALWAYS_INLINE static MapData* getMapData(CallFrame* callFrame, JSValue thisValue)
......
......@@ -62,9 +62,9 @@ void SetPrototype::finishCreation(ExecState* exec, JSGlobalObject* globalObject)
JSC_NATIVE_FUNCTION(vm.propertyNames->has, setProtoFuncHas, DontEnum, 1);
GetterSetter* accessor = GetterSetter::create(vm);
JSFunction* function = JSFunction::create(exec, globalObject, 0, vm.propertyNames->size.string(), setProtoFuncSize);
JSFunction* function = JSFunction::create(vm, globalObject, 0, vm.propertyNames->size.string(), setProtoFuncSize);
accessor->setGetter(vm, function);
putDirectAccessor(exec, vm.propertyNames->size, accessor, DontEnum | Accessor);
putDirectNonIndexAccessor(vm, vm.propertyNames->size, accessor, DontEnum | Accessor);
}
ALWAYS_INLINE static MapData* getMapData(CallFrame* callFrame, JSValue thisValue)
......
2013-09-28 Andreas Kling <akling@apple.com>
Pass VM instead of ExecState to JSFunction constructors.
<https://webkit.org/b/122014>
Reviewed by Geoffrey Garen.
Updated for new JSFunction::create() signature.
2013-09-28 Gyuyoung Kim <gyuyoung.kim@samsung.com>
Generate toCSSFooValue() for CSSImageValue
......@@ -274,7 +274,7 @@ void printErrorMessageForFrame(Frame* frame, const String& message)
JSValue objectToStringFunctionGetter(ExecState* exec, JSValue, PropertyName propertyName)
{
return JSFunction::create(exec, exec->lexicalGlobalObject(), 0, propertyName.publicName(), objectProtoFuncToString);
return JSFunction::create(exec->vm(), exec->lexicalGlobalObject(), 0, propertyName.publicName(), objectProtoFuncToString);
}
Structure* getCachedDOMStructure(JSDOMGlobalObject* globalObject, const ClassInfo* classInfo)
......
......@@ -73,7 +73,7 @@ void JSDOMWindow::visitChildren(JSCell* cell, SlotVisitor& visitor)
template<NativeFunction nativeFunction, int length>
JSValue nonCachingStaticFunctionGetter(ExecState* exec, JSValue, PropertyName propertyName)
{
return JSFunction::create(exec, exec->lexicalGlobalObject(), length, propertyName.publicName(), nativeFunction);
return JSFunction::create(exec->vm(), exec->lexicalGlobalObject(), length, propertyName.publicName(), nativeFunction);
}
static JSValue childFrameGetter(ExecState* exec, JSValue slotBase, PropertyName propertyName)
......
......@@ -40,17 +40,17 @@ namespace WebCore {
static JSValue nonCachingStaticBackFunctionGetter(ExecState* exec, JSValue, PropertyName propertyName)
{
return JSFunction::create(exec, exec->lexicalGlobalObject(), 0, propertyName.publicName(), jsHistoryPrototypeFunctionBack);
return JSFunction::create(exec->vm(), exec->lexicalGlobalObject(), 0, propertyName.publicName(), jsHistoryPrototypeFunctionBack);
}
static JSValue nonCachingStaticForwardFunctionGetter(ExecState* exec, JSValue, PropertyName propertyName)
{
return JSFunction::create(exec, exec->lexicalGlobalObject(), 0, propertyName.publicName(), jsHistoryPrototypeFunctionForward);
return JSFunction::create(exec->vm(), exec->lexicalGlobalObject(), 0, propertyName.publicName(), jsHistoryPrototypeFunctionForward);
}
static JSValue nonCachingStaticGoFunctionGetter(ExecState* exec, JSValue, PropertyName propertyName)
{
return JSFunction::create(exec, exec->lexicalGlobalObject(), 1, propertyName.publicName(), jsHistoryPrototypeFunctionGo);
return JSFunction::create(exec->vm(), exec->lexicalGlobalObject(), 1, propertyName.publicName(), jsHistoryPrototypeFunctionGo);
}
bool JSHistory::getOwnPropertySlotDelegate(ExecState* exec, PropertyName propertyName, PropertySlot& slot)
......
......@@ -32,17 +32,17 @@ namespace WebCore {
static JSValue nonCachingStaticReplaceFunctionGetter(ExecState* exec, JSValue, PropertyName propertyName)
{
return JSFunction::create(exec, exec->lexicalGlobalObject(), 1, propertyName.publicName(), jsLocationPrototypeFunctionReplace);
return JSFunction::create(exec->vm(), exec->lexicalGlobalObject(), 1, propertyName.publicName(), jsLocationPrototypeFunctionReplace);
}
static JSValue nonCachingStaticReloadFunctionGetter(ExecState* exec, JSValue, PropertyName propertyName)
{
return JSFunction::create(exec, exec->lexicalGlobalObject(), 0, propertyName.publicName(), jsLocationPrototypeFunctionReload);
return JSFunction::create(exec->vm(), exec->lexicalGlobalObject(), 0, propertyName.publicName(), jsLocationPrototypeFunctionReload);
}
static JSValue nonCachingStaticAssignFunctionGetter(ExecState* exec, JSValue, PropertyName propertyName)
{
return JSFunction::create(exec, exec->lexicalGlobalObject(), 1, propertyName.publicName(), jsLocationPrototypeFunctionAssign);
return JSFunction::create(exec->vm(), exec->lexicalGlobalObject(), 1, propertyName.publicName(), jsLocationPrototypeFunctionAssign);
}
bool JSLocation::getOwnPropertySlotDelegate(ExecState* exec, PropertyName propertyName, PropertySlot& slot)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment