Index: test/mjsunit/regress/regress-crbug-138887.js |
diff --git a/test/mjsunit/pixel-array-rounding.js b/test/mjsunit/regress/regress-crbug-138887.js |
old mode 100755 |
new mode 100644 |
similarity index 75% |
copy from test/mjsunit/pixel-array-rounding.js |
copy to test/mjsunit/regress/regress-crbug-138887.js |
index 0c307e62e55297faefe3e2ae253e7a344f4ee6c6..8d8e1694b620aa36941f4b2e17a90f69f6a17cfa |
--- a/test/mjsunit/pixel-array-rounding.js |
+++ b/test/mjsunit/regress/regress-crbug-138887.js |
@@ -27,18 +27,22 @@ |
// Flags: --allow-natives-syntax |
-var pixels = new Uint8ClampedArray(8); |
+function worker1(ignored) { |
+ return 100; |
+} |
-function f() { |
- for (var i = 0; i < 8; i++) { |
- pixels[i] = (i * 1.1); |
+function factory(worker) { |
+ return function(call_depth) { |
+ if (call_depth == 0) return 10; |
+ return 1 + worker(call_depth - 1); |
} |
- return pixels[1] + pixels[6]; |
} |
-f(); |
-f(); |
-assertEquals(6, pixels[5]); |
-%OptimizeFunctionOnNextCall(f); |
-f(); |
-assertEquals(6, pixels[5]); |
+var f1 = factory(worker1); |
+var f2 = factory(f1); |
+assertEquals(11, f2(1)); // Result: 1 + f1(0) == 1 + 10. |
+assertEquals(11, f2(1)); |
+%OptimizeFunctionOnNextCall(f1); |
+assertEquals(10, f1(0)); // Terminates immediately -> returns 10. |
+%OptimizeFunctionOnNextCall(f2); |
+assertEquals(102, f2(1000)); // 1 + f1(999) == 1 + 1 + worker1(998) == 102 |