aboutsummaryrefslogtreecommitdiffstats
path: root/src/qml/jsruntime/qv4function_p.h
diff options
context:
space:
mode:
authorErik Verbruggen <erik.verbruggen@qt.io>2018-10-09 14:58:01 +0200
committerErik Verbruggen <erik.verbruggen@qt.io>2019-01-25 10:26:13 +0000
commit784a55a15ddc65b59cc4709e54453238438eae48 (patch)
tree2903e0c690a8aef0b49f3e5d6c26ef4ac90543aa /src/qml/jsruntime/qv4function_p.h
parent923fef3ad3076e337eba4e603a6f759c54cc404c (diff)
V4: Collect trace information in the interpreter
Collect type information about values used in a function. These include all parameters, and the results of many bytecode instructions. For array loads/stores, it also tracks if the access is in-bounds of a SimpleArrayData. Collection is only enabled when the qml-tracing feature is turned on while configuring. In subsequent patches this is used to generated optimized JITted code. Change-Id: I63985c334c3fdc55fca7fb4addfe3e535989aac5 Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/jsruntime/qv4function_p.h')
-rw-r--r--src/qml/jsruntime/qv4function_p.h47
1 files changed, 43 insertions, 4 deletions
diff --git a/src/qml/jsruntime/qv4function_p.h b/src/qml/jsruntime/qv4function_p.h
index 86343ea061..374e46b929 100644
--- a/src/qml/jsruntime/qv4function_p.h
+++ b/src/qml/jsruntime/qv4function_p.h
@@ -64,10 +64,24 @@ struct QQmlSourceLocation;
namespace QV4 {
-struct Q_QML_EXPORT Function {
- const CompiledData::Function *compiledFunction;
+struct Q_QML_EXPORT FunctionData {
CompiledData::CompilationUnit *compilationUnit;
+ FunctionData(CompiledData::CompilationUnit *compilationUnit)
+ : compilationUnit(compilationUnit)
+ {}
+};
+// Make sure this class can be accessed through offsetof (done by the assemblers):
+Q_STATIC_ASSERT(std::is_standard_layout< FunctionData >::value);
+
+struct Q_QML_EXPORT Function : public FunctionData {
+private:
+ Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit, const CompiledData::Function *function);
+ ~Function();
+
+public:
+ const CompiledData::Function *compiledFunction;
+
ReturnedValue call(const Value *thisObject, const Value *argv, int argc, const ExecutionContext *context);
const char *codeData;
@@ -83,8 +97,8 @@ struct Q_QML_EXPORT Function {
bool hasQmlDependencies;
bool isEval = false;
- Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit, const CompiledData::Function *function);
- ~Function();
+ static Function *create(ExecutionEngine *engine, CompiledData::CompilationUnit *unit, const CompiledData::Function *function);
+ void destroy();
// used when dynamically assigning signal handlers (QQmlConnection)
void updateInternalClass(ExecutionEngine *engine, const QList<QByteArray> &parameters);
@@ -110,6 +124,31 @@ struct Q_QML_EXPORT Function {
return nullptr;
return compilationUnit->runtimeFunctions[compiledFunction->nestedFunctionIndex];
}
+
+ Q_NEVER_INLINE QString traceInfoToString();
+
+ quint8 *traceInfo(uint i)
+ {
+#if QT_CONFIG(qml_tracing)
+ Q_ASSERT((tracingEnabled() && i < traceInfoCount()) || (i == 0));
+ return reinterpret_cast<quint8 *>(this) + sizeof(Function) + i;
+#else
+ Q_UNUSED(i);
+ return nullptr;
+#endif
+ }
+
+ quint32 traceInfoCount() const
+ { return compiledFunction->nTraceInfos; }
+
+ bool tracingEnabled() const
+ {
+#if QT_CONFIG(qml_tracing)
+ return traceInfoCount() != CompiledData::Function::NoTracing();
+#else
+ return false;
+#endif
+ }
};
}