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/qv4object.cpp | |
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/qv4object.cpp')
-rw-r--r-- | src/qml/jsruntime/qv4object.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp index ff3208485e..0fc5f95dad 100644 --- a/src/qml/jsruntime/qv4object.cpp +++ b/src/qml/jsruntime/qv4object.cpp @@ -109,7 +109,8 @@ ReturnedValue Object::getValue(const Value &thisObject, const Value &v, Property Scope scope(f->engine()); ScopedCallData callData(scope); callData->thisObject = thisObject; - return f->call(callData); + f->call(scope, callData); + return scope.result.asReturnedValue(); } void Object::putValue(uint memberIndex, const Value &value) @@ -128,7 +129,7 @@ void Object::putValue(uint memberIndex, const Value &value) ScopedCallData callData(scope, 1); callData->args[0] = value; callData->thisObject = this; - setter->call(callData); + setter->call(scope, callData); return; } goto reject; @@ -389,14 +390,14 @@ bool Object::hasOwnProperty(uint index) const return false; } -ReturnedValue Object::construct(const Managed *m, CallData *) +void Object::construct(const Managed *m, Scope &scope, CallData *) { - return static_cast<const Object *>(m)->engine()->throwTypeError(); + scope.result = static_cast<const Object *>(m)->engine()->throwTypeError(); } -ReturnedValue Object::call(const Managed *m, CallData *) +void Object::call(const Managed *m, Scope &scope, CallData *) { - return static_cast<const Object *>(m)->engine()->throwTypeError(); + scope.result = static_cast<const Object *>(m)->engine()->throwTypeError(); } ReturnedValue Object::get(const Managed *m, String *name, bool *hasProperty) @@ -744,7 +745,7 @@ void Object::internalPut(String *name, const Value &value) ScopedCallData callData(scope, 1); callData->args[0] = value; callData->thisObject = this; - setter->call(callData); + setter->call(scope, callData); return; } @@ -814,7 +815,7 @@ void Object::internalPutIndexed(uint index, const Value &value) ScopedCallData callData(scope, 1); callData->args[0] = value; callData->thisObject = this; - setter->call(callData); + setter->call(scope, callData); return; } |