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 // Regression test for dart2js, whose value range analysis phase |
| 6 // assumed loop phis that were integer necessarily had integer inputs. |
| 7 |
| 8 var array = const [0, 0.5]; |
| 9 var globalB = array[0]; |
| 10 var otherArray = [5]; |
| 11 |
| 12 main() { |
| 13 var b = globalB; |
| 14 var a = b + 1; |
| 15 if (otherArray[0] == 0) { |
| 16 // Use a non-existing selector to prevent adding a bailout check. |
| 17 a.noSuch(); |
| 18 a = otherArray[0]; |
| 19 } |
| 20 |
| 21 // Use [a] to make sure it does not become dead code. |
| 22 var f = array[a]; |
| 23 |
| 24 // Add an integer check on [b]. |
| 25 var d = array[b]; |
| 26 |
| 27 // This instruction will be GVN to the same value as [a]. |
| 28 // By being GVN'ed, [e] will have its type changed from integer |
| 29 // to number: because of the int type check on [b], we know |
| 30 // [: b + 1 :] returns an integer. |
| 31 // However we update this instruction with the previous [: b + 1 :] |
| 32 // that did not have that information and therefore only knows that |
| 33 // the instruction returns a number. |
| 34 var e = b + 1; |
| 35 |
| 36 // Introduce a loop phi that has [e] as header input, and [e++] as |
| 37 // update input. By having [e] as input, dart2js will compute an |
| 38 // integer type for the phi. However, after GVN, [e] becomes a |
| 39 // number. |
| 40 |
| 41 while (otherArray[0] == 0) { |
| 42 // Use [e] as an index for an array so that the value range |
| 43 // analysis tries to compute a range for [e]. |
| 44 otherArray[e] = d + f; |
| 45 e++; |
| 46 } |
| 47 } |
OLD | NEW |