Commit 3828a863 authored by akling@apple.com's avatar akling@apple.com

Pass VM instead of JSGlobalObject to MathObject constructor.

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

Reviewed by Geoffrey Garen.

The MathObject constructor was only using the global object to get
to the VM. finishCreation() still uses it to set up functions.


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@156679 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 7f4e88e7
2013-09-30 Andreas Kling <akling@apple.com>
Pass VM instead of JSGlobalObject to MathObject constructor.
<https://webkit.org/b/122119>
Reviewed by Geoffrey Garen.
The MathObject constructor was only using the global object to get
to the VM. finishCreation() still uses it to set up functions.
2013-09-30 Filip Pizlo <fpizlo@apple.com>
Get rid of the AlreadyInJSStack recoveries since they are totally redundant with the DisplacedInJSStack recoveries
......@@ -388,7 +388,7 @@ void JSGlobalObject::reset(JSValue prototype)
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);
putDirectWithoutTransition(vm, vm.propertyNames->Math, MathObject::create(exec, this, MathObject::createStructure(vm, this, m_objectPrototype.get())), DontEnum);
putDirectWithoutTransition(vm, vm.propertyNames->Math, MathObject::create(vm, this, MathObject::createStructure(vm, this, m_objectPrototype.get())), DontEnum);
FixedArray<InternalFunction*, NUMBER_OF_TYPED_ARRAY_TYPES> typedArrayConstructors;
typedArrayConstructors[toIndex(TypeInt8)] = JSInt8ArrayConstructor::create(vm, JSInt8ArrayConstructor::createStructure(vm, this, m_functionPrototype.get()), m_typedArrays[toIndex(TypeInt8)].prototype.get(), "Int8Array");
......
......@@ -2210,12 +2210,11 @@ void JSObject::putDirectNativeFunction(VM& vm, JSGlobalObject* globalObject, con
putDirect(vm, propertyName, function, attributes);
}
void JSObject::putDirectNativeFunctionWithoutTransition(ExecState* exec, JSGlobalObject* globalObject, const PropertyName& propertyName, unsigned functionLength, NativeFunction nativeFunction, Intrinsic intrinsic, unsigned attributes)
void JSObject::putDirectNativeFunctionWithoutTransition(VM& vm, JSGlobalObject* globalObject, const PropertyName& propertyName, unsigned functionLength, NativeFunction nativeFunction, Intrinsic intrinsic, unsigned attributes)
{
StringImpl* name = propertyName.publicName();
ASSERT(name);
VM& vm = exec->vm();
JSFunction* function = JSFunction::create(vm, globalObject, functionLength, name, nativeFunction, intrinsic);
putDirectWithoutTransition(vm, propertyName, function, attributes);
}
......
......@@ -578,7 +578,7 @@ public:
void putDirectUndefined(PropertyOffset offset) { locationForOffset(offset)->setUndefined(); }
void putDirectNativeFunction(VM&, JSGlobalObject*, const PropertyName&, unsigned functionLength, NativeFunction, Intrinsic, unsigned attributes);
void putDirectNativeFunctionWithoutTransition(ExecState*, JSGlobalObject*, const PropertyName&, unsigned functionLength, NativeFunction, Intrinsic, unsigned attributes);
void putDirectNativeFunctionWithoutTransition(VM&, JSGlobalObject*, const PropertyName&, unsigned functionLength, NativeFunction, Intrinsic, unsigned attributes);
JS_EXPORT_PRIVATE static bool defineOwnProperty(JSObject*, ExecState*, PropertyName, const PropertyDescriptor&, bool shouldThrow);
......
......@@ -60,44 +60,44 @@ namespace JSC {
const ClassInfo MathObject::s_info = { "Math", &Base::s_info, 0, 0, CREATE_METHOD_TABLE(MathObject) };
MathObject::MathObject(JSGlobalObject* globalObject, Structure* structure)
: JSNonFinalObject(globalObject->vm(), structure)
MathObject::MathObject(VM& vm, Structure* structure)
: JSNonFinalObject(vm, structure)
{
}
void MathObject::finishCreation(ExecState* exec, JSGlobalObject* globalObject)
void MathObject::finishCreation(VM& vm, JSGlobalObject* globalObject)
{
Base::finishCreation(globalObject->vm());
Base::finishCreation(vm);
ASSERT(inherits(info()));
putDirectWithoutTransition(exec->vm(), Identifier(exec, "E"), jsNumber(exp(1.0)), DontDelete | DontEnum | ReadOnly);
putDirectWithoutTransition(exec->vm(), Identifier(exec, "LN2"), jsNumber(log(2.0)), DontDelete | DontEnum | ReadOnly);
putDirectWithoutTransition(exec->vm(), Identifier(exec, "LN10"), jsNumber(log(10.0)), DontDelete | DontEnum | ReadOnly);
putDirectWithoutTransition(exec->vm(), Identifier(exec, "LOG2E"), jsNumber(1.0 / log(2.0)), DontDelete | DontEnum | ReadOnly);
putDirectWithoutTransition(exec->vm(), Identifier(exec, "LOG10E"), jsNumber(0.4342944819032518), DontDelete | DontEnum | ReadOnly);
putDirectWithoutTransition(exec->vm(), Identifier(exec, "PI"), jsNumber(piDouble), DontDelete | DontEnum | ReadOnly);
putDirectWithoutTransition(exec->vm(), Identifier(exec, "SQRT1_2"), jsNumber(sqrt(0.5)), DontDelete | DontEnum | ReadOnly);
putDirectWithoutTransition(exec->vm(), Identifier(exec, "SQRT2"), jsNumber(sqrt(2.0)), DontDelete | DontEnum | ReadOnly);
putDirectNativeFunctionWithoutTransition(exec, globalObject, Identifier(exec, "abs"), 1, mathProtoFuncAbs, AbsIntrinsic, DontEnum | Function);
putDirectNativeFunctionWithoutTransition(exec, globalObject, Identifier(exec, "acos"), 1, mathProtoFuncACos, NoIntrinsic, DontEnum | Function);
putDirectNativeFunctionWithoutTransition(exec, globalObject, Identifier(exec, "asin"), 1, mathProtoFuncASin, NoIntrinsic, DontEnum | Function);
putDirectNativeFunctionWithoutTransition(exec, globalObject, Identifier(exec, "atan"), 1, mathProtoFuncATan, NoIntrinsic, DontEnum | Function);
putDirectNativeFunctionWithoutTransition(exec, globalObject, Identifier(exec, "atan2"), 2, mathProtoFuncATan2, NoIntrinsic, DontEnum | Function);
putDirectNativeFunctionWithoutTransition(exec, globalObject, Identifier(exec, "ceil"), 1, mathProtoFuncCeil, CeilIntrinsic, DontEnum | Function);
putDirectNativeFunctionWithoutTransition(exec, globalObject, Identifier(exec, "cos"), 1, mathProtoFuncCos, NoIntrinsic, DontEnum | Function);
putDirectNativeFunctionWithoutTransition(exec, globalObject, Identifier(exec, "exp"), 1, mathProtoFuncExp, ExpIntrinsic, DontEnum | Function);
putDirectNativeFunctionWithoutTransition(exec, globalObject, Identifier(exec, "floor"), 1, mathProtoFuncFloor, FloorIntrinsic, DontEnum | Function);
putDirectNativeFunctionWithoutTransition(exec, globalObject, Identifier(exec, "log"), 1, mathProtoFuncLog, LogIntrinsic, DontEnum | Function);
putDirectNativeFunctionWithoutTransition(exec, globalObject, Identifier(exec, "max"), 2, mathProtoFuncMax, MaxIntrinsic, DontEnum | Function);
putDirectNativeFunctionWithoutTransition(exec, globalObject, Identifier(exec, "min"), 2, mathProtoFuncMin, MinIntrinsic, DontEnum | Function);
putDirectNativeFunctionWithoutTransition(exec, globalObject, Identifier(exec, "pow"), 2, mathProtoFuncPow, PowIntrinsic, DontEnum | Function);
putDirectNativeFunctionWithoutTransition(exec, globalObject, Identifier(exec, "random"), 0, mathProtoFuncRandom, NoIntrinsic, DontEnum | Function);
putDirectNativeFunctionWithoutTransition(exec, globalObject, Identifier(exec, "round"), 1, mathProtoFuncRound, RoundIntrinsic, DontEnum | Function);
putDirectNativeFunctionWithoutTransition(exec, globalObject, Identifier(exec, "sin"), 1, mathProtoFuncSin, NoIntrinsic, DontEnum | Function);
putDirectNativeFunctionWithoutTransition(exec, globalObject, Identifier(exec, "sqrt"), 1, mathProtoFuncSqrt, SqrtIntrinsic, DontEnum | Function);
putDirectNativeFunctionWithoutTransition(exec, globalObject, Identifier(exec, "tan"), 1, mathProtoFuncTan, NoIntrinsic, DontEnum | Function);
putDirectNativeFunctionWithoutTransition(exec, globalObject, Identifier(exec, "imul"), 1, mathProtoFuncIMul, IMulIntrinsic, DontEnum | Function);
putDirectWithoutTransition(vm, Identifier(&vm, "E"), jsNumber(exp(1.0)), DontDelete | DontEnum | ReadOnly);
putDirectWithoutTransition(vm, Identifier(&vm, "LN2"), jsNumber(log(2.0)), DontDelete | DontEnum | ReadOnly);
putDirectWithoutTransition(vm, Identifier(&vm, "LN10"), jsNumber(log(10.0)), DontDelete | DontEnum | ReadOnly);
putDirectWithoutTransition(vm, Identifier(&vm, "LOG2E"), jsNumber(1.0 / log(2.0)), DontDelete | DontEnum | ReadOnly);
putDirectWithoutTransition(vm, Identifier(&vm, "LOG10E"), jsNumber(0.4342944819032518), DontDelete | DontEnum | ReadOnly);
putDirectWithoutTransition(vm, Identifier(&vm, "PI"), jsNumber(piDouble), DontDelete | DontEnum | ReadOnly);
putDirectWithoutTransition(vm, Identifier(&vm, "SQRT1_2"), jsNumber(sqrt(0.5)), DontDelete | DontEnum | ReadOnly);
putDirectWithoutTransition(vm, Identifier(&vm, "SQRT2"), jsNumber(sqrt(2.0)), DontDelete | DontEnum | ReadOnly);
putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier(&vm, "abs"), 1, mathProtoFuncAbs, AbsIntrinsic, DontEnum | Function);
putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier(&vm, "acos"), 1, mathProtoFuncACos, NoIntrinsic, DontEnum | Function);
putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier(&vm, "asin"), 1, mathProtoFuncASin, NoIntrinsic, DontEnum | Function);
putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier(&vm, "atan"), 1, mathProtoFuncATan, NoIntrinsic, DontEnum | Function);
putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier(&vm, "atan2"), 2, mathProtoFuncATan2, NoIntrinsic, DontEnum | Function);
putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier(&vm, "ceil"), 1, mathProtoFuncCeil, CeilIntrinsic, DontEnum | Function);
putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier(&vm, "cos"), 1, mathProtoFuncCos, NoIntrinsic, DontEnum | Function);
putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier(&vm, "exp"), 1, mathProtoFuncExp, ExpIntrinsic, DontEnum | Function);
putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier(&vm, "floor"), 1, mathProtoFuncFloor, FloorIntrinsic, DontEnum | Function);
putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier(&vm, "log"), 1, mathProtoFuncLog, LogIntrinsic, DontEnum | Function);
putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier(&vm, "max"), 2, mathProtoFuncMax, MaxIntrinsic, DontEnum | Function);
putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier(&vm, "min"), 2, mathProtoFuncMin, MinIntrinsic, DontEnum | Function);
putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier(&vm, "pow"), 2, mathProtoFuncPow, PowIntrinsic, DontEnum | Function);
putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier(&vm, "random"), 0, mathProtoFuncRandom, NoIntrinsic, DontEnum | Function);
putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier(&vm, "round"), 1, mathProtoFuncRound, RoundIntrinsic, DontEnum | Function);
putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier(&vm, "sin"), 1, mathProtoFuncSin, NoIntrinsic, DontEnum | Function);
putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier(&vm, "sqrt"), 1, mathProtoFuncSqrt, SqrtIntrinsic, DontEnum | Function);
putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier(&vm, "tan"), 1, mathProtoFuncTan, NoIntrinsic, DontEnum | Function);
putDirectNativeFunctionWithoutTransition(vm, globalObject, Identifier(&vm, "imul"), 1, mathProtoFuncIMul, IMulIntrinsic, DontEnum | Function);
}
// ------------------------------ Functions --------------------------------
......
......@@ -27,15 +27,15 @@ namespace JSC {
class MathObject : public JSNonFinalObject {
private:
MathObject(JSGlobalObject*, Structure*);
MathObject(VM&, Structure*);
public:
typedef JSNonFinalObject Base;
static MathObject* create(ExecState* exec, JSGlobalObject* globalObject, Structure* structure)
static MathObject* create(VM& vm, JSGlobalObject* globalObject, Structure* structure)
{
MathObject* object = new (NotNull, allocateCell<MathObject>(*exec->heap())) MathObject(globalObject, structure);
object->finishCreation(exec, globalObject);
MathObject* object = new (NotNull, allocateCell<MathObject>(vm.heap)) MathObject(vm, structure);
object->finishCreation(vm, globalObject);
return object;
}
......@@ -47,7 +47,7 @@ namespace JSC {
}
protected:
void finishCreation(ExecState*, JSGlobalObject*);
void finishCreation(VM&, JSGlobalObject*);
static const unsigned StructureFlags = OverridesGetOwnPropertySlot | JSObject::StructureFlags;
};
......
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