Qt 6.x
The Qt SDK
Loading...
Searching...
No Matches
qv4function_p.h
Go to the documentation of this file.
1// Copyright (C) 2016 The Qt Company Ltd.
2// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR LGPL-3.0-only OR GPL-2.0-only OR GPL-3.0-only
3#ifndef QV4FUNCTION_H
4#define QV4FUNCTION_H
5
6//
7// W A R N I N G
8// -------------
9//
10// This file is not part of the Qt API. It exists purely as an
11// implementation detail. This header file may change from version to
12// version without notice, or even be removed.
13//
14// We mean it.
15//
16
17#include <qqmlprivate.h>
18#include "qv4global_p.h"
19#include <private/qv4executablecompilationunit_p.h>
20#include <private/qv4context_p.h>
21#include <private/qv4string_p.h>
22
23namespace JSC {
24class MacroAssemblerCodeRef;
25}
26
28
30
31namespace QV4 {
32
33struct Q_QML_EXPORT FunctionData {
35
36 // Intentionally require an ExecutableCompilationUnit but save only a pointer to
37 // CompilationUnitBase. This is so that we can take advantage of the standard layout
38 // of CompilationUnitBase in the JIT. Furthermore we can safely static_cast to
39 // ExecutableCompilationUnit where we need it.
41 : compilationUnit(compilationUnit)
42 {}
43};
44// Make sure this class can be accessed through offsetof (done by the assemblers):
45Q_STATIC_ASSERT(std::is_standard_layout< FunctionData >::value);
46
47struct Q_QML_EXPORT Function : public FunctionData {
48protected:
51 ~Function();
52
53public:
57 };
58
60
62 {
63 // This is safe: We require an ExecutableCompilationUnit in the ctor.
64 return static_cast<QV4::ExecutableCompilationUnit *>(compilationUnit);
65 }
66
68 {
69 return compilationUnit->runtimeStrings[i];
70 }
71
72 bool call(QObject *thisObject, void **a, const QMetaType *types, int argc,
74 ReturnedValue call(const Value *thisObject, const Value *argv, int argc,
76
77 const char *codeData;
78
79 typedef ReturnedValue (*JittedCode)(CppStackFrame *, ExecutionEngine *);
80 JittedCode jittedCode;
81 JSC::MacroAssemblerCodeRef *codeRef;
82 union {
83 const QQmlPrivate::AOTCompiledFunction *aotCompiledFunction = nullptr;
85 };
86
87 // first nArguments names in internalClass are the actual arguments
89 int interpreterCallCount = 0;
91 enum Kind : quint8 { JsUntyped, JsTyped, AotCompiled, Eval };
92 Kind kind = JsUntyped;
93 bool detectedInjectedParameters = false;
94
96 const CompiledData::Function *function,
97 const QQmlPrivate::AOTCompiledFunction *aotFunction);
98 void destroy();
99
100 // used when dynamically assigning signal handlers (QQmlConnection)
101 void updateInternalClass(ExecutionEngine *engine, const QList<QByteArray> &parameters);
102
103 inline Heap::String *name() const {
104 return runtimeString(compiledFunction->nameIndex);
105 }
106
107 static QString prettyName(const Function *function, const void *address);
108
109 inline QString sourceFile() const { return executableCompilationUnit()->fileName(); }
110 inline QUrl finalUrl() const { return executableCompilationUnit()->finalUrl(); }
111
112 inline bool isStrict() const { return compiledFunction->flags & CompiledData::Function::IsStrict; }
113 inline bool isArrowFunction() const { return compiledFunction->flags & CompiledData::Function::IsArrowFunction; }
114 inline bool isGenerator() const { return compiledFunction->flags & CompiledData::Function::IsGenerator; }
115 inline bool isClosureWrapper() const { return compiledFunction->flags & CompiledData::Function::IsClosureWrapper; }
116
117 QQmlSourceLocation sourceLocation() const;
118
120 {
121 if (compiledFunction->nestedFunctionIndex == std::numeric_limits<uint32_t>::max())
122 return nullptr;
123 return executableCompilationUnit()->runtimeFunctions[compiledFunction->nestedFunctionIndex];
124 }
125};
126
127}
128
130
131#endif
Definition qlist.h:74
\inmodule QtCore
Definition qmetatype.h:320
\inmodule QtCore
Definition qobject.h:90
\macro QT_RESTRICTED_CAST_FROM_ASCII
Definition qstring.h:127
\inmodule QtCore
Definition qurl.h:94
Combined button and popup list for selecting options.
\qmltype Particle \inqmlmodule QtQuick.Particles
quint64 ReturnedValue
static void * context
#define Q_STATIC_ASSERT(Condition)
Definition qassert.h:105
DBusConnection const char DBusError DBusBusType DBusError return DBusConnection DBusHandleMessageFunction function
GLboolean GLboolean GLboolean GLboolean a
[7]
GLsizei GLenum GLenum * types
GLuint GLuint64EXT address
unsigned short quint16
Definition qtypes.h:43
unsigned int uint
Definition qtypes.h:29
unsigned char quint8
Definition qtypes.h:41
view create()
QJSEngine engine
[0]
FunctionData(ExecutableCompilationUnit *compilationUnit)
CompiledData::CompilationUnitBase * compilationUnit
QList< QQmlType > argumentTypes
QUrl finalUrl() const
QString sourceFile() const
const JSTypedFunction * jsTypedFunction
bool isStrict() const
QV4::ExecutableCompilationUnit * executableCompilationUnit() const
bool isArrowFunction() const
const CompiledData::Function * compiledFunction
JSC::MacroAssemblerCodeRef * codeRef
QV4::Heap::String * runtimeString(uint i) const
Function * nestedFunction() const
const char * codeData
Heap::String * name() const
JittedCode jittedCode
bool isClosureWrapper() const
bool isGenerator() const
Heap::InternalClass * internalClass