| 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 import "package:expect/expect.dart"; | 5 import "package:expect/expect.dart"; |
| 6 | 6 |
| 7 class A { | 7 class A { |
| 8 _uniqueSelector() { } | 8 _uniqueSelector() {} |
| 9 final uniqueField = 10; | 9 final uniqueField = 10; |
| 10 } | 10 } |
| 11 | 11 |
| 12 test1(obj) { | 12 test1(obj) { |
| 13 var res = 0; | 13 var res = 0; |
| 14 for (var i = 0; i < 2; i++) { | 14 for (var i = 0; i < 2; i++) { |
| 15 obj._uniqueSelector(); | 15 obj._uniqueSelector(); |
| 16 res += obj.uniqueField; // This load must not be hoisted out of the loop. | 16 res += obj.uniqueField; // This load must not be hoisted out of the loop. |
| 17 } | 17 } |
| 18 return res; | 18 return res; |
| 19 } | 19 } |
| 20 | 20 |
| 21 test2(obj) { | 21 test2(obj) { |
| 22 final objAlias = obj; | 22 final objAlias = obj; |
| 23 closure() => objAlias; | 23 closure() => objAlias; |
| 24 var res = 0; | 24 var res = 0; |
| 25 for (var i = 0; i < 2; i++) { | 25 for (var i = 0; i < 2; i++) { |
| 26 obj._uniqueSelector(); | 26 obj._uniqueSelector(); |
| 27 res += objAlias.uniqueField; // This load must not be hoisted out of the lo
op. | 27 res += |
| 28 objAlias.uniqueField; // This load must not be hoisted out of the loop. |
| 28 } | 29 } |
| 29 return res; | 30 return res; |
| 30 } | 31 } |
| 31 | 32 |
| 32 var foofoo_ = test1; | 33 var foofoo_ = test1; |
| 33 | 34 |
| 34 main () { | 35 main() { |
| 35 Expect.equals(20, foofoo_(new A())); | 36 Expect.equals(20, foofoo_(new A())); |
| 36 Expect.throws(() => foofoo_(0)); | 37 Expect.throws(() => foofoo_(0)); |
| 37 | 38 |
| 38 foofoo_ = test2; | 39 foofoo_ = test2; |
| 39 | 40 |
| 40 Expect.equals(20, foofoo_(new A())); | 41 Expect.equals(20, foofoo_(new A())); |
| 41 Expect.throws(() => foofoo_(0)); | 42 Expect.throws(() => foofoo_(0)); |
| 42 } | 43 } |
| OLD | NEW |