diff options
author | Erik Verbruggen <[email protected]> | 2017-11-23 11:34:27 +0100 |
---|---|---|
committer | Erik Verbruggen <[email protected]> | 2017-12-14 09:24:03 +0000 |
commit | 6793683b165bca058e4bd9ee1b3beac8cff12b9d (patch) | |
tree | a3d4b875bd7a5f98d67cd5a870ceb7e756c9f63c /src | |
parent | a1fd2866465c4be2815a6ada776867b3d4efc557 (diff) |
V4: Only start JITting after a minimum of 3 calls
Change-Id: I748e06041f3085980ce48391ba2d829a9d86a727
Reviewed-by: Lars Knoll <[email protected]>
Reviewed-by: Ulf Hermann <[email protected]>
Diffstat (limited to 'src')
-rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 18 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4engine_p.h | 14 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4function_p.h | 1 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4vme_moth.cpp | 8 |
4 files changed, 27 insertions, 14 deletions
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index c57f39f61c..c97ba38dec 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -168,6 +168,15 @@ ExecutionEngine::ExecutionEngine() /* writable */ true, /* executable */ false, /* includesGuardPages */ true); + { + bool ok = false; + jitCallCountThreshold = qEnvironmentVariableIntValue("QV4_JIT_CALL_THRESHOLD", &ok); + if (!ok) + jitCallCountThreshold = 3; + if (qEnvironmentVariableIsSet("QV4_FORCE_INTERPRETER")) + jitCallCountThreshold = std::numeric_limits<int>::max(); + } + exceptionValue = jsAlloca(1); globalObject = static_cast<Object *>(jsAlloca(1)); jsObjects = jsAlloca(NJSObjects); @@ -1545,15 +1554,6 @@ QV4::ReturnedValue ExecutionEngine::metaTypeToJS(int type, const void *data) return 0; } -bool ExecutionEngine::canJIT() -{ -#ifdef V4_ENABLE_JIT - return true; -#else - return false; -#endif -} - // Converts a JS value to a meta-type. // data must point to a place that can store a value of the given type. // Returns true if conversion succeeded, false otherwise. diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h index 346f290feb..61efe0c41e 100644 --- a/src/qml/jsruntime/qv4engine_p.h +++ b/src/qml/jsruntime/qv4engine_p.h @@ -56,7 +56,9 @@ #include <private/qintrusivelist_p.h> #include "qv4enginebase_p.h" + #ifndef V4_BOOTSTRAP +# include "qv4function_p.h" # include <private/qv8engine_p.h> # include <private/qv4compileddata_p.h> #endif @@ -85,6 +87,7 @@ namespace CompiledData { struct CompilationUnit; } +struct Function; struct InternalClass; struct InternalClassPool; @@ -481,13 +484,22 @@ public: bool checkStackLimits(); - static bool canJIT(); + bool canJIT(Function *f) + { +#if defined(V4_ENABLE_JIT) && !defined(V4_BOOTSTRAP) + return f->interpreterCallCount > jitCallCountThreshold; +#else + Q_UNUSED(f); + return false; +#endif + } private: #if QT_CONFIG(qml_debug) QScopedPointer<QV4::Debugging::Debugger> m_debugger; QScopedPointer<QV4::Profiling::Profiler> m_profiler; #endif + int jitCallCountThreshold; }; // This is a trick to tell the code generators that functions taking a NoThrowContext won't diff --git a/src/qml/jsruntime/qv4function_p.h b/src/qml/jsruntime/qv4function_p.h index 0e61be5115..dcbd41f2e6 100644 --- a/src/qml/jsruntime/qv4function_p.h +++ b/src/qml/jsruntime/qv4function_p.h @@ -83,6 +83,7 @@ struct Q_QML_EXPORT Function { // first nArguments names in internalClass are the actual arguments InternalClass *internalClass; uint nFormals; + int interpreterCallCount = 0; bool hasQmlDependencies; Function(ExecutionEngine *engine, CompiledData::CompilationUnit *unit, const CompiledData::Function *function, Code codePtr); diff --git a/src/qml/jsruntime/qv4vme_moth.cpp b/src/qml/jsruntime/qv4vme_moth.cpp index c21d992e98..6956112718 100644 --- a/src/qml/jsruntime/qv4vme_moth.cpp +++ b/src/qml/jsruntime/qv4vme_moth.cpp @@ -552,17 +552,17 @@ QV4::ReturnedValue VME::exec(const FunctionObject *fo, const Value *thisObject, Profiling::FunctionCallProfiler profiler(engine, function); // start execution profiling QV4::Debugging::Debugger *debugger = engine->debugger(); - const uchar *exceptionHandler = 0; QV4::Value &accumulator = frame.jsFrame->accumulator; QV4::ReturnedValue acc = Encode::undefined(); #ifdef V4_ENABLE_JIT - static const bool forceInterpreter = qEnvironmentVariableIsSet("QV4_FORCE_INTERPRETER"); - if (function->jittedCode == nullptr) { - if (ExecutionEngine::canJIT() && debugger == nullptr && !forceInterpreter) + if (function->jittedCode == nullptr && debugger == nullptr) { + if (engine->canJIT(function)) QV4::JIT::BaselineJIT(function).generate(); + else + ++function->interpreterCallCount; } #endif // V4_ENABLE_JIT |