OLD | NEW |
---|---|
1 // Copyright (c) 2013, the Dart project authors. Please see the AUTHORS file | 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 | 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. | 3 // BSD-style license that can be found in the LICENSE file. |
4 // Test correct handling of phis with only environment uses that were inserted | 4 // Test correct handling of phis with only environment uses that were inserted |
5 // by store to load forwarding. | 5 // by store to load forwarding. |
6 // VMOptions=--optimization_counter_threshold=10 | 6 // VMOptions=--optimization_counter_threshold=10 |
7 | 7 |
8 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
9 | 9 |
10 class A { | 10 class A { |
11 var foo; | 11 var foo; |
12 } | 12 } |
13 | 13 |
14 class B { | 14 class B { |
15 get foo => null; | 15 get foo => null; |
16 } | 16 } |
17 | 17 |
18 test(obj) => obj.foo == null ? "null" : "other"; | 18 test(obj) => obj.foo == null ? "null" : "other"; |
19 | 19 |
20 | |
21 class C { | |
22 C(this.x, this.y); | |
23 final x; | |
24 final y; | |
25 } | |
26 | |
27 test_deopt(a, b) { | |
28 var c = new C(a, b); | |
29 return c.x + c.y; | |
30 } | |
31 | |
32 | |
33 create_error (x) { | |
34 return x as int; | |
35 } | |
36 | |
37 check_stacktrace(e) { | |
38 var s = e.stackTrace; | |
39 if (identical(s, null)) throw "FAIL"; | |
Ivan Posva
2013/11/01 04:50:05
Why not just s == null?
Florian Schneider
2013/11/01 10:39:27
I can't have an IC call here: it will introduce a
| |
40 // s should never be null. | |
41 return "OK"; | |
42 } | |
43 | |
44 test_stacktrace() { | |
45 try { | |
46 create_error("bar"); | |
47 } catch (e) { | |
48 Expect.equals("OK", check_stacktrace(e)); | |
49 for (var i=0; i<20; i++) check_stacktrace(e); | |
Ivan Posva
2013/11/01 04:50:05
ditto
Florian Schneider
2013/11/01 10:39:27
Done.
| |
50 Expect.equals("OK", check_stacktrace(e)); | |
51 } | |
52 } | |
53 | |
54 | |
20 main() { | 55 main() { |
21 var a = new A(); | 56 var a = new A(); |
22 var b = new B(); | 57 var b = new B(); |
23 // Trigger optimization of test with a polymorphic load. | 58 // Trigger optimization of test with a polymorphic load. |
24 // The guarded type of foo is null. | 59 // The guarded type of foo is null. |
25 test(a); | 60 test(a); |
26 test(b); | 61 test(b); |
27 for (var i = 0; i < 20; ++i) test(a); | 62 for (var i = 0; i < 20; ++i) test(a); |
28 Expect.equals("null", test(a)); | 63 Expect.equals("null", test(a)); |
29 Expect.equals("null", test(b)); | 64 Expect.equals("null", test(b)); |
30 | 65 |
31 // Store a non-null object into foo to trigger deoptimization of test. | 66 // Store a non-null object into foo to trigger deoptimization of test. |
32 a.foo = 123; | 67 a.foo = 123; |
33 Expect.equals("other", test(a)); | 68 Expect.equals("other", test(a)); |
34 Expect.equals("null", test(b)); | 69 Expect.equals("null", test(b)); |
70 | |
71 // Test guarded fields with allocation sinking and deoptimization. | |
72 Expect.equals(43, test_deopt(42, 1)); | |
73 for (var i = 0; i < 20; i++) test_deopt(42, 1); | |
Ivan Posva
2013/11/01 04:50:05
ditto
Florian Schneider
2013/11/01 10:39:27
Done.
| |
74 Expect.equals(43, test_deopt(42, 1)); | |
75 Expect.equals("aaabbb", test_deopt("aaa", "bbb")); | |
76 | |
77 // Regression test for fields initialized in native code (Error._stackTrace). | |
78 test_stacktrace(); | |
35 } | 79 } |
OLD | NEW |