diff options
-rw-r--r-- | src/qml/jsruntime/qv4engine.cpp | 3 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4engine_p.h | 11 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4regexp.cpp | 6 | ||||
-rw-r--r-- | src/qml/jsruntime/qv4regexp_p.h | 2 |
4 files changed, 16 insertions, 6 deletions
diff --git a/src/qml/jsruntime/qv4engine.cpp b/src/qml/jsruntime/qv4engine.cpp index 259df976c5..ce29afdb6c 100644 --- a/src/qml/jsruntime/qv4engine.cpp +++ b/src/qml/jsruntime/qv4engine.cpp @@ -120,6 +120,9 @@ QQmlEngine *ExecutionEngine::qmlEngine() const #endif // V4_BOOTSTRAP qint32 ExecutionEngine::maxCallDepth = -1; +#if defined(V4_ENABLE_JIT) && !defined(V4_BOOTSTRAP) +const bool ExecutionEngine::canAllocateExecutableMemory = OSAllocator::canAllocateExecutableMemory(); +#endif ExecutionEngine::ExecutionEngine() : executableAllocator(new QV4::ExecutableAllocator) diff --git a/src/qml/jsruntime/qv4engine_p.h b/src/qml/jsruntime/qv4engine_p.h index c048f5f68d..930ad8fed1 100644 --- a/src/qml/jsruntime/qv4engine_p.h +++ b/src/qml/jsruntime/qv4engine_p.h @@ -484,10 +484,14 @@ public: bool checkStackLimits(); - bool canJIT(Function *f) + bool canJIT(Function *f = nullptr) { #if defined(V4_ENABLE_JIT) && !defined(V4_BOOTSTRAP) - return f->interpreterCallCount >= jitCallCountThreshold; + if (!canAllocateExecutableMemory) + return false; + if (f) + return f->interpreterCallCount >= jitCallCountThreshold; + return true; #else Q_UNUSED(f); return false; @@ -502,6 +506,9 @@ private: QScopedPointer<QV4::Profiling::Profiler> m_profiler; #endif int jitCallCountThreshold; +#if defined(V4_ENABLE_JIT) && !defined(V4_BOOTSTRAP) + static const bool canAllocateExecutableMemory; +#endif }; // This is a trick to tell the code generators that functions taking a NoThrowContext won't diff --git a/src/qml/jsruntime/qv4regexp.cpp b/src/qml/jsruntime/qv4regexp.cpp index fb49def317..36616bc024 100644 --- a/src/qml/jsruntime/qv4regexp.cpp +++ b/src/qml/jsruntime/qv4regexp.cpp @@ -82,7 +82,7 @@ Heap::RegExp *RegExp::create(ExecutionEngine* engine, const QString& pattern, bo return result->d(); Scope scope(engine); - Scoped<RegExp> result(scope, engine->memoryManager->alloc<RegExp>(pattern, ignoreCase, multiline, global)); + Scoped<RegExp> result(scope, engine->memoryManager->alloc<RegExp>(engine, pattern, ignoreCase, multiline, global)); result->d()->cache = cache; cachedValue.set(engine, result); @@ -90,7 +90,7 @@ Heap::RegExp *RegExp::create(ExecutionEngine* engine, const QString& pattern, bo return result->d(); } -void Heap::RegExp::init(const QString &pattern, bool ignoreCase, bool multiline, bool global) +void Heap::RegExp::init(ExecutionEngine *engine, const QString &pattern, bool ignoreCase, bool multiline, bool global) { Base::init(); this->pattern = new QString(pattern); @@ -106,7 +106,7 @@ void Heap::RegExp::init(const QString &pattern, bool ignoreCase, bool multiline, return; subPatternCount = yarrPattern.m_numSubpatterns; #if ENABLE(YARR_JIT) - if (!yarrPattern.m_containsBackreferences) { + if (!yarrPattern.m_containsBackreferences && engine->canJIT()) { jitCode = new JSC::Yarr::YarrCodeBlock; JSC::JSGlobalData dummy(internalClass->engine->regExpAllocator); JSC::Yarr::jitCompile(yarrPattern, JSC::Yarr::Char16, &dummy, *jitCode); diff --git a/src/qml/jsruntime/qv4regexp_p.h b/src/qml/jsruntime/qv4regexp_p.h index 94bebbd931..56454f73d3 100644 --- a/src/qml/jsruntime/qv4regexp_p.h +++ b/src/qml/jsruntime/qv4regexp_p.h @@ -76,7 +76,7 @@ struct RegExpCacheKey; namespace Heap { struct RegExp : Base { - void init(const QString& pattern, bool ignoreCase, bool multiline, bool global); + void init(ExecutionEngine *engine, const QString& pattern, bool ignoreCase, bool multiline, bool global); void destroy(); QString *pattern; |