v8/test/mjsunit/regress/regress-599710.js
Mathias Bynens c6a16c10dd [test] Add %PrepareForOptimization to even more tests
With bytecode flushing and lazy feedback allocation, we need to call
%PrepareForOptimization before we call %OptimizeFunctionOnNextCall,
ideally after declaring the function.

Bug: v8:8801, v8:8394, v8:9183
Change-Id: I3fb257282a30f6526a376a3afdedb44786320d34
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1648255
Commit-Queue: Mathias Bynens <mathias@chromium.org>
Reviewed-by: Maya Lekova <mslekova@chromium.org>
Reviewed-by: Mythri Alle <mythria@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62119}
2019-06-12 14:40:14 +00:00

78 lines
1.2 KiB
JavaScript

// Copyright 2016 the V8 project authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
// Flags: --allow-natives-syntax
var f1 = function() {
while (1) {
}
};
function g1() {
var s = "hey";
f1 = function() {
return true;
};
if (f1()) {
return s;
}
};
%PrepareFunctionForOptimization(g1);
%OptimizeFunctionOnNextCall(g1);
assertEquals("hey", g1());
var f2 = function() {
do {
} while (1);
};
function g2() {
var s = "hey";
f2 = function() {
return true;
};
if (f2()) {
return s;
}
};
%PrepareFunctionForOptimization(g2);
%OptimizeFunctionOnNextCall(g2);
assertEquals("hey", g2());
var f3 = function() {
for (;;)
;
};
function g3() {
var s = "hey";
f3 = function() {
return true;
};
if (f3()) {
return s;
}
};
%PrepareFunctionForOptimization(g3);
%OptimizeFunctionOnNextCall(g3);
assertEquals("hey", g3());
var f4 = function() {
for (;;)
;
};
function g4() {
var s = "hey";
f4 = function() {
return true;
};
while (f4()) {
return s;
}
};
%PrepareFunctionForOptimization(g4);
%OptimizeFunctionOnNextCall(g4);
assertEquals("hey", g4());