zhifei_fang@apple.com | 7316680 | 2019-10-22 22:46:40 +0000 | [diff] [blame] | 1 | //@ skip if $model == "Apple Watch Series 3" # added by mark-jsc-stress-test.py |
ossy@webkit.org | 8f73aef | 2016-07-21 18:08:38 +0000 | [diff] [blame] | 2 | //@ runNoFTL |
mark.lam@apple.com | bf0f2fc | 2016-04-22 23:48:44 +0000 | [diff] [blame] | 3 | |
| 4 | // Regression test for https://bugs.webkit.org/show_bug.cgi?id=153431. |
| 5 | // Reduced version based on the reproduction case provided by Ryan Sturgell in the bug, |
| 6 | // with some variable renames to read slightly better. |
| 7 | |
| 8 | function assert(testedValue) { |
| 9 | if (!testedValue) |
| 10 | throw Error("Failed assertion"); |
| 11 | } |
| 12 | |
| 13 | function badFunc(arr, operand, resultArr) { |
| 14 | // This re-use of variable "operand" is important - rename it and the bug goes away. |
| 15 | operand = arr[operand]; |
| 16 | if (false) { |
| 17 | // If this unreachable block is removed, the bug goes away!! |
| 18 | } else |
| 19 | { |
| 20 | resultArr[0] = operand; |
| 21 | } |
| 22 | } |
| 23 | noInline(badFunc); |
| 24 | |
| 25 | function run() { |
| 26 | for (var i = 0; i < 10000; i++) { |
| 27 | var arr = new Uint32Array([0x80000000,1]); // Needs to be an Uint32Array. |
| 28 | var resultArr = []; |
| 29 | |
| 30 | badFunc(arr, 0, resultArr); |
| 31 | assert(resultArr[0] == arr[0]); |
| 32 | badFunc(arr, 1, resultArr); |
| 33 | assert(resultArr[0] == arr[1]); |
| 34 | } |
| 35 | } |
| 36 | |
| 37 | run(); |