OLD | NEW |
(Empty) | |
| 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 |
| 3 // BSD-style license that can be found in the LICENSE file. |
| 4 |
| 5 // dart2js was generating incorrect code for the [A] constructor, by |
| 6 // using a temporary variable for two instructions, even though they |
| 7 // are both live at the same time. |
| 8 |
| 9 import "package:expect/expect.dart"; |
| 10 |
| 11 var globalVar = [1, 2]; |
| 12 |
| 13 class A { |
| 14 final field1; |
| 15 final field2; |
| 16 var field3; |
| 17 |
| 18 A(this.field1, this.field2) { |
| 19 bool entered = false; |
| 20 // We use [field1] twice to ensure it will have a temporary. |
| 21 for (var a in field1) { |
| 22 try { |
| 23 entered = true; |
| 24 // We use [field2] twice to ensure it will have a temporary. |
| 25 print(field2); |
| 26 print(field2); |
| 27 } catch (e) { |
| 28 // Because the catch is aborting, the SSA graph we used to |
| 29 // generate thought that the whole try/catch was aborting, and |
| 30 // therefore it could not reach the code after the loop. |
| 31 throw e; |
| 32 } |
| 33 } |
| 34 Expect.isTrue(entered); |
| 35 // dart2js used to overwrite the temporary for [field1] with |
| 36 // [field2]. |
| 37 Expect.equals(globalVar, field1); |
| 38 } |
| 39 } |
| 40 |
| 41 main() { |
| 42 new A(globalVar, null); |
| 43 } |
OLD | NEW |