From 79c7d3d8bcc2d2f2dee15d02dd8d703ea9e43f24 Mon Sep 17 00:00:00 2001 From: Ryan Macnak Date: Fri, 1 Nov 2019 17:06:02 +0000 Subject: [PATCH] [vm] Always use bytecode when it is present in a kernel file. Let FLAG_use_bytecode_compiler only control whether the kernel isolate generates bytecode. We no longer generate kernel files containing both AST and bytecode, so we don't need a flag to choose between them. Change-Id: I1a4f7df507c649019c9fe254fa18a5826e2006aa Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/122402 Reviewed-by: Alexander Markov Commit-Queue: Ryan Macnak --- runtime/vm/benchmark_test.cc | 6 ----- runtime/vm/clustered_snapshot.cc | 7 ----- runtime/vm/compilation_trace.cc | 3 --- .../frontend/kernel_binary_flowgraph.cc | 7 ----- runtime/vm/compiler/jit/compiler.cc | 1 - runtime/vm/dart.cc | 3 --- runtime/vm/kernel_loader.cc | 27 ++++++------------- runtime/vm/object.cc | 1 - 8 files changed, 8 insertions(+), 47 deletions(-) diff --git a/runtime/vm/benchmark_test.cc b/runtime/vm/benchmark_test.cc index a95642a7239..11527a780a0 100644 --- a/runtime/vm/benchmark_test.cc +++ b/runtime/vm/benchmark_test.cc @@ -131,12 +131,6 @@ static int64_t GenKernelKernelBenchmark(const char* name, bool read_fully = file->ReadFully(kernel_buffer, kernel_buffer_size); EXPECT(read_fully); - // Enable bytecode compiler in order to read bytecode. - // Enabling interpreter also does the trick, but it causes flaky crashes - // as unoptimized background compiler (which is required for interpreter) - // was not initialized when isolate was created. - SetFlagScope sfs(&FLAG_use_bytecode_compiler, true); - Timer timer(true, name); if (benchmark_load) { timer.Start(); diff --git a/runtime/vm/clustered_snapshot.cc b/runtime/vm/clustered_snapshot.cc index 09695382e64..17a946a653f 100644 --- a/runtime/vm/clustered_snapshot.cc +++ b/runtime/vm/clustered_snapshot.cc @@ -605,13 +605,6 @@ class FunctionDeserializationCluster : public DeserializationCluster { if (func.HasCode() && !code.IsDisabled()) { func.SetInstructions(code); // Set entrypoint. func.SetWasCompiled(true); -#if !defined(DART_PRECOMPILED_RUNTIME) - } else if (FLAG_enable_interpreter && func.HasBytecode()) { - // Set the code entry_point to InterpretCall stub. - func.SetInstructions(StubCode::InterpretCall()); - } else if (FLAG_use_bytecode_compiler && func.HasBytecode()) { - func.SetInstructions(StubCode::LazyCompile()); -#endif // !defined(DART_PRECOMPILED_RUNTIME) } else { func.ClearCode(); // Set code and entrypoint to lazy compile stub. } diff --git a/runtime/vm/compilation_trace.cc b/runtime/vm/compilation_trace.cc index f47cc568e67..0d1b36a6112 100644 --- a/runtime/vm/compilation_trace.cc +++ b/runtime/vm/compilation_trace.cc @@ -449,9 +449,6 @@ static char* CompilerFlags() { ADD_FLAG(causal_async_stacks); ADD_FLAG(fields_may_be_reset); #undef ADD_FLAG - buffer.AddString(FLAG_use_bytecode_compiler || FLAG_enable_interpreter - ? " bytecode" - : " no-bytecode"); return buffer.Steal(); } diff --git a/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc b/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc index 98900df0375..b093215faca 100644 --- a/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc +++ b/runtime/vm/compiler/frontend/kernel_binary_flowgraph.cc @@ -993,13 +993,6 @@ FlowGraph* StreamingFlowGraphBuilder::BuildGraph() { ActiveTypeParametersScope active_type_params(active_class(), function, Z); if (function.is_declared_in_bytecode()) { - if (!(FLAG_use_bytecode_compiler || FLAG_enable_interpreter)) { - FATAL1( - "Cannot run bytecode function %s: specify --enable-interpreter or " - "--use-bytecode-compiler", - function.ToFullyQualifiedCString()); - } - bytecode_metadata_helper_.ParseBytecodeFunction(parsed_function()); switch (function.kind()) { diff --git a/runtime/vm/compiler/jit/compiler.cc b/runtime/vm/compiler/jit/compiler.cc index 9608373a34b..e52a66fc51a 100644 --- a/runtime/vm/compiler/jit/compiler.cc +++ b/runtime/vm/compiler/jit/compiler.cc @@ -108,7 +108,6 @@ static void PrecompilationModeHandler(bool value) { FLAG_reorder_basic_blocks = true; FLAG_use_field_guards = false; FLAG_use_cha_deopt = false; - FLAG_use_bytecode_compiler = true; #if !defined(DART_PRECOMPILED_RUNTIME) // Not present with DART_PRECOMPILED_RUNTIME diff --git a/runtime/vm/dart.cc b/runtime/vm/dart.cc index 8b17c9fab73..05fb029bcba 100644 --- a/runtime/vm/dart.cc +++ b/runtime/vm/dart.cc @@ -847,9 +847,6 @@ const char* Dart::FeaturesString(Isolate* isolate, buffer.AddString(FLAG_causal_async_stacks ? " causal_async_stacks" : " no-causal_async_stacks"); - buffer.AddString((FLAG_enable_interpreter || FLAG_use_bytecode_compiler) - ? " bytecode" - : " no-bytecode"); // Generated code must match the host architecture and ABI. #if defined(TARGET_ARCH_ARM) diff --git a/runtime/vm/kernel_loader.cc b/runtime/vm/kernel_loader.cc index fce72a90097..3ab242d20d4 100644 --- a/runtime/vm/kernel_loader.cc +++ b/runtime/vm/kernel_loader.cc @@ -430,9 +430,7 @@ void KernelLoader::InitializeFields(UriToSourceTable* uri_to_source_table) { scripts.SetAt(index, script); } - if (FLAG_enable_interpreter || FLAG_use_bytecode_compiler) { - bytecode_metadata_helper_.ReadBytecodeComponent(); - } + bytecode_metadata_helper_.ReadBytecodeComponent(); } KernelLoader::KernelLoader(const Script& script, @@ -734,12 +732,7 @@ RawObject* KernelLoader::LoadProgram(bool process_pending_classes) { LongJumpScope jump; if (setjmp(*jump.Set()) == 0) { - bool libraries_loaded = false; - if (FLAG_enable_interpreter || FLAG_use_bytecode_compiler) { - libraries_loaded = bytecode_metadata_helper_.ReadLibraries(); - } - - if (!libraries_loaded) { + if (!bytecode_metadata_helper_.ReadLibraries()) { // Note that `problemsAsJson` on Component is implicitly skipped. const intptr_t length = program_->library_count(); for (intptr_t i = 0; i < length; i++) { @@ -785,11 +778,9 @@ RawObject* KernelLoader::LoadProgram(bool process_pending_classes) { void KernelLoader::LoadLibrary(const Library& library) { ASSERT(!library.Loaded()); - if (FLAG_enable_interpreter || FLAG_use_bytecode_compiler) { - bytecode_metadata_helper_.ReadLibrary(library); - if (library.Loaded()) { - return; - } + bytecode_metadata_helper_.ReadLibrary(library); + if (library.Loaded()) { + return; } const auto& uri = String::Handle(Z, library.url()); const intptr_t num_libraries = program_->library_count(); @@ -916,11 +907,9 @@ void KernelLoader::walk_incremental_kernel(BitVector* modified_libs, bool* is_empty_program, intptr_t* p_num_classes, intptr_t* p_num_procedures) { - if (FLAG_enable_interpreter || FLAG_use_bytecode_compiler) { - if (bytecode_metadata_helper_.FindModifiedLibrariesForHotReload( - modified_libs, is_empty_program, p_num_classes, p_num_procedures)) { - return; - } + if (bytecode_metadata_helper_.FindModifiedLibrariesForHotReload( + modified_libs, is_empty_program, p_num_classes, p_num_procedures)) { + return; } intptr_t length = program_->library_count(); *is_empty_program = *is_empty_program && (length == 0); diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc index 562c027dcc5..4b1984c0e62 100644 --- a/runtime/vm/object.cc +++ b/runtime/vm/object.cc @@ -5887,7 +5887,6 @@ bool Function::IsBytecodeAllowed(Zone* zone) const { void Function::AttachBytecode(const Bytecode& value) const { DEBUG_ASSERT(IsMutatorOrAtSafepoint()); - ASSERT(FLAG_enable_interpreter || FLAG_use_bytecode_compiler); ASSERT(!value.IsNull()); // Finish setting up code before activating it. if (!value.InVMIsolateHeap()) {