| OLD | NEW |
| 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2012, 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 that fast method extraction returns correct closure. | 4 // Test that fast method extraction returns correct closure. |
| 5 // VMOptions=--optimization-counter-threshold=10 --no-use-osr |
| 5 | 6 |
| 6 import "package:expect/expect.dart"; | 7 import "package:expect/expect.dart"; |
| 7 | 8 |
| 8 class A { | 9 class A { |
| 9 var f; | 10 var f; |
| 10 A(this.f); | 11 A(this.f); |
| 11 foo() => 40 + f; | 12 foo() => 40 + f; |
| 12 } | 13 } |
| 13 | 14 |
| 14 class B { | 15 class B { |
| (...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 67 } | 68 } |
| 68 | 69 |
| 69 extractFromNull() { | 70 extractFromNull() { |
| 70 var f = (null).toString; | 71 var f = (null).toString; |
| 71 Expect.equals("null", f()); | 72 Expect.equals("null", f()); |
| 72 } | 73 } |
| 73 | 74 |
| 74 main() { | 75 main() { |
| 75 var a = new A(2); | 76 var a = new A(2); |
| 76 var b = new B(2); | 77 var b = new B(2); |
| 77 for (var i = 0; i < 10000; i++) { | 78 for (var i = 0; i < 20; i++) { |
| 78 Expect.equals(42, mono(a)); | 79 Expect.equals(42, mono(a)); |
| 79 } | 80 } |
| 80 | 81 |
| 81 for (var i = 0; i < 10000; i++) { | 82 for (var i = 0; i < 20; i++) { |
| 82 Expect.equals(42, poly(a)); | 83 Expect.equals(42, poly(a)); |
| 83 Expect.equals(-42, poly(b)); | 84 Expect.equals(-42, poly(b)); |
| 84 } | 85 } |
| 85 | 86 |
| 86 var c = new C<X>(); | 87 var c = new C<X>(); |
| 87 var x = new X(); | 88 var x = new X(); |
| 88 for (var i = 0; i < 10000; i++) { | 89 for (var i = 0; i < 20; i++) { |
| 89 types(c, x); | 90 types(c, x); |
| 90 } | 91 } |
| 91 | 92 |
| 92 var chaA = new ChaA("magicA"); | 93 var chaA = new ChaA("magicA"); |
| 93 for (var i = 0; i < 10000; i++) { | 94 for (var i = 0; i < 20; i++) { |
| 94 Expect.equals("A", cha(chaA)); | 95 Expect.equals("A", cha(chaA)); |
| 95 } | 96 } |
| 96 | 97 |
| 97 var chaB = new ChaB("magicB"); | 98 var chaB = new ChaB("magicB"); |
| 98 for (var i = 0; i < 10000; i++) { | 99 for (var i = 0; i < 20; i++) { |
| 99 Expect.equals("B", cha(chaB)); | 100 Expect.equals("B", cha(chaB)); |
| 100 } | 101 } |
| 101 | 102 |
| 102 for (var i = 0; i < 10000; i++) { | 103 for (var i = 0; i < 20; i++) { |
| 103 extractFromNull(); | 104 extractFromNull(); |
| 104 } | 105 } |
| 105 } | 106 } |
| 106 | 107 |
| OLD | NEW |