Commit 9e60db1f authored by mstarzinger's avatar mstarzinger Committed by Commit bot

[interpreter] Add ability to preserve bytecode.

This adds the --ignition-preserve-bytecode flag which will preserve any
existing bytecode, even if a tier-up to baseline code is performed. This
is preparatory work in order to allow mixed stacks where bytecode and
baseline code can be active at the same time.

It also adds a {HasBaselineCode} predicate symmetric to the existing
{HasBytecodeArray} predicate. Both predicates are independent and any
combination of answers is valid.

Further adaptation of the rest of the runtime will be done step-wise in
follow-up changes.

R=yangguo@chromium.org
BUG=v8:5265

Review-Url: https://codereview.chromium.org/2224923003
Cr-Commit-Position: refs/heads/master@{#38540}
parent 8e8bfb5d
......@@ -992,7 +992,7 @@ MaybeHandle<Code> GetBaselineCode(Handle<JSFunction> function) {
// 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
// that it can be used as the "source of truth" eventually.
shared->ClearBytecodeArray();
if (!FLAG_ignition_preserve_bytecode) shared->ClearBytecodeArray();
// Update the shared function info with the scope info.
InstallSharedScopeInfo(&info, shared);
......@@ -1432,7 +1432,7 @@ bool Compiler::EnsureDeoptimizationSupport(CompilationInfo* info) {
// 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
// that it can be used as the "source of truth" eventually.
shared->ClearBytecodeArray();
if (!FLAG_ignition_preserve_bytecode) shared->ClearBytecodeArray();
// The scope info might not have been set if a lazily compiled
// function is inlined before being called for the first time.
......
......@@ -986,9 +986,9 @@ void LiveEdit::ReplaceFunctionCode(
// Clear old bytecode. This will trigger self-healing if we do not install
// new bytecode.
shared_info->ClearBytecodeArray();
if (old_code->is_interpreter_trampoline_builtin()) {
if (!shared_info->HasBaselineCode()) {
// Every function from this SFI is interpreted.
if (new_code->is_interpreter_trampoline_builtin()) {
if (!new_shared_info->HasBaselineCode()) {
// We have newly compiled bytecode. Simply replace the old one.
shared_info->set_bytecode_array(new_shared_info->bytecode_array());
} else {
......
......@@ -308,6 +308,8 @@ DEFINE_BOOL(ignition_peephole, true, "use ignition peephole optimizer")
DEFINE_BOOL(ignition_reo, true, "use ignition register equivalence optimizer")
DEFINE_BOOL(ignition_filter_expression_positions, true,
"filter expression positions before the bytecode pipeline")
DEFINE_BOOL(ignition_preserve_bytecode, false,
"preserve generated bytecode even when switching tiers")
DEFINE_BOOL(print_bytecode, false,
"print bytecode generated by ignition interpreter")
DEFINE_BOOL(trace_ignition, false,
......
......@@ -6103,6 +6103,9 @@ void SharedFunctionInfo::ReplaceCode(Code* value) {
if (is_compiled()) set_never_compiled(false);
}
bool SharedFunctionInfo::HasBaselineCode() const {
return code()->kind() == Code::FUNCTION;
}
ScopeInfo* SharedFunctionInfo::scope_info() const {
return reinterpret_cast<ScopeInfo*>(READ_FIELD(this, kScopeInfoOffset));
......@@ -6119,8 +6122,7 @@ void SharedFunctionInfo::set_scope_info(ScopeInfo* value,
mode);
}
bool SharedFunctionInfo::is_compiled() {
bool SharedFunctionInfo::is_compiled() const {
Builtins* builtins = GetIsolate()->builtins();
DCHECK(code() != builtins->builtin(Builtins::kCompileOptimizedConcurrent));
DCHECK(code() != builtins->builtin(Builtins::kCompileOptimized));
......@@ -6149,7 +6151,7 @@ DebugInfo* SharedFunctionInfo::GetDebugInfo() {
bool SharedFunctionInfo::HasDebugCode() {
return HasBytecodeArray() ||
(code()->kind() == Code::FUNCTION && code()->has_debug_break_slots());
(HasBaselineCode() && code()->has_debug_break_slots());
}
......
......@@ -6894,6 +6894,7 @@ class SharedFunctionInfo: public HeapObject {
inline AbstractCode* abstract_code();
inline void ReplaceCode(Code* code);
inline bool HasBaselineCode() const;
// [optimized_code_map]: Map from native context to optimized code
// and a shared literals array.
......@@ -6980,7 +6981,7 @@ class SharedFunctionInfo: public HeapObject {
void SetConstructStub(Code* code);
// Returns if this function has been compiled to native code yet.
inline bool is_compiled();
inline bool is_compiled() const;
// [length]: The function length - usually the number of declared parameters.
// Use up to 2^30 parameters.
......
......@@ -171,7 +171,7 @@ RUNTIME_FUNCTION(Runtime_OptimizeOsr) {
// Make the profiler arm all back edges in unoptimized code.
if (function->shared()->HasBytecodeArray() ||
function->shared()->code()->kind() == Code::FUNCTION) {
function->shared()->HasBaselineCode()) {
isolate->runtime_profiler()->AttemptOnStackReplacement(
*function, AbstractCode::kMaxLoopNestingMarker);
}
......
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