aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4jscall_p.h
diff options
context:
space:
mode:
authorUlf Hermann <ulf.hermann@qt.io>2021-03-12 14:57:24 +0100
committerUlf Hermann <ulf.hermann@qt.io>2021-03-17 13:10:16 +0100
commitb0e9c83f99aa7090c82b7c55894f5e264b74608a (patch)
tree39a11795b7d17483ce05be5b23c380864eb9bb29 /src/qml/jsruntime/qv4jscall_p.h
parent2fab46e711abfc04edd1791d050722d1fbfbc7d2 (diff)
Don't store the scope in JSCallData
We only need it when generating CallData, or when filling in any thisObject or arguments that weren't provided. Provide a constructor that expects thisObject and arguments to be pre-allocated and one that allocates them in a scope passed as argument. Change-Id: Iddfba63f4dbc5b09e2b33fb22a94eea88f515902 Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io> Reviewed-by: Andrei Golubev <andrei.golubev@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4jscall_p.h')
-rw-r--r--src/qml/jsruntime/qv4jscall_p.h22
1 files changed, 9 insertions, 13 deletions
diff --git a/src/qml/jsruntime/qv4jscall_p.h b/src/qml/jsruntime/qv4jscall_p.h
index 66ff1e7c3b..43dc0de727 100644
--- a/src/qml/jsruntime/qv4jscall_p.h
+++ b/src/qml/jsruntime/qv4jscall_p.h
@@ -62,30 +62,27 @@ QT_BEGIN_NAMESPACE
namespace QV4 {
struct JSCallData {
- JSCallData(const Scope &scope, int argc = 0, const Value *argv = nullptr, const Value *thisObject = nullptr)
- : scope(scope), argc(argc)
+ JSCallData(const Value *thisObject, const Value *argv, int argc)
+ : argc(argc), args(const_cast<Value *>(argv)), thisObject(const_cast<Value *>(thisObject))
+ {
+ }
+
+ JSCallData(const Scope &scope, int argc = 0)
+ : argc(argc), args(scope.alloc(argc)), thisObject(scope.alloc())
{
- if (thisObject)
- this->thisObject = const_cast<Value *>(thisObject);
- else
- this->thisObject = scope.alloc();
- if (argv)
- this->args = const_cast<Value *>(argv);
- else
- this->args = scope.alloc(argc);
}
JSCallData *operator->() {
return this;
}
- CallData *callData(const FunctionObject *f = nullptr) const {
+ CallData *callData(const Scope &scope, const FunctionObject *f = nullptr) const {
int size = int(offsetof(QV4::CallData, args)/sizeof(QV4::Value)) + argc;
CallData *ptr = reinterpret_cast<CallData *>(scope.alloc<Scope::Uninitialized>(size));
ptr->function = Encode::undefined();
ptr->context = Encode::undefined();
ptr->accumulator = Encode::undefined();
- ptr->thisObject = thisObject->asReturnedValue();
+ ptr->thisObject = thisObject ? thisObject->asReturnedValue() : Encode::undefined();
ptr->newTarget = Encode::undefined();
ptr->setArgc(argc);
if (argc)
@@ -94,7 +91,6 @@ struct JSCallData {
ptr->function = f->asReturnedValue();
return ptr;
}
- const Scope &scope;
int argc;
Value *args;
Value *thisObject;