From 58282f4510961317b8d5a364a6f740a78926716f Mon Sep 17 00:00:00 2001 From: David Brazdil Date: Thu, 14 Jan 2016 12:45:10 +0000 Subject: ART: Remove Baseline compiler We don't need Baseline any more and it hasn't been maintained for a while anyway. Let's remove it. Change-Id: I442ed26855527be2df3c79935403a25b1ee55df6 --- compiler/optimizing/optimizing_compiler.cc | 149 ++++++++--------------------- 1 file changed, 41 insertions(+), 108 deletions(-) (limited to 'compiler/optimizing/optimizing_compiler.cc') diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc index bb840eabdd..eeffe93b53 100644 --- a/compiler/optimizing/optimizing_compiler.cc +++ b/compiler/optimizing/optimizing_compiler.cc @@ -305,30 +305,19 @@ class OptimizingCompiler FINAL : public Compiler { SHARED_REQUIRES(Locks::mutator_lock_); private: - // Whether we should run any optimization or register allocation. If false, will - // just run the code generation after the graph was built. - const bool run_optimizations_; - // Create a 'CompiledMethod' for an optimized graph. - CompiledMethod* EmitOptimized(ArenaAllocator* arena, - CodeVectorAllocator* code_allocator, - CodeGenerator* codegen, - CompilerDriver* driver) const; - - // Create a 'CompiledMethod' for a non-optimized graph. - CompiledMethod* EmitBaseline(ArenaAllocator* arena, - CodeVectorAllocator* code_allocator, - CodeGenerator* codegen, - CompilerDriver* driver) const; + CompiledMethod* Emit(ArenaAllocator* arena, + CodeVectorAllocator* code_allocator, + CodeGenerator* codegen, + CompilerDriver* driver) const; // Try compiling a method and return the code generator used for // compiling it. // This method: // 1) Builds the graph. Returns null if it failed to build it. - // 2) If `run_optimizations_` is set: - // 2.1) Transform the graph to SSA. Returns null if it failed. - // 2.2) Run optimizations on the graph, including register allocator. - // 3) Generate code with the `code_allocator` provided. + // 2) Transforms the graph to SSA. Returns null if it failed. + // 3) Runs optimizations on the graph, including register allocator. + // 4) Generates code with the `code_allocator` provided. CodeGenerator* TryCompile(ArenaAllocator* arena, CodeVectorAllocator* code_allocator, const DexFile::CodeItem* code_item, @@ -350,9 +339,7 @@ class OptimizingCompiler FINAL : public Compiler { static const int kMaximumCompilationTimeBeforeWarning = 100; /* ms */ OptimizingCompiler::OptimizingCompiler(CompilerDriver* driver) - : Compiler(driver, kMaximumCompilationTimeBeforeWarning), - run_optimizations_( - driver->GetCompilerOptions().GetCompilerFilter() != CompilerOptions::kTime) {} + : Compiler(driver, kMaximumCompilationTimeBeforeWarning) {} void OptimizingCompiler::Init() { // Enable C1visualizer output. Must be done in Init() because the compiler @@ -577,17 +564,6 @@ static void RunOptimizations(HGraph* graph, AllocateRegisters(graph, codegen, pass_observer); } -// The stack map we generate must be 4-byte aligned on ARM. Since existing -// maps are generated alongside these stack maps, we must also align them. -static ArrayRef AlignVectorSize(ArenaVector& vector) { - size_t size = vector.size(); - size_t aligned_size = RoundUp(size, 4); - for (; size < aligned_size; ++size) { - vector.push_back(0); - } - return ArrayRef(vector); -} - static ArenaVector EmitAndSortLinkerPatches(CodeGenerator* codegen) { ArenaVector linker_patches(codegen->GetGraph()->GetArena()->Adapter()); codegen->EmitLinkerPatches(&linker_patches); @@ -601,10 +577,10 @@ static ArenaVector EmitAndSortLinkerPatches(CodeGenerator* codegen) return linker_patches; } -CompiledMethod* OptimizingCompiler::EmitOptimized(ArenaAllocator* arena, - CodeVectorAllocator* code_allocator, - CodeGenerator* codegen, - CompilerDriver* compiler_driver) const { +CompiledMethod* OptimizingCompiler::Emit(ArenaAllocator* arena, + CodeVectorAllocator* code_allocator, + CodeGenerator* codegen, + CompilerDriver* compiler_driver) const { ArenaVector linker_patches = EmitAndSortLinkerPatches(codegen); ArenaVector stack_map(arena->Adapter(kArenaAllocStackMaps)); stack_map.resize(codegen->ComputeStackMapsSize()); @@ -630,39 +606,6 @@ CompiledMethod* OptimizingCompiler::EmitOptimized(ArenaAllocator* arena, return compiled_method; } -CompiledMethod* OptimizingCompiler::EmitBaseline( - ArenaAllocator* arena, - CodeVectorAllocator* code_allocator, - CodeGenerator* codegen, - CompilerDriver* compiler_driver) const { - ArenaVector linker_patches = EmitAndSortLinkerPatches(codegen); - - ArenaVector mapping_table(arena->Adapter(kArenaAllocBaselineMaps)); - codegen->BuildMappingTable(&mapping_table); - ArenaVector vmap_table(arena->Adapter(kArenaAllocBaselineMaps)); - codegen->BuildVMapTable(&vmap_table); - ArenaVector gc_map(arena->Adapter(kArenaAllocBaselineMaps)); - codegen->BuildNativeGCMap(&gc_map, *compiler_driver); - - CompiledMethod* compiled_method = CompiledMethod::SwapAllocCompiledMethod( - compiler_driver, - codegen->GetInstructionSet(), - ArrayRef(code_allocator->GetMemory()), - // Follow Quick's behavior and set the frame size to zero if it is - // considered "empty" (see the definition of - // art::CodeGenerator::HasEmptyFrame). - codegen->HasEmptyFrame() ? 0 : codegen->GetFrameSize(), - codegen->GetCoreSpillMask(), - codegen->GetFpuSpillMask(), - ArrayRef(), - AlignVectorSize(mapping_table), - AlignVectorSize(vmap_table), - AlignVectorSize(gc_map), - ArrayRef(*codegen->GetAssembler()->cfi().data()), - ArrayRef(linker_patches)); - return compiled_method; -} - CodeGenerator* OptimizingCompiler::TryCompile(ArenaAllocator* arena, CodeVectorAllocator* code_allocator, const DexFile::CodeItem* code_item, @@ -775,41 +718,37 @@ CodeGenerator* OptimizingCompiler::TryCompile(ArenaAllocator* arena, VLOG(compiler) << "Optimizing " << pass_observer.GetMethodName(); - if (run_optimizations_) { - ScopedObjectAccess soa(Thread::Current()); - StackHandleScopeCollection handles(soa.Self()); - ScopedThreadSuspension sts(soa.Self(), kNative); - - { - PassScope scope(SsaBuilder::kSsaBuilderPassName, &pass_observer); - GraphAnalysisResult result = graph->TryBuildingSsa(&handles); - if (result != kAnalysisSuccess) { - switch (result) { - case kAnalysisFailThrowCatchLoop: - MaybeRecordStat(MethodCompilationStat::kNotCompiledThrowCatchLoop); - break; - case kAnalysisFailAmbiguousArrayOp: - MaybeRecordStat(MethodCompilationStat::kNotCompiledAmbiguousArrayOp); - break; - case kAnalysisSuccess: - UNREACHABLE(); - } - pass_observer.SetGraphInBadState(); - return nullptr; + ScopedObjectAccess soa(Thread::Current()); + StackHandleScopeCollection handles(soa.Self()); + ScopedThreadSuspension sts(soa.Self(), kNative); + + { + PassScope scope(SsaBuilder::kSsaBuilderPassName, &pass_observer); + GraphAnalysisResult result = graph->TryBuildingSsa(&handles); + if (result != kAnalysisSuccess) { + switch (result) { + case kAnalysisFailThrowCatchLoop: + MaybeRecordStat(MethodCompilationStat::kNotCompiledThrowCatchLoop); + break; + case kAnalysisFailAmbiguousArrayOp: + MaybeRecordStat(MethodCompilationStat::kNotCompiledAmbiguousArrayOp); + break; + case kAnalysisSuccess: + UNREACHABLE(); } + pass_observer.SetGraphInBadState(); + return nullptr; } - - RunOptimizations(graph, - codegen.get(), - compiler_driver, - compilation_stats_.get(), - dex_compilation_unit, - &pass_observer, - &handles); - codegen->CompileOptimized(code_allocator); - } else { - codegen->CompileBaseline(code_allocator); } + + RunOptimizations(graph, + codegen.get(), + compiler_driver, + compilation_stats_.get(), + dex_compilation_unit, + &pass_observer, + &handles); + codegen->Compile(code_allocator); pass_observer.DumpDisassembly(); if (kArenaAllocatorCountAllocations) { @@ -861,11 +800,7 @@ CompiledMethod* OptimizingCompiler::Compile(const DexFile::CodeItem* code_item, dex_cache)); if (codegen.get() != nullptr) { MaybeRecordStat(MethodCompilationStat::kCompiled); - if (run_optimizations_) { - method = EmitOptimized(&arena, &code_allocator, codegen.get(), compiler_driver); - } else { - method = EmitBaseline(&arena, &code_allocator, codegen.get(), compiler_driver); - } + method = Emit(&arena, &code_allocator, codegen.get(), compiler_driver); } } else { if (compiler_driver->GetCompilerOptions().VerifyAtRuntime()) { @@ -928,8 +863,6 @@ bool OptimizingCompiler::JitCompile(Thread* self, { // Go to native so that we don't block GC during compilation. ScopedThreadSuspension sts(self, kNative); - - DCHECK(run_optimizations_); codegen.reset( TryCompile(&arena, &code_allocator, -- cgit v1.2.3-59-g8ed1b