Introduce an enum for the compilation kind.
Test: test.py
Change-Id: I5329e50a6b4521933b6b171c8c0fbc618c3f67cd
diff --git a/compiler/compiler.h b/compiler/compiler.h
index e363e70..afa0dba 100644
--- a/compiler/compiler.h
+++ b/compiler/compiler.h
@@ -19,6 +19,7 @@
#include "base/mutex.h"
#include "base/os.h"
+#include "compilation_kind.h"
#include "dex/invoke_type.h"
namespace art {
@@ -75,8 +76,7 @@
jit::JitCodeCache* code_cache ATTRIBUTE_UNUSED,
jit::JitMemoryRegion* region ATTRIBUTE_UNUSED,
ArtMethod* method ATTRIBUTE_UNUSED,
- bool baseline ATTRIBUTE_UNUSED,
- bool osr ATTRIBUTE_UNUSED,
+ CompilationKind compilation_kind ATTRIBUTE_UNUSED,
jit::JitLogger* jit_logger ATTRIBUTE_UNUSED)
REQUIRES_SHARED(Locks::mutator_lock_) {
return false;
diff --git a/compiler/jit/jit_compiler.cc b/compiler/jit/jit_compiler.cc
index 632a4fb..2ad3942 100644
--- a/compiler/jit/jit_compiler.cc
+++ b/compiler/jit/jit_compiler.cc
@@ -165,10 +165,10 @@
}
bool JitCompiler::CompileMethod(
- Thread* self, JitMemoryRegion* region, ArtMethod* method, bool baseline, bool osr) {
+ Thread* self, JitMemoryRegion* region, ArtMethod* method, CompilationKind compilation_kind) {
SCOPED_TRACE << "JIT compiling "
<< method->PrettyMethod()
- << " (baseline=" << baseline << ", osr=" << osr << ")";
+ << " (kind=" << compilation_kind << ")";
DCHECK(!method->IsProxyMethod());
DCHECK(method->GetDeclaringClass()->IsResolved());
@@ -185,7 +185,7 @@
JitCodeCache* const code_cache = runtime->GetJit()->GetCodeCache();
uint64_t start_ns = NanoTime();
success = compiler_->JitCompile(
- self, code_cache, region, method, baseline, osr, jit_logger_.get());
+ self, code_cache, region, method, compilation_kind, jit_logger_.get());
uint64_t duration_ns = NanoTime() - start_ns;
VLOG(jit) << "Compilation of "
<< method->PrettyMethod()
diff --git a/compiler/jit/jit_compiler.h b/compiler/jit/jit_compiler.h
index 09de1f8..9dd84f0 100644
--- a/compiler/jit/jit_compiler.h
+++ b/compiler/jit/jit_compiler.h
@@ -18,6 +18,7 @@
#define ART_COMPILER_JIT_JIT_COMPILER_H_
#include "base/mutex.h"
+#include "compilation_kind.h"
#include "jit/jit.h"
@@ -40,7 +41,7 @@
// Compilation entrypoint. Returns whether the compilation succeeded.
bool CompileMethod(
- Thread* self, JitMemoryRegion* region, ArtMethod* method, bool baseline, bool osr)
+ Thread* self, JitMemoryRegion* region, ArtMethod* method, CompilationKind kind)
REQUIRES_SHARED(Locks::mutator_lock_) override;
const CompilerOptions& GetCompilerOptions() const {
diff --git a/compiler/optimizing/inliner.cc b/compiler/optimizing/inliner.cc
index ef5669a..d3a4407 100644
--- a/compiler/optimizing/inliner.cc
+++ b/compiler/optimizing/inliner.cc
@@ -2045,8 +2045,7 @@
invoke_type,
callee_dead_reference_safe,
graph_->IsDebuggable(),
- /* osr= */ false,
- /* baseline= */ graph_->IsCompilingBaseline(),
+ graph_->GetCompilationKind(),
/* start_instruction_id= */ caller_instruction_counter);
callee_graph->SetArtMethod(resolved_method);
diff --git a/compiler/optimizing/nodes.h b/compiler/optimizing/nodes.h
index a7ea371..e562b87 100644
--- a/compiler/optimizing/nodes.h
+++ b/compiler/optimizing/nodes.h
@@ -33,6 +33,7 @@
#include "base/transform_array_ref.h"
#include "art_method.h"
#include "class_root.h"
+#include "compilation_kind.h"
#include "data_type.h"
#include "deoptimization_kind.h"
#include "dex/dex_file.h"
@@ -378,8 +379,7 @@
InvokeType invoke_type = kInvalidInvokeType,
bool dead_reference_safe = false,
bool debuggable = false,
- bool osr = false,
- bool baseline = false,
+ CompilationKind compilation_kind = CompilationKind::kOptimized,
int start_instruction_id = 0)
: allocator_(allocator),
arena_stack_(arena_stack),
@@ -415,8 +415,7 @@
cached_double_constants_(std::less<int64_t>(), allocator->Adapter(kArenaAllocConstantsMap)),
cached_current_method_(nullptr),
art_method_(nullptr),
- osr_(osr),
- baseline_(baseline),
+ compilation_kind_(compilation_kind),
cha_single_implementation_list_(allocator->Adapter(kArenaAllocCHA)) {
blocks_.reserve(kDefaultNumberOfBlocks);
}
@@ -645,9 +644,11 @@
return instruction_set_;
}
- bool IsCompilingOsr() const { return osr_; }
+ bool IsCompilingOsr() const { return compilation_kind_ == CompilationKind::kOsr; }
- bool IsCompilingBaseline() const { return baseline_; }
+ bool IsCompilingBaseline() const { return compilation_kind_ == CompilationKind::kBaseline; }
+
+ CompilationKind GetCompilationKind() const { return compilation_kind_; }
ArenaSet<ArtMethod*>& GetCHASingleImplementationList() {
return cha_single_implementation_list_;
@@ -837,14 +838,11 @@
// (such as when the superclass could not be found).
ArtMethod* art_method_;
- // Whether we are compiling this graph for on stack replacement: this will
- // make all loops seen as irreducible and emit special stack maps to mark
- // compiled code entries which the interpreter can directly jump to.
- const bool osr_;
-
- // Whether we are compiling baseline (not running optimizations). This affects
- // the code being generated.
- const bool baseline_;
+ // How we are compiling the graph: either optimized, osr, or baseline.
+ // For osr, we will make all loops seen as irreducible and emit special
+ // stack maps to mark compiled code entries which the interpreter can
+ // directly jump to.
+ const CompilationKind compilation_kind_;
// List of methods that are assumed to have single implementation.
ArenaSet<ArtMethod*> cha_single_implementation_list_;
diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc
index 8d4aa9f..bae402e 100644
--- a/compiler/optimizing/optimizing_compiler.cc
+++ b/compiler/optimizing/optimizing_compiler.cc
@@ -298,8 +298,7 @@
jit::JitCodeCache* code_cache,
jit::JitMemoryRegion* region,
ArtMethod* method,
- bool baseline,
- bool osr,
+ CompilationKind compilation_kind,
jit::JitLogger* jit_logger)
override
REQUIRES_SHARED(Locks::mutator_lock_);
@@ -379,8 +378,7 @@
CodeVectorAllocator* code_allocator,
const DexCompilationUnit& dex_compilation_unit,
ArtMethod* method,
- bool baseline,
- bool osr,
+ CompilationKind compilation_kind,
VariableSizedHandleScope* handles) const;
CodeGenerator* TryCompileIntrinsic(ArenaAllocator* allocator,
@@ -717,8 +715,7 @@
CodeVectorAllocator* code_allocator,
const DexCompilationUnit& dex_compilation_unit,
ArtMethod* method,
- bool baseline,
- bool osr,
+ CompilationKind compilation_kind,
VariableSizedHandleScope* handles) const {
MaybeRecordStat(compilation_stats_.get(), MethodCompilationStat::kAttemptBytecodeCompilation);
const CompilerOptions& compiler_options = GetCompilerOptions();
@@ -787,8 +784,7 @@
kInvalidInvokeType,
dead_reference_safe,
compiler_options.GetDebuggable(),
- /* osr= */ osr,
- /* baseline= */ baseline);
+ compilation_kind);
if (method != nullptr) {
graph->SetArtMethod(method);
@@ -861,7 +857,7 @@
}
}
- if (baseline) {
+ if (compilation_kind == CompilationKind::kBaseline) {
RunBaselineOptimizations(graph, codegen.get(), dex_compilation_unit, &pass_observer);
} else {
RunOptimizations(graph, codegen.get(), dex_compilation_unit, &pass_observer);
@@ -914,7 +910,7 @@
kInvalidInvokeType,
/* dead_reference_safe= */ true, // Intrinsics don't affect dead reference safety.
compiler_options.GetDebuggable(),
- /* osr= */ false);
+ CompilationKind::kOptimized);
DCHECK(Runtime::Current()->IsAotCompiler());
DCHECK(method != nullptr);
@@ -1047,8 +1043,9 @@
&code_allocator,
dex_compilation_unit,
method,
- compiler_options.IsBaseline(),
- /* osr= */ false,
+ compiler_options.IsBaseline()
+ ? CompilationKind::kBaseline
+ : CompilationKind::kOptimized,
&handles));
}
}
@@ -1194,10 +1191,14 @@
jit::JitCodeCache* code_cache,
jit::JitMemoryRegion* region,
ArtMethod* method,
- bool baseline,
- bool osr,
+ CompilationKind compilation_kind,
jit::JitLogger* jit_logger) {
const CompilerOptions& compiler_options = GetCompilerOptions();
+ // If the baseline flag was explicitly passed, change the compilation kind
+ // from optimized to baseline.
+ if (compiler_options.IsBaseline() && compilation_kind == CompilationKind::kOptimized) {
+ compilation_kind = CompilationKind::kBaseline;
+ }
DCHECK(compiler_options.IsJitCompiler());
DCHECK_EQ(compiler_options.IsJitCompilerForSharedCode(), code_cache->IsSharedRegion(*region));
StackHandleScope<3> hs(self);
@@ -1275,7 +1276,7 @@
ArrayRef<const uint8_t>(stack_map),
debug_info,
/* is_full_debug_info= */ compiler_options.GetGenerateDebugInfo(),
- osr,
+ compilation_kind,
/* has_should_deoptimize_flag= */ false,
cha_single_implementation_list)) {
code_cache->Free(self, region, reserved_code.data(), reserved_data.data());
@@ -1316,8 +1317,7 @@
&code_allocator,
dex_compilation_unit,
method,
- baseline || compiler_options.IsBaseline(),
- osr,
+ compilation_kind,
&handles));
if (codegen.get() == nullptr) {
return false;
@@ -1384,7 +1384,7 @@
ArrayRef<const uint8_t>(stack_map),
debug_info,
/* is_full_debug_info= */ compiler_options.GetGenerateDebugInfo(),
- osr,
+ compilation_kind,
codegen->GetGraph()->HasShouldDeoptimizeFlag(),
codegen->GetGraph()->GetCHASingleImplementationList())) {
code_cache->Free(self, region, reserved_code.data(), reserved_data.data());