OSDN Git Service

ART: Refactor CompileOptimized
authorAndreas Gampe <agampe@google.com>
Fri, 10 Apr 2015 17:49:32 +0000 (10:49 -0700)
committerAndreas Gampe <agampe@google.com>
Fri, 10 Apr 2015 18:06:16 +0000 (11:06 -0700)
Factor out register allocation. Both Clang and GCC inline the
function, but it changes how Clang stack-allocates enough so
that the resulting frame size is below our limit.

Bug: 20139216
Change-Id: I2cf393aed70f2ce0556252b61ae639aacab6f3a7

compiler/optimizing/optimizing_compiler.cc

index 0e02212..f642dfc 100644 (file)
@@ -371,9 +371,20 @@ static ArrayRef<const uint8_t> AlignVectorSize(std::vector<uint8_t>& vector) {
   return ArrayRef<const uint8_t>(vector);
 }
 
-// TODO: The function below uses too much stack space.
-#pragma GCC diagnostic push
-#pragma GCC diagnostic ignored "-Wframe-larger-than="
+static void AllocateRegisters(HGraph* graph,
+                              CodeGenerator* codegen,
+                              PassInfoPrinter* pass_info_printer) {
+  PrepareForRegisterAllocation(graph).Run();
+  SsaLivenessAnalysis liveness(*graph, codegen);
+  {
+    PassInfo pass_info(SsaLivenessAnalysis::kLivenessPassName, pass_info_printer);
+    liveness.Analyze();
+  }
+  {
+    PassInfo pass_info(RegisterAllocator::kRegisterAllocatorPassName, pass_info_printer);
+    RegisterAllocator(graph->GetArena(), codegen, liveness).AllocateRegisters();
+  }
+}
 
 CompiledMethod* OptimizingCompiler::CompileOptimized(HGraph* graph,
                                                      CodeGenerator* codegen,
@@ -385,16 +396,7 @@ CompiledMethod* OptimizingCompiler::CompileOptimized(HGraph* graph,
   RunOptimizations(graph, compiler_driver, &compilation_stats_,
                    dex_file, dex_compilation_unit, pass_info_printer, &handles);
 
-  PrepareForRegisterAllocation(graph).Run();
-  SsaLivenessAnalysis liveness(*graph, codegen);
-  {
-    PassInfo pass_info(SsaLivenessAnalysis::kLivenessPassName, pass_info_printer);
-    liveness.Analyze();
-  }
-  {
-    PassInfo pass_info(RegisterAllocator::kRegisterAllocatorPassName, pass_info_printer);
-    RegisterAllocator(graph->GetArena(), codegen, liveness).AllocateRegisters();
-  }
+  AllocateRegisters(graph, codegen, pass_info_printer);
 
   CodeVectorAllocator allocator;
   codegen->CompileOptimized(&allocator);
@@ -427,8 +429,6 @@ CompiledMethod* OptimizingCompiler::CompileOptimized(HGraph* graph,
       ArrayRef<const LinkerPatch>());
 }
 
-#pragma GCC diagnostic pop
-
 CompiledMethod* OptimizingCompiler::CompileBaseline(
     CodeGenerator* codegen,
     CompilerDriver* compiler_driver,