Add flag to the engine to enable/disable RegExp JITting.
authorErik Verbruggen <erik.verbruggen@me.com>
Tue, 7 May 2013 09:54:45 +0000 (11:54 +0200)
committerSimon Hausmann <simon.hausmann@digia.com>
Wed, 8 May 2013 11:15:38 +0000 (13:15 +0200)
Change-Id: I4b632e6f8ab7cf20576f94764ed506de8be63efb
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
src/3rdparty/masm/masm-defs.pri
src/qml/qml/v4/moth/qv4isel_moth_p.h
src/qml/qml/v4/qv4engine.cpp
src/qml/qml/v4/qv4isel_masm_p.h
src/qml/qml/v4/qv4isel_p.h
src/qml/qml/v4/qv4regexp.cpp
tools/v4/main.cpp

index a75de9f..8265bba 100644 (file)
@@ -1,3 +1,4 @@
+DEFINES += V4_ENABLE_JIT
 
 DEFINES += WTF_EXPORT_PRIVATE="" JS_EXPORT_PRIVATE=""
 
index 23ca930..58f8eec 100644 (file)
@@ -3,6 +3,7 @@
 
 #include <private/qv4global_p.h>
 #include <private/qv4isel_p.h>
+#include <private/qv4isel_util_p.h>
 #include <private/qv4jsir_p.h>
 #include <private/qv4object_p.h>
 #include "qv4instr_moth_p.h"
@@ -154,6 +155,8 @@ public:
     virtual ~ISelFactory() {}
     virtual EvalInstructionSelection *create(QV4::ExecutionEngine *engine, V4IR::Module *module)
     { return new InstructionSelection(engine, module); }
+    virtual bool jitCompileRegexps() const
+    { return false; }
 };
 
 template<int InstrT>
index f26e616..e702a06 100644 (file)
 #include <qv4stringobject_p.h>
 #include <qv4identifier_p.h>
 #include <qv4unwindhelper_p.h>
-#include "qv4isel_masm_p.h"
 #include "qv4debugging_p.h"
 #include "qv4executableallocator_p.h"
 
+#ifdef V4_ENABLE_JIT
+#  include "qv4isel_masm_p.h"
+#else // !V4_ENABLE_JIT
+#  include "qv4isel_moth_p.h"
+#endif // V4_ENABLE_JIT
+
 using namespace QV4;
 
 ExecutionEngine::ExecutionEngine(QQmlJS::EvalISelFactory *factory)
@@ -76,8 +81,13 @@ ExecutionEngine::ExecutionEngine(QQmlJS::EvalISelFactory *factory)
 {
     MemoryManager::GCBlocker gcBlocker(memoryManager);
 
-    if (!factory)
+    if (!factory) {
+#ifdef V4_ENABLE_JIT
         factory = new QQmlJS::MASM::ISelFactory;
+#else // !V4_ENABLE_JIT
+        factory = new QQmlJS::Moth::ISelFactory;
+#endif // V4_ENABLE_JIT
+    }
     iselFactory.reset(factory);
 
     memoryManager->setExecutionEngine(this);
index 396801b..437c250 100644 (file)
@@ -891,6 +891,8 @@ public:
     virtual ~ISelFactory() {}
     virtual EvalInstructionSelection *create(QV4::ExecutionEngine *engine, V4IR::Module *module)
     { return new InstructionSelection(engine, module); }
+    virtual bool jitCompileRegexps() const
+    { return true; }
 };
 
 } // end of namespace MASM
index b3efacc..6739ff1 100644 (file)
@@ -82,6 +82,7 @@ class Q_QML_EXPORT EvalISelFactory
 public:
     virtual ~EvalISelFactory() = 0;
     virtual EvalInstructionSelection *create(QV4::ExecutionEngine *engine, V4IR::Module *module) = 0;
+    virtual bool jitCompileRegexps() const = 0;
 };
 
 namespace V4IR {
index 6ea9841..053a32d 100644 (file)
@@ -111,7 +111,7 @@ RegExp::RegExp(ExecutionEngine* engine, const QString &pattern, bool ignoreCase,
     m_subPatternCount = yarrPattern.m_numSubpatterns;
     m_byteCode = JSC::Yarr::byteCompile(yarrPattern, engine->bumperPointerAllocator);
 #if ENABLE(YARR_JIT)
-    if (!yarrPattern.m_containsBackreferences) {
+    if (!yarrPattern.m_containsBackreferences && engine->iselFactory->jitCompileRegexps()) {
         JSC::JSGlobalData dummy(engine->executableAllocator);
         JSC::Yarr::jitCompile(yarrPattern, JSC::Yarr::Char16, &dummy, m_jitCode);
     }
index 525649f..5529930 100644 (file)
@@ -50,7 +50,6 @@
 #include "private/qv4errorobject_p.h"
 #include "private/qv4globalobject_p.h"
 #include "private/qv4codegen_p.h"
-#include "private/qv4isel_masm_p.h"
 #include "private/qv4isel_moth_p.h"
 #include "private/qv4vme_moth_p.h"
 #include "private/qv4syntaxchecker_p.h"
 #include "private/qv4mm_p.h"
 #include "private/qv4context_p.h"
 
+#ifdef V4_ENABLE_JIT
+#  include "private/qv4isel_masm_p.h"
+#endif // V4_ENABLE_JIT
+
 #include <QtCore>
 #include <private/qqmljsengine_p.h>
 #include <private/qqmljslexer_p.h>
@@ -345,8 +348,10 @@ int main(int argc, char *argv[])
         QQmlJS::EvalISelFactory* iSelFactory = 0;
         if (mode == use_moth) {
             iSelFactory = new QQmlJS::Moth::ISelFactory;
+#ifdef V4_ENABLE_JIT
         } else {
             iSelFactory = new QQmlJS::MASM::ISelFactory;
+#endif // V4_ENABLE_JIT
         }
 
         QV4::ExecutionEngine vm(iSelFactory);