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 import "dart:typed_data"; |
9 | 10 |
10 class A { | 11 class A { |
11 var foo; | 12 var foo; |
12 } | 13 } |
13 | 14 |
14 class B { | 15 class B { |
15 get foo => null; | 16 get foo => null; |
16 } | 17 } |
17 | 18 |
18 test(obj) => obj.foo == null ? "null" : "other"; | 19 test(obj) => obj.foo == null ? "null" : "other"; |
(...skipping 26 matching lines...) Expand all Loading... |
45 try { | 46 try { |
46 create_error("bar"); | 47 create_error("bar"); |
47 } catch (e) { | 48 } catch (e) { |
48 Expect.equals("OK", check_stacktrace(e)); | 49 Expect.equals("OK", check_stacktrace(e)); |
49 for (var i=0; i<20; i++) { check_stacktrace(e); } | 50 for (var i=0; i<20; i++) { check_stacktrace(e); } |
50 Expect.equals("OK", check_stacktrace(e)); | 51 Expect.equals("OK", check_stacktrace(e)); |
51 } | 52 } |
52 } | 53 } |
53 | 54 |
54 | 55 |
| 56 class D { |
| 57 final List f; |
| 58 final Uint8List g; |
| 59 D(this.f, this.g); |
| 60 D.named(this.f, this.g); |
| 61 } |
| 62 |
| 63 |
| 64 test_guarded_length() { |
| 65 var a = new D(new List(5), new Uint8List(5)); |
| 66 var b = new D.named(new List(5), new Uint8List(5)); |
| 67 Expect.equals(5, a.f.length); |
| 68 Expect.equals(5, b.f.length); |
| 69 Expect.equals(5, a.g.length); |
| 70 Expect.equals(5, b.g.length); |
| 71 } |
| 72 |
| 73 |
55 main() { | 74 main() { |
56 var a = new A(); | 75 var a = new A(); |
57 var b = new B(); | 76 var b = new B(); |
58 // Trigger optimization of test with a polymorphic load. | 77 // Trigger optimization of test with a polymorphic load. |
59 // The guarded type of foo is null. | 78 // The guarded type of foo is null. |
60 test(a); | 79 test(a); |
61 test(b); | 80 test(b); |
62 for (var i = 0; i < 20; ++i) test(a); | 81 for (var i = 0; i < 20; ++i) test(a); |
63 Expect.equals("null", test(a)); | 82 Expect.equals("null", test(a)); |
64 Expect.equals("null", test(b)); | 83 Expect.equals("null", test(b)); |
65 | 84 |
66 // Store a non-null object into foo to trigger deoptimization of test. | 85 // Store a non-null object into foo to trigger deoptimization of test. |
67 a.foo = 123; | 86 a.foo = 123; |
68 Expect.equals("other", test(a)); | 87 Expect.equals("other", test(a)); |
69 Expect.equals("null", test(b)); | 88 Expect.equals("null", test(b)); |
70 | 89 |
71 // Test guarded fields with allocation sinking and deoptimization. | 90 // Test guarded fields with allocation sinking and deoptimization. |
72 Expect.equals(43, test_deopt(42, 1)); | 91 Expect.equals(43, test_deopt(42, 1)); |
73 for (var i = 0; i < 20; i++) { test_deopt(42, 1); } | 92 for (var i = 0; i < 20; i++) { test_deopt(42, 1); } |
74 Expect.equals(43, test_deopt(42, 1)); | 93 Expect.equals(43, test_deopt(42, 1)); |
75 Expect.equals("aaabbb", test_deopt("aaa", "bbb")); | 94 Expect.equals("aaabbb", test_deopt("aaa", "bbb")); |
76 | 95 |
77 // Regression test for fields initialized in native code (Error._stackTrace). | 96 // Regression test for fields initialized in native code (Error._stackTrace). |
78 test_stacktrace(); | 97 test_stacktrace(); |
| 98 |
| 99 // Test guarded list length. |
| 100 for (var i = 0; i < 20; i++) test_guarded_length(); |
79 } | 101 } |
OLD | NEW |