diff options
author | Erik Verbruggen <erik.verbruggen@qt.io> | 2018-11-23 12:50:27 +0100 |
---|---|---|
committer | Erik Verbruggen <erik.verbruggen@qt.io> | 2019-03-04 12:55:16 +0000 |
commit | 80f9634f7e3a1c31cda0c804d811c532aeee103b (patch) | |
tree | f9fb44f5f8a952021014109e109411ca29698897 /src/qml/jsruntime | |
parent | 00bcc365403f253e0c6fd54b7b1715ba974679c5 (diff) |
V4: Add IR that can use traced information to JIT
This is the in a series of patches for a JIT that can use traced
information to generate better code. In this patch, traced information
is not used/stored yet. It allows testing the basic infrastructure
without trying to do any optimizations, therefore making it easier to
debug, test, and review.
Change-Id: I589bdadf731c36542331abe64e1b39e305b6723e
Reviewed-by: Ulf Hermann <ulf.hermann@qt.io>
Diffstat (limited to 'src/qml/jsruntime')
-rw-r--r-- | src/qml/jsruntime/qv4runtimeapi_p.h | 2 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4vme_moth.cpp | 40 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4vme_moth_p.h | 2 |
3 files changed, 37 insertions, 7 deletions
diff --git a/src/qml/jsruntime/qv4runtimeapi_p.h b/src/qml/jsruntime/qv4runtimeapi_p.h index d3ce828254..0312522d90 100644 --- a/src/qml/jsruntime/qv4runtimeapi_p.h +++ b/src/qml/jsruntime/qv4runtimeapi_p.h @@ -293,7 +293,7 @@ struct Q_QML_PRIVATE_EXPORT Runtime { { static ReturnedValue call(ExecutionEngine *); }; - struct Q_QML_PRIVATE_EXPORT CreateRestParameter : Method<Throws::Yes> + struct Q_QML_PRIVATE_EXPORT CreateRestParameter : PureMethod { static ReturnedValue call(ExecutionEngine *, int); }; diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index c16bd7aae1..3098837e1c 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -65,6 +65,8 @@ #undef COUNT_INSTRUCTIONS +enum { ShowWhenDeoptimiationHappens = 0 }; + extern "C" { // This is the interface to Qt Creator's (new) QML debugger. @@ -488,13 +490,17 @@ ReturnedValue VME::exec(CppStackFrame *frame, ExecutionEngine *engine) #ifdef V4_ENABLE_JIT if (debugger == nullptr) { if (function->jittedCode == nullptr) { - if (engine->canJIT(function)) - QV4::JIT::BaselineJIT(function).generate(); - else + if (engine->canJIT(function)) { +#if QT_CONFIG(qml_tracing) + if (function->tracingEnabled()) + runTracingJit(function); + else +#endif + QV4::JIT::BaselineJIT(function).generate(); + } else { ++function->interpreterCallCount; + } } - if (function->jittedCode != nullptr) - return function->jittedCode(frame, engine); } #endif // V4_ENABLE_JIT @@ -502,7 +508,29 @@ ReturnedValue VME::exec(CppStackFrame *frame, ExecutionEngine *engine) if (debugger) debugger->enteringFunction(); - ReturnedValue result = interpret(frame, engine, function->codeData); + ReturnedValue result; + if (function->jittedCode != nullptr && debugger == nullptr) { + result = function->jittedCode(frame, engine); + if (QV4::Value::fromReturnedValue(result).isEmpty()) { // de-optimize! + if (ShowWhenDeoptimiationHappens) { + // This is debug code, which is disabled by default, and completely removed by the + // compiler. + fprintf(stderr, "*********************** DEOPT! %s ***********************\n" + "*** deopt IP: %d, line: %d\n", + function->name()->toQString().toUtf8().constData(), + frame->instructionPointer, + frame->lineNumber()); + } + delete function->codeRef; + function->codeRef = nullptr; + function->jittedCode = nullptr; + function->interpreterCallCount = 0; // reset to restart tracing: apparently we didn't have enough info before + result = interpret(frame, engine, function->codeData + frame->instructionPointer); + } + } else { + // interpreter + result = interpret(frame, engine, function->codeData); + } if (debugger) debugger->leavingFunction(result); diff --git a/src/qml/jsruntime/qv4vme_moth_p.h b/src/qml/jsruntime/qv4vme_moth_p.h index 8a76e60f20..4ac7120d36 100644 --- a/src/qml/jsruntime/qv4vme_moth_p.h +++ b/src/qml/jsruntime/qv4vme_moth_p.h @@ -58,6 +58,8 @@ QT_BEGIN_NAMESPACE namespace QV4 { namespace Moth { +void runTracingJit(QV4::Function *function); + class VME { public: |