Chromium Code Reviews| 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 _b = array[0]; | |
|
karlklose
2013/07/16 09:26:17
b_ -> b2?
ngeoffray
2013/07/16 10:27:06
Done.
| |
| 10 var otherArray = [5]; | |
| 11 | |
| 12 main() { | |
| 13 var b = _b; | |
| 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 with [a]. By being GVN'ed, [e] will | |
|
karlklose
2013/07/16 09:26:17
'will be GVN'ed to the same value as [a]'?
ngeoffray
2013/07/16 10:27:06
Done.
| |
| 28 // have its type changed from integer to number: because of the int | |
| 29 // type check on [b], we know [: b + 1 :] returns an integer. | |
| 30 // However we update this instruction with the previous [: b + 1 :] | |
| 31 // that did not have that information and therefore only knows that | |
| 32 // the instruction returns a number. | |
| 33 var e = b + 1; | |
| 34 | |
| 35 // Introduce a loop phi that has [e] as header input, and [e++] as | |
| 36 // update input. By having [e] as input, dart2js will compute an | |
| 37 // integer type for the phi. However, after GVN, [e] becomes a | |
| 38 // number. | |
| 39 | |
| 40 while (otherArray[0] == 0) { | |
| 41 // Use [e] as an index for an array so that the value range | |
| 42 // analysis tries to compute a range for [e]. | |
| 43 otherArray[e] = d + f; | |
| 44 e++; | |
| 45 } | |
| 46 } | |
| OLD | NEW |