From aa8f956e8d742ec25a01dfeb0d7a7ce54b49ed73 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Fri, 1 Sep 2017 10:09:45 +0200 Subject: Move ScopedCallData and ScopedStackFrame into a separate file Change-Id: I9ae42aa7a811aa93fe0950725e9d253a0c5e8dba Reviewed-by: Simon Hausmann --- src/imports/localstorage/plugin.cpp | 1 + .../qmltooling/qmldbg_debugger/qv4debugjob.cpp | 1 + src/qml/jsapi/qjsvalue.cpp | 6 +- src/qml/jsruntime/jsruntime.pri | 1 + src/qml/jsruntime/qv4argumentsobject.cpp | 5 +- src/qml/jsruntime/qv4arraybuffer.cpp | 1 + src/qml/jsruntime/qv4arraydata.cpp | 1 + src/qml/jsruntime/qv4arrayobject.cpp | 2 +- src/qml/jsruntime/qv4dateobject.cpp | 1 + src/qml/jsruntime/qv4functionobject.cpp | 1 + src/qml/jsruntime/qv4globalobject.cpp | 1 + src/qml/jsruntime/qv4include.cpp | 1 + src/qml/jsruntime/qv4jscall_p.h | 118 +++++++++++++++++++++ src/qml/jsruntime/qv4jsonobject.cpp | 1 + src/qml/jsruntime/qv4lookup.cpp | 2 +- src/qml/jsruntime/qv4object.cpp | 1 + src/qml/jsruntime/qv4objectproto.cpp | 1 + src/qml/jsruntime/qv4qobjectwrapper.cpp | 1 + src/qml/jsruntime/qv4regexpobject.cpp | 1 + src/qml/jsruntime/qv4runtime.cpp | 1 + src/qml/jsruntime/qv4scopedvalue_p.h | 41 ------- src/qml/jsruntime/qv4script.cpp | 1 + src/qml/jsruntime/qv4sequenceobject.cpp | 1 + src/qml/jsruntime/qv4stringobject.cpp | 6 +- src/qml/jsruntime/qv4typedarray.cpp | 1 + src/qml/qml/qqmlboundsignal.cpp | 1 + src/qml/qml/qqmlcomponent.cpp | 1 + src/qml/qml/qqmldelayedcallqueue.cpp | 1 + src/qml/qml/qqmljavascriptexpression.cpp | 1 + src/qml/qml/qqmlvmemetaobject.cpp | 1 + src/qml/qml/qqmlxmlhttprequest.cpp | 1 + src/qml/types/qquickworkerscript.cpp | 1 + src/quick/items/context2d/qquickcanvasitem.cpp | 1 + 33 files changed, 153 insertions(+), 53 deletions(-) create mode 100644 src/qml/jsruntime/qv4jscall_p.h (limited to 'src') diff --git a/src/imports/localstorage/plugin.cpp b/src/imports/localstorage/plugin.cpp index 3cc869de47..5f3cfc43c4 100644 --- a/src/imports/localstorage/plugin.cpp +++ b/src/imports/localstorage/plugin.cpp @@ -58,6 +58,7 @@ #include #include #include +#include #include static void initResources() diff --git a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp index b0607c574a..e852f574a7 100644 --- a/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp +++ b/src/plugins/qmltooling/qmldbg_debugger/qv4debugjob.cpp @@ -44,6 +44,7 @@ #include #include #include +#include #include diff --git a/src/qml/jsapi/qjsvalue.cpp b/src/qml/jsapi/qjsvalue.cpp index b2f8a35b51..3e2d0ccef0 100644 --- a/src/qml/jsapi/qjsvalue.cpp +++ b/src/qml/jsapi/qjsvalue.cpp @@ -53,7 +53,7 @@ #include "qv4errorobject_p.h" #include "private/qv8engine_p.h" #include -#include +#include #include /*! @@ -657,7 +657,7 @@ QJSValue QJSValue::call(const QJSValueList &args) Q_ASSERT(engine); Scope scope(engine); - ScopedCallData callData(scope, args.length()); + ScopedCallData callData(scope, f, args.length()); callData->thisObject = engine->globalObject; for (int i = 0; i < args.size(); ++i) { if (!QJSValuePrivate::checkEngine(engine, args.at(i))) { @@ -667,7 +667,7 @@ QJSValue QJSValue::call(const QJSValueList &args) callData->args[i] = QJSValuePrivate::convertedToValue(engine, args.at(i)); } - ScopedValue result(scope, f->call(callData)); + ScopedValue result(scope, callData.call()); if (engine->hasException) result = engine->catchException(); diff --git a/src/qml/jsruntime/jsruntime.pri b/src/qml/jsruntime/jsruntime.pri index 811014607a..a270cb1aa3 100644 --- a/src/qml/jsruntime/jsruntime.pri +++ b/src/qml/jsruntime/jsruntime.pri @@ -59,6 +59,7 @@ HEADERS += \ $$PWD/qv4identifiertable_p.h \ $$PWD/qv4managed_p.h \ $$PWD/qv4internalclass_p.h \ + $$PWD/qv4jscall_p.h \ $$PWD/qv4sparsearray_p.h \ $$PWD/qv4arraydata_p.h \ $$PWD/qv4arrayobject_p.h \ diff --git a/src/qml/jsruntime/qv4argumentsobject.cpp b/src/qml/jsruntime/qv4argumentsobject.cpp index c91af88c30..b90a186551 100644 --- a/src/qml/jsruntime/qv4argumentsobject.cpp +++ b/src/qml/jsruntime/qv4argumentsobject.cpp @@ -41,6 +41,7 @@ #include #include #include +#include using namespace QV4; @@ -138,10 +139,10 @@ bool ArgumentsObject::defineOwnProperty(ExecutionEngine *engine, uint index, con if (isMapped && attrs.isData()) { Q_ASSERT(arrayData()); ScopedFunctionObject setter(scope, map->setter()); - ScopedCallData callData(scope, 1); + ScopedCallData callData(scope, setter, 1); callData->thisObject = this->asReturnedValue(); callData->args[0] = desc->value; - setter->call(callData); + callData.call(); if (attrs.isWritable()) { setArrayAttributes(index, mapAttrs); diff --git a/src/qml/jsruntime/qv4arraybuffer.cpp b/src/qml/jsruntime/qv4arraybuffer.cpp index 3f0ff10e58..33ef7fa6df 100644 --- a/src/qml/jsruntime/qv4arraybuffer.cpp +++ b/src/qml/jsruntime/qv4arraybuffer.cpp @@ -40,6 +40,7 @@ #include "qv4typedarray_p.h" #include "qv4dataview_p.h" #include "qv4string_p.h" +#include "qv4jscall_p.h" using namespace QV4; diff --git a/src/qml/jsruntime/qv4arraydata.cpp b/src/qml/jsruntime/qv4arraydata.cpp index df9884d84a..fe9736ea9b 100644 --- a/src/qml/jsruntime/qv4arraydata.cpp +++ b/src/qml/jsruntime/qv4arraydata.cpp @@ -43,6 +43,7 @@ #include "qv4runtime_p.h" #include "qv4argumentsobject_p.h" #include "qv4string_p.h" +#include "qv4jscall_p.h" using namespace QV4; diff --git a/src/qml/jsruntime/qv4arrayobject.cpp b/src/qml/jsruntime/qv4arrayobject.cpp index ecf8645141..f7486471ee 100644 --- a/src/qml/jsruntime/qv4arrayobject.cpp +++ b/src/qml/jsruntime/qv4arrayobject.cpp @@ -40,7 +40,7 @@ #include "qv4arrayobject_p.h" #include "qv4sparsearray_p.h" #include "qv4objectproto_p.h" -#include "qv4scopedvalue_p.h" +#include "qv4jscall_p.h" #include "qv4argumentsobject_p.h" #include "qv4runtime_p.h" #include "qv4string_p.h" diff --git a/src/qml/jsruntime/qv4dateobject.cpp b/src/qml/jsruntime/qv4dateobject.cpp index 2802483ff9..5ac2a43b19 100644 --- a/src/qml/jsruntime/qv4dateobject.cpp +++ b/src/qml/jsruntime/qv4dateobject.cpp @@ -43,6 +43,7 @@ #include "qv4scopedvalue_p.h" #include "qv4runtime_p.h" #include "qv4string_p.h" +#include "qv4jscall_p.h" #include #include diff --git a/src/qml/jsruntime/qv4functionobject.cpp b/src/qml/jsruntime/qv4functionobject.cpp index 642fd69aa6..4a6890c651 100644 --- a/src/qml/jsruntime/qv4functionobject.cpp +++ b/src/qml/jsruntime/qv4functionobject.cpp @@ -45,6 +45,7 @@ #include "qv4arrayobject_p.h" #include "qv4scopedvalue_p.h" +#include "qv4jscall_p.h" #include "qv4argumentsobject_p.h" #include diff --git a/src/qml/jsruntime/qv4globalobject.cpp b/src/qml/jsruntime/qv4globalobject.cpp index c4f52758dd..74173f6a6a 100644 --- a/src/qml/jsruntime/qv4globalobject.cpp +++ b/src/qml/jsruntime/qv4globalobject.cpp @@ -47,6 +47,7 @@ #include "qv4script_p.h" #include "qv4scopedvalue_p.h" #include "qv4string_p.h" +#include "qv4jscall_p.h" #include #include diff --git a/src/qml/jsruntime/qv4include.cpp b/src/qml/jsruntime/qv4include.cpp index 49ccb7c2e9..3c378bf398 100644 --- a/src/qml/jsruntime/qv4include.cpp +++ b/src/qml/jsruntime/qv4include.cpp @@ -39,6 +39,7 @@ #include "qv4include_p.h" #include "qv4scopedvalue_p.h" +#include "qv4jscall_p.h" #include #if QT_CONFIG(qml_network) diff --git a/src/qml/jsruntime/qv4jscall_p.h b/src/qml/jsruntime/qv4jscall_p.h new file mode 100644 index 0000000000..f871034789 --- /dev/null +++ b/src/qml/jsruntime/qv4jscall_p.h @@ -0,0 +1,118 @@ +/**************************************************************************** +** +** Copyright (C) 2017 The Qt Company Ltd. +** Contact: https://www.qt.io/licensing/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** Commercial License Usage +** Licensees holding valid commercial Qt licenses may use this file in +** accordance with the commercial license agreement provided with the +** Software or, alternatively, in accordance with the terms contained in +** a written agreement between you and The Qt Company. For licensing terms +** and conditions see https://www.qt.io/terms-conditions. For further +** information use the contact form at https://www.qt.io/contact-us. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 3 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL3 included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 3 requirements +** will be met: https://www.gnu.org/licenses/lgpl-3.0.html. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 2.0 or (at your option) the GNU General +** Public license version 3 or any later version approved by the KDE Free +** Qt Foundation. The licenses are as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3 +** included in the packaging of this file. Please review the following +** information to ensure the GNU General Public License requirements will +** be met: https://www.gnu.org/licenses/gpl-2.0.html and +** https://www.gnu.org/licenses/gpl-3.0.html. +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +#ifndef QV4JSCALL_H +#define QV4JSCALL_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include "qv4object_p.h" +#include "qv4function_p.h" +#include "qv4functionobject_p.h" +#include "qv4context_p.h" +#include "qv4scopedvalue_p.h" + +QT_BEGIN_NAMESPACE + +namespace QV4 { + +struct ScopedCallData { + ScopedCallData(const Scope &scope, int argc = 0) + { + int size = int(offsetof(QV4::CallData, args)/sizeof(QV4::Value)) + qMax(argc , int(QV4::Global::ReservedArgumentCount)); + ptr = reinterpret_cast(scope.alloc(size)); + ptr->tag = quint32(QV4::Value::ValueTypeInternal::Integer); + ptr->argc = argc; + } + + ScopedCallData(const Scope &scope, const FunctionObject *function, int argc = 0) + { + int size = int(offsetof(QV4::CallData, args)/sizeof(QV4::Value)) + qMax(argc , int(QV4::Global::ReservedArgumentCount)); + ptr = reinterpret_cast(scope.alloc(size)); + ptr->tag = quint32(QV4::Value::ValueTypeInternal::Integer); + ptr->argc = argc; + ptr->function = *function; + } + + CallData *operator->() { + return ptr; + } + + operator CallData *() const { + return ptr; + } + + ReturnedValue call() const { + return static_cast(ptr->function).call(ptr); + } + + CallData *ptr; +}; + +struct ScopedStackFrame { + Scope &scope; + CppStackFrame frame; + + ScopedStackFrame(Scope &scope, Heap::ExecutionContext *context) + : scope(scope) + { + frame.parent = scope.engine->currentStackFrame; + if (!context) + return; + frame.jsFrame = reinterpret_cast(scope.alloc(sizeof(CallData)/sizeof(Value))); + frame.jsFrame->context = context; + frame.v4Function = frame.parent ? frame.parent->v4Function : 0; + scope.engine->currentStackFrame = &frame; + } + ~ScopedStackFrame() { + scope.engine->currentStackFrame = frame.parent; + } +}; + +} + +#endif diff --git a/src/qml/jsruntime/qv4jsonobject.cpp b/src/qml/jsruntime/qv4jsonobject.cpp index 27cce52512..88fc0d6b3c 100644 --- a/src/qml/jsruntime/qv4jsonobject.cpp +++ b/src/qml/jsruntime/qv4jsonobject.cpp @@ -46,6 +46,7 @@ #include #include #include "qv4string_p.h" +#include "qv4jscall_p.h" #include #include diff --git a/src/qml/jsruntime/qv4lookup.cpp b/src/qml/jsruntime/qv4lookup.cpp index 429623e482..392ab565b0 100644 --- a/src/qml/jsruntime/qv4lookup.cpp +++ b/src/qml/jsruntime/qv4lookup.cpp @@ -38,7 +38,7 @@ ****************************************************************************/ #include "qv4lookup_p.h" #include "qv4functionobject_p.h" -#include "qv4scopedvalue_p.h" +#include "qv4jscall_p.h" #include "qv4string_p.h" #include diff --git a/src/qml/jsruntime/qv4object.cpp b/src/qml/jsruntime/qv4object.cpp index c701e981b7..b778a064be 100644 --- a/src/qml/jsruntime/qv4object.cpp +++ b/src/qml/jsruntime/qv4object.cpp @@ -49,6 +49,7 @@ #include "qv4identifier_p.h" #include "qv4string_p.h" #include "qv4identifiertable_p.h" +#include "qv4jscall_p.h" #include diff --git a/src/qml/jsruntime/qv4objectproto.cpp b/src/qml/jsruntime/qv4objectproto.cpp index 37bf5c3cb6..e7ef9d93cf 100644 --- a/src/qml/jsruntime/qv4objectproto.cpp +++ b/src/qml/jsruntime/qv4objectproto.cpp @@ -46,6 +46,7 @@ #include "qv4runtime_p.h" #include "qv4objectiterator_p.h" #include "qv4string_p.h" +#include "qv4jscall_p.h" #include #include diff --git a/src/qml/jsruntime/qv4qobjectwrapper.cpp b/src/qml/jsruntime/qv4qobjectwrapper.cpp index 2d791092dd..ddce96f9ca 100644 --- a/src/qml/jsruntime/qv4qobjectwrapper.cpp +++ b/src/qml/jsruntime/qv4qobjectwrapper.cpp @@ -62,6 +62,7 @@ #include #include #include +#include #include #include #include diff --git a/src/qml/jsruntime/qv4regexpobject.cpp b/src/qml/jsruntime/qv4regexpobject.cpp index 8a23da24cc..4124188b59 100644 --- a/src/qml/jsruntime/qv4regexpobject.cpp +++ b/src/qml/jsruntime/qv4regexpobject.cpp @@ -43,6 +43,7 @@ #include "qv4stringobject_p.h" #include #include "qv4scopedvalue_p.h" +#include "qv4jscall_p.h" #include #include diff --git a/src/qml/jsruntime/qv4runtime.cpp b/src/qml/jsruntime/qv4runtime.cpp index 18eac9a7fb..187cd7c313 100644 --- a/src/qml/jsruntime/qv4runtime.cpp +++ b/src/qml/jsruntime/qv4runtime.cpp @@ -53,6 +53,7 @@ #include "qv4numberobject_p.h" #include "private/qlocale_tools_p.h" #include "qv4scopedvalue_p.h" +#include "qv4jscall_p.h" #include #include #include diff --git a/src/qml/jsruntime/qv4scopedvalue_p.h b/src/qml/jsruntime/qv4scopedvalue_p.h index 9522e919bd..575f4e6e3f 100644 --- a/src/qml/jsruntime/qv4scopedvalue_p.h +++ b/src/qml/jsruntime/qv4scopedvalue_p.h @@ -52,7 +52,6 @@ #include "qv4engine_p.h" #include "qv4value_p.h" -#include "qv4persistent_p.h" #include "qv4property_p.h" #ifdef V4_USE_VALGRIND @@ -351,46 +350,6 @@ struct Scoped Value *ptr; }; -struct ScopedCallData { - ScopedCallData(const Scope &scope, int argc = 0) - { - int size = int(offsetof(QV4::CallData, args)/sizeof(QV4::Value)) + qMax(argc , int(QV4::Global::ReservedArgumentCount)); - ptr = reinterpret_cast(scope.alloc(size)); - ptr->tag = quint32(QV4::Value::ValueTypeInternal::Integer); - ptr->argc = argc; - } - - CallData *operator->() { - return ptr; - } - - operator CallData *() const { - return ptr; - } - - CallData *ptr; -}; - -struct ScopedStackFrame { - Scope &scope; - CppStackFrame frame; - - ScopedStackFrame(Scope &scope, Heap::ExecutionContext *context) - : scope(scope) - { - frame.parent = scope.engine->currentStackFrame; - if (!context) - return; - frame.jsFrame = reinterpret_cast(scope.alloc(sizeof(CallData)/sizeof(Value))); - frame.jsFrame->context = context; - frame.v4Function = frame.parent ? frame.parent->v4Function : 0; - scope.engine->currentStackFrame = &frame; - } - ~ScopedStackFrame() { - scope.engine->currentStackFrame = frame.parent; - } -}; - inline Value &Value::operator =(const ScopedValue &v) { _val = v.ptr->rawValue(); diff --git a/src/qml/jsruntime/qv4script.cpp b/src/qml/jsruntime/qv4script.cpp index 59d418a6d3..598c12ffd4 100644 --- a/src/qml/jsruntime/qv4script.cpp +++ b/src/qml/jsruntime/qv4script.cpp @@ -45,6 +45,7 @@ #include "qv4debugging_p.h" #include "qv4profiling_p.h" #include "qv4scopedvalue_p.h" +#include "qv4jscall_p.h" #include #include diff --git a/src/qml/jsruntime/qv4sequenceobject.cpp b/src/qml/jsruntime/qv4sequenceobject.cpp index 54a32e0747..ed9f798cd7 100644 --- a/src/qml/jsruntime/qv4sequenceobject.cpp +++ b/src/qml/jsruntime/qv4sequenceobject.cpp @@ -45,6 +45,7 @@ #include #include #include +#include #include "qv4runtime_p.h" #include "qv4objectiterator_p.h" #include diff --git a/src/qml/jsruntime/qv4stringobject.cpp b/src/qml/jsruntime/qv4stringobject.cpp index a3d272469b..4964769b88 100644 --- a/src/qml/jsruntime/qv4stringobject.cpp +++ b/src/qml/jsruntime/qv4stringobject.cpp @@ -45,15 +45,11 @@ #include #include "qv4scopedvalue_p.h" #include "qv4alloca_p.h" +#include "qv4jscall_p.h" #include #include #include -#include -#include -#include -#include - #include #ifndef Q_OS_WIN diff --git a/src/qml/jsruntime/qv4typedarray.cpp b/src/qml/jsruntime/qv4typedarray.cpp index 6e237b2e23..3d0acb19b9 100644 --- a/src/qml/jsruntime/qv4typedarray.cpp +++ b/src/qml/jsruntime/qv4typedarray.cpp @@ -39,6 +39,7 @@ #include "qv4typedarray_p.h" #include "qv4arraybuffer_p.h" #include "qv4string_p.h" +#include "qv4jscall_p.h" #include diff --git a/src/qml/qml/qqmlboundsignal.cpp b/src/qml/qml/qqmlboundsignal.cpp index 2c0f0091ea..20c84b34e6 100644 --- a/src/qml/qml/qqmlboundsignal.cpp +++ b/src/qml/qml/qqmlboundsignal.cpp @@ -55,6 +55,7 @@ #include #include +#include #include #include diff --git a/src/qml/qml/qqmlcomponent.cpp b/src/qml/qml/qqmlcomponent.cpp index 0ebeb48ea4..4affc5a453 100644 --- a/src/qml/qml/qqmlcomponent.cpp +++ b/src/qml/qml/qqmlcomponent.cpp @@ -58,6 +58,7 @@ #include #include #include +#include #include #include diff --git a/src/qml/qml/qqmldelayedcallqueue.cpp b/src/qml/qml/qqmldelayedcallqueue.cpp index a32a9dd783..87b6fac10e 100644 --- a/src/qml/qml/qqmldelayedcallqueue.cpp +++ b/src/qml/qml/qqmldelayedcallqueue.cpp @@ -42,6 +42,7 @@ #include #include #include +#include #include #include diff --git a/src/qml/qml/qqmljavascriptexpression.cpp b/src/qml/qml/qqmljavascriptexpression.cpp index e61c8f551c..36881f02ba 100644 --- a/src/qml/qml/qqmljavascriptexpression.cpp +++ b/src/qml/qml/qqmljavascriptexpression.cpp @@ -46,6 +46,7 @@ #include #include #include +#include #include #include #include diff --git a/src/qml/qml/qqmlvmemetaobject.cpp b/src/qml/qml/qqmlvmemetaobject.cpp index c784adb845..3510367fd3 100644 --- a/src/qml/qml/qqmlvmemetaobject.cpp +++ b/src/qml/qml/qqmlvmemetaobject.cpp @@ -55,6 +55,7 @@ #include #include #include +#include #include QT_BEGIN_NAMESPACE diff --git a/src/qml/qml/qqmlxmlhttprequest.cpp b/src/qml/qml/qqmlxmlhttprequest.cpp index 023ecbbb64..a77c4c5678 100644 --- a/src/qml/qml/qqmlxmlhttprequest.cpp +++ b/src/qml/qml/qqmlxmlhttprequest.cpp @@ -51,6 +51,7 @@ #include #include #include +#include #include #include diff --git a/src/qml/types/qquickworkerscript.cpp b/src/qml/types/qquickworkerscript.cpp index 3acc615541..a26bd81c8b 100644 --- a/src/qml/types/qquickworkerscript.cpp +++ b/src/qml/types/qquickworkerscript.cpp @@ -65,6 +65,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE diff --git a/src/quick/items/context2d/qquickcanvasitem.cpp b/src/quick/items/context2d/qquickcanvasitem.cpp index 027b4b3595..ddf34666a2 100644 --- a/src/quick/items/context2d/qquickcanvasitem.cpp +++ b/src/quick/items/context2d/qquickcanvasitem.cpp @@ -57,6 +57,7 @@ #include #include #include +#include #include QT_BEGIN_NAMESPACE -- cgit v1.2.3