| 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 | 4 |
| 5 // This unit test of dart2js checks that a SSA bailout target | 5 // This unit test of dart2js checks that a SSA bailout target |
| 6 // instruction gets removed from the graph when it's not used. | 6 // instruction gets removed from the graph when it's not used. |
| 7 | 7 |
| 8 import "package:expect/expect.dart"; | 8 import "package:expect/expect.dart"; |
| 9 import 'compiler_helper.dart'; | 9 import 'compiler_helper.dart'; |
| 10 | 10 |
| 11 String TEST = r''' | 11 String TEST = r''' |
| 12 main() { | 12 main() { |
| 13 foo(1); | 13 foo(1); |
| 14 foo([]); | 14 foo([]); |
| 15 } | 15 } |
| 16 | 16 |
| 17 class A { |
| 18 operator -() => this; |
| 19 } |
| 20 |
| 17 foo(a) { | 21 foo(a) { |
| 22 new A(); // Force having another operator- |
| 18 // Make the method recursive to always enable bailouts | 23 // Make the method recursive to always enable bailouts |
| 19 // and force a list instantiation. | 24 // and force a list instantiation. |
| 20 foo([]); | 25 foo([]); |
| 21 // Force bailout on [a]. | 26 // Force bailout on [a]. |
| 22 for (int i = 0; i < 100; i++) a[0] = 42; | 27 for (int i = 0; i < 100; i++) a[0] = 42; |
| 23 // Force bailout on [:a.length:]. | 28 // Force bailout on [:a.length:]. |
| 24 for (int i = 0; i < 200; i++) a[0] = -a.length; | 29 for (int i = 0; i < 200; i++) a[0] = -a.length; |
| 25 } | 30 } |
| 26 '''; | 31 '''; |
| 27 | 32 |
| (...skipping 27 matching lines...) Expand all Loading... |
| 55 | 60 |
| 56 // Check that the bailout method has a case 2 for the state, which | 61 // Check that the bailout method has a case 2 for the state, which |
| 57 // is the second bailout in foo. | 62 // is the second bailout in foo. |
| 58 RegExp state = new RegExp('case 2:[ \n]+state0 = 0;'); | 63 RegExp state = new RegExp('case 2:[ \n]+state0 = 0;'); |
| 59 checkNumberOfMatches(state.allMatches(generated).iterator, 1); | 64 checkNumberOfMatches(state.allMatches(generated).iterator, 1); |
| 60 | 65 |
| 61 // Finally, make sure that the reason foo does not contain | 66 // Finally, make sure that the reason foo does not contain |
| 62 // 'getInterceptor' is not because the compiler renamed it. | 67 // 'getInterceptor' is not because the compiler renamed it. |
| 63 Expect.isTrue(generated.contains('getInterceptor')); | 68 Expect.isTrue(generated.contains('getInterceptor')); |
| 64 } | 69 } |
| OLD | NEW |