Disable the old v4 engine by default
authorLars Knoll <lars.knoll@digia.com>
Fri, 19 Apr 2013 20:45:05 +0000 (22:45 +0200)
committerSimon Hausmann <simon.hausmann@digia.com>
Sat, 20 Apr 2013 07:15:30 +0000 (09:15 +0200)
Left the code in there, as a reference for how we might want to
build up binding evaluation in the new v4.

Change-Id: I5c81ea986d642b524fb02087d819b39c4e3fb257
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
src/qml/debugger/qv8debugservice.cpp
src/qml/qml/qml.pri
src/qml/qml/qqmlabstractbinding.cpp
src/qml/qml/qqmlcompiler.cpp
src/qml/qml/qqmlcontext.cpp
src/qml/qml/qqmlcontext_p.h
src/qml/qml/qqmlinstruction.cpp
src/qml/qml/qqmlinstruction_p.h
src/qml/qml/qqmlnotifier.cpp
src/qml/qml/qqmlvme.cpp

index d9d4323..babc6ce 100644 (file)
@@ -191,7 +191,9 @@ void QV8DebugService::init()
 //    ### FIXME: v4
 //    v8::Debug::SetMessageHandler2(DebugMessageHandler);
 //    v8::Debug::SetDebugMessageDispatchHandler(DebugMessageDispatchHandler);
+#ifdef QT_USE_OLD_V4
     QV4Compiler::enableV4(false);
+#endif
 }
 
 // executed in the gui thread
index d0026d4..304e08d 100644 (file)
@@ -130,6 +130,9 @@ HEADERS += \
 include(parser/parser.pri)
 include(rewriter/rewriter.pri)
 include(ftw/ftw.pri)
-include(v4/v4.pri)
+use_old_v4 {
+    include(v4/v4.pri)
+    DEFINES += QT_USE_OLD_V4
+}
 include(v8/v8.pri)
 include(v4vm/v4vm.pri)
index 695dbfb..bf37fd7 100644 (file)
@@ -49,12 +49,18 @@ QT_BEGIN_NAMESPACE
 
 extern QQmlAbstractBinding::VTable QQmlBinding_vtable;
 extern QQmlAbstractBinding::VTable QQmlValueTypeProxyBinding_vtable;
+#ifdef QT_USE_OLD_V4
 extern QQmlAbstractBinding::VTable QV4Bindings_Binding_vtable;
+#endif
 extern QQmlAbstractBinding::VTable QV8Bindings_Binding_vtable;
 
 QQmlAbstractBinding::VTable *QQmlAbstractBinding::vTables[] = {
     &QQmlBinding_vtable,
+#ifdef QT_USE_OLD_V4
     &QV4Bindings_Binding_vtable,
+#else
+    0,
+#endif
     &QV8Bindings_Binding_vtable,
     &QQmlValueTypeProxyBinding_vtable
 };
index 6951c8c..5467bfa 100644 (file)
@@ -60,7 +60,9 @@
 #include "qqmlscriptstring.h"
 #include "qqmlglobal_p.h"
 #include "qqmlbinding_p.h"
+#ifdef QT_USE_OLD_V4
 #include <private/qv4compiler_p.h>
+#endif
 
 #include <QDebug>
 #include <QPointF>
@@ -3545,6 +3547,7 @@ void QQmlCompiler::genBindingAssignment(QQmlScript::Value *binding,
         output->addInstruction(store);
     } else
 #endif
+#ifdef QT_USE_OLD_V4
     if (ref.dataType == BindingReference::V4) {
         const JSBindingReference &js = static_cast<const JSBindingReference &>(ref);
 
@@ -3573,7 +3576,9 @@ void QQmlCompiler::genBindingAssignment(QQmlScript::Value *binding,
             js.dataType = BindingReference::V8;
             genBindingAssignment(binding, prop, obj, valueTypeProperty);
         }
-    } else if (ref.dataType == BindingReference::V8) {
+    } else
+#endif
+    if (ref.dataType == BindingReference::V8) {
         const JSBindingReference &js = static_cast<const JSBindingReference &>(ref);
 
         Instruction::StoreV8Binding store;
@@ -3664,12 +3669,14 @@ bool QQmlCompiler::completeComponentBuild()
          aliasObject = compileState->aliasingObjects.next(aliasObject)) 
         COMPILE_CHECK(buildDynamicMetaAliases(aliasObject));
 
+#ifdef QT_USE_OLD_V4
     QV4Compiler::Expression expr(unit->imports());
     expr.component = compileState->root;
     expr.ids = &compileState->ids;
     expr.importCache = output->importCache;
 
     QV4Compiler bindingCompiler;
+#endif
 
     QList<JSBindingReference*> sharedBindings;
 
@@ -3678,6 +3685,7 @@ bool QQmlCompiler::completeComponentBuild()
         JSBindingReference &binding = *b;
 
         // First try v4
+#ifdef QT_USE_OLD_V4
         expr.context = binding.bindingContext.object;
         expr.property = binding.property;
         expr.expression = binding.expression;
@@ -3696,6 +3704,9 @@ bool QQmlCompiler::completeComponentBuild()
 
             // Drop through. We need to create a V8 binding in case the V4 binding is invalidated
         }
+#else
+        bool needsFallback = false;
+#endif
 
         // Pre-rewrite the expression
         QString expression = binding.expression.asScript();
@@ -3764,8 +3775,10 @@ bool QQmlCompiler::completeComponentBuild()
         compileState->v8BindingProgramLine = startLineNumber;
     }
 
-    if (bindingCompiler.isValid()) 
+#ifdef QT_USE_OLD_V4
+    if (bindingCompiler.isValid())
         compileState->compiledBindingData = bindingCompiler.program();
+#endif
 
     // Check pop()'s matched push()'s
     Q_ASSERT(compileState->objectDepth.depth() == 0);
index e0a16d1..b865ff0 100644 (file)
@@ -48,7 +48,9 @@
 #include "qqmlengine_p.h"
 #include "qqmlengine.h"
 #include "qqmlinfo.h"
+#ifdef QT_USE_OLD_V4
 #include <private/qv4bindings_p.h>
+#endif
 #include <private/qv8bindings_p.h>
 
 #include <qjsengine.h>
@@ -518,7 +520,11 @@ QQmlContextData::QQmlContextData()
   publicContext(0), activeVMEData(0),
   propertyNames(0), contextObject(0), imports(0), childContexts(0), nextChild(0), prevChild(0),
   expressions(0), contextObjects(0), contextGuards(0), idValues(0), idValueCount(0), linkedContext(0),
-  componentAttached(0), v4bindings(0), v8bindings(0)
+  componentAttached(0),
+#ifdef QT_USE_OLD_V4
+  v4bindings(0),
+#endif
+  v8bindings(0)
 {
 }
 
@@ -528,7 +534,11 @@ QQmlContextData::QQmlContextData(QQmlContext *ctxt)
   publicContext(ctxt), activeVMEData(0),
   propertyNames(0), contextObject(0), imports(0), childContexts(0), nextChild(0), prevChild(0),
   expressions(0), contextObjects(0), contextGuards(0), idValues(0), idValueCount(0), linkedContext(0),
-  componentAttached(0), v4bindings(0), v8bindings(0)
+  componentAttached(0),
+#ifdef QT_USE_OLD_V4
+  v4bindings(0),
+#endif
+  v8bindings(0)
 {
 }
 
@@ -636,8 +646,10 @@ void QQmlContextData::destroy()
     if (imports)
         imports->release();
 
+#ifdef QT_USE_OLD_V4
     if (v4bindings)
         v4bindings->release();
+#endif
 
     if (v8bindings)
         v8bindings->release();
index b19c64f..10105bd 100644 (file)
@@ -82,7 +82,9 @@ class QQmlEngine;
 class QQmlExpression;
 class QQmlExpressionPrivate;
 class QQmlAbstractExpression;
+#ifdef QT_USE_OLD_V4
 class QV4Bindings;
+#endif
 class QQmlContextData;
 
 class QQmlContextPrivate : public QObjectPrivate
@@ -212,7 +214,9 @@ public:
     QQmlComponentAttached *componentAttached;
 
     // Optimized binding objects.  Needed for deferred properties.
+#ifdef QT_USE_OLD_V4
     QV4Bindings *v4bindings;
+#endif
     QV8Bindings *v8bindings;
 
     // Return the outermost id for obj, if any.
index c2eba72..998726e 100644 (file)
@@ -227,9 +227,11 @@ void QQmlCompiledData::dump(QQmlInstruction *instr, int idx)
     case QQmlInstruction::StoreBinding:
         qWarning().nospace() << idx << "\t\t" << "STORE_BINDING\t" << instr->assignBinding.property.coreIndex << "\t" << instr->assignBinding.value << "\t" << instr->assignBinding.context;
         break;
+#ifdef QT_USE_OLD_V4
     case QQmlInstruction::StoreV4Binding:
         qWarning().nospace() << idx << "\t\t" << "STORE_COMPILED_BINDING\t" << instr->assignV4Binding.property << "\t" << instr->assignV4Binding.value << "\t" << instr->assignV4Binding.context;
         break;
+#endif
     case QQmlInstruction::StoreV8Binding:
         qWarning().nospace() << idx << "\t\t" << "STORE_V8_BINDING\t" << instr->assignBinding.property.coreIndex << "\t" << instr->assignBinding.value << "\t" << instr->assignBinding.context;
         break;
index 328b246..a13d564 100644 (file)
 
 QT_BEGIN_NAMESPACE
 
+#ifdef QT_USE_OLD_V4
+#define FV4(x, y) F(x,y)
+#else
+#define FV4(x, y)
+#endif
+
 #define FOR_EACH_QML_INSTR(F) \
     F(Init, init) \
     F(DeferInit, deferInit) \
@@ -119,7 +125,7 @@ QT_BEGIN_NAMESPACE
     F(InitV8Bindings, initV8Bindings) \
     F(StoreBinding, assignBinding) \
     F(StoreV8Binding, assignBinding) \
-    F(StoreV4Binding, assignV4Binding) \
+    FV4(StoreV4Binding, assignV4Binding) \
     F(StoreValueSource, assignValueSource) \
     F(StoreValueInterceptor, assignValueInterceptor) \
     F(StoreObjectQList, common) \
index 3253a5f..7e9b6b4 100644 (file)
@@ -51,14 +51,18 @@ typedef void (*Callback)(QQmlNotifierEndpoint *, void **);
 void QQmlBoundSignal_callback(QQmlNotifierEndpoint *, void **);
 void QQmlJavaScriptExpressionGuard_callback(QQmlNotifierEndpoint *, void **);
 void QQmlVMEMetaObjectEndpoint_callback(QQmlNotifierEndpoint *, void **);
+#ifdef QT_USE_OLD_V4
 void QV4BindingsSubscription_callback(QQmlNotifierEndpoint *, void **);
+#endif
 
 static Callback QQmlNotifier_callbacks[] = {
     0,
     QQmlBoundSignal_callback,
     QQmlJavaScriptExpressionGuard_callback,
-    QQmlVMEMetaObjectEndpoint_callback,
-    QV4BindingsSubscription_callback
+    QQmlVMEMetaObjectEndpoint_callback
+#ifdef QT_USE_OLD_V4
+    , QV4BindingsSubscription_callback
+#endif
 };
 
 void QQmlNotifier::emitNotify(QQmlNotifierEndpoint *endpoint, void **a)
index 8198eec..91c2226 100644 (file)
@@ -57,7 +57,9 @@
 #include "qqmlcomponent_p.h"
 #include "qqmlvmemetaobject_p.h"
 #include "qqmlcontext_p.h"
+#ifdef QT_USE_OLD_V4
 #include <private/qv4bindings_p.h>
+#endif
 #include <private/qv8bindings_p.h>
 #include "qqmlglobal_p.h"
 #include <private/qfinitestack_p.h>
@@ -446,10 +448,12 @@ QObject *QQmlVME::run(QList<QQmlError> *errors,
             CTXT->setParent(parentCtxt);
             if (instr.contextCache != -1) 
                 CTXT->setIdPropertyData(COMP->contextCaches.at(instr.contextCache));
+#ifdef QT_USE_OLD_V4
             if (instr.compiledBinding != -1) {
                 const char *v4data = DATAS.at(instr.compiledBinding).constData();
                 CTXT->v4bindings = new QV4Bindings(v4data, CTXT);
             }
+#endif
             if (states.count() == 1) {
                 rootContext = CTXT;
                 rootContext->activeVMEData = data;
@@ -841,10 +845,11 @@ QObject *QQmlVME::run(QList<QQmlError> *errors,
             }
         QML_END_INSTR(StoreBinding)
 
+#ifdef QT_USE_OLD_V4
         QML_BEGIN_INSTR(StoreV4Binding)
-            QObject *target = 
+            QObject *target =
                 objects.at(objects.count() - 1 - instr.owner);
-            QObject *scope = 
+            QObject *scope =
                 objects.at(objects.count() - 1 - instr.context);
 
             int propertyIdx = (instr.property & 0x0000FFFF);
@@ -879,6 +884,7 @@ QObject *QQmlVME::run(QList<QQmlError> *errors,
                 }
             }
         QML_END_INSTR(StoreV4Binding)
+#endif
 
         QML_BEGIN_INSTR(StoreV8Binding)
             QObject *target =