v8/test/mjsunit/regress/regress-5262.js
Ross McIlroy d7a8170d2d [cleanup] Add missing %PrepareFunctionForOptimize in mjsunit tests
Bug: v8:8801,v8:8394,v8:9183
Change-Id: If482c6a14f389d54c6ca3891aa7b8475f7a1fce1
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1660617
Commit-Queue: Ross McIlroy <rmcilroy@chromium.org>
Reviewed-by: Mythri Alle <mythria@chromium.org>
Auto-Submit: Ross McIlroy <rmcilroy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#62192}
2019-06-14 17:03:41 +00:00

28 lines
839 B
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: --ignition-osr --allow-natives-syntax
function g() { return 23 }
function h() { return 42 }
function boom(o) { o.g = h }
function f(osr_and_recurse) {
if (osr_and_recurse) {
for (var i = 0; i < 3; ++i) {
if (i == 1) %OptimizeOsr();
}
%PrepareFunctionForOptimization(f);
%OptimizeFunctionOnNextCall(f);
f(false); // Trigger tier-up due to recursive call.
boom(this); // Causes a deopt due to below dependency.
var x = g(); // Install dependency on the {g} function.
return x;
}
return 65;
}
%PrepareFunctionForOptimization(f);
assertEquals(65, f(false));
assertEquals(65, f(false));
assertEquals(42, f(true));