[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}
This commit is contained in:
mythria 2017-01-03 07:11:32 -08:00 committed by Commit bot
parent a11a9c7dd7
commit d338b94e86
3 changed files with 24 additions and 0 deletions

View File

@ -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);

View File

@ -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 &&

View File

@ -0,0 +1,16 @@
// 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();