-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
VM: Fix bug in type propagation at conditionals.
Propagating type/cid at conditional branches is not possible because it may cause invalid code motion. For this to be safe we need to explicitly represent the dependency between checks eliminated in a branch and the condition that constrains the type/cid. BUG= R=vegorov@google.com Review URL: https://codereview.chromium.org/1491373005 .
- Loading branch information
Showing
3 changed files
with
56 additions
and
58 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
// Copyright (c) 2015, the Dart project authors. Please see the AUTHORS file | ||
// for details. All rights reserved. Use of this source code is governed by a | ||
// BSD-style license that can be found in the LICENSE file. | ||
// VMOptions=--optimization-counter-threshold=1000 --max-polymorphic-checks=1 | ||
|
||
// Test correct loop invariant code motion and type propagation from is-checks | ||
// and null-comparisons. | ||
|
||
class B { | ||
var b; | ||
B(this.b); | ||
} | ||
|
||
class C { | ||
final f0; | ||
|
||
final a; | ||
C() : a = new B(0); | ||
} | ||
|
||
foo(x) { | ||
for (var i = 0; i < 10; i++) { | ||
i + i; | ||
i + i; | ||
if (x is C) { | ||
x.a.b < 0; | ||
} | ||
} | ||
} | ||
|
||
class Y { var f = null; } | ||
|
||
bar(y) { | ||
var x = y.f; | ||
for (var i = 0; i < 10; i++) { | ||
if (x != null) { | ||
x.a.b < 0; | ||
} | ||
} | ||
} | ||
|
||
|
||
main () { | ||
var o = new Y(); | ||
o.f = new C(); | ||
bar(o); | ||
o.f = null; | ||
bar(o); | ||
|
||
for (var i = 0; i < 1000; i++) bar(o); | ||
|
||
foo(new C()); | ||
foo(0); | ||
|
||
for (var i = 0; i < 1000; i++) foo(0); | ||
} |