Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(143)

Side by Side Diff: tests/language/type_propagation3_test.dart

Issue 54473003: Fix a bug in the way we deal with HTypeKnown instructions in our SSA type propagation phase. (Closed) Base URL: http://dart.googlecode.com/svn/branches/bleeding_edge/dart/
Patch Set: Created 7 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/types_propagation.dart ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file.
4
5 // Regression test for dart2js that used to generate wrong code for
6 // it. The bug happened in the SSA type propagation.
7
8 class A {
9 next() => new B();
10 doIt() => null;
11 bool get isEmpty => false;
12 foo() => 42;
13 bar() => 54;
14 }
15
16 bool entered = false;
17
18 class B extends A {
19 foo() => 54;
20 doIt() => new A();
21 bool get isEmpty => true;
22 bar() => entered = true;
23 }
24
25 // (1) At initialization phase of the type propagation, [a] would be
26 // marked as [exact A].
27 // (2) Will make the loop phi [b] typed [null, exact A].
28 // (3) Will create a [HTypeKnown] [exact A] for [b].
29 // (4) Will create a [HTypeKnown] [exact A] for [b] and update users
30 // of [b] to use this [HTypeKnown] instead.
31 // (5) [a] will be updated to [subclass A].
32 // (6) Will change the [HTypeKnown] of [b] from [exact A] to [subclass A].
33 // (7) Receiver is [subclass A] and it will refine it to
34 // [subclass A]. We used to wrongly assume there was
35 // no need to update the [HTypeKnown] created in (3).
36 // (8) Consider that bar is called on an [exact A] (the [HTypeKnown]
37 // created in (3)) and remove the call because it does not have
38 // any side effects.
39
40 main() {
41 var a = new A();
42 for (var i in [42]) {
43 a = a.next();
44 }
45
46 // (1, 5)
47
48 var b = a;
49 while (b.isEmpty) { // (4, 6)
50 b.foo(); // (3, 7)
51 b.bar(); // (8)
52 b = b.doIt(); // (2)
53 }
54
55 if (!entered) throw 'Test failed';
56 }
OLDNEW
« no previous file with comments | « sdk/lib/_internal/compiler/implementation/ssa/types_propagation.dart ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698