2022-05-13 13:12:05 +00:00
|
|
|
// Copyright (C) 2018 The Qt Company Ltd.
|
2025-01-03 05:44:42 +00:00
|
|
|
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
|
2018-06-27 12:18:17 +00:00
|
|
|
#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
|
|
|
|
{
|
2021-05-17 14:38:25 +00:00
|
|
|
enum class Kind : quint8 { JS, Meta };
|
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 12:18:17 +00:00
|
|
|
CppStackFrame *parent;
|
|
|
|
Function *v4Function;
|
|
|
|
int originalArgumentsCount;
|
|
|
|
int instructionPointer;
|
2018-06-27 15:23:39 +00:00
|
|
|
|
2022-04-28 02:09:34 +00:00
|
|
|
QT_WARNING_PUSH
|
|
|
|
QT_WARNING_DISABLE_MSVC(4201) // nonstandard extension used: nameless struct/union
|
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 {
|
2021-05-17 14:38:25 +00:00
|
|
|
Value *savedStackTop;
|
|
|
|
CallData *jsFrame;
|
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 *originalArguments;
|
|
|
|
const char *yield;
|
|
|
|
const char *unwindHandler;
|
|
|
|
const char *unwindLabel;
|
|
|
|
int unwindLevel;
|
|
|
|
bool yieldIsIterator;
|
|
|
|
bool callerCanHandleTailCall;
|
|
|
|
bool pendingTailCall;
|
|
|
|
bool isTailCalling;
|
|
|
|
};
|
|
|
|
struct {
|
2021-05-17 14:38:25 +00:00
|
|
|
ExecutionContext *context;
|
|
|
|
QObject *thisObject;
|
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 QMetaType *metaTypes;
|
|
|
|
void **returnAndArgs;
|
2021-06-15 07:38:17 +00:00
|
|
|
bool returnValueIsUndefined;
|
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
|
|
|
};
|
|
|
|
};
|
2022-04-28 02:09:34 +00:00
|
|
|
QT_WARNING_POP
|
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
|
|
|
|
|
|
|
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;
|
|
|
|
|
2021-05-17 14:38:25 +00:00
|
|
|
void init(Function *v4Function, int argc, Kind kind) {
|
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 isJSTypesFrame() const { return kind == Kind::JS; }
|
|
|
|
bool isMetaTypesFrame() const { return kind == Kind::Meta; }
|
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
|
|
|
QString source() const;
|
|
|
|
QString function() const;
|
|
|
|
int lineNumber() const;
|
2022-09-29 11:30:42 +00:00
|
|
|
int statementNumber() const;
|
2021-05-17 14:38:25 +00:00
|
|
|
|
2023-05-08 09:38:14 +00:00
|
|
|
int missingLineNumber() const;
|
|
|
|
|
2021-05-17 14:38:25 +00:00
|
|
|
CppStackFrame *parentFrame() const { return parent; }
|
|
|
|
void setParentFrame(CppStackFrame *parentFrame) { parent = parentFrame; }
|
|
|
|
|
|
|
|
int argc() const { return originalArgumentsCount; }
|
|
|
|
|
|
|
|
inline ExecutionContext *context() const;
|
|
|
|
|
|
|
|
Heap::CallContext *callContext() const { return callContext(context()->d()); }
|
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
|
|
|
ReturnedValue thisObject() const;
|
2018-06-27 15:23:39 +00:00
|
|
|
|
2021-05-17 14:38:25 +00:00
|
|
|
protected:
|
|
|
|
CppStackFrame() = default;
|
|
|
|
|
|
|
|
void push(EngineBase *engine)
|
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
|
|
|
{
|
2021-05-17 14:38:25 +00:00
|
|
|
Q_ASSERT(kind == Kind::JS || kind == Kind::Meta);
|
|
|
|
parent = engine->currentStackFrame;
|
|
|
|
engine->currentStackFrame = this;
|
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
|
|
|
}
|
|
|
|
|
2021-05-17 14:38:25 +00:00
|
|
|
void pop(EngineBase *engine)
|
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
|
|
|
{
|
2021-05-17 14:38:25 +00:00
|
|
|
engine->currentStackFrame = parent;
|
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
|
|
|
}
|
|
|
|
|
2021-05-17 14:38:25 +00:00
|
|
|
Heap::CallContext *callContext(Heap::ExecutionContext *ctx) const
|
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
|
|
|
{
|
|
|
|
while (ctx->type != Heap::ExecutionContext::Type_CallContext)
|
|
|
|
ctx = ctx->outer;
|
|
|
|
return static_cast<Heap::CallContext *>(ctx);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
struct Q_QML_PRIVATE_EXPORT MetaTypesStackFrame : public CppStackFrame
|
|
|
|
{
|
2021-05-17 14:38:25 +00:00
|
|
|
using CppStackFrame::push;
|
|
|
|
using CppStackFrame::pop;
|
|
|
|
|
|
|
|
void init(Function *v4Function, QObject *thisObject, ExecutionContext *context,
|
|
|
|
void **returnAndArgs, const QMetaType *metaTypes, int argc)
|
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
|
|
|
{
|
|
|
|
CppStackFrame::init(v4Function, argc, Kind::Meta);
|
2021-05-17 14:38:25 +00:00
|
|
|
CppStackFrameBase::thisObject = thisObject;
|
|
|
|
CppStackFrameBase::context = context;
|
|
|
|
CppStackFrameBase::metaTypes = metaTypes;
|
|
|
|
CppStackFrameBase::returnAndArgs = returnAndArgs;
|
2021-06-15 07:38:17 +00:00
|
|
|
CppStackFrameBase::returnValueIsUndefined = false;
|
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
|
|
|
}
|
|
|
|
|
|
|
|
QMetaType returnType() const { return metaTypes[0]; }
|
|
|
|
void *returnValue() const { return returnAndArgs[0]; }
|
|
|
|
|
2021-06-15 07:38:17 +00:00
|
|
|
bool isReturnValueUndefined() const { return CppStackFrameBase::returnValueIsUndefined; }
|
|
|
|
void setReturnValueUndefined() { CppStackFrameBase::returnValueIsUndefined = true; }
|
|
|
|
|
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 QMetaType *argTypes() const { return metaTypes + 1; }
|
|
|
|
void **argv() const { return returnAndArgs + 1; }
|
2021-05-17 14:38:25 +00:00
|
|
|
|
|
|
|
QObject *thisObject() const { return CppStackFrameBase::thisObject; }
|
|
|
|
|
|
|
|
ExecutionContext *context() const { return CppStackFrameBase::context; }
|
|
|
|
void setContext(ExecutionContext *context) { CppStackFrameBase::context = context; }
|
|
|
|
|
|
|
|
Heap::CallContext *callContext() const
|
|
|
|
{
|
|
|
|
return CppStackFrame::callContext(CppStackFrameBase::context->d());
|
|
|
|
}
|
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 Q_QML_PRIVATE_EXPORT JSTypesStackFrame : public CppStackFrame
|
|
|
|
{
|
2021-05-17 14:38:25 +00:00
|
|
|
using CppStackFrame::jsFrame;
|
|
|
|
|
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
|
|
|
// 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; }
|
|
|
|
|
2021-05-17 14:38:25 +00:00
|
|
|
static uint requiredJSStackFrameSize(uint nRegisters) {
|
|
|
|
return CallData::HeaderSize() + nRegisters;
|
|
|
|
}
|
|
|
|
static uint requiredJSStackFrameSize(Function *v4Function) {
|
|
|
|
return CallData::HeaderSize() + v4Function->compiledFunction->nRegisters;
|
|
|
|
}
|
|
|
|
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
|
|
|
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)
|
|
|
|
{
|
2021-05-17 14:38:25 +00:00
|
|
|
jsFrame = reinterpret_cast<CallData *>(stackSpace);
|
|
|
|
jsFrame->function = function;
|
|
|
|
jsFrame->context = scope->asReturnedValue();
|
|
|
|
jsFrame->accumulator = Encode::undefined();
|
|
|
|
jsFrame->thisObject = thisObject;
|
|
|
|
jsFrame->newTarget = 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
|
|
|
|
2021-05-17 14:38:25 +00:00
|
|
|
ExecutionContext *context() const
|
|
|
|
{
|
|
|
|
return static_cast<ExecutionContext *>(&jsFrame->context);
|
|
|
|
}
|
|
|
|
|
|
|
|
void setContext(ExecutionContext *context)
|
|
|
|
{
|
|
|
|
jsFrame->context = context;
|
|
|
|
}
|
|
|
|
|
|
|
|
Heap::CallContext *callContext() const
|
|
|
|
{
|
|
|
|
return CppStackFrame::callContext(static_cast<ExecutionContext &>(jsFrame->context).d());
|
|
|
|
}
|
|
|
|
|
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; }
|
2021-05-17 14:38:25 +00:00
|
|
|
|
|
|
|
ReturnedValue thisObject() const
|
|
|
|
{
|
|
|
|
return jsFrame->thisObject.asReturnedValue();
|
|
|
|
}
|
|
|
|
|
|
|
|
Value *framePointer() const { return savedStackTop; }
|
|
|
|
|
|
|
|
void push(EngineBase *engine) {
|
|
|
|
CppStackFrame::push(engine);
|
|
|
|
savedStackTop = engine->jsStackTop;
|
|
|
|
}
|
|
|
|
|
|
|
|
void pop(EngineBase *engine) {
|
|
|
|
CppStackFrame::pop(engine);
|
|
|
|
engine->jsStackTop = savedStackTop;
|
|
|
|
}
|
2018-06-27 12:18:17 +00:00
|
|
|
};
|
|
|
|
|
2021-05-17 14:38:25 +00:00
|
|
|
inline ExecutionContext *CppStackFrame::context() const
|
|
|
|
{
|
|
|
|
if (isJSTypesFrame())
|
|
|
|
return static_cast<const JSTypesStackFrame *>(this)->context();
|
|
|
|
|
|
|
|
Q_ASSERT(isMetaTypesFrame());
|
|
|
|
return static_cast<const MetaTypesStackFrame *>(this)->context();
|
|
|
|
}
|
|
|
|
|
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
|