diff options
author | Erik Verbruggen <erik.verbruggen@qt.io> | 2016-06-22 10:12:13 +0200 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@qt.io> | 2016-06-22 11:07:05 +0000 |
commit | 702c4247d74ffb7e4fb1aaca96d70f4591203ba2 (patch) | |
tree | 6c0a41332cf4a8ab0051600efdd27b0746574795 /src/qml/jsruntime/qv4functionobject_p.h | |
parent | fd0e3c6d569a7410fff33974ce9f908dc2de0e22 (diff) |
V4: Pass scope around as parameters inside the runtime.
The implementation of many (or all) runtime functions consist of first
creating a QV4::Scope, which saves and restores the JS stack pointer.
It also prevents tail-calls because of that restoring behavior. In many
cases it suffices to do that at the entry-point of the runtime.
The return value of a JS function call is now also stored in the scope.
Previously, all return values were stored in a ScopedValue, got loaded
on return, and immediately stored in another ScopedValue in the caller.
This resulted in a lot of stores, where now there is only one store
needed, and no extra ScopedValue for every function.
Change-Id: I13d80fc0ce72c5702ef1536d41d12f710c5914fa
Reviewed-by: Simon Hausmann <simon.hausmann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4functionobject_p.h')
-rw-r--r-- | src/qml/jsruntime/qv4functionobject_p.h | 28 |
1 files changed, 13 insertions, 15 deletions
diff --git a/src/qml/jsruntime/qv4functionobject_p.h b/src/qml/jsruntime/qv4functionobject_p.h index 4a4545eca4..be80b87873 100644 --- a/src/qml/jsruntime/qv4functionobject_p.h +++ b/src/qml/jsruntime/qv4functionobject_p.h @@ -145,8 +145,6 @@ struct Q_QML_EXPORT FunctionObject: Object { void init(String *name, bool createProto); - ReturnedValue newInstance(); - using Object::construct; using Object::call; static ReturnedValue construct(const Managed *that, CallData *); @@ -178,8 +176,8 @@ struct FunctionCtor: FunctionObject { V4_OBJECT2(FunctionCtor, FunctionObject) - static ReturnedValue construct(const Managed *that, CallData *callData); - static ReturnedValue call(const Managed *that, CallData *callData); + static void construct(const Managed *that, Scope &scope, CallData *callData); + static void call(const Managed *that, Scope &scope, CallData *callData); }; struct FunctionPrototype: FunctionObject @@ -202,20 +200,20 @@ struct Q_QML_EXPORT BuiltinFunction: FunctionObject { return scope->engine()->memoryManager->allocObject<BuiltinFunction>(scope, name, code); } - static ReturnedValue construct(const Managed *, CallData *); - static ReturnedValue call(const Managed *that, CallData *callData); + static void construct(const Managed *, Scope &scope, CallData *); + static void call(const Managed *that, Scope &scope, CallData *callData); }; struct IndexedBuiltinFunction: FunctionObject { V4_OBJECT2(IndexedBuiltinFunction, FunctionObject) - static ReturnedValue construct(const Managed *m, CallData *) + static void construct(const Managed *m, Scope &scope, CallData *) { - return static_cast<const IndexedBuiltinFunction *>(m)->engine()->throwTypeError(); + scope.result = static_cast<const IndexedBuiltinFunction *>(m)->engine()->throwTypeError(); } - static ReturnedValue call(const Managed *that, CallData *callData); + static void call(const Managed *that, Scope &scope, CallData *callData); }; Heap::IndexedBuiltinFunction::IndexedBuiltinFunction(QV4::ExecutionContext *scope, uint index, @@ -231,8 +229,8 @@ struct SimpleScriptFunction: FunctionObject { V4_OBJECT2(SimpleScriptFunction, FunctionObject) V4_INTERNALCLASS(simpleScriptFunctionClass) - static ReturnedValue construct(const Managed *, CallData *callData); - static ReturnedValue call(const Managed *that, CallData *callData); + static void construct(const Managed *, Scope &scope, CallData *callData); + static void call(const Managed *that, Scope &scope, CallData *callData); Heap::Object *protoForConstructor(); }; @@ -240,8 +238,8 @@ struct SimpleScriptFunction: FunctionObject { struct ScriptFunction: SimpleScriptFunction { V4_OBJECT2(ScriptFunction, FunctionObject) - static ReturnedValue construct(const Managed *, CallData *callData); - static ReturnedValue call(const Managed *that, CallData *callData); + static void construct(const Managed *, Scope &scope, CallData *callData); + static void call(const Managed *that, Scope &scope, CallData *callData); }; @@ -257,8 +255,8 @@ struct BoundFunction: FunctionObject { Value boundThis() const { return d()->boundThis; } Heap::MemberData *boundArgs() const { return d()->boundArgs; } - static ReturnedValue construct(const Managed *, CallData *d); - static ReturnedValue call(const Managed *that, CallData *dd); + static void construct(const Managed *, Scope &scope, CallData *d); + static void call(const Managed *that, Scope &scope, CallData *dd); static void markObjects(Heap::Base *that, ExecutionEngine *e); }; |