Commit 77c94fae authored by Ulan Degenbaev's avatar Ulan Degenbaev Committed by Commit Bot

[test] Make deopt-array-push test robust against page size changes

Bug: chromium:852420
Change-Id: Ic34b996460b9ad2124f4bdb18afdcc83f2453e6a
Reviewed-on: https://chromium-review.googlesource.com/c/1470109Reviewed-by: 's avatarSigurd Schneider <sigurds@chromium.org>
Commit-Queue: Ulan Degenbaev <ulan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#59573}
parent b5b8c8a6
...@@ -80,18 +80,28 @@ ...@@ -80,18 +80,28 @@
})(); })();
(function test() { (function test() {
function mkArray() { // Conservative arrays lengths in slow and fast mode.
const N = 128 * 1024; const kFastModeLength = 1024;
const kSlowModeLength = 512 * 1024;
function mkArray(length) {
let a = [0.1]; let a = [0.1];
a.length = N; a.length = length;
return a; return a;
} }
function foo(a) { a.push(0.23441233123); } function foo(a) { a.push(0.23441233123); }
foo(mkArray());
foo(mkArray()); // 1. Optimize foo to handle fast mode arrays.
foo(mkArray(kFastModeLength));
foo(mkArray(kFastModeLength));
%OptimizeFunctionOnNextCall(foo); %OptimizeFunctionOnNextCall(foo);
foo(mkArray()); foo(mkArray(kFastModeLength));
// 2. Given a slow mode array, foo will deopt.
foo(mkArray(kSlowModeLength));
// 3. Optimize foo again.
%OptimizeFunctionOnNextCall(foo); %OptimizeFunctionOnNextCall(foo);
foo(mkArray()); foo(mkArray(kSlowModeLength));
// 4. It should stay optimized.
assertOptimized(foo); assertOptimized(foo);
})(); })();
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment