Runtime support for the new stack maps for the opt compiler.

Now most of the methods supported by the compiler can be optimized,
instead of using the baseline.

Change-Id: I80ab36a34913fa4e7dd576c7bf55af63594dc1fa
diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc
index 3461276..75f4155 100644
--- a/compiler/optimizing/optimizing_compiler.cc
+++ b/compiler/optimizing/optimizing_compiler.cc
@@ -240,8 +240,27 @@
 
     visualizer.DumpGraph(kRegisterAllocatorPassName);
     codegen->CompileOptimized(&allocator);
+
+    std::vector<uint8_t> mapping_table;
+    SrcMap src_mapping_table;
+    codegen->BuildMappingTable(&mapping_table,
+            GetCompilerDriver()->GetCompilerOptions().GetIncludeDebugSymbols() ?
+                 &src_mapping_table : nullptr);
+
+    std::vector<uint8_t> stack_map;
+    codegen->BuildStackMaps(&stack_map);
+
+    return new CompiledMethod(GetCompilerDriver(),
+                              instruction_set,
+                              allocator.GetMemory(),
+                              codegen->GetFrameSize(),
+                              codegen->GetCoreSpillMask(),
+                              0, /* FPR spill mask, unused */
+                              mapping_table,
+                              stack_map);
   } else if (shouldOptimize && RegisterAllocator::Supports(instruction_set)) {
     LOG(FATAL) << "Could not allocate registers in optimizing compiler";
+    return nullptr;
   } else {
     codegen->CompileBaseline(&allocator);
 
@@ -253,29 +272,29 @@
     SsaLivenessAnalysis liveness(*graph, codegen);
     liveness.Analyze();
     visualizer.DumpGraph(kLivenessPassName);
+
+    std::vector<uint8_t> mapping_table;
+    SrcMap src_mapping_table;
+    codegen->BuildMappingTable(&mapping_table,
+            GetCompilerDriver()->GetCompilerOptions().GetIncludeDebugSymbols() ?
+                 &src_mapping_table : nullptr);
+    std::vector<uint8_t> vmap_table;
+    codegen->BuildVMapTable(&vmap_table);
+    std::vector<uint8_t> gc_map;
+    codegen->BuildNativeGCMap(&gc_map, dex_compilation_unit);
+
+    return new CompiledMethod(GetCompilerDriver(),
+                              instruction_set,
+                              allocator.GetMemory(),
+                              codegen->GetFrameSize(),
+                              codegen->GetCoreSpillMask(),
+                              0, /* FPR spill mask, unused */
+                              &src_mapping_table,
+                              mapping_table,
+                              vmap_table,
+                              gc_map,
+                              nullptr);
   }
-
-  std::vector<uint8_t> mapping_table;
-  SrcMap src_mapping_table;
-  codegen->BuildMappingTable(&mapping_table,
-          GetCompilerDriver()->GetCompilerOptions().GetIncludeDebugSymbols() ?
-               &src_mapping_table : nullptr);
-  std::vector<uint8_t> vmap_table;
-  codegen->BuildVMapTable(&vmap_table);
-  std::vector<uint8_t> gc_map;
-  codegen->BuildNativeGCMap(&gc_map, dex_compilation_unit);
-
-  return new CompiledMethod(GetCompilerDriver(),
-                            instruction_set,
-                            allocator.GetMemory(),
-                            codegen->GetFrameSize(),
-                            codegen->GetCoreSpillMask(),
-                            0, /* FPR spill mask, unused */
-                            &src_mapping_table,
-                            mapping_table,
-                            vmap_table,
-                            gc_map,
-                            nullptr);
 }
 
 CompiledMethod* OptimizingCompiler::Compile(const DexFile::CodeItem* code_item,