Commit 5e08f435 authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[interpreter] Allow mixed stacks if bytecode is preserved.

This changes the compilation pipeline so that mixed stacks are allowed
when bytecode is preserved. This means there can be activations of both,
"baseline" as well as "unoptimized" code active on the stack at the same
time for any single given function.

R=rmcilroy@chromium.org
BUG=v8:4280

Review-Url: https://codereview.chromium.org/2267693002
Cr-Commit-Position: refs/heads/master@{#38809}
parent 00c49a3e
...@@ -947,9 +947,10 @@ MaybeHandle<Code> GetBaselineCode(Handle<JSFunction> function) { ...@@ -947,9 +947,10 @@ MaybeHandle<Code> GetBaselineCode(Handle<JSFunction> function) {
} }
// TODO(4280): For now we disable switching to baseline code in the presence // TODO(4280): For now we disable switching to baseline code in the presence
// of interpreter activations of the given function. The reasons are: // of interpreter activations of the given function. The reasons is that the
// 1) The debugger assumes each function is either full-code or bytecode. // underlying bytecode is cleared below. Note that this only applies in case
// 2) The underlying bytecode is cleared below, breaking stack unwinding. // the --ignition-preserve-bytecode flag is not passed.
if (!FLAG_ignition_preserve_bytecode) {
InterpreterActivationsFinder activations_finder(function->shared()); InterpreterActivationsFinder activations_finder(function->shared());
if (HasInterpreterActivations(isolate, &activations_finder)) { if (HasInterpreterActivations(isolate, &activations_finder)) {
if (FLAG_trace_opt) { if (FLAG_trace_opt) {
...@@ -968,6 +969,7 @@ MaybeHandle<Code> GetBaselineCode(Handle<JSFunction> function) { ...@@ -968,6 +969,7 @@ MaybeHandle<Code> GetBaselineCode(Handle<JSFunction> function) {
return MaybeHandle<Code>(); return MaybeHandle<Code>();
} }
}
if (FLAG_trace_opt) { if (FLAG_trace_opt) {
OFStream os(stdout); OFStream os(stdout);
...@@ -989,7 +991,8 @@ MaybeHandle<Code> GetBaselineCode(Handle<JSFunction> function) { ...@@ -989,7 +991,8 @@ MaybeHandle<Code> GetBaselineCode(Handle<JSFunction> function) {
// TODO(4280): For now we play it safe and remove the bytecode array when we // TODO(4280): For now we play it safe and remove the bytecode array when we
// switch to baseline code. We might consider keeping around the bytecode so // switch to baseline code. We might consider keeping around the bytecode so
// that it can be used as the "source of truth" eventually. // that it can be used as the "source of truth" eventually. Note that this
// only applies in case the --ignition-preserve-bytecode flag is not passed.
if (!FLAG_ignition_preserve_bytecode) shared->ClearBytecodeArray(); if (!FLAG_ignition_preserve_bytecode) shared->ClearBytecodeArray();
// Update the shared function info with the scope info. // Update the shared function info with the scope info.
...@@ -1414,12 +1417,12 @@ bool Compiler::EnsureDeoptimizationSupport(CompilationInfo* info) { ...@@ -1414,12 +1417,12 @@ bool Compiler::EnsureDeoptimizationSupport(CompilationInfo* info) {
if (shared->is_resumable()) return false; if (shared->is_resumable()) return false;
// TODO(4280): For now we disable switching to baseline code in the presence // TODO(4280): For now we disable switching to baseline code in the presence
// of interpreter activations of the given function. The reasons are: // of interpreter activations of the given function. The reasons is that the
// 1) The debugger assumes each function is either full-code or bytecode. // underlying bytecode is cleared below. The expensive check for activations
// 2) The underlying bytecode is cleared below, breaking stack unwinding. // only needs to be done when the given function has bytecode, otherwise we
// The expensive check for activations only needs to be done when the given // can be sure there are no activations. Note that this only applies in case
// function has bytecode, otherwise we can be sure there are no activations. // the --ignition-preserve-bytecode flag is not passed.
if (shared->HasBytecodeArray()) { if (!FLAG_ignition_preserve_bytecode && shared->HasBytecodeArray()) {
InterpreterActivationsFinder activations_finder(*shared); InterpreterActivationsFinder activations_finder(*shared);
if (HasInterpreterActivations(info->isolate(), &activations_finder)) { if (HasInterpreterActivations(info->isolate(), &activations_finder)) {
return false; return false;
...@@ -1438,9 +1441,10 @@ bool Compiler::EnsureDeoptimizationSupport(CompilationInfo* info) { ...@@ -1438,9 +1441,10 @@ bool Compiler::EnsureDeoptimizationSupport(CompilationInfo* info) {
// TODO(4280): For now we play it safe and remove the bytecode array when we // TODO(4280): For now we play it safe and remove the bytecode array when we
// switch to baseline code. We might consider keeping around the bytecode so // switch to baseline code. We might consider keeping around the bytecode so
// that it can be used as the "source of truth" eventually. // that it can be used as the "source of truth" eventually. Note that this
if (shared->HasBytecodeArray()) { // only applies in case the --ignition-preserve-bytecode flag is not passed.
if (!FLAG_ignition_preserve_bytecode) shared->ClearBytecodeArray(); if (!FLAG_ignition_preserve_bytecode && shared->HasBytecodeArray()) {
shared->ClearBytecodeArray();
} }
// The scope info might not have been set if a lazily compiled // The scope info might not have been set if a lazily compiled
......
...@@ -781,6 +781,10 @@ static void InstallIsBaselineCompiledHelper(v8::Isolate* isolate) { ...@@ -781,6 +781,10 @@ static void InstallIsBaselineCompiledHelper(v8::Isolate* isolate) {
} }
TEST(IgnitionBaselineOnReturn) { TEST(IgnitionBaselineOnReturn) {
// TODO(4280): Remove this entire test once --ignition-preserve-bytecode is
// the default and the flag is removed. This test doesn't provide benefit any
// longer once {InterpreterActivationsFinder} is gone.
if (FLAG_ignition_preserve_bytecode) return;
FLAG_allow_natives_syntax = true; FLAG_allow_natives_syntax = true;
FLAG_always_opt = false; FLAG_always_opt = false;
CcTest::InitializeVM(); CcTest::InitializeVM();
......
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