aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4context_p.h
diff options
context:
space:
mode:
authorLars Knoll <lars.knoll@qt.io>2017-08-13 22:34:05 +0200
committerErik Verbruggen <erik.verbruggen@qt.io>2017-08-18 10:05:51 +0000
commitaf5adb9e32713edb7196f761bcabd19f35722c57 (patch)
treef5c1f9d4e70c6bc9f9c7bb77d2d7be60797b668a /src/qml/jsruntime/qv4context_p.h
parent456632225f3173d401c68e301fb6d38f6c42e493 (diff)
Cleanup argument handling in contexts
Fix the compiler to already deal with duplicated argument names. Doing this at runtime was not ideal. Remove the callData member from the context. Instead use the fact that the arguments already followed the locals in the context. Don't copy the thisObject over into the CallContext anymore, it's never used from there anyway. Fix the ordering of names in the internalclass, so that arguments don't require special handling anymore when looking them up by name. Adjust all places that used callData, and related methods. Change-Id: I0bc45e1be3f1fcd38dc3b4f04e91edaf7b9ed103 Reviewed-by: Erik Verbruggen <erik.verbruggen@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4context_p.h')
-rw-r--r--src/qml/jsruntime/qv4context_p.h36
1 files changed, 14 insertions, 22 deletions
diff --git a/src/qml/jsruntime/qv4context_p.h b/src/qml/jsruntime/qv4context_p.h
index dfe0645f9d..57ba29c228 100644
--- a/src/qml/jsruntime/qv4context_p.h
+++ b/src/qml/jsruntime/qv4context_p.h
@@ -125,11 +125,10 @@ DECLARE_HEAP_OBJECT(ExecutionContext, Base) {
type = t;
}
- quint8 type;
+ quint32 type : 8;
+ quint32 nArgs : 24;
#if QT_POINTER_SIZE == 8
- quint8 padding_[7];
-#else
- quint8 padding_[3];
+ quint8 padding_[4];
#endif
};
V4_ASSERT_IS_TRIVIAL(ExecutionContext)
@@ -141,7 +140,6 @@ Q_STATIC_ASSERT(offsetof(ExecutionContextData, activation) == offsetof(Execution
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)
@@ -153,13 +151,19 @@ DECLARE_HEAP_OBJECT(CallContext, ExecutionContext) {
ExecutionContext::init(Type_CallContext);
}
- inline unsigned int formalParameterCount() const;
+ int argc() const {
+ return static_cast<int>(nArgs);
+ }
+ const Value *args() const {
+ return &locals[locals.size];
+ }
+ void setArg(uint index, Value v);
+ inline unsigned int formalParameterCount() const;
};
V4_ASSERT_IS_TRIVIAL(CallContext)
Q_STATIC_ASSERT(std::is_standard_layout<CallContextData>::value);
-Q_STATIC_ASSERT(offsetof(CallContextData, callData) == 0);
-Q_STATIC_ASSERT(offsetof(CallContextData, function) == offsetof(CallContextData, callData) + 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.
@@ -222,23 +226,11 @@ struct Q_QML_EXPORT CallContext : public ExecutionContext
V4_MANAGED(CallContext, ExecutionContext)
V4_INTERNALCLASS(CallContext)
- // formals are in reverse order
- Identifier * const *formals() const;
- unsigned int formalCount() const;
- Identifier * const *variables() const;
- unsigned int variableCount() const;
-
- Value &thisObject() const {
- return d()->callData->thisObject;
- }
int argc() const {
- return d()->callData->argc;
+ return d()->argc();
}
const Value *args() const {
- return d()->callData->args;
- }
- ReturnedValue argument(int i) const {
- return d()->callData->argument(i);
+ return d()->args();
}
};