blob: 855f24eae3e9a427350884cd86c3680a92021235 [file] [log] [blame]
zhifei_fang@apple.com73166802019-10-22 22:46:40 +00001//@ skip if $model == "Apple Watch Series 3" # added by mark-jsc-stress-test.py
ossy@webkit.org8f73aef2016-07-21 18:08:38 +00002//@ runNoFTL
mark.lam@apple.combf0f2fc2016-04-22 23:48:44 +00003
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
8function assert(testedValue) {
9 if (!testedValue)
10 throw Error("Failed assertion");
11}
12
13function 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}
23noInline(badFunc);
24
25function 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
37run();