aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime
diff options
context:
space:
mode:
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r--src/qml/jsruntime/qv4context.cpp15
-rw-r--r--src/qml/jsruntime/qv4context_p.h16
-rw-r--r--src/qml/jsruntime/qv4function.cpp2
-rw-r--r--src/qml/jsruntime/qv4function_p.h4
-rw-r--r--src/qml/jsruntime/qv4globalobject.cpp3
-rw-r--r--src/qml/jsruntime/qv4lookup.cpp14
-rw-r--r--src/qml/jsruntime/qv4object.cpp4
-rw-r--r--src/qml/jsruntime/qv4profiling_p.h4
-rw-r--r--src/qml/jsruntime/qv4qmlcontext.cpp4
-rw-r--r--src/qml/jsruntime/qv4runtime.cpp44
-rw-r--r--src/qml/jsruntime/qv4script.cpp4
-rw-r--r--src/qml/jsruntime/qv4script_p.h16
-rw-r--r--src/qml/jsruntime/qv4vme_moth.cpp28
-rw-r--r--src/qml/jsruntime/qv4vme_moth_p.h2
14 files changed, 66 insertions, 94 deletions
diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp
index 9fd05aad38..b1fb017f99 100644
--- a/src/qml/jsruntime/qv4context.cpp
+++ b/src/qml/jsruntime/qv4context.cpp
@@ -71,10 +71,6 @@ Heap::CallContext *ExecutionContext::newCallContext(Function *function, CallData
c->strictMode = function->isStrict();
c->outer.set(v4, this->d());
- c->compilationUnit = function->compilationUnit;
- c->lookups = function->compilationUnit->runtimeLookups;
- c->constantTable = function->compilationUnit->constants;
-
const CompiledData::Function *compiledFunction = function->compiledFunction;
uint nLocals = compiledFunction->nLocals;
c->locals.size = nLocals;
@@ -102,9 +98,7 @@ Heap::ExecutionContext *ExecutionContext::newWithContext(Heap::Object *with)
c->activation.set(engine(), with);
c->callData = d()->callData;
- c->lookups = d()->lookups;
- c->constantTable = d()->constantTable;
- c->compilationUnit = d()->compilationUnit;
+ c->v4Function = d()->v4Function;
return c;
}
@@ -167,9 +161,7 @@ void Heap::CatchContext::init(ExecutionContext *outerContext, String *exceptionV
outer.set(internalClass->engine, outerContext);
strictMode = outer->strictMode;
callData = outer->callData;
- lookups = outer->lookups;
- constantTable = outer->constantTable;
- compilationUnit = outer->compilationUnit;
+ v4Function = outer->v4Function;
this->exceptionVarName.set(internalClass->engine, exceptionVarName);
this->exceptionValue.set(internalClass->engine, exceptionValue);
@@ -267,9 +259,6 @@ void QV4::ExecutionContext::simpleCall(Scope &scope, CallData *callData, Functio
ctx->strictMode = function->isStrict();
ctx->callData = callData;
ctx->v4Function = function;
- ctx->compilationUnit = function->compilationUnit;
- ctx->lookups = function->compilationUnit->runtimeLookups;
- ctx->constantTable = function->compilationUnit->constants;
ctx->outer.set(scope.engine, this->d());
for (int i = callData->argc; i < (int)function->nFormals; ++i)
callData->args[i] = Encode::undefined();
diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h
index 916ead9d09..f565f57be8 100644
--- a/src/qml/jsruntime/qv4context_p.h
+++ b/src/qml/jsruntime/qv4context_p.h
@@ -105,10 +105,8 @@ struct QmlContext;
#define ExecutionContextMembers(class, Member) \
Member(class, NoMark, CallData *, callData) \
Member(class, Pointer, ExecutionContext *, outer) \
- Member(class, NoMark, Lookup *, lookups) \
- Member(class, NoMark, const QV4::Value *, constantTable) \
- Member(class, NoMark, CompiledData::CompilationUnitBase *, compilationUnit) \
Member(class, Pointer, Object *, activation) \
+ Member(class, NoMark, QV4::Function *, v4Function) \
Member(class, NoMark, int, lineNumber) // as member of non-pointer size this has to come last to preserve the ability to
// translate offsetof of it between 64-bit and 32-bit.
@@ -146,14 +144,11 @@ Q_STATIC_ASSERT(sizeof(ExecutionContext) == sizeof(Base) + sizeof(ExecutionConte
Q_STATIC_ASSERT(std::is_standard_layout<ExecutionContextData>::value);
Q_STATIC_ASSERT(offsetof(ExecutionContextData, callData) == 0);
Q_STATIC_ASSERT(offsetof(ExecutionContextData, outer) == offsetof(ExecutionContextData, callData) + QT_POINTER_SIZE);
-Q_STATIC_ASSERT(offsetof(ExecutionContextData, lookups) == offsetof(ExecutionContextData, outer) + QT_POINTER_SIZE);
-Q_STATIC_ASSERT(offsetof(ExecutionContextData, constantTable) == offsetof(ExecutionContextData, lookups) + QT_POINTER_SIZE);
-Q_STATIC_ASSERT(offsetof(ExecutionContextData, compilationUnit) == offsetof(ExecutionContextData, constantTable) + QT_POINTER_SIZE);
-Q_STATIC_ASSERT(offsetof(ExecutionContextData, activation) == offsetof(ExecutionContextData, compilationUnit) + QT_POINTER_SIZE);
-Q_STATIC_ASSERT(offsetof(ExecutionContextData, lineNumber) == offsetof(ExecutionContextData, activation) + QT_POINTER_SIZE);
+Q_STATIC_ASSERT(offsetof(ExecutionContextData, activation) == offsetof(ExecutionContextData, outer) + QT_POINTER_SIZE);
+Q_STATIC_ASSERT(offsetof(ExecutionContextData, v4Function) == offsetof(ExecutionContextData, activation) + QT_POINTER_SIZE);
+Q_STATIC_ASSERT(offsetof(ExecutionContextData, lineNumber) == offsetof(ExecutionContextData, v4Function) + QT_POINTER_SIZE);
#define CallContextMembers(class, Member) \
- Member(class, NoMark, QV4::Function *, v4Function) \
Member(class, Pointer, FunctionObject *, function) \
Member(class, ValueArray, ValueArray, locals)
@@ -170,8 +165,7 @@ DECLARE_HEAP_OBJECT(CallContext, ExecutionContext) {
};
V4_ASSERT_IS_TRIVIAL(CallContext)
Q_STATIC_ASSERT(std::is_standard_layout<CallContextData>::value);
-Q_STATIC_ASSERT(offsetof(CallContextData, v4Function) == 0);
-Q_STATIC_ASSERT(offsetof(CallContextData, function) == QT_POINTER_SIZE);
+Q_STATIC_ASSERT(offsetof(CallContextData, function) == 0);
Q_STATIC_ASSERT(offsetof(CallContextData, locals) == offsetof(CallContextData, function) + QT_POINTER_SIZE);
//### The following size check fails on Win8. With the ValueArray at the end of the
// CallContextMembers, it doesn't look very useful.
diff --git a/src/qml/jsruntime/qv4function.cpp b/src/qml/jsruntime/qv4function.cpp
index e2efded3b8..713ed589b7 100644
--- a/src/qml/jsruntime/qv4function.cpp
+++ b/src/qml/jsruntime/qv4function.cpp
@@ -50,7 +50,7 @@ QT_BEGIN_NAMESPACE
using namespace QV4;
Function::Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit, const CompiledData::Function *function,
- ReturnedValue (*codePtr)(ExecutionEngine *, const uchar *))
+ ReturnedValue (*codePtr)(Function *, ExecutionEngine *))
: compiledFunction(function)
, compilationUnit(unit)
, code(codePtr)
diff --git a/src/qml/jsruntime/qv4function_p.h b/src/qml/jsruntime/qv4function_p.h
index db651d2d0c..70561f28e8 100644
--- a/src/qml/jsruntime/qv4function_p.h
+++ b/src/qml/jsruntime/qv4function_p.h
@@ -63,7 +63,7 @@ struct Q_QML_EXPORT Function {
const CompiledData::Function *compiledFunction;
CompiledData::CompilationUnit *compilationUnit;
- ReturnedValue (*code)(ExecutionEngine *, const uchar *);
+ ReturnedValue (*code)(Function *, ExecutionEngine *);
const uchar *codeData;
// first nArguments names in internalClass are the actual arguments
@@ -73,7 +73,7 @@ struct Q_QML_EXPORT Function {
bool canUseSimpleCall;
Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit, const CompiledData::Function *function,
- ReturnedValue (*codePtr)(ExecutionEngine *, const uchar *));
+ ReturnedValue (*codePtr)(Function *, ExecutionEngine *));
~Function();
// used when dynamically assigning signal handlers (QQmlConnection)
diff --git a/src/qml/jsruntime/qv4globalobject.cpp b/src/qml/jsruntime/qv4globalobject.cpp
index c0f05d7a3d..ff395adb27 100644
--- a/src/qml/jsruntime/qv4globalobject.cpp
+++ b/src/qml/jsruntime/qv4globalobject.cpp
@@ -392,8 +392,7 @@ void EvalFunction::evalCall(Scope &scope, CallData *callData, bool directCall) c
// set the correct strict mode flag on the context
ctx->d()->strictMode = false;
- ctx->d()->compilationUnit = function->compilationUnit;
- ctx->d()->constantTable = function->compilationUnit->constants;
+ ctx->d()->v4Function = function;
scope.result = Q_V4_PROFILE(ctx->engine(), function);
}
diff --git a/src/qml/jsruntime/qv4lookup.cpp b/src/qml/jsruntime/qv4lookup.cpp
index d943ae1340..a576da0ea7 100644
--- a/src/qml/jsruntime/qv4lookup.cpp
+++ b/src/qml/jsruntime/qv4lookup.cpp
@@ -49,7 +49,7 @@ using namespace QV4;
ReturnedValue Lookup::lookup(const Value &thisObject, Object *o, PropertyAttributes *attrs)
{
ExecutionEngine *engine = o->engine();
- Identifier *name = engine->current->compilationUnit->runtimeStrings[nameIndex]->identifier;
+ Identifier *name = engine->current->v4Function->compilationUnit->runtimeStrings[nameIndex]->identifier;
int i = 0;
Heap::Object *obj = o->d();
while (i < Size && obj) {
@@ -85,7 +85,7 @@ ReturnedValue Lookup::lookup(const Object *thisObject, PropertyAttributes *attrs
{
Heap::Object *obj = thisObject->d();
ExecutionEngine *engine = thisObject->engine();
- Identifier *name = engine->current->compilationUnit->runtimeStrings[nameIndex]->identifier;
+ Identifier *name = engine->current->v4Function->compilationUnit->runtimeStrings[nameIndex]->identifier;
int i = 0;
while (i < Size && obj) {
classList[i] = obj->internalClass;
@@ -267,7 +267,7 @@ ReturnedValue Lookup::getterGeneric(Lookup *l, ExecutionEngine *engine, const Va
Q_ASSERT(object.isString());
proto = engine->stringPrototype();
Scope scope(engine);
- ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[l->nameIndex]);
+ ScopedString name(scope, engine->current->v4Function->compilationUnit->runtimeStrings[l->nameIndex]);
if (name->equals(engine->id_length())) {
// special case, as the property is on the object itself
l->getter = stringLengthGetter;
@@ -368,7 +368,7 @@ ReturnedValue Lookup::getterFallback(Lookup *l, ExecutionEngine *engine, const V
QV4::ScopedObject o(scope, object.toObject(scope.engine));
if (!o)
return Encode::undefined();
- ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[l->nameIndex]);
+ ScopedString name(scope, engine->current->v4Function->compilationUnit->runtimeStrings[l->nameIndex]);
return o->get(name);
}
@@ -719,7 +719,7 @@ ReturnedValue Lookup::globalGetterGeneric(Lookup *l, ExecutionEngine *engine)
}
}
Scope scope(engine);
- ScopedString n(scope, engine->current->compilationUnit->runtimeStrings[l->nameIndex]);
+ ScopedString n(scope, engine->current->v4Function->compilationUnit->runtimeStrings[l->nameIndex]);
return engine->throwReferenceError(n);
}
@@ -839,7 +839,7 @@ void Lookup::setterGeneric(Lookup *l, ExecutionEngine *engine, Value &object, co
o = RuntimeHelpers::convertToObject(scope.engine, object);
if (!o) // type error
return;
- ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[l->nameIndex]);
+ ScopedString name(scope, engine->current->v4Function->compilationUnit->runtimeStrings[l->nameIndex]);
o->put(name, value);
return;
}
@@ -870,7 +870,7 @@ void Lookup::setterFallback(Lookup *l, ExecutionEngine *engine, Value &object, c
QV4::Scope scope(engine);
QV4::ScopedObject o(scope, object.toObject(scope.engine));
if (o) {
- ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[l->nameIndex]);
+ ScopedString name(scope, engine->current->v4Function->compilationUnit->runtimeStrings[l->nameIndex]);
o->put(name, value);
}
}
diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp
index 963a3fe454..8032c11add 100644
--- a/src/qml/jsruntime/qv4object.cpp
+++ b/src/qml/jsruntime/qv4object.cpp
@@ -514,7 +514,7 @@ void Object::setLookup(Managed *m, Lookup *l, const Value &value)
{
Scope scope(static_cast<Object *>(m)->engine());
ScopedObject o(scope, static_cast<Object *>(m));
- ScopedString name(scope, scope.engine->current->compilationUnit->runtimeStrings[l->nameIndex]);
+ ScopedString name(scope, scope.engine->current->v4Function->compilationUnit->runtimeStrings[l->nameIndex]);
InternalClass *c = o->internalClass();
uint idx = c->find(name);
@@ -1258,7 +1258,7 @@ void Heap::ArrayObject::init(const QStringList &list)
ReturnedValue ArrayObject::getLookup(const Managed *m, Lookup *l)
{
Scope scope(static_cast<const Object *>(m)->engine());
- ScopedString name(scope, scope.engine->current->compilationUnit->runtimeStrings[l->nameIndex]);
+ ScopedString name(scope, scope.engine->current->v4Function->compilationUnit->runtimeStrings[l->nameIndex]);
if (name->equals(scope.engine->id_length())) {
// special case, as the property is on the object itself
l->getter = Lookup::arrayLengthGetter;
diff --git a/src/qml/jsruntime/qv4profiling_p.h b/src/qml/jsruntime/qv4profiling_p.h
index 9de597ad0e..71a6d34f9d 100644
--- a/src/qml/jsruntime/qv4profiling_p.h
+++ b/src/qml/jsruntime/qv4profiling_p.h
@@ -89,7 +89,7 @@ QT_END_NAMESPACE
(Q_UNLIKELY(engine->profiler()) &&\
(engine->profiler()->featuresEnabled & (1 << Profiling::FeatureFunctionCall)) ?\
Profiling::FunctionCallProfiler::profileCall(engine->profiler(), engine, function) :\
- function->code(engine, function->codeData))
+ function->code(function, engine))
QT_BEGIN_NAMESPACE
@@ -282,7 +282,7 @@ public:
static ReturnedValue profileCall(Profiler *profiler, ExecutionEngine *engine, Function *function)
{
FunctionCallProfiler callProfiler(profiler, function);
- return function->code(engine, function->codeData);
+ return function->code(function, engine);
}
Profiler *profiler;
diff --git a/src/qml/jsruntime/qv4qmlcontext.cpp b/src/qml/jsruntime/qv4qmlcontext.cpp
index 13243e1575..8c6d6f11fa 100644
--- a/src/qml/jsruntime/qv4qmlcontext.cpp
+++ b/src/qml/jsruntime/qv4qmlcontext.cpp
@@ -301,9 +301,7 @@ void Heap::QmlContext::init(QV4::ExecutionContext *outerContext, QV4::QQmlContex
outer.set(internalClass->engine, outerContext->d());
strictMode = false;
callData = outer->callData;
- lookups = outer->lookups;
- constantTable = outer->constantTable;
- compilationUnit = outer->compilationUnit;
+ v4Function = outer->v4Function;
this->activation.set(internalClass->engine, qml->d());
}
diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp
index b9ea73f6a8..cbe55fe080 100644
--- a/src/qml/jsruntime/qv4runtime.cpp
+++ b/src/qml/jsruntime/qv4runtime.cpp
@@ -308,7 +308,7 @@ void RuntimeHelpers::numberToString(QString *result, double num, int radix)
ReturnedValue Runtime::method_closure(ExecutionEngine *engine, int functionId)
{
- QV4::Function *clos = static_cast<CompiledData::CompilationUnit*>(engine->current->compilationUnit)->runtimeFunctions[functionId];
+ QV4::Function *clos = static_cast<CompiledData::CompilationUnit*>(engine->current->v4Function->compilationUnit)->runtimeFunctions[functionId];
Q_ASSERT(clos);
return FunctionObject::createScriptFunction(engine->currentContext, clos)->asReturnedValue();
}
@@ -331,7 +331,7 @@ ReturnedValue Runtime::method_deleteElement(ExecutionEngine *engine, const Value
ReturnedValue Runtime::method_deleteMember(ExecutionEngine *engine, const Value &base, int nameIndex)
{
Scope scope(engine);
- ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[nameIndex]);
+ ScopedString name(scope, engine->current->v4Function->compilationUnit->runtimeStrings[nameIndex]);
return method_deleteMemberString(engine, base, name);
}
@@ -347,7 +347,7 @@ ReturnedValue Runtime::method_deleteMemberString(ExecutionEngine *engine, const
ReturnedValue Runtime::method_deleteName(ExecutionEngine *engine, int nameIndex)
{
Scope scope(engine);
- ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[nameIndex]);
+ ScopedString name(scope, engine->current->v4Function->compilationUnit->runtimeStrings[nameIndex]);
return Encode(engine->currentContext->deleteProperty(name));
}
@@ -592,7 +592,7 @@ QV4::ReturnedValue Runtime::method_addString(ExecutionEngine *engine, const Valu
void Runtime::method_setProperty(ExecutionEngine *engine, const Value &object, int nameIndex, const Value &value)
{
Scope scope(engine);
- ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[nameIndex]);
+ ScopedString name(scope, engine->current->v4Function->compilationUnit->runtimeStrings[nameIndex]);
ScopedObject o(scope, object.toObject(engine));
if (!o)
return;
@@ -743,14 +743,14 @@ ReturnedValue Runtime::method_foreachNextPropertyName(const Value &foreach_itera
void Runtime::method_setActivationProperty(ExecutionEngine *engine, int nameIndex, const Value &value)
{
Scope scope(engine);
- ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[nameIndex]);
+ ScopedString name(scope, engine->current->v4Function->compilationUnit->runtimeStrings[nameIndex]);
engine->currentContext->setProperty(name, value);
}
ReturnedValue Runtime::method_getProperty(ExecutionEngine *engine, const Value &object, int nameIndex)
{
Scope scope(engine);
- ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[nameIndex]);
+ ScopedString name(scope, engine->current->v4Function->compilationUnit->runtimeStrings[nameIndex]);
ScopedObject o(scope, object);
if (o)
@@ -770,7 +770,7 @@ ReturnedValue Runtime::method_getProperty(ExecutionEngine *engine, const Value &
ReturnedValue Runtime::method_getActivationProperty(ExecutionEngine *engine, int nameIndex)
{
Scope scope(engine);
- ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[nameIndex]);
+ ScopedString name(scope, engine->current->v4Function->compilationUnit->runtimeStrings[nameIndex]);
return engine->currentContext->getProperty(name);
}
@@ -1005,12 +1005,12 @@ ReturnedValue Runtime::method_callGlobalLookup(ExecutionEngine *engine, uint ind
Scope scope(engine);
Q_ASSERT(callData->thisObject.isUndefined());
- Lookup *l = engine->current->lookups + index;
+ Lookup *l = engine->current->v4Function->compilationUnit->runtimeLookups + index;
ScopedFunctionObject o(scope, l->globalGetter(l, engine));
if (!o)
return engine->throwTypeError();
- ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[l->nameIndex]);
+ ScopedString name(scope, engine->current->v4Function->compilationUnit->runtimeStrings[l->nameIndex]);
if (o->d() == scope.engine->evalFunction()->d() && name->equals(scope.engine->id_eval())) {
static_cast<EvalFunction *>(o.getPointer())->evalCall(scope, callData, true);
} else {
@@ -1025,7 +1025,7 @@ ReturnedValue Runtime::method_callActivationProperty(ExecutionEngine *engine, in
{
Q_ASSERT(callData->thisObject.isUndefined());
Scope scope(engine);
- ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[nameIndex]);
+ ScopedString name(scope, engine->current->v4Function->compilationUnit->runtimeStrings[nameIndex]);
ScopedObject base(scope);
ScopedValue func(scope, engine->currentContext->getPropertyAndBase(name, base.getRef()));
@@ -1056,7 +1056,7 @@ ReturnedValue Runtime::method_callActivationProperty(ExecutionEngine *engine, in
ReturnedValue Runtime::method_callProperty(ExecutionEngine *engine, int nameIndex, CallData *callData)
{
Scope scope(engine);
- ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[nameIndex]);
+ ScopedString name(scope, engine->current->v4Function->compilationUnit->runtimeStrings[nameIndex]);
ScopedObject baseObject(scope, callData->thisObject);
if (!baseObject) {
Q_ASSERT(!callData->thisObject.isEmpty());
@@ -1084,7 +1084,7 @@ ReturnedValue Runtime::method_callProperty(ExecutionEngine *engine, int nameInde
ReturnedValue Runtime::method_callPropertyLookup(ExecutionEngine *engine, uint index, CallData *callData)
{
- Lookup *l = engine->current->lookups + index;
+ Lookup *l = engine->current->v4Function->compilationUnit->runtimeLookups + index;
Value v;
v = l->getter(l, engine, callData->thisObject);
Object *o = v.objectValue();
@@ -1130,7 +1130,7 @@ ReturnedValue Runtime::method_constructGlobalLookup(ExecutionEngine *engine, uin
Scope scope(engine);
Q_ASSERT(callData->thisObject.isUndefined());
- Lookup *l = engine->current->lookups + index;
+ Lookup *l = engine->current->v4Function->compilationUnit->runtimeLookups + index;
ScopedObject f(scope, l->globalGetter(l, engine));
if (f) {
f->construct(scope, callData);
@@ -1144,7 +1144,7 @@ ReturnedValue Runtime::method_constructGlobalLookup(ExecutionEngine *engine, uin
ReturnedValue Runtime::method_constructActivationProperty(ExecutionEngine *engine, int nameIndex, CallData *callData)
{
Scope scope(engine);
- ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[nameIndex]);
+ ScopedString name(scope, engine->current->v4Function->compilationUnit->runtimeStrings[nameIndex]);
ScopedValue func(scope, engine->currentContext->getProperty(name));
if (scope.engine->hasException)
return Encode::undefined();
@@ -1172,7 +1172,7 @@ ReturnedValue Runtime::method_constructProperty(ExecutionEngine *engine, int nam
{
Scope scope(engine);
ScopedObject thisObject(scope, callData->thisObject.toObject(engine));
- ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[nameIndex]);
+ ScopedString name(scope, engine->current->v4Function->compilationUnit->runtimeStrings[nameIndex]);
if (scope.engine->hasException)
return Encode::undefined();
@@ -1188,7 +1188,7 @@ ReturnedValue Runtime::method_constructProperty(ExecutionEngine *engine, int nam
ReturnedValue Runtime::method_constructPropertyLookup(ExecutionEngine *engine, uint index, CallData *callData)
{
- Lookup *l = engine->current->lookups + index;
+ Lookup *l = engine->current->v4Function->compilationUnit->runtimeLookups + index;
Value v;
v = l->getter(l, engine, callData->thisObject);
Object *o = v.objectValue();
@@ -1239,7 +1239,7 @@ ReturnedValue Runtime::method_typeofValue(ExecutionEngine *engine, const Value &
QV4::ReturnedValue Runtime::method_typeofName(ExecutionEngine *engine, int nameIndex)
{
Scope scope(engine);
- ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[nameIndex]);
+ ScopedString name(scope, engine->current->v4Function->compilationUnit->runtimeStrings[nameIndex]);
ScopedValue prop(scope, engine->currentContext->getProperty(name));
// typeof doesn't throw. clear any possible exception
scope.engine->hasException = false;
@@ -1271,7 +1271,7 @@ void Runtime::method_pushCatchScope(NoThrowEngine *engine, int exceptionVarNameI
{
engine->jsAlloca(1); // keep this symmetric with pushWithScope
ExecutionContext *c = engine->currentContext;
- engine->pushContext(c->newCatchContext(c->d()->compilationUnit->runtimeStrings[exceptionVarNameIndex], engine->catchException(0)));
+ engine->pushContext(c->newCatchContext(engine->current->v4Function->compilationUnit->runtimeStrings[exceptionVarNameIndex], engine->catchException(0)));
Q_ASSERT(engine->jsStackTop == engine->currentContext + 2);
}
@@ -1285,7 +1285,7 @@ void Runtime::method_popScope(NoThrowEngine *engine)
void Runtime::method_declareVar(ExecutionEngine *engine, bool deletable, int nameIndex)
{
Scope scope(engine);
- ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[nameIndex]);
+ ScopedString name(scope, engine->current->v4Function->compilationUnit->runtimeStrings[nameIndex]);
engine->currentContext->createMutableBinding(name, deletable);
}
@@ -1297,7 +1297,7 @@ ReturnedValue Runtime::method_arrayLiteral(ExecutionEngine *engine, Value *value
ReturnedValue Runtime::method_objectLiteral(ExecutionEngine *engine, const QV4::Value *args, int classId, int arrayValueCount, int arrayGetterSetterCountAndFlags)
{
Scope scope(engine);
- QV4::InternalClass *klass = static_cast<CompiledData::CompilationUnit*>(engine->current->compilationUnit)->runtimeClasses[classId];
+ QV4::InternalClass *klass = static_cast<CompiledData::CompilationUnit*>(engine->current->v4Function->compilationUnit)->runtimeClasses[classId];
ScopedObject o(scope, engine->newObject(klass, engine->objectPrototype()));
{
@@ -1409,7 +1409,7 @@ ReturnedValue Runtime::method_getQmlContext(NoThrowEngine *engine)
ReturnedValue Runtime::method_regexpLiteral(ExecutionEngine *engine, int id)
{
- return static_cast<CompiledData::CompilationUnit*>(engine->current->compilationUnit)->runtimeRegularExpressions[id].asReturnedValue();
+ return static_cast<CompiledData::CompilationUnit*>(engine->current->v4Function->compilationUnit)->runtimeRegularExpressions[id].asReturnedValue();
}
ReturnedValue Runtime::method_getQmlScopeObjectProperty(ExecutionEngine *engine, const Value &context, int propertyIndex, bool captureRequired)
@@ -1462,7 +1462,7 @@ ReturnedValue Runtime::method_getQmlImportedScripts(NoThrowEngine *engine)
QV4::ReturnedValue Runtime::method_getQmlSingleton(QV4::NoThrowEngine *engine, int nameIndex)
{
Scope scope(engine);
- ScopedString name(scope, engine->current->compilationUnit->runtimeStrings[nameIndex]);
+ ScopedString name(scope, engine->current->v4Function->compilationUnit->runtimeStrings[nameIndex]);
return engine->qmlSingletonWrapper(name);
}
diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp
index 30cc4c664c..7868b1a7d2 100644
--- a/src/qml/jsruntime/qv4script.cpp
+++ b/src/qml/jsruntime/qv4script.cpp
@@ -151,9 +151,7 @@ ReturnedValue Script::run()
ExecutionContextSaver ctxSaver(valueScope);
ContextStateSaver stateSaver(valueScope, scope);
scope->d()->strictMode = vmFunction->isStrict();
- scope->d()->lookups = vmFunction->compilationUnit->runtimeLookups;
- scope->d()->constantTable = vmFunction->compilationUnit->constants;
- scope->d()->compilationUnit = vmFunction->compilationUnit;
+ scope->d()->v4Function = vmFunction;
return Q_V4_PROFILE(engine, vmFunction);
} else {
diff --git a/src/qml/jsruntime/qv4script_p.h b/src/qml/jsruntime/qv4script_p.h
index 75045dda9c..ef48dde6db 100644
--- a/src/qml/jsruntime/qv4script_p.h
+++ b/src/qml/jsruntime/qv4script_p.h
@@ -66,17 +66,13 @@ namespace QV4 {
struct ContextStateSaver {
Value *savedContext;
bool strictMode;
- Lookup *lookups;
- const QV4::Value *constantTable;
- CompiledData::CompilationUnitBase *compilationUnit;
+ QV4::Function *v4Function;
int lineNumber;
ContextStateSaver(const Scope &scope, ExecutionContext *context)
: savedContext(scope.alloc(1))
, strictMode(context->d()->strictMode)
- , lookups(context->d()->lookups)
- , constantTable(context->d()->constantTable)
- , compilationUnit(context->d()->compilationUnit)
+ , v4Function(context->d()->v4Function)
, lineNumber(context->d()->lineNumber)
{
savedContext->setM(context->d());
@@ -84,9 +80,7 @@ struct ContextStateSaver {
ContextStateSaver(const Scope &scope, Heap::ExecutionContext *context)
: savedContext(scope.alloc(1))
, strictMode(context->strictMode)
- , lookups(context->lookups)
- , constantTable(context->constantTable)
- , compilationUnit(context->compilationUnit)
+ , v4Function(context->v4Function)
, lineNumber(context->lineNumber)
{
savedContext->setM(context);
@@ -96,9 +90,7 @@ struct ContextStateSaver {
{
Heap::ExecutionContext *ctx = static_cast<Heap::ExecutionContext *>(savedContext->m());
ctx->strictMode = strictMode;
- ctx->lookups = lookups;
- ctx->constantTable = constantTable;
- ctx->compilationUnit = compilationUnit;
+ ctx->v4Function = v4Function;
ctx->lineNumber = lineNumber;
}
};
diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp
index 53f02fa990..85def98492 100644
--- a/src/qml/jsruntime/qv4vme_moth.cpp
+++ b/src/qml/jsruntime/qv4vme_moth.cpp
@@ -414,12 +414,12 @@ static inline void storeArg(ExecutionEngine *engine, QV4::Heap::ExecutionContext
*slot = value;
}
-static inline const QV4::Value &constant(ExecutionEngine *engine, int index)
+static inline const QV4::Value &constant(Function *function, int index)
{
- return engine->current->constantTable[index];
+ return function->compilationUnit->constants[index];
}
-QV4::ReturnedValue VME::exec(ExecutionEngine *engine, const uchar *code)
+QV4::ReturnedValue VME::exec(Function *function, ExecutionEngine *engine)
{
#ifdef DO_TRACE_INSTR
qDebug("Starting VME with context=%p and code=%p", context, code);
@@ -469,6 +469,8 @@ QV4::ReturnedValue VME::exec(ExecutionEngine *engine, const uchar *code)
if (QV4::Debugging::Debugger *debugger = engine->debugger())
debugger->enteringFunction();
+ const uchar *code = function->codeData;
+
for (;;) {
const Instr *genericInstr = reinterpret_cast<const Instr *>(code);
#ifdef MOTH_THREADED_INTERPRETER
@@ -478,11 +480,11 @@ QV4::ReturnedValue VME::exec(ExecutionEngine *engine, const uchar *code)
#endif
MOTH_BEGIN_INSTR(LoadConst)
- accumulator = constant(engine, instr.index);
+ accumulator = constant(function, instr.index);
MOTH_END_INSTR(LoadConst)
MOTH_BEGIN_INSTR(MoveConst)
- TEMP_VALUE(instr.destTemp) = constant(engine, instr.constIndex);
+ TEMP_VALUE(instr.destTemp) = constant(function, instr.constIndex);
MOTH_END_INSTR(MoveConst)
MOTH_BEGIN_INSTR(LoadReg)
@@ -551,11 +553,11 @@ QV4::ReturnedValue VME::exec(ExecutionEngine *engine, const uchar *code)
MOTH_END_INSTR(StoreScopedArg)
MOTH_BEGIN_INSTR(LoadRuntimeString)
- accumulator = engine->current->compilationUnit->runtimeStrings[instr.stringId];
+ accumulator = function->compilationUnit->runtimeStrings[instr.stringId];
MOTH_END_INSTR(LoadRuntimeString)
MOTH_BEGIN_INSTR(LoadRegExp)
- accumulator = static_cast<CompiledData::CompilationUnit*>(engine->current->compilationUnit)->runtimeRegularExpressions[instr.regExpId];
+ accumulator = function->compilationUnit->runtimeRegularExpressions[instr.regExpId];
MOTH_END_INSTR(LoadRegExp)
MOTH_BEGIN_INSTR(LoadClosure)
@@ -567,7 +569,7 @@ QV4::ReturnedValue VME::exec(ExecutionEngine *engine, const uchar *code)
MOTH_END_INSTR(LoadName)
MOTH_BEGIN_INSTR(GetGlobalLookup)
- QV4::Lookup *l = engine->current->lookups + instr.index;
+ QV4::Lookup *l = function->compilationUnit->runtimeLookups + instr.index;
STORE_ACCUMULATOR(l->globalGetter(l, engine));
MOTH_END_INSTR(GetGlobalLookup)
@@ -585,7 +587,7 @@ QV4::ReturnedValue VME::exec(ExecutionEngine *engine, const uchar *code)
MOTH_END_INSTR(LoadElementA)
MOTH_BEGIN_INSTR(LoadElementLookup)
- QV4::Lookup *l = engine->current->lookups + instr.lookup;
+ QV4::Lookup *l = function->compilationUnit->runtimeLookups + instr.lookup;
STORE_ACCUMULATOR(l->indexedGetter(l, engine, TEMP_VALUE(instr.base), TEMP_VALUE(instr.index)));
MOTH_END_INSTR(LoadElementLookup)
@@ -595,7 +597,7 @@ QV4::ReturnedValue VME::exec(ExecutionEngine *engine, const uchar *code)
MOTH_END_INSTR(StoreElement)
MOTH_BEGIN_INSTR(StoreElementLookup)
- QV4::Lookup *l = engine->current->lookups + instr.lookup;
+ QV4::Lookup *l = function->compilationUnit->runtimeLookups + instr.lookup;
l->indexedSetter(l, engine, TEMP_VALUE(instr.base), TEMP_VALUE(instr.index), accumulator);
CHECK_EXCEPTION;
MOTH_END_INSTR(StoreElementLookup)
@@ -609,12 +611,12 @@ QV4::ReturnedValue VME::exec(ExecutionEngine *engine, const uchar *code)
MOTH_END_INSTR(LoadPropertyA)
MOTH_BEGIN_INSTR(GetLookup)
- QV4::Lookup *l = engine->current->lookups + instr.index;
+ QV4::Lookup *l = function->compilationUnit->runtimeLookups + instr.index;
STORE_ACCUMULATOR(l->getter(l, engine, TEMP_VALUE(instr.base)));
MOTH_END_INSTR(GetLookup)
MOTH_BEGIN_INSTR(GetLookupA)
- QV4::Lookup *l = engine->current->lookups + instr.index;
+ QV4::Lookup *l = function->compilationUnit->runtimeLookups + instr.index;
STORE_ACCUMULATOR(l->getter(l, engine, accumulator));
MOTH_END_INSTR(GetLookupA)
@@ -624,7 +626,7 @@ QV4::ReturnedValue VME::exec(ExecutionEngine *engine, const uchar *code)
MOTH_END_INSTR(StoreProperty)
MOTH_BEGIN_INSTR(SetLookup)
- QV4::Lookup *l = engine->current->lookups + instr.index;
+ QV4::Lookup *l = function->compilationUnit->runtimeLookups + instr.index;
l->setter(l, engine, TEMP_VALUE(instr.base), accumulator);
CHECK_EXCEPTION;
MOTH_END_INSTR(SetLookup)
diff --git a/src/qml/jsruntime/qv4vme_moth_p.h b/src/qml/jsruntime/qv4vme_moth_p.h
index 8692eabe79..4e42ca6fde 100644
--- a/src/qml/jsruntime/qv4vme_moth_p.h
+++ b/src/qml/jsruntime/qv4vme_moth_p.h
@@ -65,7 +65,7 @@ namespace Moth {
class VME
{
public:
- static QV4::ReturnedValue exec(QV4::ExecutionEngine *, const uchar *);
+ static QV4::ReturnedValue exec(QV4::Function *, QV4::ExecutionEngine *);
};
} // namespace Moth