V4 IR: fix type inference.
authorErik Verbruggen <erik.verbruggen@me.com>
Tue, 1 Oct 2013 15:44:54 +0000 (17:44 +0200)
committerThe Qt Project <gerrit-noreply@qt-project.org>
Wed, 2 Oct 2013 14:07:33 +0000 (16:07 +0200)
When a phi-node couldn't be fully typed (e.g., when one of the temps
was not yet typed), VarType was assumed. When a circular dependency
between two phi-nodes occurred, like with a condition inside a loop,
then depending on the ordering of the work-list, the two phi-nodes
could start oscillating between VarType and the correct type.

The fix is to check if one of the temps is not fully typed, and if so,
assume whatever we currently have as the result and have the statement
re-scheduled. Full typing will occur when the temp with the missing
type information is typed.

Change-Id: I950d81fe7fa8272cb37f7eea5b88092d1eb4817e
Reviewed-by: Tor Arne Vestbø <tor.arne.vestbo@digia.com>
Reviewed-by: Simon Hausmann <simon.hausmann@digia.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
src/qml/compiler/qv4ssa.cpp

index a058ed5..3d6cd44 100644 (file)
@@ -1503,11 +1503,19 @@ protected:
         _ty = run(s->d->incoming[0]);
         for (int i = 1, ei = s->d->incoming.size(); i != ei; ++i) {
             TypingResult ty = run(s->d->incoming[i]);
+            if (!ty.fullyTyped && _ty.fullyTyped) {
+                // When one of the temps not fully typed, we already know that we cannot completely type this node.
+                // So, pick the type we calculated upto this point, and wait until the unknown one will be typed.
+                // At that point, this statement will be re-scheduled, and then we can fully type this node.
+                _ty.fullyTyped = false;
+                break;
+            }
             _ty.type |= ty.type;
             _ty.fullyTyped &= ty.fullyTyped;
         }
 
         switch (_ty.type) {
+        case UnknownType:
         case UndefinedType:
         case NullType:
         case BoolType: