2018-06-27 12:18:17 +00:00
|
|
|
/****************************************************************************
|
|
|
|
**
|
|
|
|
** Copyright (C) 2018 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 QV4STACKFRAME_H
|
|
|
|
#define QV4STACKFRAME_H
|
|
|
|
|
2018-07-31 16:22:09 +00:00
|
|
|
//
|
|
|
|
// 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.
|
|
|
|
//
|
|
|
|
|
2018-06-27 12:18:17 +00:00
|
|
|
#include <private/qv4context_p.h>
|
2018-06-27 15:23:39 +00:00
|
|
|
#include <private/qv4enginebase_p.h>
|
2019-05-09 13:48:09 +00:00
|
|
|
#include <private/qv4calldata_p.h>
|
2018-06-27 12:18:17 +00:00
|
|
|
#include <private/qv4function_p.h>
|
|
|
|
|
Optimize stack frame setup for AOT compiled functions
When called via the metaobject system, parameters and return values are
passed as void*, with accompanying type information in the form of
QMetaType. The same format is expected when calling an AOT
compiled function.
Previously, we would first convert all the parameters to QV4::Value,
just to convert them back the moment we notice that there is an AOT
compiled function. This is wasteful.
This change provides a second call infrastructure that accepts void* and
QMetaType as parameter and return value format, and passes them as-is
all the way to any AOT compiled functions. If there is no AOT compiled
function, the conversion is done when detecting this, rather than when
initiating the call. This also passes the information "ignore return
value" all the way down to the actual function call. If the caller is
not interested in the return value, we don't have to marshal it back at
all.
For now, we only add the extra "callWithMetaTypes" vtable entry to
ArrowFunction. However, other callables could also receive variants
optimized for calling with void*/int rather than V4 values.
This required changing the way how function arguments are stored in the
property cache. We squeeze the return type into
QQmlPropertyCacheMethodArguments now, and we use QMetaType instead of
integers. In turn, we remove some unused bits.
Change-Id: I946e603e623d9d985c54d3a15f6f4b7c7b7d8c60
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-03-12 22:25:30 +00:00
|
|
|
#include <type_traits>
|
|
|
|
|
2018-06-27 12:18:17 +00:00
|
|
|
QT_BEGIN_NAMESPACE
|
|
|
|
|
|
|
|
namespace QV4 {
|
|
|
|
|
Optimize stack frame setup for AOT compiled functions
When called via the metaobject system, parameters and return values are
passed as void*, with accompanying type information in the form of
QMetaType. The same format is expected when calling an AOT
compiled function.
Previously, we would first convert all the parameters to QV4::Value,
just to convert them back the moment we notice that there is an AOT
compiled function. This is wasteful.
This change provides a second call infrastructure that accepts void* and
QMetaType as parameter and return value format, and passes them as-is
all the way to any AOT compiled functions. If there is no AOT compiled
function, the conversion is done when detecting this, rather than when
initiating the call. This also passes the information "ignore return
value" all the way down to the actual function call. If the caller is
not interested in the return value, we don't have to marshal it back at
all.
For now, we only add the extra "callWithMetaTypes" vtable entry to
ArrowFunction. However, other callables could also receive variants
optimized for calling with void*/int rather than V4 values.
This required changing the way how function arguments are stored in the
property cache. We squeeze the return type into
QQmlPropertyCacheMethodArguments now, and we use QMetaType instead of
integers. In turn, we remove some unused bits.
Change-Id: I946e603e623d9d985c54d3a15f6f4b7c7b7d8c60
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-03-12 22:25:30 +00:00
|
|
|
struct CppStackFrame;
|
|
|
|
struct Q_QML_PRIVATE_EXPORT CppStackFrameBase
|
|
|
|
{
|
|
|
|
enum class Kind : quint8 { Bare, JS, Meta };
|
|
|
|
|
2018-06-27 15:23:39 +00:00
|
|
|
Value *savedStackTop;
|
2018-06-27 12:18:17 +00:00
|
|
|
CppStackFrame *parent;
|
|
|
|
Function *v4Function;
|
|
|
|
CallData *jsFrame;
|
|
|
|
int originalArgumentsCount;
|
|
|
|
int instructionPointer;
|
2018-06-27 15:23:39 +00:00
|
|
|
|
Optimize stack frame setup for AOT compiled functions
When called via the metaobject system, parameters and return values are
passed as void*, with accompanying type information in the form of
QMetaType. The same format is expected when calling an AOT
compiled function.
Previously, we would first convert all the parameters to QV4::Value,
just to convert them back the moment we notice that there is an AOT
compiled function. This is wasteful.
This change provides a second call infrastructure that accepts void* and
QMetaType as parameter and return value format, and passes them as-is
all the way to any AOT compiled functions. If there is no AOT compiled
function, the conversion is done when detecting this, rather than when
initiating the call. This also passes the information "ignore return
value" all the way down to the actual function call. If the caller is
not interested in the return value, we don't have to marshal it back at
all.
For now, we only add the extra "callWithMetaTypes" vtable entry to
ArrowFunction. However, other callables could also receive variants
optimized for calling with void*/int rather than V4 values.
This required changing the way how function arguments are stored in the
property cache. We squeeze the return type into
QQmlPropertyCacheMethodArguments now, and we use QMetaType instead of
integers. In turn, we remove some unused bits.
Change-Id: I946e603e623d9d985c54d3a15f6f4b7c7b7d8c60
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-03-12 22:25:30 +00:00
|
|
|
union {
|
|
|
|
struct {
|
|
|
|
const Value *originalArguments;
|
|
|
|
const char *yield;
|
|
|
|
const char *unwindHandler;
|
|
|
|
const char *unwindLabel;
|
|
|
|
int unwindLevel;
|
|
|
|
bool yieldIsIterator;
|
|
|
|
bool callerCanHandleTailCall;
|
|
|
|
bool pendingTailCall;
|
|
|
|
bool isTailCalling;
|
|
|
|
};
|
|
|
|
struct {
|
|
|
|
const QMetaType *metaTypes;
|
|
|
|
void **returnAndArgs;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
Kind kind;
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Q_QML_PRIVATE_EXPORT CppStackFrame : protected CppStackFrameBase
|
|
|
|
{
|
|
|
|
// We want to have those public but we can't declare them as public without making the struct
|
|
|
|
// non-standard layout. So we have this other struct with "using" in between.
|
|
|
|
using CppStackFrameBase::instructionPointer;
|
|
|
|
using CppStackFrameBase::v4Function;
|
|
|
|
using CppStackFrameBase::jsFrame;
|
|
|
|
|
|
|
|
void init(Function *v4Function, int argc, Kind kind = Kind::Bare) {
|
2018-06-27 15:23:39 +00:00
|
|
|
this->v4Function = v4Function;
|
|
|
|
originalArgumentsCount = argc;
|
|
|
|
instructionPointer = 0;
|
Optimize stack frame setup for AOT compiled functions
When called via the metaobject system, parameters and return values are
passed as void*, with accompanying type information in the form of
QMetaType. The same format is expected when calling an AOT
compiled function.
Previously, we would first convert all the parameters to QV4::Value,
just to convert them back the moment we notice that there is an AOT
compiled function. This is wasteful.
This change provides a second call infrastructure that accepts void* and
QMetaType as parameter and return value format, and passes them as-is
all the way to any AOT compiled functions. If there is no AOT compiled
function, the conversion is done when detecting this, rather than when
initiating the call. This also passes the information "ignore return
value" all the way down to the actual function call. If the caller is
not interested in the return value, we don't have to marshal it back at
all.
For now, we only add the extra "callWithMetaTypes" vtable entry to
ArrowFunction. However, other callables could also receive variants
optimized for calling with void*/int rather than V4 values.
This required changing the way how function arguments are stored in the
property cache. We squeeze the return type into
QQmlPropertyCacheMethodArguments now, and we use QMetaType instead of
integers. In turn, we remove some unused bits.
Change-Id: I946e603e623d9d985c54d3a15f6f4b7c7b7d8c60
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-03-12 22:25:30 +00:00
|
|
|
this->kind = kind;
|
2018-06-27 15:23:39 +00:00
|
|
|
}
|
|
|
|
|
Optimize stack frame setup for AOT compiled functions
When called via the metaobject system, parameters and return values are
passed as void*, with accompanying type information in the form of
QMetaType. The same format is expected when calling an AOT
compiled function.
Previously, we would first convert all the parameters to QV4::Value,
just to convert them back the moment we notice that there is an AOT
compiled function. This is wasteful.
This change provides a second call infrastructure that accepts void* and
QMetaType as parameter and return value format, and passes them as-is
all the way to any AOT compiled functions. If there is no AOT compiled
function, the conversion is done when detecting this, rather than when
initiating the call. This also passes the information "ignore return
value" all the way down to the actual function call. If the caller is
not interested in the return value, we don't have to marshal it back at
all.
For now, we only add the extra "callWithMetaTypes" vtable entry to
ArrowFunction. However, other callables could also receive variants
optimized for calling with void*/int rather than V4 values.
This required changing the way how function arguments are stored in the
property cache. We squeeze the return type into
QQmlPropertyCacheMethodArguments now, and we use QMetaType instead of
integers. In turn, we remove some unused bits.
Change-Id: I946e603e623d9d985c54d3a15f6f4b7c7b7d8c60
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-03-12 22:25:30 +00:00
|
|
|
bool isBareStackFrame() const { return kind == Kind::Bare; }
|
|
|
|
bool isJSTypesFrame() const { return kind == Kind::JS; }
|
|
|
|
bool isMetaTypesFrame() const { return kind == Kind::Meta; }
|
2018-06-27 15:23:39 +00:00
|
|
|
|
2018-06-30 17:19:18 +00:00
|
|
|
static uint requiredJSStackFrameSize(uint nRegisters) {
|
|
|
|
return CallData::HeaderSize() + nRegisters;
|
|
|
|
}
|
2018-06-27 15:23:39 +00:00
|
|
|
static uint requiredJSStackFrameSize(Function *v4Function) {
|
2018-06-27 12:18:17 +00:00
|
|
|
return CallData::HeaderSize() + v4Function->compiledFunction->nRegisters;
|
|
|
|
}
|
2018-06-27 15:23:39 +00:00
|
|
|
uint requiredJSStackFrameSize() const {
|
|
|
|
return requiredJSStackFrameSize(v4Function);
|
|
|
|
}
|
Optimize stack frame setup for AOT compiled functions
When called via the metaobject system, parameters and return values are
passed as void*, with accompanying type information in the form of
QMetaType. The same format is expected when calling an AOT
compiled function.
Previously, we would first convert all the parameters to QV4::Value,
just to convert them back the moment we notice that there is an AOT
compiled function. This is wasteful.
This change provides a second call infrastructure that accepts void* and
QMetaType as parameter and return value format, and passes them as-is
all the way to any AOT compiled functions. If there is no AOT compiled
function, the conversion is done when detecting this, rather than when
initiating the call. This also passes the information "ignore return
value" all the way down to the actual function call. If the caller is
not interested in the return value, we don't have to marshal it back at
all.
For now, we only add the extra "callWithMetaTypes" vtable entry to
ArrowFunction. However, other callables could also receive variants
optimized for calling with void*/int rather than V4 values.
This required changing the way how function arguments are stored in the
property cache. We squeeze the return type into
QQmlPropertyCacheMethodArguments now, and we use QMetaType instead of
integers. In turn, we remove some unused bits.
Change-Id: I946e603e623d9d985c54d3a15f6f4b7c7b7d8c60
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-03-12 22:25:30 +00:00
|
|
|
|
2018-06-27 15:23:39 +00:00
|
|
|
void setupJSFrame(Value *stackSpace, const Value &function, const Heap::ExecutionContext *scope,
|
Optimize stack frame setup for AOT compiled functions
When called via the metaobject system, parameters and return values are
passed as void*, with accompanying type information in the form of
QMetaType. The same format is expected when calling an AOT
compiled function.
Previously, we would first convert all the parameters to QV4::Value,
just to convert them back the moment we notice that there is an AOT
compiled function. This is wasteful.
This change provides a second call infrastructure that accepts void* and
QMetaType as parameter and return value format, and passes them as-is
all the way to any AOT compiled functions. If there is no AOT compiled
function, the conversion is done when detecting this, rather than when
initiating the call. This also passes the information "ignore return
value" all the way down to the actual function call. If the caller is
not interested in the return value, we don't have to marshal it back at
all.
For now, we only add the extra "callWithMetaTypes" vtable entry to
ArrowFunction. However, other callables could also receive variants
optimized for calling with void*/int rather than V4 values.
This required changing the way how function arguments are stored in the
property cache. We squeeze the return type into
QQmlPropertyCacheMethodArguments now, and we use QMetaType instead of
integers. In turn, we remove some unused bits.
Change-Id: I946e603e623d9d985c54d3a15f6f4b7c7b7d8c60
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-03-12 22:25:30 +00:00
|
|
|
const Value &thisObject, const Value &newTarget = Value::undefinedValue())
|
2018-06-27 15:23:39 +00:00
|
|
|
{
|
|
|
|
jsFrame = reinterpret_cast<CallData *>(stackSpace);
|
|
|
|
jsFrame->function = function;
|
|
|
|
jsFrame->context = scope->asReturnedValue();
|
|
|
|
jsFrame->accumulator = Encode::undefined();
|
|
|
|
jsFrame->thisObject = thisObject;
|
|
|
|
jsFrame->newTarget = newTarget;
|
Optimize stack frame setup for AOT compiled functions
When called via the metaobject system, parameters and return values are
passed as void*, with accompanying type information in the form of
QMetaType. The same format is expected when calling an AOT
compiled function.
Previously, we would first convert all the parameters to QV4::Value,
just to convert them back the moment we notice that there is an AOT
compiled function. This is wasteful.
This change provides a second call infrastructure that accepts void* and
QMetaType as parameter and return value format, and passes them as-is
all the way to any AOT compiled functions. If there is no AOT compiled
function, the conversion is done when detecting this, rather than when
initiating the call. This also passes the information "ignore return
value" all the way down to the actual function call. If the caller is
not interested in the return value, we don't have to marshal it back at
all.
For now, we only add the extra "callWithMetaTypes" vtable entry to
ArrowFunction. However, other callables could also receive variants
optimized for calling with void*/int rather than V4 values.
This required changing the way how function arguments are stored in the
property cache. We squeeze the return type into
QQmlPropertyCacheMethodArguments now, and we use QMetaType instead of
integers. In turn, we remove some unused bits.
Change-Id: I946e603e623d9d985c54d3a15f6f4b7c7b7d8c60
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-03-12 22:25:30 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QString source() const;
|
|
|
|
QString function() const;
|
|
|
|
int lineNumber() const;
|
|
|
|
ReturnedValue thisObject() const;
|
2018-06-27 15:23:39 +00:00
|
|
|
|
Optimize stack frame setup for AOT compiled functions
When called via the metaobject system, parameters and return values are
passed as void*, with accompanying type information in the form of
QMetaType. The same format is expected when calling an AOT
compiled function.
Previously, we would first convert all the parameters to QV4::Value,
just to convert them back the moment we notice that there is an AOT
compiled function. This is wasteful.
This change provides a second call infrastructure that accepts void* and
QMetaType as parameter and return value format, and passes them as-is
all the way to any AOT compiled functions. If there is no AOT compiled
function, the conversion is done when detecting this, rather than when
initiating the call. This also passes the information "ignore return
value" all the way down to the actual function call. If the caller is
not interested in the return value, we don't have to marshal it back at
all.
For now, we only add the extra "callWithMetaTypes" vtable entry to
ArrowFunction. However, other callables could also receive variants
optimized for calling with void*/int rather than V4 values.
This required changing the way how function arguments are stored in the
property cache. We squeeze the return type into
QQmlPropertyCacheMethodArguments now, and we use QMetaType instead of
integers. In turn, we remove some unused bits.
Change-Id: I946e603e623d9d985c54d3a15f6f4b7c7b7d8c60
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-03-12 22:25:30 +00:00
|
|
|
ExecutionContext *context() const
|
|
|
|
{
|
|
|
|
return static_cast<ExecutionContext *>(&jsFrame->context);
|
|
|
|
}
|
|
|
|
|
|
|
|
void setContext(ExecutionContext *context)
|
|
|
|
{
|
|
|
|
jsFrame->context = context;
|
|
|
|
}
|
|
|
|
|
|
|
|
Heap::CallContext *callContext() const
|
|
|
|
{
|
|
|
|
Heap::ExecutionContext *ctx = static_cast<ExecutionContext &>(jsFrame->context).d();\
|
|
|
|
while (ctx->type != Heap::ExecutionContext::Type_CallContext)
|
|
|
|
ctx = ctx->outer;
|
|
|
|
return static_cast<Heap::CallContext *>(ctx);
|
|
|
|
}
|
|
|
|
|
|
|
|
CppStackFrame *parentFrame() const { return parent; }
|
|
|
|
void setParentFrame(CppStackFrame *parentFrame) { parent = parentFrame; }
|
|
|
|
|
|
|
|
int argc() const { return originalArgumentsCount; }
|
|
|
|
Value *framePointer() const { return savedStackTop; }
|
|
|
|
|
|
|
|
void push(EngineBase *engine) {
|
|
|
|
parent = engine->currentStackFrame;
|
|
|
|
engine->currentStackFrame = this;
|
|
|
|
savedStackTop = engine->jsStackTop;
|
|
|
|
}
|
|
|
|
|
|
|
|
void pop(EngineBase *engine) {
|
|
|
|
engine->currentStackFrame = parent;
|
|
|
|
engine->jsStackTop = savedStackTop;
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Q_QML_PRIVATE_EXPORT MetaTypesStackFrame : public CppStackFrame
|
|
|
|
{
|
|
|
|
void init(Function *v4Function, void **a, const QMetaType *types, int argc)
|
|
|
|
{
|
|
|
|
CppStackFrame::init(v4Function, argc, Kind::Meta);
|
|
|
|
metaTypes = types;
|
|
|
|
returnAndArgs = a;
|
|
|
|
}
|
|
|
|
|
|
|
|
QMetaType returnType() const { return metaTypes[0]; }
|
|
|
|
void *returnValue() const { return returnAndArgs[0]; }
|
|
|
|
|
|
|
|
const QMetaType *argTypes() const { return metaTypes + 1; }
|
|
|
|
void **argv() const { return returnAndArgs + 1; }
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Q_QML_PRIVATE_EXPORT JSTypesStackFrame : public CppStackFrame
|
|
|
|
{
|
|
|
|
// The JIT needs to poke directly into those using offsetof
|
|
|
|
using CppStackFrame::unwindHandler;
|
|
|
|
using CppStackFrame::unwindLabel;
|
|
|
|
using CppStackFrame::unwindLevel;
|
|
|
|
|
|
|
|
void init(Function *v4Function, const Value *argv, int argc,
|
|
|
|
bool callerCanHandleTailCall = false)
|
|
|
|
{
|
|
|
|
CppStackFrame::init(v4Function, argc, Kind::JS);
|
|
|
|
CppStackFrame::originalArguments = argv;
|
|
|
|
CppStackFrame::yield = nullptr;
|
|
|
|
CppStackFrame::unwindHandler = nullptr;
|
|
|
|
CppStackFrame::yieldIsIterator = false;
|
|
|
|
CppStackFrame::callerCanHandleTailCall = callerCanHandleTailCall;
|
|
|
|
CppStackFrame::pendingTailCall = false;
|
|
|
|
CppStackFrame::isTailCalling = false;
|
|
|
|
CppStackFrame::unwindLabel = nullptr;
|
|
|
|
CppStackFrame::unwindLevel = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
const Value *argv() const { return originalArguments; }
|
|
|
|
|
|
|
|
void setupJSFrame(Value *stackSpace, const Value &function, const Heap::ExecutionContext *scope,
|
|
|
|
const Value &thisObject, const Value &newTarget = Value::undefinedValue()) {
|
|
|
|
setupJSFrame(stackSpace, function, scope, thisObject, newTarget,
|
|
|
|
v4Function->compiledFunction->nFormals,
|
|
|
|
v4Function->compiledFunction->nRegisters);
|
|
|
|
}
|
|
|
|
|
|
|
|
void setupJSFrame(
|
|
|
|
Value *stackSpace, const Value &function, const Heap::ExecutionContext *scope,
|
|
|
|
const Value &thisObject, const Value &newTarget, uint nFormals, uint nRegisters)
|
|
|
|
{
|
|
|
|
CppStackFrame::setupJSFrame(stackSpace, function, scope, thisObject, newTarget);
|
2021-03-11 13:52:21 +00:00
|
|
|
|
2018-06-27 15:23:39 +00:00
|
|
|
uint argc = uint(originalArgumentsCount);
|
2018-06-30 17:19:18 +00:00
|
|
|
if (argc > nFormals)
|
|
|
|
argc = nFormals;
|
2018-06-27 15:23:39 +00:00
|
|
|
jsFrame->setArgc(argc);
|
|
|
|
|
2021-05-28 08:27:24 +00:00
|
|
|
// memcpy requires non-null ptr, even if argc * sizeof(Value) == 0
|
|
|
|
if (originalArguments)
|
|
|
|
memcpy(jsFrame->args, originalArguments, argc * sizeof(Value));
|
2018-09-11 08:27:32 +00:00
|
|
|
Q_STATIC_ASSERT(Encode::undefined() == 0);
|
Optimize stack frame setup for AOT compiled functions
When called via the metaobject system, parameters and return values are
passed as void*, with accompanying type information in the form of
QMetaType. The same format is expected when calling an AOT
compiled function.
Previously, we would first convert all the parameters to QV4::Value,
just to convert them back the moment we notice that there is an AOT
compiled function. This is wasteful.
This change provides a second call infrastructure that accepts void* and
QMetaType as parameter and return value format, and passes them as-is
all the way to any AOT compiled functions. If there is no AOT compiled
function, the conversion is done when detecting this, rather than when
initiating the call. This also passes the information "ignore return
value" all the way down to the actual function call. If the caller is
not interested in the return value, we don't have to marshal it back at
all.
For now, we only add the extra "callWithMetaTypes" vtable entry to
ArrowFunction. However, other callables could also receive variants
optimized for calling with void*/int rather than V4 values.
This required changing the way how function arguments are stored in the
property cache. We squeeze the return type into
QQmlPropertyCacheMethodArguments now, and we use QMetaType instead of
integers. In turn, we remove some unused bits.
Change-Id: I946e603e623d9d985c54d3a15f6f4b7c7b7d8c60
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-03-12 22:25:30 +00:00
|
|
|
memset(jsFrame->args + argc, 0, (nRegisters - argc) * sizeof(Value));
|
2018-08-21 14:51:17 +00:00
|
|
|
|
|
|
|
if (v4Function && v4Function->compiledFunction) {
|
Optimize stack frame setup for AOT compiled functions
When called via the metaobject system, parameters and return values are
passed as void*, with accompanying type information in the form of
QMetaType. The same format is expected when calling an AOT
compiled function.
Previously, we would first convert all the parameters to QV4::Value,
just to convert them back the moment we notice that there is an AOT
compiled function. This is wasteful.
This change provides a second call infrastructure that accepts void* and
QMetaType as parameter and return value format, and passes them as-is
all the way to any AOT compiled functions. If there is no AOT compiled
function, the conversion is done when detecting this, rather than when
initiating the call. This also passes the information "ignore return
value" all the way down to the actual function call. If the caller is
not interested in the return value, we don't have to marshal it back at
all.
For now, we only add the extra "callWithMetaTypes" vtable entry to
ArrowFunction. However, other callables could also receive variants
optimized for calling with void*/int rather than V4 values.
This required changing the way how function arguments are stored in the
property cache. We squeeze the return type into
QQmlPropertyCacheMethodArguments now, and we use QMetaType instead of
integers. In turn, we remove some unused bits.
Change-Id: I946e603e623d9d985c54d3a15f6f4b7c7b7d8c60
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-03-12 22:25:30 +00:00
|
|
|
const int firstDeadZoneRegister
|
|
|
|
= v4Function->compiledFunction->firstTemporalDeadZoneRegister;
|
|
|
|
const int registerDeadZoneSize
|
|
|
|
= v4Function->compiledFunction->sizeOfRegisterTemporalDeadZone;
|
2018-08-21 14:51:17 +00:00
|
|
|
|
|
|
|
const Value * tdzEnd = stackSpace + firstDeadZoneRegister + registerDeadZoneSize;
|
|
|
|
for (Value *v = stackSpace + firstDeadZoneRegister; v < tdzEnd; ++v)
|
2018-09-11 09:07:32 +00:00
|
|
|
*v = Value::emptyValue().asReturnedValue();
|
2018-08-21 14:51:17 +00:00
|
|
|
}
|
2018-06-27 15:23:39 +00:00
|
|
|
}
|
2018-06-27 12:18:17 +00:00
|
|
|
|
Optimize stack frame setup for AOT compiled functions
When called via the metaobject system, parameters and return values are
passed as void*, with accompanying type information in the form of
QMetaType. The same format is expected when calling an AOT
compiled function.
Previously, we would first convert all the parameters to QV4::Value,
just to convert them back the moment we notice that there is an AOT
compiled function. This is wasteful.
This change provides a second call infrastructure that accepts void* and
QMetaType as parameter and return value format, and passes them as-is
all the way to any AOT compiled functions. If there is no AOT compiled
function, the conversion is done when detecting this, rather than when
initiating the call. This also passes the information "ignore return
value" all the way down to the actual function call. If the caller is
not interested in the return value, we don't have to marshal it back at
all.
For now, we only add the extra "callWithMetaTypes" vtable entry to
ArrowFunction. However, other callables could also receive variants
optimized for calling with void*/int rather than V4 values.
This required changing the way how function arguments are stored in the
property cache. We squeeze the return type into
QQmlPropertyCacheMethodArguments now, and we use QMetaType instead of
integers. In turn, we remove some unused bits.
Change-Id: I946e603e623d9d985c54d3a15f6f4b7c7b7d8c60
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-03-12 22:25:30 +00:00
|
|
|
bool isTailCalling() const { return CppStackFrame::isTailCalling; }
|
|
|
|
void setTailCalling(bool tailCalling) { CppStackFrame::isTailCalling = tailCalling; }
|
2018-06-27 12:18:17 +00:00
|
|
|
|
Optimize stack frame setup for AOT compiled functions
When called via the metaobject system, parameters and return values are
passed as void*, with accompanying type information in the form of
QMetaType. The same format is expected when calling an AOT
compiled function.
Previously, we would first convert all the parameters to QV4::Value,
just to convert them back the moment we notice that there is an AOT
compiled function. This is wasteful.
This change provides a second call infrastructure that accepts void* and
QMetaType as parameter and return value format, and passes them as-is
all the way to any AOT compiled functions. If there is no AOT compiled
function, the conversion is done when detecting this, rather than when
initiating the call. This also passes the information "ignore return
value" all the way down to the actual function call. If the caller is
not interested in the return value, we don't have to marshal it back at
all.
For now, we only add the extra "callWithMetaTypes" vtable entry to
ArrowFunction. However, other callables could also receive variants
optimized for calling with void*/int rather than V4 values.
This required changing the way how function arguments are stored in the
property cache. We squeeze the return type into
QQmlPropertyCacheMethodArguments now, and we use QMetaType instead of
integers. In turn, we remove some unused bits.
Change-Id: I946e603e623d9d985c54d3a15f6f4b7c7b7d8c60
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-03-12 22:25:30 +00:00
|
|
|
bool pendingTailCall() const { return CppStackFrame::pendingTailCall; }
|
|
|
|
void setPendingTailCall(bool pending) { CppStackFrame::pendingTailCall = pending; }
|
|
|
|
|
|
|
|
const char *yield() const { return CppStackFrame::yield; }
|
|
|
|
void setYield(const char *yield) { CppStackFrame::yield = yield; }
|
|
|
|
|
|
|
|
bool yieldIsIterator() const { return CppStackFrame::yieldIsIterator; }
|
|
|
|
void setYieldIsIterator(bool isIter) { CppStackFrame::yieldIsIterator = isIter; }
|
|
|
|
|
|
|
|
bool callerCanHandleTailCall() const { return CppStackFrame::callerCanHandleTailCall; }
|
2018-06-27 12:18:17 +00:00
|
|
|
};
|
|
|
|
|
Optimize stack frame setup for AOT compiled functions
When called via the metaobject system, parameters and return values are
passed as void*, with accompanying type information in the form of
QMetaType. The same format is expected when calling an AOT
compiled function.
Previously, we would first convert all the parameters to QV4::Value,
just to convert them back the moment we notice that there is an AOT
compiled function. This is wasteful.
This change provides a second call infrastructure that accepts void* and
QMetaType as parameter and return value format, and passes them as-is
all the way to any AOT compiled functions. If there is no AOT compiled
function, the conversion is done when detecting this, rather than when
initiating the call. This also passes the information "ignore return
value" all the way down to the actual function call. If the caller is
not interested in the return value, we don't have to marshal it back at
all.
For now, we only add the extra "callWithMetaTypes" vtable entry to
ArrowFunction. However, other callables could also receive variants
optimized for calling with void*/int rather than V4 values.
This required changing the way how function arguments are stored in the
property cache. We squeeze the return type into
QQmlPropertyCacheMethodArguments now, and we use QMetaType instead of
integers. In turn, we remove some unused bits.
Change-Id: I946e603e623d9d985c54d3a15f6f4b7c7b7d8c60
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
2021-03-12 22:25:30 +00:00
|
|
|
Q_STATIC_ASSERT(sizeof(CppStackFrame) == sizeof(JSTypesStackFrame));
|
|
|
|
Q_STATIC_ASSERT(sizeof(CppStackFrame) == sizeof(MetaTypesStackFrame));
|
|
|
|
Q_STATIC_ASSERT(std::is_standard_layout_v<CppStackFrame>);
|
|
|
|
Q_STATIC_ASSERT(std::is_standard_layout_v<JSTypesStackFrame>);
|
|
|
|
Q_STATIC_ASSERT(std::is_standard_layout_v<MetaTypesStackFrame>);
|
|
|
|
|
2018-06-27 12:18:17 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
QT_END_NAMESPACE
|
|
|
|
|
|
|
|
#endif
|