Commit d338b94e authored by mythria's avatar mythria Committed by Commit bot

[Interpreter] Ensure that a function is compiled before tiering up to baseline.

When baselining a function using the BaselineFunctionOnNextCall intrinsic, it is
not always ensured that a function is already compiled. Update the
Runtime_BaselineFunctionOnNextCall function to trigger a compile if it is not already
compiled.

BUG=v8:5768

Review-Url: https://codereview.chromium.org/2594543003
Cr-Commit-Position: refs/heads/master@{#42033}
parent a11a9c7d
......@@ -822,6 +822,8 @@ MaybeHandle<Code> GetBaselineCode(Handle<JSFunction> function) {
ParseInfo parse_info(&zone, handle(function->shared()));
CompilationInfo info(&parse_info, function);
DCHECK(function->shared()->is_compiled());
// Function no longer needs to be tiered up
function->shared()->set_marked_for_tier_up(false);
......
......@@ -177,6 +177,12 @@ RUNTIME_FUNCTION(Runtime_BaselineFunctionOnNextCall) {
}
Handle<JSFunction> function = Handle<JSFunction>::cast(function_object);
// If function isn't compiled, compile it now.
if (!function->shared()->is_compiled() &&
!Compiler::Compile(function, Compiler::CLEAR_EXCEPTION)) {
return isolate->heap()->undefined_value();
}
// Do not tier down if we are already on optimized code. Replacing optimized
// code without actual deoptimization can lead to funny bugs.
if (function->code()->kind() != Code::OPTIMIZED_FUNCTION &&
......
// 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 a = 0;
function f() {
// access a global variable to trigger the use of
// typefeedback vector.
return a;
}
%BaselineFunctionOnNextCall(f)
// We try to baseline a function that was not compiled before.
// It should setup the typefeedback data correctly.
f();
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