| 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 we get rid of duplicate type guards on a field when that | 4 // Test that we get rid of duplicate type guards on a field when that |
| 5 // field is being gvn'ed. | 5 // field is being gvn'ed. |
| 6 | 6 |
| 7 import 'compiler_helper.dart'; | 7 import 'compiler_helper.dart'; |
| 8 import "package:async_helper/async_helper.dart"; |
| 8 | 9 |
| 9 const String TEST = r""" | 10 const String TEST = r""" |
| 10 class A { | 11 class A { |
| 11 var field = 52; | 12 var field = 52; |
| 12 foo() { | 13 foo() { |
| 13 var a = this.field; | 14 var a = this.field; |
| 14 while (a + 42 == 42); | 15 while (a + 42 == 42); |
| 15 // This field get should be GVN'ed | 16 // This field get should be GVN'ed |
| 16 a = this.field; | 17 a = this.field; |
| 17 while (a + 87 == 87); | 18 while (a + 87 == 87); |
| 18 field = 'bar'; | 19 field = 'bar'; |
| 19 } | 20 } |
| 20 } | 21 } |
| 21 | 22 |
| 22 main() { | 23 main() { |
| 23 while (true) new A().foo(); | 24 while (true) new A().foo(); |
| 24 } | 25 } |
| 25 """; | 26 """; |
| 26 | 27 |
| 27 main() { | 28 main() { |
| 28 String generated = compileAll(TEST); | 29 asyncTest(() => compileAll(TEST).then((generated) { |
| 29 RegExp regexp = new RegExp('foo\\\$0\\\$bailout'); | 30 RegExp regexp = new RegExp('foo\\\$0\\\$bailout'); |
| 30 Iterator matches = regexp.allMatches(generated).iterator; | 31 Iterator matches = regexp.allMatches(generated).iterator; |
| 31 | 32 |
| 32 // We check that there is only one call to the bailout method. | 33 // We check that there is only one call to the bailout method. |
| 33 // One match for the call, one for the definition. | 34 // One match for the call, one for the definition. |
| 34 checkNumberOfMatches(matches, 2); | 35 checkNumberOfMatches(matches, 2); |
| 36 })); |
| 35 } | 37 } |
| OLD | NEW |