Move evalfunction and thrower onto the js stack
authorLars Knoll <lars.knoll@theqtcompany.com>
Wed, 25 Mar 2015 20:31:16 +0000 (21:31 +0100)
committerSimon Hausmann <simon.hausmann@theqtcompany.com>
Fri, 24 Apr 2015 15:21:43 +0000 (15:21 +0000)
Change-Id: I3a0abe13d802aff8998d1c64f86b5a8f98c8335f
Reviewed-by: Simon Hausmann <simon.hausmann@theqtcompany.com>
src/qml/jsruntime/qv4argumentsobject.cpp
src/qml/jsruntime/qv4engine.cpp
src/qml/jsruntime/qv4engine_p.h
src/qml/jsruntime/qv4functionobject.cpp
src/qml/jsruntime/qv4runtime.cpp

index d7a8127..69053f1 100644 (file)
@@ -56,10 +56,10 @@ Heap::ArgumentsObject::ArgumentsObject(QV4::CallContext *context)
     if (context->d()->strictMode) {
         Q_ASSERT(CalleePropertyIndex == args->internalClass()->find(context->d()->engine->id_callee));
         Q_ASSERT(CallerPropertyIndex == args->internalClass()->find(context->d()->engine->id_caller));
-        args->propertyAt(CalleePropertyIndex)->value = v4->thrower;
-        args->propertyAt(CalleePropertyIndex)->set = v4->thrower;
-        args->propertyAt(CallerPropertyIndex)->value = v4->thrower;
-        args->propertyAt(CallerPropertyIndex)->set = v4->thrower;
+        args->propertyAt(CalleePropertyIndex)->value = v4->thrower();
+        args->propertyAt(CalleePropertyIndex)->set = v4->thrower();
+        args->propertyAt(CallerPropertyIndex)->value = v4->thrower();
+        args->propertyAt(CallerPropertyIndex)->set = v4->thrower();
 
         args->arrayReserve(context->argc());
         args->arrayPut(0, context->args(), context->argc());
index a2edcbc..a7c9ff8 100644 (file)
@@ -427,8 +427,8 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory)
     globalObject->defineReadonlyProperty(QStringLiteral("Infinity"), Primitive::fromDouble(Q_INFINITY));
 
 
-    evalFunction = memoryManager->alloc<EvalFunction>(global);
-    globalObject->defineDefaultProperty(QStringLiteral("eval"), (o = evalFunction));
+    jsObjects[Eval_Function] = memoryManager->alloc<EvalFunction>(global);
+    globalObject->defineDefaultProperty(QStringLiteral("eval"), *evalFunction());
 
     globalObject->defineDefaultProperty(QStringLiteral("parseInt"), GlobalFunctions::method_parseInt, 2);
     globalObject->defineDefaultProperty(QStringLiteral("parseFloat"), GlobalFunctions::method_parseFloat, 1);
@@ -442,7 +442,7 @@ ExecutionEngine::ExecutionEngine(EvalISelFactory *factory)
     globalObject->defineDefaultProperty(QStringLiteral("unescape"), GlobalFunctions::method_unescape, 1);
 
     ScopedString name(scope, newString(QStringLiteral("thrower")));
-    thrower = BuiltinFunction::create(global, name, ::throwTypeError);
+    jsObjects[ThrowerObject] = BuiltinFunction::create(global, name, ::throwTypeError);
 }
 
 ExecutionEngine::~ExecutionEngine()
@@ -937,8 +937,6 @@ void ExecutionEngine::markObjects()
     for (int i = 0; i < Heap::TypedArray::NTypes; ++i)
         typedArrayCtors[i].mark(this);
 
-    thrower->mark(this);
-
     if (m_qmlExtensions)
         m_qmlExtensions->markObjects(this);
 
index e983e96..92376d5 100644 (file)
@@ -166,6 +166,9 @@ public:
         URIError_Ctor,
         ArrayBuffer_Ctor,
         DataView_Ctor,
+
+        Eval_Function,
+        ThrowerObject,
         NJSObjects
     };
     Value *jsObjects;
@@ -226,8 +229,8 @@ public:
     InternalClass *argumentsObjectClass;
     InternalClass *strictArgumentsObjectClass;
 
-    Heap::EvalFunction *evalFunction;
-    Heap::FunctionObject *thrower;
+    EvalFunction *evalFunction() const { return reinterpret_cast<EvalFunction *>(jsObjects + Eval_Function); }
+    FunctionObject *thrower() const { return reinterpret_cast<FunctionObject *>(jsObjects + ThrowerObject); }
 
     Property *argumentsAccessors;
     int nArgumentsAccessors;
index ca46176..27b7448 100644 (file)
@@ -489,8 +489,8 @@ Heap::SimpleScriptFunction::SimpleScriptFunction(QV4::ExecutionContext *scope, F
 
     if (scope->d()->strictMode) {
         ScopedProperty pd(s);
-        pd->value = s.engine->thrower;
-        pd->set = s.engine->thrower;
+        pd->value = s.engine->thrower();
+        pd->set = s.engine->thrower();
         f->insertMember(scope->d()->engine->id_caller, pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
         f->insertMember(scope->d()->engine->id_arguments, pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
     }
@@ -658,8 +658,8 @@ Heap::BoundFunction::BoundFunction(QV4::ExecutionContext *scope, QV4::FunctionOb
     f->defineReadonlyProperty(s.engine->id_length, Primitive::fromInt32(len));
 
     ScopedProperty pd(s);
-    pd->value = s.engine->thrower;
-    pd->set = s.engine->thrower;
+    pd->value = s.engine->thrower();
+    pd->set = s.engine->thrower();
     f->insertMember(s.engine->id_arguments, pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
     f->insertMember(s.engine->id_caller, pd, Attr_Accessor|Attr_NotConfigurable|Attr_NotEnumerable);
 }
index f2565e2..b04d404 100644 (file)
@@ -910,7 +910,7 @@ ReturnedValue Runtime::callGlobalLookup(ExecutionEngine *engine, uint index, Cal
         return engine->throwTypeError();
 
     ScopedString name(scope, engine->currentContext()->compilationUnit->runtimeStrings[l->nameIndex]);
-    if (o->d() == scope.engine->evalFunction && name->equals(scope.engine->id_eval))
+    if (o->d() == scope.engine->evalFunction()->d() && name->equals(scope.engine->id_eval))
         return static_cast<EvalFunction *>(o.getPointer())->evalCall(callData, true);
 
     return o->call(callData);
@@ -941,7 +941,7 @@ ReturnedValue Runtime::callActivationProperty(ExecutionEngine *engine, int nameI
         return engine->throwTypeError(msg);
     }
 
-    if (o->d() == scope.engine->evalFunction && name->equals(scope.engine->id_eval)) {
+    if (o->d() == scope.engine->evalFunction()->d() && name->equals(scope.engine->id_eval)) {
         return static_cast<EvalFunction *>(o)->evalCall(callData, true);
     }