[vm/compiler] Split compiler sources out of normal VM sources.
Make them form its own source set (libdart_compiler) and completely exclude
them from AOT runtime targets.
Previously we had some inconsistencies, with some files were using
DART_PRECOMPILED_RUNTIME to fully or partially exclude either contents
from their headers or from implementation, while other files did nothing
and relied on linker to throw their contents away.
This change tries to address this inconsistency.
A follow up change would include a check in most compiler headers which
would prohibit to use them while building AOT runtime.
Change-Id: Ief11b11cbc518b301d3e93fce80580a31bbad151
Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/142993
Reviewed-by: Alexander Markov <alexmarkov@google.com>
Reviewed-by: Martin Kustermann <kustermann@google.com>
diff --git a/runtime/BUILD.gn b/runtime/BUILD.gn
index 88b27a9..c7d66dc 100644
--- a/runtime/BUILD.gn
+++ b/runtime/BUILD.gn
@@ -236,6 +236,7 @@
"vm:libdart_lib",
"vm:libdart_vm",
]
+ compiler_lib = "vm:libdart_compiler"
extra_configs = [ ":dart_shared_lib" ]
include_dirs = [ "." ]
public_configs = [ ":dart_public_config" ]
diff --git a/runtime/configs.gni b/runtime/configs.gni
index 04d8998..971d242 100644
--- a/runtime/configs.gni
+++ b/runtime/configs.gni
@@ -65,56 +65,67 @@
suffix = "_jit"
configs = _jit_config
snapshot = true
+ compiler = true
},
{
suffix = "_jit_product"
configs = _jit_product_config
snapshot = true
+ compiler = true
},
{
suffix = "_precompiled_runtime"
configs = _precompiled_runtime_config
snapshot = true
+ compiler = false
},
{
suffix = "_precompiled_runtime_product"
configs = _precompiled_runtime_product_config
snapshot = true
+ compiler = false
},
{
suffix = "_precompiler"
configs = _precompiler_config
snapshot = false
+ compiler = true
},
{
suffix = "_precompiler_product"
configs = _precompiler_product_config
snapshot = false
+ compiler = true
},
{
suffix = "_precompiler_fuchsia"
configs = _precompiler_fuchsia_config
snapshot = false
+ compiler = true
},
{
suffix = "_precompiler_product_fuchsia"
configs = _precompiler_product_fuchsia_config
snapshot = false
+ compiler = true
},
{
suffix = "_precompiler_host_targeting_host"
configs = _precompiler_host_targeting_host_config
snapshot = false
+ compiler = true
},
{
suffix = "_precompiler_product_host_targeting_host"
configs = _precompiler_product_host_targeting_host_config
snapshot = false
+ compiler = true
},
{
suffix = "_libfuzzer"
configs = _libfuzzer_config
snapshot = true
+ compiler = true
},
]
@@ -177,6 +188,13 @@
foreach(dep, configurable_deps) {
configured_deps += [ "${dep}${conf.suffix}" ]
}
+ if (defined(compiler_lib)) {
+ if (conf.compiler) {
+ configured_deps += [ "${compiler_lib}${conf.suffix}" ]
+ } else {
+ not_needed([ "compiler_lib" ])
+ }
+ }
deps = configured_deps + extra_deps
if (conf.snapshot) {
if (defined(snapshot_sources)) {
@@ -190,3 +208,47 @@
}
}
}
+
+template("library_for_all_configs_with_compiler") {
+ assert(defined(invoker.target_type))
+ extra_configs = []
+ if (defined(invoker.extra_configs)) {
+ extra_configs += invoker.extra_configs
+ }
+ configurable_deps = []
+ if (defined(invoker.configurable_deps)) {
+ configurable_deps += invoker.configurable_deps
+ }
+ extra_deps = []
+ if (defined(invoker.extra_deps)) {
+ extra_deps += invoker.extra_deps
+ }
+ foreach(conf, _all_configs) {
+ if (conf.compiler) {
+ target(invoker.target_type, "${target_name}${conf.suffix}") {
+ forward_variables_from(invoker,
+ "*",
+ [
+ "extra_configs",
+ "extra_deps",
+ "configurable_deps",
+ ])
+ configs += conf.configs + extra_configs
+ configured_deps = []
+ foreach(dep, configurable_deps) {
+ configured_deps += [ "${dep}${conf.suffix}" ]
+ }
+ deps = configured_deps + extra_deps
+ if (conf.snapshot) {
+ if (defined(snapshot_sources)) {
+ sources += snapshot_sources
+ }
+ } else {
+ if (defined(snapshot_sources)) {
+ not_needed([ "snapshot_sources" ])
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/runtime/lib/ffi.cc b/runtime/lib/ffi.cc
index 47ead67..58f1d77 100644
--- a/runtime/lib/ffi.cc
+++ b/runtime/lib/ffi.cc
@@ -8,11 +8,7 @@
#include "vm/bootstrap_natives.h"
#include "vm/class_finalizer.h"
#include "vm/class_id.h"
-#include "vm/compiler/assembler/assembler.h"
-#include "vm/compiler/ffi/call.h"
-#include "vm/compiler/ffi/callback.h"
#include "vm/compiler/ffi/native_type.h"
-#include "vm/compiler/jit/compiler.h"
#include "vm/exceptions.h"
#include "vm/flags.h"
#include "vm/log.h"
@@ -22,6 +18,13 @@
#include "vm/object_store.h"
#include "vm/symbols.h"
+#if !defined(DART_PRECOMPILED_RUNTIME)
+#include "vm/compiler/assembler/assembler.h"
+#include "vm/compiler/ffi/call.h"
+#include "vm/compiler/ffi/callback.h"
+#include "vm/compiler/jit/compiler.h"
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
+
namespace dart {
// The following functions are runtime checks on type arguments.
@@ -69,7 +72,7 @@
return Double::Cast(instance);
}
-// Calcuate the size of a native type.
+// Calculate the size of a native type.
//
// You must check [IsConcreteNativeType] and [CheckSized] first to verify that
// this type has a defined size.
diff --git a/runtime/lib/regexp.cc b/runtime/lib/regexp.cc
index eb4237c..6deab66 100644
--- a/runtime/lib/regexp.cc
+++ b/runtime/lib/regexp.cc
@@ -8,10 +8,13 @@
#include "vm/native_entry.h"
#include "vm/object.h"
#include "vm/regexp_assembler_bytecode.h"
-#include "vm/regexp_assembler_ir.h"
#include "vm/regexp_parser.h"
#include "vm/thread.h"
+#if !defined(DART_PRECOMPILED_RUNTIME)
+#include "vm/regexp_assembler_ir.h"
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
+
namespace dart {
DEFINE_NATIVE_ENTRY(RegExp_factory, 0, 6) {
diff --git a/runtime/vm/BUILD.gn b/runtime/vm/BUILD.gn
index bac066b..e3b2a7a 100644
--- a/runtime/vm/BUILD.gn
+++ b/runtime/vm/BUILD.gn
@@ -90,11 +90,23 @@
"*_test.cc",
"*_test.h",
])
- sources = vm_sources + rebase_path(compiler_sources, ".", "./compiler/") +
+ sources = vm_sources + rebase_path(compiler_api_sources, ".", "./compiler/") +
+ rebase_path(disassembler_sources, ".", "./compiler/") +
rebase_path(heap_sources, ".", "./heap/")
include_dirs = [ ".." ]
}
+library_for_all_configs_with_compiler("libdart_compiler") {
+ target_type = "source_set"
+ public_configs = [ ":libdart_vm_config" ]
+ set_sources_assignment_filter([
+ "*_test.cc",
+ "*_test.h",
+ ])
+ sources = rebase_path(compiler_sources, ".", "./compiler/")
+ include_dirs = [ ".." ]
+}
+
library_for_all_configs("libdart_lib") {
target_type = "source_set"
if (is_fuchsia) {
diff --git a/runtime/vm/clustered_snapshot.cc b/runtime/vm/clustered_snapshot.cc
index 706ed49..2fded51 100644
--- a/runtime/vm/clustered_snapshot.cc
+++ b/runtime/vm/clustered_snapshot.cc
@@ -9,10 +9,8 @@
#include "vm/bss_relocs.h"
#include "vm/class_id.h"
#include "vm/code_observers.h"
+#include "vm/compiler/api/print_filter.h"
#include "vm/compiler/assembler/disassembler.h"
-#include "vm/compiler/backend/code_statistics.h"
-#include "vm/compiler/backend/il_printer.h"
-#include "vm/compiler/relocation.h"
#include "vm/dart.h"
#include "vm/dispatch_table.h"
#include "vm/flag_list.h"
@@ -28,6 +26,12 @@
#include "vm/timeline.h"
#include "vm/version.h"
+#if !defined(DART_PRECOMPILED_RUNTIME)
+#include "vm/compiler/backend/code_statistics.h"
+#include "vm/compiler/backend/il_printer.h"
+#include "vm/compiler/relocation.h"
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
+
namespace dart {
#if !defined(DART_PRECOMPILED_RUNTIME)
@@ -1746,7 +1750,7 @@
if (owner.IsFunction()) {
if ((FLAG_disassemble ||
(code.is_optimized() && FLAG_disassemble_optimized)) &&
- FlowGraphPrinter::ShouldPrint(Function::Cast(owner))) {
+ compiler::PrintFilter::ShouldPrint(Function::Cast(owner))) {
Disassembler::DisassembleCode(Function::Cast(owner), code,
code.is_optimized());
}
diff --git a/runtime/vm/code_comments.cc b/runtime/vm/code_comments.cc
index 74f8458..d1344d3 100644
--- a/runtime/vm/code_comments.cc
+++ b/runtime/vm/code_comments.cc
@@ -1,14 +1,13 @@
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+#if !defined(DART_PRECOMPILED_RUNTIME) && \
+ (!defined(PRODUCT) || defined(FORCE_INCLUDE_DISASSEMBLER))
#include "vm/code_comments.h"
namespace dart {
-#if !defined(DART_PRECOMPILED_RUNTIME) && \
- (!defined(PRODUCT) || defined(FORCE_INCLUDE_DISASSEMBLER))
-
const Code::Comments& CreateCommentsFrom(compiler::Assembler* assembler) {
const auto& comments = assembler->comments();
Code::Comments& result = Code::Comments::New(comments.length());
@@ -21,7 +20,6 @@
return result;
}
+} // namespace dart
#endif // !defined(DART_PRECOMPILED_RUNTIME) && \
// (!defined(PRODUCT) || defined(FORCE_INCLUDE_DISASSEMBLER))
-
-} // namespace dart
diff --git a/runtime/vm/code_comments.h b/runtime/vm/code_comments.h
index 9c86524..18f0e75 100644
--- a/runtime/vm/code_comments.h
+++ b/runtime/vm/code_comments.h
@@ -5,15 +5,15 @@
#ifndef RUNTIME_VM_CODE_COMMENTS_H_
#define RUNTIME_VM_CODE_COMMENTS_H_
+#if !defined(DART_PRECOMPILED_RUNTIME) && \
+ (!defined(PRODUCT) || defined(FORCE_INCLUDE_DISASSEMBLER))
+
#include "vm/code_observers.h"
#include "vm/compiler/assembler/assembler.h"
#include "vm/object.h"
namespace dart {
-#if !defined(DART_PRECOMPILED_RUNTIME) && \
- (!defined(PRODUCT) || defined(FORCE_INCLUDE_DISASSEMBLER))
-
class CodeCommentsWrapper final : public CodeComments {
public:
explicit CodeCommentsWrapper(const Code::Comments& comments)
@@ -37,9 +37,9 @@
const Code::Comments& CreateCommentsFrom(compiler::Assembler* assembler);
-#endif // !defined(DART_PRECOMPILED_RUNTIME) && \
- // (!defined(PRODUCT) || defined(FORCE_INCLUDE_DISASSEMBLER))
} // namespace dart
+#endif // !defined(DART_PRECOMPILED_RUNTIME) && \
+ // (!defined(PRODUCT) || defined(FORCE_INCLUDE_DISASSEMBLER))
#endif // RUNTIME_VM_CODE_COMMENTS_H_
diff --git a/runtime/vm/code_descriptors.cc b/runtime/vm/code_descriptors.cc
index 5136d03..d773325 100644
--- a/runtime/vm/code_descriptors.cc
+++ b/runtime/vm/code_descriptors.cc
@@ -4,7 +4,7 @@
#include "vm/code_descriptors.h"
-#include "vm/compiler/compiler_state.h"
+#include "vm/compiler/api/deopt_id.h"
#include "vm/log.h"
#include "vm/object_store.h"
#include "vm/zone_text_buffer.h"
diff --git a/runtime/vm/code_patcher_arm.cc b/runtime/vm/code_patcher_arm.cc
index 024a6ab..aaa1392 100644
--- a/runtime/vm/code_patcher_arm.cc
+++ b/runtime/vm/code_patcher_arm.cc
@@ -7,7 +7,6 @@
#include "vm/code_patcher.h"
-#include "vm/compiler/backend/flow_graph_compiler.h"
#include "vm/instructions.h"
#include "vm/object.h"
diff --git a/runtime/vm/code_patcher_ia32.cc b/runtime/vm/code_patcher_ia32.cc
index 7e97f67..c58b5fe 100644
--- a/runtime/vm/code_patcher_ia32.cc
+++ b/runtime/vm/code_patcher_ia32.cc
@@ -6,8 +6,6 @@
#if defined(TARGET_ARCH_IA32)
#include "vm/code_patcher.h"
-#include "vm/compiler/assembler/assembler.h"
-#include "vm/compiler/backend/flow_graph_compiler.h"
#include "vm/cpu.h"
#include "vm/dart_entry.h"
#include "vm/instructions.h"
diff --git a/runtime/vm/code_patcher_x64.cc b/runtime/vm/code_patcher_x64.cc
index e67d187..8cf78d8 100644
--- a/runtime/vm/code_patcher_x64.cc
+++ b/runtime/vm/code_patcher_x64.cc
@@ -6,8 +6,6 @@
#if defined(TARGET_ARCH_X64)
#include "vm/code_patcher.h"
-#include "vm/compiler/assembler/assembler.h"
-#include "vm/compiler/backend/flow_graph_compiler.h"
#include "vm/cpu.h"
#include "vm/dart_entry.h"
#include "vm/instructions.h"
diff --git a/runtime/vm/compiler/api/deopt_id.h b/runtime/vm/compiler/api/deopt_id.h
new file mode 100644
index 0000000..c203e45
--- /dev/null
+++ b/runtime/vm/compiler/api/deopt_id.h
@@ -0,0 +1,52 @@
+// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#ifndef RUNTIME_VM_COMPILER_API_DEOPT_ID_H_
+#define RUNTIME_VM_COMPILER_API_DEOPT_ID_H_
+
+#include "platform/allocation.h"
+
+namespace dart {
+
+// Deoptimization Id logic.
+//
+// Deoptimization ids are used to refer to deoptimization points, at which
+// control can enter unoptimized code from the optimized version of the code.
+//
+// Note: any instruction that does a call has two deoptimization points,
+// one before the call and one after the call - so that we could deoptimize
+// to either before or after the call depending on whether the same call
+// already occured in the optimized code (and potentially produced
+// observable side-effects) or not.
+//
+// To simplify implementation we always allocate two deopt ids (one for before
+// point and one for the after point).
+class DeoptId : public AllStatic {
+ public:
+ static constexpr intptr_t kNone = -1;
+
+ static inline intptr_t Next(intptr_t deopt_id) { return deopt_id + kStep; }
+
+ static inline intptr_t ToDeoptAfter(intptr_t deopt_id) {
+ ASSERT(IsDeoptBefore(deopt_id));
+ return deopt_id + kAfterOffset;
+ }
+
+ static inline bool IsDeoptBefore(intptr_t deopt_id) {
+ return (deopt_id % kStep) == kBeforeOffset;
+ }
+
+ static inline bool IsDeoptAfter(intptr_t deopt_id) {
+ return (deopt_id % kStep) == kAfterOffset;
+ }
+
+ private:
+ static constexpr intptr_t kStep = 2;
+ static constexpr intptr_t kBeforeOffset = 0;
+ static constexpr intptr_t kAfterOffset = 1;
+};
+
+} // namespace dart
+
+#endif // RUNTIME_VM_COMPILER_API_DEOPT_ID_H_
diff --git a/runtime/vm/compiler/api/print_filter.cc b/runtime/vm/compiler/api/print_filter.cc
new file mode 100644
index 0000000..ee2a06f
--- /dev/null
+++ b/runtime/vm/compiler/api/print_filter.cc
@@ -0,0 +1,70 @@
+// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+#if !defined(PRODUCT) || defined(FORCE_INCLUDE_DISASSEMBLER)
+
+#include "vm/compiler/api/print_filter.h"
+
+#include "vm/flags.h"
+#include "vm/object.h"
+
+namespace dart {
+
+DEFINE_FLAG(charp,
+ print_flow_graph_filter,
+ NULL,
+ "Print only IR of functions with matching names");
+
+namespace compiler {
+
+// Checks whether function's name matches the given filter, which is
+// a comma-separated list of strings.
+static bool PassesFilter(const char* filter, const Function& function) {
+ if (filter == NULL) {
+ return true;
+ }
+
+ char* save_ptr; // Needed for strtok_r.
+ const char* scrubbed_name =
+ String::Handle(function.QualifiedScrubbedName()).ToCString();
+ const char* function_name = function.ToFullyQualifiedCString();
+ intptr_t function_name_len = strlen(function_name);
+
+ intptr_t len = strlen(filter) + 1; // Length with \0.
+ char* filter_buffer = new char[len];
+ strncpy(filter_buffer, filter, len); // strtok modifies arg 1.
+ char* token = strtok_r(filter_buffer, ",", &save_ptr);
+ bool found = false;
+ while (token != NULL) {
+ if ((strstr(function_name, token) != NULL) ||
+ (strstr(scrubbed_name, token) != NULL)) {
+ found = true;
+ break;
+ }
+ const intptr_t token_len = strlen(token);
+ if (token[token_len - 1] == '%') {
+ if (function_name_len > token_len) {
+ const char* suffix =
+ function_name + (function_name_len - token_len + 1);
+ if (strncmp(suffix, token, token_len - 1) == 0) {
+ found = true;
+ break;
+ }
+ }
+ }
+ token = strtok_r(NULL, ",", &save_ptr);
+ }
+ delete[] filter_buffer;
+
+ return found;
+}
+
+bool PrintFilter::ShouldPrint(const Function& function) {
+ return PassesFilter(FLAG_print_flow_graph_filter, function);
+}
+
+} // namespace compiler
+
+} // namespace dart
+
+#endif // !defined(PRODUCT) || defined(FORCE_INCLUDE_DISASSEMBLER)
diff --git a/runtime/vm/compiler/api/print_filter.h b/runtime/vm/compiler/api/print_filter.h
new file mode 100644
index 0000000..1eea14a
--- /dev/null
+++ b/runtime/vm/compiler/api/print_filter.h
@@ -0,0 +1,27 @@
+// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#ifndef RUNTIME_VM_COMPILER_API_PRINT_FILTER_H_
+#define RUNTIME_VM_COMPILER_API_PRINT_FILTER_H_
+#if !defined(PRODUCT) || defined(FORCE_INCLUDE_DISASSEMBLER)
+
+#include "platform/allocation.h"
+
+namespace dart {
+
+class Function;
+
+namespace compiler {
+
+class PrintFilter : public AllStatic {
+ public:
+ static bool ShouldPrint(const Function& function);
+};
+
+} // namespace compiler
+
+} // namespace dart
+
+#endif // !defined(PRODUCT) || defined(FORCE_INCLUDE_DISASSEMBLER)
+#endif // RUNTIME_VM_COMPILER_API_PRINT_FILTER_H_
diff --git a/runtime/vm/compiler/api/type_check_mode.h b/runtime/vm/compiler/api/type_check_mode.h
new file mode 100644
index 0000000..7710607
--- /dev/null
+++ b/runtime/vm/compiler/api/type_check_mode.h
@@ -0,0 +1,29 @@
+// Copyright (c) 2020, the Dart project authors. Please see the AUTHORS file
+// for details. All rights reserved. Use of this source code is governed by a
+// BSD-style license that can be found in the LICENSE file.
+
+#ifndef RUNTIME_VM_COMPILER_API_TYPE_CHECK_MODE_H_
+#define RUNTIME_VM_COMPILER_API_TYPE_CHECK_MODE_H_
+
+namespace dart {
+
+// Invocation mode for TypeCheck runtime entry that describes
+// where we are calling it from.
+enum TypeCheckMode {
+ // TypeCheck is invoked from LazySpecializeTypeTest stub.
+ // It should replace stub on the type with a specialized version.
+ kTypeCheckFromLazySpecializeStub,
+
+ // TypeCheck is invoked from the SlowTypeTest stub.
+ // This means that cache can be lazily created (if needed)
+ // and dst_name can be fetched from the pool.
+ kTypeCheckFromSlowStub,
+
+ // TypeCheck is invoked from normal inline AssertAssignable.
+ // Both cache and dst_name must be already populated.
+ kTypeCheckFromInline
+};
+
+} // namespace dart
+
+#endif // RUNTIME_VM_COMPILER_API_TYPE_CHECK_MODE_H_
diff --git a/runtime/vm/compiler/assembler/assembler_arm.h b/runtime/vm/compiler/assembler/assembler_arm.h
index bd79c03..81ed9f6 100644
--- a/runtime/vm/compiler/assembler/assembler_arm.h
+++ b/runtime/vm/compiler/assembler/assembler_arm.h
@@ -589,8 +589,6 @@
B4 | (imm16 & 0xf);
}
- static uword GetBreakInstructionFiller() { return BkptEncoding(0); }
-
// Floating point instructions (VFPv3-D16 and VFPv3-D32 profiles).
void vmovsr(SRegister sn, Register rt, Condition cond = AL);
void vmovrs(Register rt, SRegister sn, Condition cond = AL);
diff --git a/runtime/vm/compiler/assembler/assembler_arm64.h b/runtime/vm/compiler/assembler/assembler_arm64.h
index 26ab378..071bb36 100644
--- a/runtime/vm/compiler/assembler/assembler_arm64.h
+++ b/runtime/vm/compiler/assembler/assembler_arm64.h
@@ -1034,11 +1034,6 @@
// Breakpoint.
void brk(uint16_t imm) { EmitExceptionGenOp(BRK, imm); }
- static uword GetBreakInstructionFiller() {
- const intptr_t encoding = ExceptionGenOpEncoding(BRK, 0);
- return encoding << 32 | encoding;
- }
-
// Double floating point.
bool fmovdi(VRegister vd, double immd) {
int64_t imm64 = bit_cast<int64_t, double>(immd);
diff --git a/runtime/vm/compiler/assembler/assembler_ia32.h b/runtime/vm/compiler/assembler/assembler_ia32.h
index c60968e..286b6f9 100644
--- a/runtime/vm/compiler/assembler/assembler_ia32.h
+++ b/runtime/vm/compiler/assembler/assembler_ia32.h
@@ -549,8 +549,6 @@
void int3();
void hlt();
- static uword GetBreakInstructionFiller() { return 0xCCCCCCCC; }
-
void j(Condition condition, Label* label, bool near = kFarJump);
void j(Condition condition, const ExternalLabel* label);
diff --git a/runtime/vm/compiler/assembler/assembler_x64.h b/runtime/vm/compiler/assembler/assembler_x64.h
index 0c281ca..42a17d8 100644
--- a/runtime/vm/compiler/assembler/assembler_x64.h
+++ b/runtime/vm/compiler/assembler/assembler_x64.h
@@ -642,8 +642,6 @@
// 'size' indicates size in bytes and must be in the range 1..8.
void nop(int size = 1);
- static uword GetBreakInstructionFiller() { return 0xCCCCCCCCCCCCCCCC; }
-
void j(Condition condition, Label* label, bool near = kFarJump);
void jmp(Register reg) { EmitUnaryL(reg, 0xFF, 4); }
void jmp(const Address& address) { EmitUnaryL(address, 0xFF, 4); }
diff --git a/runtime/vm/compiler/assembler/disassembler.cc b/runtime/vm/compiler/assembler/disassembler.cc
index 37c3743..89e9204 100644
--- a/runtime/vm/compiler/assembler/disassembler.cc
+++ b/runtime/vm/compiler/assembler/disassembler.cc
@@ -5,8 +5,6 @@
#include "vm/compiler/assembler/disassembler.h"
#include "vm/code_patcher.h"
-#include "vm/compiler/assembler/assembler.h"
-#include "vm/compiler/backend/il_printer.h"
#include "vm/deopt_instructions.h"
#include "vm/globals.h"
#include "vm/instructions.h"
@@ -18,7 +16,10 @@
#if !defined(PRODUCT) || defined(FORCE_INCLUDE_DISASSEMBLER)
+#if !defined(DART_PRECOMPILED_RUNTIME)
DECLARE_FLAG(bool, trace_inlining_intervals);
+#endif
+
DEFINE_FLAG(bool, trace_source_positions, false, "Source position diagnostics");
void DisassembleToStdout::ConsumeInstruction(char* hex_buffer,
@@ -416,9 +417,12 @@
}
#endif // defined(DART_PRECOMPILED_RUNTIME)
+#if !defined(DART_PRECOMPILED_RUNTIME)
if (optimized && FLAG_trace_inlining_intervals) {
code.DumpInlineIntervals();
}
+#endif
+
if (FLAG_trace_source_positions) {
code.DumpSourcePositions();
}
diff --git a/runtime/vm/compiler/assembler/disassembler.h b/runtime/vm/compiler/assembler/disassembler.h
index 861051d..4a86177 100644
--- a/runtime/vm/compiler/assembler/disassembler.h
+++ b/runtime/vm/compiler/assembler/disassembler.h
@@ -6,11 +6,14 @@
#define RUNTIME_VM_COMPILER_ASSEMBLER_DISASSEMBLER_H_
#include "vm/allocation.h"
-#include "vm/compiler/assembler/assembler.h"
#include "vm/globals.h"
#include "vm/log.h"
#include "vm/object.h"
+#if !defined(DART_PRECOMPILED_RUNTIME)
+#include "vm/compiler/assembler/assembler.h"
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
+
namespace dart {
// Forward declaration.
diff --git a/runtime/vm/compiler/assembler/disassembler_x86.cc b/runtime/vm/compiler/assembler/disassembler_x86.cc
index b51f464..0d162a5 100644
--- a/runtime/vm/compiler/assembler/disassembler_x86.cc
+++ b/runtime/vm/compiler/assembler/disassembler_x86.cc
@@ -11,6 +11,7 @@
#include "platform/utils.h"
#include "vm/allocation.h"
+#include "vm/constants_x86.h"
#include "vm/heap/heap.h"
#include "vm/instructions.h"
#include "vm/os.h"
diff --git a/runtime/vm/compiler/backend/flow_graph_compiler_arm.cc b/runtime/vm/compiler/backend/flow_graph_compiler_arm.cc
index 2a45dcb..2d5388c 100644
--- a/runtime/vm/compiler/backend/flow_graph_compiler_arm.cc
+++ b/runtime/vm/compiler/backend/flow_graph_compiler_arm.cc
@@ -7,6 +7,7 @@
#include "vm/compiler/backend/flow_graph_compiler.h"
+#include "vm/compiler/api/type_check_mode.h"
#include "vm/compiler/backend/il_printer.h"
#include "vm/compiler/backend/locations.h"
#include "vm/compiler/jit/compiler.h"
diff --git a/runtime/vm/compiler/backend/flow_graph_compiler_arm64.cc b/runtime/vm/compiler/backend/flow_graph_compiler_arm64.cc
index 353cc31..051740f 100644
--- a/runtime/vm/compiler/backend/flow_graph_compiler_arm64.cc
+++ b/runtime/vm/compiler/backend/flow_graph_compiler_arm64.cc
@@ -7,6 +7,7 @@
#include "vm/compiler/backend/flow_graph_compiler.h"
+#include "vm/compiler/api/type_check_mode.h"
#include "vm/compiler/backend/il_printer.h"
#include "vm/compiler/backend/locations.h"
#include "vm/compiler/jit/compiler.h"
diff --git a/runtime/vm/compiler/backend/flow_graph_compiler_ia32.cc b/runtime/vm/compiler/backend/flow_graph_compiler_ia32.cc
index 086ea4d..d982292 100644
--- a/runtime/vm/compiler/backend/flow_graph_compiler_ia32.cc
+++ b/runtime/vm/compiler/backend/flow_graph_compiler_ia32.cc
@@ -8,6 +8,7 @@
#include "vm/compiler/backend/flow_graph_compiler.h"
#include "vm/code_patcher.h"
+#include "vm/compiler/api/type_check_mode.h"
#include "vm/compiler/backend/il_printer.h"
#include "vm/compiler/backend/locations.h"
#include "vm/compiler/frontend/flow_graph_builder.h"
diff --git a/runtime/vm/compiler/backend/flow_graph_compiler_x64.cc b/runtime/vm/compiler/backend/flow_graph_compiler_x64.cc
index e9e7b22..cade733 100644
--- a/runtime/vm/compiler/backend/flow_graph_compiler_x64.cc
+++ b/runtime/vm/compiler/backend/flow_graph_compiler_x64.cc
@@ -7,6 +7,7 @@
#include "vm/compiler/backend/flow_graph_compiler.h"
+#include "vm/compiler/api/type_check_mode.h"
#include "vm/compiler/backend/il_printer.h"
#include "vm/compiler/backend/locations.h"
#include "vm/compiler/ffi/native_location.h"
diff --git a/runtime/vm/compiler/backend/il.h b/runtime/vm/compiler/backend/il.h
index c727de1..85a4cb2 100644
--- a/runtime/vm/compiler/backend/il.h
+++ b/runtime/vm/compiler/backend/il.h
@@ -5804,13 +5804,8 @@
virtual bool HasUnknownSideEffects() const { return false; }
virtual bool WillAllocateNewOrRemembered() const {
- return WillAllocateNewOrRemembered(num_context_variables_);
- }
-
- static bool WillAllocateNewOrRemembered(intptr_t num_context_variables) {
- if (!Context::IsValidLength(num_context_variables)) return false;
- return Heap::IsAllocatableInNewSpace(
- Context::InstanceSize(num_context_variables));
+ return compiler::target::WillAllocateNewOrRememberedContext(
+ num_context_variables_);
}
virtual AliasIdentity Identity() const { return identity_; }
@@ -5965,12 +5960,8 @@
if (!num_elements()->BindsToConstant()) return false;
const Object& length = num_elements()->BoundConstant();
if (!length.IsSmi()) return false;
- return WillAllocateNewOrRemembered(Smi::Cast(length).Value());
- }
-
- static bool WillAllocateNewOrRemembered(const intptr_t length) {
- if (!Array::IsValidLength(length)) return false;
- return !Array::UseCardMarkingForAllocation(length);
+ return compiler::target::WillAllocateNewOrRememberedArray(
+ Smi::Cast(length).Value());
}
private:
@@ -6291,13 +6282,8 @@
virtual bool HasUnknownSideEffects() const { return false; }
virtual bool WillAllocateNewOrRemembered() const {
- return WillAllocateNewOrRemembered(context_slots().length());
- }
-
- static bool WillAllocateNewOrRemembered(intptr_t num_context_variables) {
- if (!Context::IsValidLength(num_context_variables)) return false;
- return Heap::IsAllocatableInNewSpace(
- Context::InstanceSize(num_context_variables));
+ return compiler::target::WillAllocateNewOrRememberedContext(
+ context_slots().length());
}
PRINT_OPERANDS_TO_SUPPORT
diff --git a/runtime/vm/compiler/backend/il_printer.cc b/runtime/vm/compiler/backend/il_printer.cc
index 7903b2e..ab4c572 100644
--- a/runtime/vm/compiler/backend/il_printer.cc
+++ b/runtime/vm/compiler/backend/il_printer.cc
@@ -4,6 +4,7 @@
#include "vm/compiler/backend/il_printer.h"
+#include "vm/compiler/api/print_filter.h"
#include "vm/compiler/backend/il.h"
#include "vm/compiler/backend/range_analysis.h"
#include "vm/compiler/ffi/native_calling_convention.h"
@@ -14,60 +15,6 @@
#if !defined(PRODUCT) || defined(FORCE_INCLUDE_DISASSEMBLER)
-DEFINE_FLAG(charp,
- print_flow_graph_filter,
- NULL,
- "Print only IR of functions with matching names");
-
-// Checks whether function's name matches the given filter, which is
-// a comma-separated list of strings.
-bool FlowGraphPrinter::PassesFilter(const char* filter,
- const Function& function) {
- if (filter == NULL) {
- return true;
- }
-
- char* save_ptr; // Needed for strtok_r.
- const char* scrubbed_name =
- String::Handle(function.QualifiedScrubbedName()).ToCString();
- const char* function_name = function.ToFullyQualifiedCString();
- intptr_t function_name_len = strlen(function_name);
-
- intptr_t len = strlen(filter) + 1; // Length with \0.
- char* filter_buffer = new char[len];
- strncpy(filter_buffer, filter, len); // strtok modifies arg 1.
- char* token = strtok_r(filter_buffer, ",", &save_ptr);
- bool found = false;
- while (token != NULL) {
- if ((strstr(function_name, token) != NULL) ||
- (strstr(scrubbed_name, token) != NULL)) {
- found = true;
- break;
- }
- const intptr_t token_len = strlen(token);
- if (token[token_len - 1] == '%') {
- if (function_name_len > token_len) {
- const char* suffix =
- function_name + (function_name_len - token_len + 1);
- if (strncmp(suffix, token, token_len - 1) == 0) {
- found = true;
- break;
- }
- }
- }
- token = strtok_r(NULL, ",", &save_ptr);
- }
- delete[] filter_buffer;
-
- return found;
-}
-
-bool FlowGraphPrinter::ShouldPrint(const Function& function) {
- return PassesFilter(FLAG_print_flow_graph_filter, function);
-}
-
-#if !defined(DART_PRECOMPILED_RUNTIME)
-
DEFINE_FLAG(bool,
display_sorted_ic_data,
false,
@@ -76,6 +23,10 @@
DECLARE_FLAG(bool, trace_inlining_intervals);
+bool FlowGraphPrinter::ShouldPrint(const Function& function) {
+ return compiler::PrintFilter::ShouldPrint(function);
+}
+
void FlowGraphPrinter::PrintGraph(const char* phase, FlowGraph* flow_graph) {
LogBlock lb;
THR_Print("*** BEGIN CFG\n%s\n", phase);
@@ -1224,12 +1175,8 @@
return Thread::Current()->zone()->MakeCopyOfString(buffer);
}
-#endif // !defined(DART_PRECOMPILED_RUNTIME)
-
#else // !defined(PRODUCT) || defined(FORCE_INCLUDE_DISASSEMBLER)
-#if !defined(DART_PRECOMPILED_RUNTIME)
-
const char* Instruction::ToCString() const {
return DebugName();
}
@@ -1266,8 +1213,6 @@
return false;
}
-#endif // !defined(DART_PRECOMPILED_RUNTIME)
-
#endif // !defined(PRODUCT) || defined(FORCE_INCLUDE_DISASSEMBLER)
} // namespace dart
diff --git a/runtime/vm/compiler/backend/il_printer.h b/runtime/vm/compiler/backend/il_printer.h
index 32cc84a..becdf59 100644
--- a/runtime/vm/compiler/backend/il_printer.h
+++ b/runtime/vm/compiler/backend/il_printer.h
@@ -54,8 +54,6 @@
static bool ShouldPrint(const Function& function);
- static bool PassesFilter(const char* filter, const Function& function);
-
private:
const Function& function_;
const GrowableArray<BlockEntryInstr*>& block_order_;
diff --git a/runtime/vm/compiler/compiler_sources.gni b/runtime/vm/compiler/compiler_sources.gni
index fe2e471..f39d83a 100644
--- a/runtime/vm/compiler/compiler_sources.gni
+++ b/runtime/vm/compiler/compiler_sources.gni
@@ -28,13 +28,6 @@
"assembler/assembler_ia32.h",
"assembler/assembler_x64.cc",
"assembler/assembler_x64.h",
- "assembler/disassembler.cc",
- "assembler/disassembler.h",
- "assembler/disassembler_arm.cc",
- "assembler/disassembler_arm64.cc",
- "assembler/disassembler_kbc.cc",
- "assembler/disassembler_kbc.h",
- "assembler/disassembler_x86.cc",
"assembler/object_pool_builder.h",
"backend/block_builder.h",
"backend/block_scheduler.cc",
@@ -112,8 +105,6 @@
"ffi/native_calling_convention.h",
"ffi/native_location.cc",
"ffi/native_location.h",
- "ffi/native_type.cc",
- "ffi/native_type.h",
"ffi/recognized_method.cc",
"ffi/recognized_method.h",
"frontend/base_flow_graph_builder.cc",
@@ -150,8 +141,6 @@
"graph_intrinsifier_x64.cc",
"intrinsifier.cc",
"intrinsifier.h",
- "jit/compiler.cc",
- "jit/compiler.h",
"jit/jit_call_specializer.cc",
"jit/jit_call_specializer.h",
"method_recognizer.cc",
@@ -159,8 +148,6 @@
"recognized_methods_list.h",
"relocation.cc",
"relocation.h",
- "runtime_api.cc",
- "runtime_api.h",
"stub_code_compiler.cc",
"stub_code_compiler.h",
"stub_code_compiler_arm.cc",
@@ -196,3 +183,26 @@
"cha_test.cc",
"write_barrier_elimination_test.cc",
]
+
+compiler_api_sources = [
+ "api/deopt_id.h",
+ "api/print_filter.cc",
+ "api/print_filter.h",
+ "api/type_check_mode.h",
+ "ffi/native_type.cc",
+ "ffi/native_type.h",
+ "jit/compiler.cc",
+ "jit/compiler.h",
+ "runtime_api.cc",
+ "runtime_api.h",
+]
+
+disassembler_sources = [
+ "assembler/disassembler.cc",
+ "assembler/disassembler.h",
+ "assembler/disassembler_arm.cc",
+ "assembler/disassembler_arm64.cc",
+ "assembler/disassembler_kbc.cc",
+ "assembler/disassembler_kbc.h",
+ "assembler/disassembler_x86.cc",
+]
diff --git a/runtime/vm/compiler/compiler_state.cc b/runtime/vm/compiler/compiler_state.cc
index 47407f5..cdf77e6 100644
--- a/runtime/vm/compiler/compiler_state.cc
+++ b/runtime/vm/compiler/compiler_state.cc
@@ -3,12 +3,11 @@
// BSD-style license that can be found in the LICENSE file.
#include "vm/compiler/compiler_state.h"
-#include "vm/growable_array.h"
-
-#ifndef DART_PRECOMPILED_RUNTIME
#include <functional>
+#include "vm/compiler/backend/slot.h"
+#include "vm/growable_array.h"
#include "vm/scopes.h"
namespace dart {
@@ -72,5 +71,3 @@
}
} // namespace dart
-
-#endif // DART_PRECOMPILED_RUNTIME
diff --git a/runtime/vm/compiler/compiler_state.h b/runtime/vm/compiler/compiler_state.h
index 4b3a590..619f25b 100644
--- a/runtime/vm/compiler/compiler_state.h
+++ b/runtime/vm/compiler/compiler_state.h
@@ -5,6 +5,7 @@
#ifndef RUNTIME_VM_COMPILER_COMPILER_STATE_H_
#define RUNTIME_VM_COMPILER_COMPILER_STATE_H_
+#include "vm/compiler/api/deopt_id.h"
#include "vm/compiler/cha.h"
#include "vm/heap/safepoint.h"
#include "vm/thread.h"
@@ -16,44 +17,6 @@
class SlotCache;
class Slot;
-// Deoptimization Id logic.
-//
-// Deoptimization ids are used to refer to deoptimization points, at which
-// control can enter unoptimized code from the optimized version of the code.
-//
-// Note: any instruction that does a call has two deoptimization points,
-// one before the call and one after the call - so that we could deoptimize
-// to either before or after the call depending on whether the same call
-// already occured in the optimized code (and potentially produced
-// observable side-effects) or not.
-//
-// To simplify implementation we always allocate two deopt ids (one for before
-// point and one for the after point).
-class DeoptId : public AllStatic {
- public:
- static constexpr intptr_t kNone = -1;
-
- static inline intptr_t Next(intptr_t deopt_id) { return deopt_id + kStep; }
-
- static inline intptr_t ToDeoptAfter(intptr_t deopt_id) {
- ASSERT(IsDeoptBefore(deopt_id));
- return deopt_id + kAfterOffset;
- }
-
- static inline bool IsDeoptBefore(intptr_t deopt_id) {
- return (deopt_id % kStep) == kBeforeOffset;
- }
-
- static inline bool IsDeoptAfter(intptr_t deopt_id) {
- return (deopt_id % kStep) == kAfterOffset;
- }
-
- private:
- static constexpr intptr_t kStep = 2;
- static constexpr intptr_t kBeforeOffset = 0;
- static constexpr intptr_t kAfterOffset = 1;
-};
-
// Global compiler state attached to the thread.
class CompilerState : public ThreadStackResource {
public:
diff --git a/runtime/vm/compiler/ffi/native_type.cc b/runtime/vm/compiler/ffi/native_type.cc
index e69380c..adcc57a 100644
--- a/runtime/vm/compiler/ffi/native_type.cc
+++ b/runtime/vm/compiler/ffi/native_type.cc
@@ -6,10 +6,13 @@
#include "platform/assert.h"
#include "platform/globals.h"
-#include "vm/compiler/backend/locations.h"
#include "vm/compiler/runtime_api.h"
#include "vm/object.h"
+#if !defined(DART_PRECOMPILED_RUNTIME)
+#include "vm/compiler/backend/locations.h"
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
+
namespace dart {
namespace compiler {
@@ -121,6 +124,7 @@
UNREACHABLE();
}
+#if !defined(DART_PRECOMPILED_RUNTIME)
bool NativeFundamentalType::IsExpressibleAsRepresentation() const {
switch (representation_) {
case kInt8:
@@ -163,6 +167,7 @@
UNREACHABLE();
}
}
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
bool NativeFundamentalType::Equals(const NativeType& other) const {
if (!other.IsFundamental()) {
@@ -242,6 +247,7 @@
return NativeType::FromTypedDataClassId(type.type_class_id(), zone);
}
+#if !defined(DART_PRECOMPILED_RUNTIME)
static FundamentalType fundamental_rep(Representation rep) {
switch (rep) {
case kUnboxedDouble:
@@ -264,6 +270,7 @@
Zone* zone) {
return *new (zone) NativeFundamentalType(fundamental_rep(rep));
}
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
const char* NativeType::ToCString() const {
char buffer[1024];
diff --git a/runtime/vm/compiler/ffi/native_type.h b/runtime/vm/compiler/ffi/native_type.h
index ddd6941..0eee4de 100644
--- a/runtime/vm/compiler/ffi/native_type.h
+++ b/runtime/vm/compiler/ffi/native_type.h
@@ -9,11 +9,16 @@
#include "platform/assert.h"
#include "vm/allocation.h"
-#include "vm/compiler/backend/locations.h"
#include "vm/compiler/runtime_api.h"
+#if !defined(DART_PRECOMPILED_RUNTIME)
+#include "vm/compiler/backend/locations.h"
+#endif
+
namespace dart {
+class BufferFormatter;
+
namespace compiler {
namespace ffi {
@@ -31,7 +36,7 @@
// * tagged
// * untagged
//
-// Instead, NativeTypes support representations not supprted in Dart's unboxed
+// Instead, NativeTypes support representations not supported in Dart's unboxed
// Representations, such as:
// * Fundamental types (https://en.cppreference.com/w/cpp/language/types):
// * int8_t
@@ -48,8 +53,11 @@
public:
static NativeType& FromAbstractType(const AbstractType& type, Zone* zone);
static NativeType& FromTypedDataClassId(classid_t class_id, Zone* zone);
+
+#if !defined(DART_PRECOMPILED_RUNTIME)
static NativeFundamentalType& FromUnboxedRepresentation(Representation rep,
Zone* zone);
+#endif
virtual bool IsFundamental() const { return false; }
const NativeFundamentalType& AsFundamental() const;
@@ -71,6 +79,7 @@
// The alignment in bytes of this representation as member of a composite.
virtual intptr_t AlignmentInBytesField() const = 0;
+#if !defined(DART_PRECOMPILED_RUNTIME)
// NativeTypes which are available as unboxed Representations.
virtual bool IsExpressibleAsRepresentation() const { return false; }
@@ -82,6 +91,7 @@
const auto& widened = WidenTo4Bytes(zone_);
return widened.AsRepresentation();
}
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
virtual bool Equals(const NativeType& other) const { UNREACHABLE(); }
@@ -135,8 +145,10 @@
virtual intptr_t AlignmentInBytesStack() const;
virtual intptr_t AlignmentInBytesField() const;
+#if !defined(DART_PRECOMPILED_RUNTIME)
virtual bool IsExpressibleAsRepresentation() const;
virtual Representation AsRepresentation() const;
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
virtual bool Equals(const NativeType& other) const;
virtual NativeFundamentalType& Split(intptr_t part, Zone* zone) const;
diff --git a/runtime/vm/compiler/jit/compiler.cc b/runtime/vm/compiler/jit/compiler.cc
index ea9e245..c8a3bf3 100644
--- a/runtime/vm/compiler/jit/compiler.cc
+++ b/runtime/vm/compiler/jit/compiler.cc
@@ -4,9 +4,9 @@
#include "vm/compiler/jit/compiler.h"
-#include "vm/compiler/assembler/assembler.h"
-
+#if !defined(DART_PRECOMPILED_RUNTIME)
#include "vm/code_patcher.h"
+#include "vm/compiler/assembler/assembler.h"
#include "vm/compiler/assembler/disassembler.h"
#include "vm/compiler/backend/block_scheduler.h"
#include "vm/compiler/backend/branch_optimizer.h"
@@ -45,6 +45,7 @@
#include "vm/thread_registry.h"
#include "vm/timeline.h"
#include "vm/timer.h"
+#endif
namespace dart {
diff --git a/runtime/vm/compiler/jit/compiler.h b/runtime/vm/compiler/jit/compiler.h
index a810124..b859021 100644
--- a/runtime/vm/compiler/jit/compiler.h
+++ b/runtime/vm/compiler/jit/compiler.h
@@ -6,7 +6,7 @@
#define RUNTIME_VM_COMPILER_JIT_COMPILER_H_
#include "vm/allocation.h"
-#include "vm/compiler/compiler_state.h"
+#include "vm/compiler/api/deopt_id.h"
#include "vm/growable_array.h"
#include "vm/runtime_entry.h"
#include "vm/thread_pool.h"
diff --git a/runtime/vm/compiler/runtime_api.cc b/runtime/vm/compiler/runtime_api.cc
index 7f92b3b..4f6221e 100644
--- a/runtime/vm/compiler/runtime_api.cc
+++ b/runtime/vm/compiler/runtime_api.cc
@@ -4,6 +4,20 @@
#include "vm/compiler/runtime_api.h"
+#include "vm/object.h"
+
+#if !defined(DART_PRECOMPILED_RUNTIME)
+#include "vm/compiler/runtime_offsets_list.h"
+#include "vm/dart_entry.h"
+#include "vm/longjump.h"
+#include "vm/native_arguments.h"
+#include "vm/native_entry.h"
+#include "vm/object_store.h"
+#include "vm/runtime_entry.h"
+#include "vm/symbols.h"
+#include "vm/timeline.h"
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
+
namespace dart {
namespace compiler {
namespace target {
@@ -14,23 +28,23 @@
return Utils::IsInt(kSmiBits + 1, v);
}
+bool WillAllocateNewOrRememberedContext(intptr_t num_context_variables) {
+ if (!dart::Context::IsValidLength(num_context_variables)) return false;
+ return dart::Heap::IsAllocatableInNewSpace(
+ dart::Context::InstanceSize(num_context_variables));
+}
+
+bool WillAllocateNewOrRememberedArray(intptr_t length) {
+ if (!dart::Array::IsValidLength(length)) return false;
+ return !dart::Array::UseCardMarkingForAllocation(length);
+}
+
} // namespace target
} // namespace compiler
} // namespace dart
#if !defined(DART_PRECOMPILED_RUNTIME)
-#include "vm/compiler/runtime_offsets_list.h"
-#include "vm/dart_entry.h"
-#include "vm/longjump.h"
-#include "vm/native_arguments.h"
-#include "vm/native_entry.h"
-#include "vm/object.h"
-#include "vm/object_store.h"
-#include "vm/runtime_entry.h"
-#include "vm/symbols.h"
-#include "vm/timeline.h"
-
namespace dart {
namespace compiler {
diff --git a/runtime/vm/compiler/runtime_api.h b/runtime/vm/compiler/runtime_api.h
index 5966425..1a0e8b8 100644
--- a/runtime/vm/compiler/runtime_api.h
+++ b/runtime/vm/compiler/runtime_api.h
@@ -362,6 +362,10 @@
word ToRawPointer(const dart::Object& a);
#endif // defined(TARGET_ARCH_IA32)
+bool WillAllocateNewOrRememberedContext(intptr_t num_context_variables);
+
+bool WillAllocateNewOrRememberedArray(intptr_t length);
+
//
// Target specific offsets and constants.
//
diff --git a/runtime/vm/compiler/stub_code_compiler.h b/runtime/vm/compiler/stub_code_compiler.h
index e4a9429..35f23fd 100644
--- a/runtime/vm/compiler/stub_code_compiler.h
+++ b/runtime/vm/compiler/stub_code_compiler.h
@@ -50,7 +50,6 @@
const Object& context_allocation_stub);
#endif
-#if !defined(DART_PRECOMPILED_RUNTIME)
static RawArray* BuildStaticCallsTable(
Zone* zone,
compiler::UnresolvedPcRelativeCalls* unresolved_calls);
@@ -121,31 +120,12 @@
static void GenerateJITCallbackTrampolines(Assembler* assembler,
intptr_t next_callback_id);
-
-#endif // !defined(DART_PRECOMPILED_RUNTIME)
};
} // namespace compiler
enum DeoptStubKind { kLazyDeoptFromReturn, kLazyDeoptFromThrow, kEagerDeopt };
-// Invocation mode for TypeCheck runtime entry that describes
-// where we are calling it from.
-enum TypeCheckMode {
- // TypeCheck is invoked from LazySpecializeTypeTest stub.
- // It should replace stub on the type with a specialized version.
- kTypeCheckFromLazySpecializeStub,
-
- // TypeCheck is invoked from the SlowTypeTest stub.
- // This means that cache can be lazily created (if needed)
- // and dst_name can be fetched from the pool.
- kTypeCheckFromSlowStub,
-
- // TypeCheck is invoked from normal inline AssertAssignable.
- // Both cache and dst_name must be already populated.
- kTypeCheckFromInline
-};
-
// Zap value used to indicate unused CODE_REG in deopt.
static const uword kZapCodeReg = 0xf1f1f1f1;
diff --git a/runtime/vm/compiler/stub_code_compiler_arm.cc b/runtime/vm/compiler/stub_code_compiler_arm.cc
index 1e817e7..8a6858b 100644
--- a/runtime/vm/compiler/stub_code_compiler_arm.cc
+++ b/runtime/vm/compiler/stub_code_compiler_arm.cc
@@ -16,6 +16,7 @@
#include "vm/class_id.h"
#include "vm/code_entry_kind.h"
+#include "vm/compiler/api/type_check_mode.h"
#include "vm/compiler/assembler/assembler.h"
#include "vm/compiler/backend/locations.h"
#include "vm/constants.h"
diff --git a/runtime/vm/compiler/stub_code_compiler_arm64.cc b/runtime/vm/compiler/stub_code_compiler_arm64.cc
index 0730c37..ced8835 100644
--- a/runtime/vm/compiler/stub_code_compiler_arm64.cc
+++ b/runtime/vm/compiler/stub_code_compiler_arm64.cc
@@ -15,6 +15,7 @@
#include "vm/class_id.h"
#include "vm/code_entry_kind.h"
+#include "vm/compiler/api/type_check_mode.h"
#include "vm/compiler/assembler/assembler.h"
#include "vm/compiler/backend/locations.h"
#include "vm/constants.h"
diff --git a/runtime/vm/compiler/stub_code_compiler_ia32.cc b/runtime/vm/compiler/stub_code_compiler_ia32.cc
index 53b0cc1..15a5c89 100644
--- a/runtime/vm/compiler/stub_code_compiler_ia32.cc
+++ b/runtime/vm/compiler/stub_code_compiler_ia32.cc
@@ -15,6 +15,7 @@
#include "vm/class_id.h"
#include "vm/code_entry_kind.h"
+#include "vm/compiler/api/type_check_mode.h"
#include "vm/compiler/assembler/assembler.h"
#include "vm/compiler/backend/locations.h"
#include "vm/constants.h"
diff --git a/runtime/vm/compiler/stub_code_compiler_x64.cc b/runtime/vm/compiler/stub_code_compiler_x64.cc
index d981a03..9a2b2c7 100644
--- a/runtime/vm/compiler/stub_code_compiler_x64.cc
+++ b/runtime/vm/compiler/stub_code_compiler_x64.cc
@@ -17,6 +17,7 @@
#include "vm/class_id.h"
#include "vm/code_entry_kind.h"
+#include "vm/compiler/api/type_check_mode.h"
#include "vm/compiler/assembler/assembler.h"
#include "vm/constants.h"
#include "vm/instructions.h"
diff --git a/runtime/vm/constants_arm.h b/runtime/vm/constants_arm.h
index 48e015e..b068e7f 100644
--- a/runtime/vm/constants_arm.h
+++ b/runtime/vm/constants_arm.h
@@ -947,6 +947,8 @@
float ReciprocalSqrtEstimate(float op);
float ReciprocalSqrtStep(float op1, float op2);
+constexpr uword kBreakInstructionFiller = 0xE1200070; // bkpt #0
+
} // namespace dart
#endif // RUNTIME_VM_CONSTANTS_ARM_H_
diff --git a/runtime/vm/constants_arm64.h b/runtime/vm/constants_arm64.h
index a7852d6..9929f0d 100644
--- a/runtime/vm/constants_arm64.h
+++ b/runtime/vm/constants_arm64.h
@@ -1326,6 +1326,8 @@
DISALLOW_IMPLICIT_CONSTRUCTORS(Instr);
};
+const uword kBreakInstructionFiller = 0xD4200000D4200000L; // brk #0; brk #0
+
} // namespace dart
#endif // RUNTIME_VM_CONSTANTS_ARM64_H_
diff --git a/runtime/vm/constants_ia32.h b/runtime/vm/constants_ia32.h
index 398fdcc..2f7d689 100644
--- a/runtime/vm/constants_ia32.h
+++ b/runtime/vm/constants_ia32.h
@@ -247,6 +247,8 @@
static constexpr ExtensionStrategy kArgumentStackExtension = kExtendedTo4;
};
+const uword kBreakInstructionFiller = 0xCCCCCCCC;
+
} // namespace dart
#endif // RUNTIME_VM_CONSTANTS_IA32_H_
diff --git a/runtime/vm/constants_x64.h b/runtime/vm/constants_x64.h
index fe2e01d..f4030c9 100644
--- a/runtime/vm/constants_x64.h
+++ b/runtime/vm/constants_x64.h
@@ -408,6 +408,8 @@
// becomes important to us.
const int MAX_NOP_SIZE = 8;
+const uword kBreakInstructionFiller = 0xCCCCCCCCCCCCCCCCL;
+
} // namespace dart
#endif // RUNTIME_VM_CONSTANTS_X64_H_
diff --git a/runtime/vm/cpu_x64.cc b/runtime/vm/cpu_x64.cc
index c892d85..7f5981c 100644
--- a/runtime/vm/cpu_x64.cc
+++ b/runtime/vm/cpu_x64.cc
@@ -8,7 +8,6 @@
#include "vm/cpu.h"
#include "vm/cpu_x64.h"
-#include "vm/compiler/assembler/assembler.h"
#include "vm/constants.h"
#include "vm/cpuinfo.h"
#include "vm/heap/heap.h"
diff --git a/runtime/vm/dart_api_impl.cc b/runtime/vm/dart_api_impl.cc
index 3ff092c..6ccd329 100644
--- a/runtime/vm/dart_api_impl.cc
+++ b/runtime/vm/dart_api_impl.cc
@@ -22,11 +22,7 @@
#include "vm/debugger.h"
#include "vm/dwarf.h"
#include "vm/elf.h"
-#if !defined(DART_PRECOMPILED_RUNTIME)
-#include "vm/kernel_loader.h"
-#endif
#include "platform/unicode.h"
-#include "vm/compiler/aot/precompiler.h"
#include "vm/exceptions.h"
#include "vm/flags.h"
#include "vm/growable_array.h"
@@ -59,6 +55,11 @@
#include "vm/uri.h"
#include "vm/version.h"
+#if !defined(DART_PRECOMPILED_RUNTIME)
+#include "vm/compiler/aot/precompiler.h"
+#include "vm/kernel_loader.h"
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
+
namespace dart {
// Facilitate quick access to the current zone once we have the current thread.
diff --git a/runtime/vm/dart_entry.cc b/runtime/vm/dart_entry.cc
index 42d53be..88a75f6 100644
--- a/runtime/vm/dart_entry.cc
+++ b/runtime/vm/dart_entry.cc
@@ -6,8 +6,6 @@
#include "platform/safe_stack.h"
#include "vm/class_finalizer.h"
-#include "vm/compiler/frontend/bytecode_reader.h"
-#include "vm/compiler/jit/compiler.h"
#include "vm/debugger.h"
#include "vm/dispatch_table.h"
#include "vm/heap/safepoint.h"
@@ -19,6 +17,11 @@
#include "vm/stub_code.h"
#include "vm/symbols.h"
+#if !defined(DART_PRECOMPILED_RUNTIME)
+#include "vm/compiler/frontend/bytecode_reader.h"
+#include "vm/compiler/jit/compiler.h"
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
+
namespace dart {
DECLARE_FLAG(bool, enable_interpreter);
diff --git a/runtime/vm/debugger.cc b/runtime/vm/debugger.cc
index d121a55..adb3591 100644
--- a/runtime/vm/debugger.cc
+++ b/runtime/vm/debugger.cc
@@ -8,13 +8,13 @@
#include "platform/address_sanitizer.h"
+#include "vm/code_descriptors.h"
#include "vm/code_patcher.h"
+#include "vm/compiler/api/deopt_id.h"
#include "vm/compiler/assembler/disassembler.h"
#include "vm/compiler/assembler/disassembler_kbc.h"
-#include "vm/compiler/frontend/bytecode_reader.h"
#include "vm/compiler/jit/compiler.h"
#include "vm/dart_entry.h"
-#include "vm/deopt_instructions.h"
#include "vm/flags.h"
#include "vm/globals.h"
#include "vm/interpreter.h"
@@ -41,6 +41,11 @@
#include "vm/token_position.h"
#include "vm/visitor.h"
+#if !defined(DART_PRECOMPILED_RUNTIME)
+#include "vm/compiler/frontend/bytecode_reader.h"
+#include "vm/deopt_instructions.h"
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
+
namespace dart {
DEFINE_FLAG(bool,
diff --git a/runtime/vm/debugger_x64.cc b/runtime/vm/debugger_x64.cc
index 883880f..3cd1810 100644
--- a/runtime/vm/debugger_x64.cc
+++ b/runtime/vm/debugger_x64.cc
@@ -8,7 +8,6 @@
#include "vm/debugger.h"
#include "vm/code_patcher.h"
-#include "vm/compiler/assembler/assembler.h"
#include "vm/cpu.h"
#include "vm/instructions.h"
#include "vm/stub_code.h"
diff --git a/runtime/vm/deopt_instructions.h b/runtime/vm/deopt_instructions.h
index 926ea1b..57fff85 100644
--- a/runtime/vm/deopt_instructions.h
+++ b/runtime/vm/deopt_instructions.h
@@ -4,10 +4,10 @@
#ifndef RUNTIME_VM_DEOPT_INSTRUCTIONS_H_
#define RUNTIME_VM_DEOPT_INSTRUCTIONS_H_
+#if !defined(DART_PRECOMPILED_RUNTIME)
#include "vm/allocation.h"
#include "vm/code_descriptors.h"
-#include "vm/compiler/assembler/assembler.h"
#include "vm/compiler/backend/flow_graph_compiler.h"
#include "vm/compiler/backend/locations.h"
#include "vm/deferred_objects.h"
@@ -19,6 +19,7 @@
namespace dart {
+class Location;
class Value;
class MaterializeObjectInstr;
class StackFrame;
@@ -615,4 +616,5 @@
} // namespace dart
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
#endif // RUNTIME_VM_DEOPT_INSTRUCTIONS_H_
diff --git a/runtime/vm/ffi_callback_trampolines.cc b/runtime/vm/ffi_callback_trampolines.cc
index 6475a3d..4bf926e 100644
--- a/runtime/vm/ffi_callback_trampolines.cc
+++ b/runtime/vm/ffi_callback_trampolines.cc
@@ -3,11 +3,14 @@
// BSD-style license that can be found in the LICENSE file.
#include "vm/ffi_callback_trampolines.h"
+
+#if !defined(DART_PRECOMPILED_RUNTIME)
#include "vm/code_comments.h"
#include "vm/code_observers.h"
#include "vm/compiler/assembler/assembler.h"
#include "vm/compiler/assembler/disassembler.h"
#include "vm/exceptions.h"
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
namespace dart {
diff --git a/runtime/vm/ffi_callback_trampolines.h b/runtime/vm/ffi_callback_trampolines.h
index 7328828..26143be 100644
--- a/runtime/vm/ffi_callback_trampolines.h
+++ b/runtime/vm/ffi_callback_trampolines.h
@@ -1,15 +1,17 @@
// Copyright (c) 2019, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+#ifndef RUNTIME_VM_FFI_CALLBACK_TRAMPOLINES_H_
+#define RUNTIME_VM_FFI_CALLBACK_TRAMPOLINES_H_
#include "platform/allocation.h"
#include "platform/growable_array.h"
-#include "vm/compiler/stub_code_compiler.h"
#include "vm/flag_list.h"
#include "vm/virtual_memory.h"
-#ifndef RUNTIME_VM_FFI_CALLBACK_TRAMPOLINES_H_
-#define RUNTIME_VM_FFI_CALLBACK_TRAMPOLINES_H_
+#if !defined(DART_PRECOMPILED_RUNTIME)
+#include "vm/compiler/stub_code_compiler.h"
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
namespace dart {
diff --git a/runtime/vm/heap/sweeper.cc b/runtime/vm/heap/sweeper.cc
index 2a19fba..96cf844 100644
--- a/runtime/vm/heap/sweeper.cc
+++ b/runtime/vm/heap/sweeper.cc
@@ -4,7 +4,6 @@
#include "vm/heap/sweeper.h"
-#include "vm/compiler/assembler/assembler.h"
#include "vm/globals.h"
#include "vm/heap/freelist.h"
#include "vm/heap/heap.h"
@@ -52,8 +51,7 @@
uword cursor = current;
uword end = current + obj_size;
while (cursor < end) {
- *reinterpret_cast<uword*>(cursor) =
- compiler::Assembler::GetBreakInstructionFiller();
+ *reinterpret_cast<uword*>(cursor) = kBreakInstructionFiller;
cursor += kWordSize;
}
} else {
diff --git a/runtime/vm/image_snapshot.cc b/runtime/vm/image_snapshot.cc
index e344120..01d5d36 100644
--- a/runtime/vm/image_snapshot.cc
+++ b/runtime/vm/image_snapshot.cc
@@ -6,7 +6,6 @@
#include "platform/assert.h"
#include "vm/class_id.h"
-#include "vm/compiler/backend/code_statistics.h"
#include "vm/compiler/runtime_api.h"
#include "vm/dwarf.h"
#include "vm/elf.h"
@@ -22,6 +21,10 @@
#include "vm/timeline.h"
#include "vm/type_testing_stubs.h"
+#if !defined(DART_PRECOMPILED_RUNTIME)
+#include "vm/compiler/backend/code_statistics.h"
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
+
namespace dart {
#if defined(DART_PRECOMPILER)
@@ -849,8 +852,7 @@
compiler::target::ObjectAlignment::kObjectAlignment) -
unaligned_size;
while (alignment_size > 0) {
- WriteWordLiteralText(
- compiler::Assembler::GetBreakInstructionFiller());
+ WriteWordLiteralText(kBreakInstructionFiller);
alignment_size -= sizeof(compiler::target::uword);
text_offset += sizeof(compiler::target::uword);
}
diff --git a/runtime/vm/interpreter.cc b/runtime/vm/interpreter.cc
index cb8c0e3..a09b6d9 100644
--- a/runtime/vm/interpreter.cc
+++ b/runtime/vm/interpreter.cc
@@ -10,6 +10,7 @@
#include "vm/interpreter.h"
+#include "vm/compiler/api/type_check_mode.h"
#include "vm/compiler/assembler/assembler.h"
#include "vm/compiler/assembler/disassembler_kbc.h"
#include "vm/compiler/backend/flow_graph_compiler.h"
diff --git a/runtime/vm/isolate.h b/runtime/vm/isolate.h
index 621dfd2..f6c8fef 100644
--- a/runtime/vm/isolate.h
+++ b/runtime/vm/isolate.h
@@ -20,7 +20,6 @@
#include "vm/class_table.h"
#include "vm/constants_kbc.h"
#include "vm/exceptions.h"
-#include "vm/ffi_callback_trampolines.h"
#include "vm/field_table.h"
#include "vm/fixed_cache.h"
#include "vm/growable_array.h"
@@ -37,6 +36,10 @@
#include "vm/token_position.h"
#include "vm/virtual_memory.h"
+#if !defined(DART_PRECOMPILED_RUNTIME)
+#include "vm/ffi_callback_trampolines.h"
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
+
namespace dart {
// Forward declarations.
diff --git a/runtime/vm/kernel.cc b/runtime/vm/kernel.cc
index 1c1c752..5e69eac 100644
--- a/runtime/vm/kernel.cc
+++ b/runtime/vm/kernel.cc
@@ -2,6 +2,8 @@
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+#if !defined(DART_PRECOMPILED_RUNTIME)
+
#include "vm/kernel.h"
#include "vm/bit_vector.h"
@@ -14,7 +16,6 @@
#include "vm/parser.h" // For Parser::kParameter* constants.
#include "vm/stack_frame.h"
-#if !defined(DART_PRECOMPILED_RUNTIME)
namespace dart {
namespace kernel {
diff --git a/runtime/vm/kernel_loader.cc b/runtime/vm/kernel_loader.cc
index b36b2a9..754d2e5 100644
--- a/runtime/vm/kernel_loader.cc
+++ b/runtime/vm/kernel_loader.cc
@@ -1,6 +1,7 @@
// Copyright (c) 2016, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+#if !defined(DART_PRECOMPILED_RUNTIME)
#include "vm/kernel_loader.h"
@@ -23,7 +24,6 @@
#include "vm/symbols.h"
#include "vm/thread.h"
-#if !defined(DART_PRECOMPILED_RUNTIME)
namespace dart {
namespace kernel {
diff --git a/runtime/vm/object.cc b/runtime/vm/object.cc
index 543c38b..9c0c307 100644
--- a/runtime/vm/object.cc
+++ b/runtime/vm/object.cc
@@ -13,17 +13,10 @@
#include "vm/bootstrap.h"
#include "vm/class_finalizer.h"
#include "vm/code_comments.h"
+#include "vm/code_descriptors.h"
#include "vm/code_observers.h"
-#include "vm/compiler/aot/precompiler.h"
-#include "vm/compiler/assembler/assembler.h"
#include "vm/compiler/assembler/disassembler.h"
#include "vm/compiler/assembler/disassembler_kbc.h"
-#include "vm/compiler/compiler_state.h"
-#include "vm/compiler/frontend/bytecode_fingerprints.h"
-#include "vm/compiler/frontend/bytecode_reader.h"
-#include "vm/compiler/frontend/kernel_fingerprints.h"
-#include "vm/compiler/frontend/kernel_translation_helper.h"
-#include "vm/compiler/intrinsifier.h"
#include "vm/compiler/jit/compiler.h"
#include "vm/cpu.h"
#include "vm/dart.h"
@@ -63,6 +56,18 @@
#include "vm/type_testing_stubs.h"
#include "vm/zone_text_buffer.h"
+#if !defined(DART_PRECOMPILED_RUNTIME)
+#include "vm/compiler/aot/precompiler.h"
+#include "vm/compiler/assembler/assembler.h"
+#include "vm/compiler/backend/code_statistics.h"
+#include "vm/compiler/compiler_state.h"
+#include "vm/compiler/frontend/bytecode_fingerprints.h"
+#include "vm/compiler/frontend/bytecode_reader.h"
+#include "vm/compiler/frontend/kernel_fingerprints.h"
+#include "vm/compiler/frontend/kernel_translation_helper.h"
+#include "vm/compiler/intrinsifier.h"
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
+
namespace dart {
DEFINE_FLAG(int,
@@ -2530,8 +2535,7 @@
uword cur = address + sizeof(RawObject);
uword end = address + size;
if (class_id == kInstructionsCid) {
- compiler::target::uword initial_value =
- compiler::Assembler::GetBreakInstructionFiller();
+ compiler::target::uword initial_value = kBreakInstructionFiller;
while (cur < end) {
*reinterpret_cast<compiler::target::uword*>(cur) = initial_value;
cur += compiler::target::kWordSize;
@@ -7469,6 +7473,7 @@
}
}
+#if !defined(DART_PRECOMPILED_RUNTIME)
bool Function::CanBeInlined() const {
// Our force-optimized functions cannot deoptimize to an unoptimized frame.
// If the instructions of the force-optimized function body get moved via
@@ -7479,14 +7484,17 @@
if (ForceOptimize()) {
return CompilerState::Current().is_aot();
}
-#if defined(PRODUCT)
- return is_inlinable() && !is_external() && !is_generated_body();
-#else
+
+#if !defined(PRODUCT)
Thread* thread = Thread::Current();
- return is_inlinable() && !is_external() && !is_generated_body() &&
- !thread->isolate()->debugger()->HasBreakpoint(*this, thread->zone());
-#endif
+ if (thread->isolate()->debugger()->HasBreakpoint(*this, thread->zone())) {
+ return false;
+ }
+#endif // !defined(PRODUCT)
+
+ return is_inlinable() && !is_external() && !is_generated_body();
}
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
intptr_t Function::NumParameters() const {
return num_fixed_parameters() + NumOptionalParameters();
diff --git a/runtime/vm/regexp.cc b/runtime/vm/regexp.cc
index 95567a9..08384be 100644
--- a/runtime/vm/regexp.cc
+++ b/runtime/vm/regexp.cc
@@ -14,12 +14,15 @@
#include "vm/dart_entry.h"
#include "vm/regexp_assembler.h"
#include "vm/regexp_assembler_bytecode.h"
-#include "vm/regexp_assembler_ir.h"
#include "vm/regexp_ast.h"
#include "vm/symbols.h"
#include "vm/thread.h"
#include "vm/unibrow-inl.h"
+#if !defined(DART_PRECOMPILED_RUNTIME)
+#include "vm/regexp_assembler_ir.h"
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
+
#define Z (zone())
namespace dart {
@@ -701,7 +704,7 @@
// Omit flushing the trace. We discard the entire stack frame anyway.
- if (!label()->IsBound()) {
+ if (!label()->is_bound()) {
// We are completely independent of the trace, since we ignore it,
// so this code can be used as the generic version.
assembler->BindBlock(label());
@@ -728,7 +731,7 @@
return;
}
RegExpMacroAssembler* assembler = compiler->macro_assembler();
- if (!label()->IsBound()) {
+ if (!label()->is_bound()) {
assembler->BindBlock(label());
}
switch (action_) {
@@ -1126,7 +1129,7 @@
EmitDoubleBoundaryTest(masm, ranges->At(cut_index),
ranges->At(cut_index + 1) - 1, &dummy, in_range_label,
&dummy);
- ASSERT(!dummy.IsLinked());
+ ASSERT(!dummy.is_linked());
// Cut out the single range by rewriting the array. This creates a new
// range that is a merger of the two ranges on either side of the one we
// are cutting out. The oddity of the labels is preserved.
@@ -1314,7 +1317,7 @@
GenerateBranches(masm, ranges, start_index, new_end_index, min_char,
border - 1, &dummy, even_label, odd_label);
- if (handle_rest.IsLinked()) {
+ if (handle_rest.is_linked()) {
masm->BindBlock(&handle_rest);
bool flip = (new_start_index & 1) != (start_index & 1);
GenerateBranches(masm, ranges, new_start_index, end_index, border, max_char,
@@ -1432,7 +1435,7 @@
RegExpMacroAssembler* macro_assembler = compiler->macro_assembler();
if (trace->is_trivial()) {
- if (label_.IsBound()) {
+ if (label_.is_bound()) {
// We are being asked to generate a generic version, but that's already
// been done so just go to it.
macro_assembler->GoTo(&label_);
@@ -3352,7 +3355,7 @@
AlternativeGeneration* alt_gen,
intptr_t preload_characters,
bool next_expects_preload) {
- if (!alt_gen->possible_success.IsLinked()) return;
+ if (!alt_gen->possible_success.is_linked()) return;
RegExpMacroAssembler* macro_assembler = compiler->macro_assembler();
macro_assembler->BindBlock(&alt_gen->possible_success);
@@ -3621,7 +3624,7 @@
printer.PrintBit("WI", info->follows_word_interest);
printer.PrintBit("SI", info->follows_start_interest);
BlockLabel* label = that->label();
- if (label->IsBound()) printer.PrintPositive("@", label->Position());
+ if (label->is_bound()) printer.PrintPositive("@", label->pos());
OS::PrintErr(
"}\"];\n"
" a%p -> n%p [style=dashed, color=grey, arrowhead=none];\n",
diff --git a/runtime/vm/regexp.h b/runtime/vm/regexp.h
index 170d412..7cefc38 100644
--- a/runtime/vm/regexp.h
+++ b/runtime/vm/regexp.h
@@ -7,9 +7,6 @@
#include "platform/unicode.h"
-#include "vm/compiler/assembler/assembler.h"
-#include "vm/compiler/backend/flow_graph_compiler.h"
-#include "vm/compiler/backend/il.h"
#include "vm/object.h"
#include "vm/regexp_assembler.h"
#include "vm/splay-tree.h"
diff --git a/runtime/vm/regexp_assembler.cc b/runtime/vm/regexp_assembler.cc
index ab242c4..8fa69ac 100644
--- a/runtime/vm/regexp_assembler.cc
+++ b/runtime/vm/regexp_assembler.cc
@@ -10,6 +10,7 @@
#include "vm/flags.h"
#include "vm/regexp.h"
+#include "vm/runtime_entry.h"
#include "vm/unibrow-inl.h"
namespace dart {
@@ -96,8 +97,7 @@
false /* is_float */,
reinterpret_cast<RuntimeFunction>(&CaseInsensitiveCompareUTF16));
-BlockLabel::BlockLabel()
- : block_(NULL), is_bound_(false), is_linked_(false), pos_(-1) {
+BlockLabel::BlockLabel() {
#if !defined(DART_PRECOMPILED_RUNTIME)
if (!FLAG_interpret_irregexp) {
// Only needed by the compiled IR backend.
diff --git a/runtime/vm/regexp_assembler.h b/runtime/vm/regexp_assembler.h
index 818f573..d7a460b 100644
--- a/runtime/vm/regexp_assembler.h
+++ b/runtime/vm/regexp_assembler.h
@@ -5,9 +5,12 @@
#ifndef RUNTIME_VM_REGEXP_ASSEMBLER_H_
#define RUNTIME_VM_REGEXP_ASSEMBLER_H_
+#include "vm/object.h"
+
+#if !defined(DART_PRECOMPILED_RUNTIME)
#include "vm/compiler/assembler/assembler.h"
#include "vm/compiler/backend/il.h"
-#include "vm/object.h"
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
namespace dart {
@@ -32,60 +35,59 @@
// Used by the IR assembler.
public:
BlockLabel();
-
- JoinEntryInstr* block() const { return block_; }
-
- bool IsBound() const { return is_bound_; }
- void SetBound(intptr_t block_id) {
- ASSERT(!is_bound_);
- block_->set_block_id(block_id);
- is_bound_ = true;
- }
-
- bool IsLinked() const { return !is_bound_ && is_linked_; }
- void SetLinked() { is_linked_ = true; }
-
- intptr_t Position() const {
- ASSERT(IsBound());
- return block_->block_id();
- }
-
- private:
- JoinEntryInstr* block_;
-
- bool is_bound_;
- bool is_linked_;
-
- // Used by the bytecode assembler.
- public:
~BlockLabel() { ASSERT(!is_linked()); }
intptr_t pos() const { return pos_; }
- bool is_bound() const { return IsBound(); }
- bool is_linked() const { return IsLinked(); }
+ bool is_bound() const { return is_bound_; }
+ bool is_linked() const { return !is_bound_ && is_linked_; }
+#if !defined(DART_PRECOMPILED_RUNTIME)
+ JoinEntryInstr* block() const { return block_; }
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
void Unuse() {
- pos_ = 0;
+ pos_ = -1;
is_bound_ = false;
is_linked_ = false;
}
- void bind_to(intptr_t pos) {
+ void BindTo(intptr_t pos) {
pos_ = pos;
+#if !defined(DART_PRECOMPILED_RUNTIME)
+ if (block_ != nullptr) block_->set_block_id(pos);
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
is_bound_ = true;
is_linked_ = false;
ASSERT(is_bound());
}
- void link_to(intptr_t pos) {
+ // Used by bytecode assembler to form a linked list out of
+ // forward jumps to an unbound label.
+ void LinkTo(intptr_t pos) {
+#if !defined(DART_PRECOMPILED_RUNTIME)
+ ASSERT(block_ == nullptr);
+#endif
+ ASSERT(!is_bound_);
pos_ = pos;
- is_bound_ = false;
is_linked_ = true;
- ASSERT(is_linked());
+ }
+
+ // Used by IR builder to mark block label as used.
+ void SetLinked() {
+#if !defined(DART_PRECOMPILED_RUNTIME)
+ ASSERT(block_ != nullptr);
+#endif
+ if (!is_bound_) {
+ is_linked_ = true;
+ }
}
private:
- intptr_t pos_;
+ bool is_bound_ = false;
+ bool is_linked_ = false;
+ intptr_t pos_ = -1;
+#if !defined(DART_PRECOMPILED_RUNTIME)
+ JoinEntryInstr* block_ = nullptr;
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
};
class RegExpMacroAssembler : public ZoneAllocated {
diff --git a/runtime/vm/regexp_assembler_bytecode.cc b/runtime/vm/regexp_assembler_bytecode.cc
index c075a86..4118969 100644
--- a/runtime/vm/regexp_assembler_bytecode.cc
+++ b/runtime/vm/regexp_assembler_bytecode.cc
@@ -44,7 +44,7 @@
*reinterpret_cast<uint32_t*>(buffer_->data() + fixup) = pc_;
}
}
- l->bind_to(pc_);
+ l->BindTo(pc_);
}
void BytecodeRegExpMacroAssembler::EmitOrLink(BlockLabel* l) {
@@ -56,7 +56,7 @@
if (l->is_linked()) {
pos = l->pos();
}
- l->link_to(pc_);
+ l->LinkTo(pc_);
Emit32(pos);
}
}
diff --git a/runtime/vm/regexp_assembler_ir.cc b/runtime/vm/regexp_assembler_ir.cc
index 500a52f..2c295ef 100644
--- a/runtime/vm/regexp_assembler_ir.cc
+++ b/runtime/vm/regexp_assembler_ir.cc
@@ -682,10 +682,10 @@
// If the BlockLabel does not yet contain a block, it is created.
// If there is a current instruction, append a goto to the bound block.
void IRRegExpMacroAssembler::BindBlock(BlockLabel* label) {
- ASSERT(!label->IsBound());
+ ASSERT(!label->is_bound());
ASSERT(label->block()->next() == NULL);
- label->SetBound(block_id_.Alloc());
+ label->BindTo(block_id_.Alloc());
blocks_.Add(label->block());
if (current_instruction_ != NULL) {
diff --git a/runtime/vm/runtime_entry.cc b/runtime/vm/runtime_entry.cc
index 6bb8000..f704db7 100644
--- a/runtime/vm/runtime_entry.cc
+++ b/runtime/vm/runtime_entry.cc
@@ -4,14 +4,14 @@
#include "vm/runtime_entry.h"
+#include "vm/code_descriptors.h"
#include "vm/code_patcher.h"
-#include "vm/compiler/assembler/assembler.h"
-#include "vm/compiler/frontend/bytecode_reader.h"
+#include "vm/compiler/api/deopt_id.h"
+#include "vm/compiler/api/type_check_mode.h"
#include "vm/compiler/jit/compiler.h"
#include "vm/dart_api_impl.h"
#include "vm/dart_entry.h"
#include "vm/debugger.h"
-#include "vm/deopt_instructions.h"
#include "vm/exceptions.h"
#include "vm/flags.h"
#include "vm/heap/verifier.h"
@@ -30,6 +30,10 @@
#include "vm/thread_registry.h"
#include "vm/type_testing_stubs.h"
+#if !defined(DART_PRECOMPILED_RUNTIME)
+#include "vm/deopt_instructions.h"
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
+
namespace dart {
DEFINE_FLAG(
@@ -342,14 +346,12 @@
const intptr_t length =
Array::LengthOf(reinterpret_cast<RawArray*>(object));
add_to_remembered_set =
- CreateArrayInstr::WillAllocateNewOrRemembered(length);
+ compiler::target::WillAllocateNewOrRememberedArray(length);
} else if (object->IsContext()) {
const intptr_t num_context_variables =
Context::NumVariables(reinterpret_cast<RawContext*>(object));
add_to_remembered_set =
- AllocateContextInstr::WillAllocateNewOrRemembered(
- num_context_variables) ||
- AllocateUninitializedContextInstr::WillAllocateNewOrRemembered(
+ compiler::target::WillAllocateNewOrRememberedContext(
num_context_variables);
}
diff --git a/runtime/vm/runtime_entry.h b/runtime/vm/runtime_entry.h
index c29e6e4..83d8a63 100644
--- a/runtime/vm/runtime_entry.h
+++ b/runtime/vm/runtime_entry.h
@@ -11,6 +11,7 @@
#endif
#include "vm/flags.h"
#include "vm/heap/safepoint.h"
+#include "vm/log.h"
#include "vm/native_arguments.h"
#include "vm/runtime_entry_list.h"
diff --git a/runtime/vm/runtime_entry_x64.cc b/runtime/vm/runtime_entry_x64.cc
index 0ff88f0..caaa2a4 100644
--- a/runtime/vm/runtime_entry_x64.cc
+++ b/runtime/vm/runtime_entry_x64.cc
@@ -7,8 +7,10 @@
#include "vm/runtime_entry.h"
+#if !defined(DART_PRECOMPILED_RUNTIME)
#include "vm/compiler/assembler/assembler.h"
#include "vm/stub_code.h"
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
namespace dart {
diff --git a/runtime/vm/scopes.cc b/runtime/vm/scopes.cc
index f722603..99273cb 100644
--- a/runtime/vm/scopes.cc
+++ b/runtime/vm/scopes.cc
@@ -1,14 +1,15 @@
// Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
// for details. All rights reserved. Use of this source code is governed by a
// BSD-style license that can be found in the LICENSE file.
+#if !defined(DART_PRECOMPILED_RUNTIME)
#include "vm/scopes.h"
+#include "vm/compiler/backend/slot.h"
#include "vm/object.h"
#include "vm/stack_frame.h"
#include "vm/symbols.h"
-#if !defined(DART_PRECOMPILED_RUNTIME)
namespace dart {
diff --git a/runtime/vm/scopes.h b/runtime/vm/scopes.h
index d855c43..a592cd6 100644
--- a/runtime/vm/scopes.h
+++ b/runtime/vm/scopes.h
@@ -10,7 +10,6 @@
#include "platform/assert.h"
#include "platform/globals.h"
#include "vm/allocation.h"
-#include "vm/compiler/backend/slot.h"
#include "vm/growable_array.h"
#include "vm/object.h"
#include "vm/raw_object.h"
@@ -21,6 +20,7 @@
class CompileType;
class LocalScope;
+class Slot;
// Indices of [LocalVariable]s are abstract and have little todo with the
// actual frame layout!
diff --git a/runtime/vm/stack_frame.cc b/runtime/vm/stack_frame.cc
index a795a0c..04309fe 100644
--- a/runtime/vm/stack_frame.cc
+++ b/runtime/vm/stack_frame.cc
@@ -5,9 +5,8 @@
#include "vm/stack_frame.h"
#include "platform/memory_sanitizer.h"
-#include "vm/compiler/assembler/assembler.h"
+#include "vm/code_descriptors.h"
#include "vm/compiler/runtime_api.h"
-#include "vm/deopt_instructions.h"
#include "vm/heap/become.h"
#include "vm/isolate.h"
#include "vm/object.h"
@@ -21,6 +20,10 @@
#include "vm/stub_code.h"
#include "vm/visitor.h"
+#if !defined(DART_PRECOMPILED_RUNTIME)
+#include "vm/deopt_instructions.h"
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
+
namespace dart {
DECLARE_FLAG(bool, enable_interpreter);
@@ -847,6 +850,7 @@
#endif // defined(DART_PRECOMPILED_RUNTIME)
}
+#if !defined(DART_PRECOMPILED_RUNTIME)
// Finds the potential offset for the current function's FP if the
// current frame were to be deoptimized.
intptr_t InlinedFunctionsIterator::GetDeoptFpOffset() const {
@@ -860,6 +864,7 @@
UNREACHABLE();
return 0;
}
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
#if defined(DEBUG)
void ValidateFrames() {
diff --git a/runtime/vm/stack_frame.h b/runtime/vm/stack_frame.h
index f430e99..70fe3ed 100644
--- a/runtime/vm/stack_frame.h
+++ b/runtime/vm/stack_frame.h
@@ -431,7 +431,9 @@
return code_.raw();
}
+#if !defined(DART_PRECOMPILED_RUNTIME)
intptr_t GetDeoptFpOffset() const;
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
private:
void SetDone() { index_ = -1; }
diff --git a/runtime/vm/stack_trace.cc b/runtime/vm/stack_trace.cc
index 7643a8c..c0d55b8 100644
--- a/runtime/vm/stack_trace.cc
+++ b/runtime/vm/stack_trace.cc
@@ -4,11 +4,14 @@
#include "vm/stack_trace.h"
-#include "vm/compiler/frontend/bytecode_reader.h"
#include "vm/dart_api_impl.h"
#include "vm/stack_frame.h"
#include "vm/symbols.h"
+#if !defined(DART_PRECOMPILED_RUNTIME)
+#include "vm/compiler/frontend/bytecode_reader.h"
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
+
namespace dart {
// Keep in sync with
diff --git a/runtime/vm/stub_code.cc b/runtime/vm/stub_code.cc
index 6ebb23a..21b71d5 100644
--- a/runtime/vm/stub_code.cc
+++ b/runtime/vm/stub_code.cc
@@ -7,8 +7,6 @@
#include "platform/assert.h"
#include "platform/globals.h"
#include "vm/clustered_snapshot.h"
-#include "vm/compiler/aot/precompiler.h"
-#include "vm/compiler/assembler/assembler.h"
#include "vm/compiler/assembler/disassembler.h"
#include "vm/flags.h"
#include "vm/heap/safepoint.h"
@@ -18,6 +16,11 @@
#include "vm/virtual_memory.h"
#include "vm/visitor.h"
+#if !defined(DART_PRECOMPILED_RUNTIME)
+#include "vm/compiler/aot/precompiler.h"
+#include "vm/compiler/assembler/assembler.h"
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
+
namespace dart {
DEFINE_FLAG(bool, disassemble_stubs, false, "Disassemble generated stubs.");
diff --git a/runtime/vm/stub_code.h b/runtime/vm/stub_code.h
index be2ad99..cffe96a 100644
--- a/runtime/vm/stub_code.h
+++ b/runtime/vm/stub_code.h
@@ -6,12 +6,15 @@
#define RUNTIME_VM_STUB_CODE_H_
#include "vm/allocation.h"
-#include "vm/compiler/assembler/assembler.h"
#include "vm/compiler/runtime_api.h"
-#include "vm/compiler/stub_code_compiler.h"
#include "vm/object.h"
#include "vm/stub_code_list.h"
+#if !defined(DART_PRECOMPILED_RUNTIME)
+#include "vm/compiler/assembler/assembler.h"
+#include "vm/compiler/stub_code_compiler.h"
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
+
namespace dart {
// Forward declarations.
@@ -66,12 +69,14 @@
compiler::ObjectPoolBuilder* pool);
#endif
+#if !defined(DART_PRECOMPILED_RUNTIME)
// Generate the stub and finalize the generated code into the stub
// code executable area.
static RawCode* Generate(
const char* name,
compiler::ObjectPoolBuilder* object_pool_builder,
void (*GenerateStub)(compiler::Assembler* assembler));
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
static const Code& UnoptimizedStaticCallEntry(intptr_t num_args_tested);
diff --git a/runtime/vm/thread.cc b/runtime/vm/thread.cc
index c69446c..420618d 100644
--- a/runtime/vm/thread.cc
+++ b/runtime/vm/thread.cc
@@ -5,7 +5,6 @@
#include "vm/thread.h"
#include "vm/dart_api_state.h"
-#include "vm/ffi_callback_trampolines.h"
#include "vm/growable_array.h"
#include "vm/heap/safepoint.h"
#include "vm/isolate.h"
@@ -25,6 +24,10 @@
#include "vm/timeline.h"
#include "vm/zone.h"
+#if !defined(DART_PRECOMPILED_RUNTIME)
+#include "vm/ffi_callback_trampolines.h"
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
+
namespace dart {
#if !defined(PRODUCT)
diff --git a/runtime/vm/type_testing_stubs.cc b/runtime/vm/type_testing_stubs.cc
index 3fcd8b7..b55430a 100644
--- a/runtime/vm/type_testing_stubs.cc
+++ b/runtime/vm/type_testing_stubs.cc
@@ -4,10 +4,14 @@
#include "vm/type_testing_stubs.h"
#include "vm/compiler/assembler/disassembler.h"
+#include "vm/object_store.h"
+#include "vm/stub_code.h"
+#include "vm/timeline.h"
+
+#if !defined(DART_PRECOMPILED_RUNTIME)
#include "vm/compiler/backend/flow_graph_compiler.h"
#include "vm/compiler/backend/il_printer.h"
-#include "vm/object_store.h"
-#include "vm/timeline.h"
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
#define __ assembler->
@@ -580,6 +584,7 @@
#else // !defined(TARGET_ARCH_IA32)
+#if !defined(DART_PRECOMPILED_RUNTIME)
void RegisterTypeArgumentsUse(const Function& function,
TypeUsageInfo* type_usage_info,
const Class& klass,
@@ -587,6 +592,7 @@
// We only have a [TypeUsageInfo] object available durin AOT compilation.
UNREACHABLE();
}
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
#endif // !defined(TARGET_ARCH_IA32)
diff --git a/runtime/vm/type_testing_stubs.h b/runtime/vm/type_testing_stubs.h
index fa9bb07..2b1279c 100644
--- a/runtime/vm/type_testing_stubs.h
+++ b/runtime/vm/type_testing_stubs.h
@@ -5,8 +5,12 @@
#ifndef RUNTIME_VM_TYPE_TESTING_STUBS_H_
#define RUNTIME_VM_TYPE_TESTING_STUBS_H_
+#include "vm/object.h"
+
+#if !defined(DART_PRECOMPILED_RUNTIME)
#include "vm/compiler/assembler/assembler.h"
#include "vm/compiler/backend/il.h"
+#endif // !defined(DART_PRECOMPILED_RUNTIME)
namespace dart {
@@ -369,10 +373,12 @@
Class& klass_;
};
+#if !defined(DART_PRECOMPILED_RUNTIME)
void RegisterTypeArgumentsUse(const Function& function,
TypeUsageInfo* type_usage_info,
const Class& klass,
Definition* type_arguments);
+#endif
#if !defined(PRODUCT) && !defined(DART_PRECOMPILED_RUNTIME)