[vm/bytecode] Fix entry point when optimized code is cleared but bytecode remains

If interpreter is enabled and a function has bytecode, then its entry
point should be set to 'interpreter call' instead of 'lazy compile'
when clearing code.

Fixes https://github.com/dart-lang/sdk/issues/35128

Change-Id: Ie714ac9c4d1ffef181512c5785c374e9de22ab95
Reviewed-on: https://dart-review.googlesource.com/c/84180
Commit-Queue: Régis Crelier <regis@google.com>
Auto-Submit: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Régis Crelier <regis@google.com>
This commit is contained in:
Alexander Markov 2018-11-13 01:04:05 +00:00 committed by commit-bot@chromium.org
parent 802db45879
commit f4a80a8466
3 changed files with 25 additions and 9 deletions

View file

@ -53,11 +53,19 @@ class SkippedCodeFunctions {
// If the code wasn't strongly visited through other references
// after skipping the function's code pointer, then we disconnect the
// code from the function.
func->StorePointer(&(func->ptr()->code_),
StubCode::LazyCompile_entry()->code());
uword entry_point = StubCode::LazyCompile_entry()->EntryPoint();
func->ptr()->entry_point_ = entry_point;
func->ptr()->unchecked_entry_point_ = entry_point;
if (FLAG_enable_interpreter && Function::HasBytecode(func)) {
func->StorePointer(&(func->ptr()->code_),
StubCode::InterpretCall_entry()->code());
uword entry_point = StubCode::InterpretCall_entry()->EntryPoint();
func->ptr()->entry_point_ = entry_point;
func->ptr()->unchecked_entry_point_ = entry_point;
} else {
func->StorePointer(&(func->ptr()->code_),
StubCode::LazyCompile_entry()->code());
uword entry_point = StubCode::LazyCompile_entry()->EntryPoint();
func->ptr()->entry_point_ = entry_point;
func->ptr()->unchecked_entry_point_ = entry_point;
}
if (FLAG_log_code_drop) {
// NOTE: This code runs while GC is in progress and runs within
// a NoHandleScope block. Hence it is not okay to use a regular Zone

View file

@ -6091,6 +6091,9 @@ void Function::SwitchToUnoptimizedCode() const {
}
void Function::SwitchToLazyCompiledUnoptimizedCode() const {
#if defined(DART_PRECOMPILED_RUNTIME)
UNREACHABLE();
#else
if (!HasOptimizedCode()) {
return;
}
@ -6105,9 +6108,14 @@ void Function::SwitchToLazyCompiledUnoptimizedCode() const {
const Code& unopt_code = Code::Handle(zone, unoptimized_code());
if (unopt_code.IsNull()) {
// Set the lazy compile code.
TIR_Print("Switched to lazy compile stub for %s\n", ToCString());
SetInstructions(Code::Handle(StubCode::LazyCompile_entry()->code()));
// Set the lazy compile or interpreter call stub code.
if (FLAG_enable_interpreter && HasBytecode()) {
TIR_Print("Switched to interpreter call stub for %s\n", ToCString());
SetInstructions(Code::Handle(StubCode::InterpretCall_entry()->code()));
} else {
TIR_Print("Switched to lazy compile stub for %s\n", ToCString());
SetInstructions(Code::Handle(StubCode::LazyCompile_entry()->code()));
}
return;
}
@ -6115,6 +6123,7 @@ void Function::SwitchToLazyCompiledUnoptimizedCode() const {
AttachCode(unopt_code);
unopt_code.Enable();
#endif
}
void Function::set_unoptimized_code(const Code& value) const {

View file

@ -75,7 +75,6 @@ dart_developer_disabled_env_test: RuntimeError
[ $compiler == dartkb && $strong ]
io/code_collection_test: RuntimeError # Reruns the same script (dill file without AST) without passing --enable-interpreter or --use-bytecode-compiler.
io/dart_std_io_pipe_test: Pass, Timeout # Please triage
io/file_lock_test: Skip # Times out, issue 35128
io/platform_resolved_executable_test/00: RuntimeError # Reruns the same script (dill file without AST) without passing --enable-interpreter or --use-bytecode-compiler.
io/platform_resolved_executable_test/01: RuntimeError # Reruns the same script (dill file without AST) without passing --enable-interpreter or --use-bytecode-compiler.
io/platform_resolved_executable_test/02: RuntimeError # Reruns the same script (dill file without AST) without passing --enable-interpreter or --use-bytecode-compiler.