aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-08-13 19:43:24 +0200
committerErik Verbruggen <erik.verbruggen@qt.io>2017-08-18 10:02:28 +0000
commit8437954c1ca0e019831423dcc5847f45cd7368ad (patch)
treef1d51cb94796e2632a4191f1152ebbdb9727d3fa /src/qml/jsruntime
parent661f9203c411b080fce6abf606ec8fb5c17a6bfe (diff)
Get rid of CallData in the ExecutionContext
Part 1, where the callData member is moved to CallContext. We'll get rid of it there in a subsequent commit. Change-Id: I6218992802133913f7766ebb3d2f47bd29f33907 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r--src/qml/jsruntime/qv4context.cpp2
-rw-r--r--src/qml/jsruntime/qv4context_p.h37
-rw-r--r--src/qml/jsruntime/qv4engine.cpp9
-rw-r--r--src/qml/jsruntime/qv4qmlcontext.cpp1
4 files changed, 17 insertions, 32 deletions
diff --git a/src/qml/jsruntime/qv4context.cpp b/src/qml/jsruntime/qv4context.cpp
index 96f668f168..fbcfcc3460 100644
--- a/src/qml/jsruntime/qv4context.cpp
+++ b/src/qml/jsruntime/qv4context.cpp
@@ -95,7 +95,6 @@ Heap::ExecutionContext *ExecutionContext::newWithContext(Heap::Object *with)
c->outer.set(engine(), d());
c->activation.set(engine(), with);
- c->callData = d()->callData;
c->v4Function = d()->v4Function;
return c;
@@ -156,7 +155,6 @@ void Heap::CatchContext::init(ExecutionContext *outerContext, String *exceptionV
{
Heap::ExecutionContext::init(Heap::ExecutionContext::Type_CatchContext);
outer.set(internalClass->engine, outerContext);
- callData = outer->callData;
v4Function = outer->v4Function;
this->exceptionVarName.set(internalClass->engine, exceptionVarName);
diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h
index d93511ba00..dfe0645f9d 100644
--- a/src/qml/jsruntime/qv4context_p.h
+++ b/src/qml/jsruntime/qv4context_p.h
@@ -103,7 +103,6 @@ namespace Heap {
struct QmlContext;
#define ExecutionContextMembers(class, Member) \
- Member(class, NoMark, CallData *, callData) \
Member(class, Pointer, ExecutionContext *, outer) \
Member(class, Pointer, Object *, activation) \
Member(class, NoMark, QV4::Function *, v4Function) \
@@ -137,12 +136,12 @@ V4_ASSERT_IS_TRIVIAL(ExecutionContext)
Q_STATIC_ASSERT(sizeof(ExecutionContext) == sizeof(Base) + sizeof(ExecutionContextData) + QT_POINTER_SIZE);
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, outer) == 0);
Q_STATIC_ASSERT(offsetof(ExecutionContextData, activation) == offsetof(ExecutionContextData, outer) + QT_POINTER_SIZE);
Q_STATIC_ASSERT(offsetof(ExecutionContextData, v4Function) == offsetof(ExecutionContextData, activation) + QT_POINTER_SIZE);
#define CallContextMembers(class, Member) \
+ Member(class, NoMark, CallData *, callData) \
Member(class, Pointer, FunctionObject *, function) \
Member(class, ValueArray, ValueArray, locals)
@@ -159,7 +158,8 @@ DECLARE_HEAP_OBJECT(CallContext, ExecutionContext) {
};
V4_ASSERT_IS_TRIVIAL(CallContext)
Q_STATIC_ASSERT(std::is_standard_layout<CallContextData>::value);
-Q_STATIC_ASSERT(offsetof(CallContextData, function) == 0);
+Q_STATIC_ASSERT(offsetof(CallContextData, callData) == 0);
+Q_STATIC_ASSERT(offsetof(CallContextData, function) == offsetof(CallContextData, callData) + QT_POINTER_SIZE);
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.
@@ -215,18 +215,6 @@ struct Q_QML_EXPORT ExecutionContext : public Managed
Function *getFunction() const;
- Value &thisObject() const {
- return d()->callData->thisObject;
- }
- int argc() const {
- return d()->callData->argc;
- }
- const Value *args() const {
- return d()->callData->args;
- }
- ReturnedValue argument(int i) const {
- return d()->callData->argument(i);
- }
};
struct Q_QML_EXPORT CallContext : public ExecutionContext
@@ -240,13 +228,20 @@ struct Q_QML_EXPORT CallContext : public ExecutionContext
Identifier * const *variables() const;
unsigned int variableCount() const;
- inline ReturnedValue argument(int i) const;
+ Value &thisObject() const {
+ return d()->callData->thisObject;
+ }
+ int argc() const {
+ return d()->callData->argc;
+ }
+ const Value *args() const {
+ return d()->callData->args;
+ }
+ ReturnedValue argument(int i) const {
+ return d()->callData->argument(i);
+ }
};
-inline ReturnedValue CallContext::argument(int i) const {
- return i < argc() ? args()[i].asReturnedValue() : Primitive::undefinedValue().asReturnedValue();
-}
-
struct CatchContext : public ExecutionContext
{
V4_MANAGED(CatchContext, ExecutionContext)
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp
index 8de733c26a..50c82e677a 100644
--- a/src/qml/jsruntime/qv4engine.cpp
+++ b/src/qml/jsruntime/qv4engine.cpp
@@ -399,7 +399,6 @@ ExecutionEngine::ExecutionEngine()
// set up the global object
//
rootContext()->d()->activation.set(scope.engine, globalObject->d());
- rootContext()->d()->callData->thisObject = globalObject;
Q_ASSERT(globalObject->d()->vtable());
globalObject->defineDefaultProperty(QStringLiteral("Object"), *objectCtor());
@@ -516,15 +515,9 @@ void ExecutionEngine::setProfiler(Profiling::Profiler *profiler)
void ExecutionEngine::initRootContext()
{
Scope scope(this);
- Scoped<ExecutionContext> r(scope, memoryManager->allocManaged<ExecutionContext>(
- sizeof(ExecutionContext::Data) + sizeof(CallData)));
+ Scoped<ExecutionContext> r(scope, memoryManager->allocManaged<ExecutionContext>(sizeof(ExecutionContext::Data)));
r->d_unchecked()->init(Heap::ExecutionContext::Type_GlobalContext);
r->d()->activation.set(this, globalObject->d());
- r->d()->callData = reinterpret_cast<CallData *>(r->d() + 1);
- r->d()->callData->tag = quint32(Value::ValueTypeInternal::Integer);
- r->d()->callData->argc = 0;
- r->d()->callData->thisObject = globalObject;
- r->d()->callData->args[0] = Encode::undefined();
jsObjects[RootContext] = r;
jsObjects[IntegerNull] = Encode((int)0);
}
diff --git a/src/qml/jsruntime/qv4qmlcontext.cpp b/src/qml/jsruntime/qv4qmlcontext.cpp
index 88bea8156f..70723a97ed 100644
--- a/src/qml/jsruntime/qv4qmlcontext.cpp
+++ b/src/qml/jsruntime/qv4qmlcontext.cpp
@@ -299,7 +299,6 @@ void Heap::QmlContext::init(QV4::ExecutionContext *outerContext, QV4::QQmlContex
{
Heap::ExecutionContext::init(Heap::ExecutionContext::Type_QmlContext);
outer.set(internalClass->engine, outerContext->d());
- callData = outer->callData;
v4Function = outer->v4Function;
this->activation.set(internalClass->engine, qml->d());