From 92cf83e001357329cbf41fa15a6e053fab6f4933 Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Tue, 18 Mar 2014 17:59:20 +0000 Subject: Run Java tests with the optimizing compiler. Also fix a vector.reserve -> vector.resize braino, and build a GC map that dex2oat expects. Change-Id: I6acf2f90a4c32f90b79bf7709bf2e43931b98757 --- compiler/optimizing/code_generator.cc | 14 ++++++++++++++ compiler/optimizing/code_generator.h | 5 ++++- compiler/optimizing/optimizing_compiler.cc | 13 +++++++++---- 3 files changed, 27 insertions(+), 5 deletions(-) (limited to 'compiler/optimizing') diff --git a/compiler/optimizing/code_generator.cc b/compiler/optimizing/code_generator.cc index b2a69d8ad5..bb6ac84a9f 100644 --- a/compiler/optimizing/code_generator.cc +++ b/compiler/optimizing/code_generator.cc @@ -18,7 +18,11 @@ #include "code_generator_arm.h" #include "code_generator_x86.h" +#include "dex/verified_method.h" +#include "driver/dex_compilation_unit.h" +#include "gc_map_builder.h" #include "utils/assembler.h" +#include "verifier/dex_gc_map.h" namespace art { @@ -110,4 +114,14 @@ CodeGenerator* CodeGenerator::Create(ArenaAllocator* allocator, } } +void CodeGenerator::BuildNativeGCMap( + std::vector* data, const DexCompilationUnit& dex_compilation_unit) const { + const std::vector& gc_map_raw = + dex_compilation_unit.GetVerifiedMethod()->GetDexGcMap(); + verifier::DexPcToReferenceMap dex_gc_map(&(gc_map_raw)[0]); + + GcMapBuilder builder(data, 0, 0, dex_gc_map.RegWidth()); +} + + } // namespace art diff --git a/compiler/optimizing/code_generator.h b/compiler/optimizing/code_generator.h index e95bb210b6..63f8cbf429 100644 --- a/compiler/optimizing/code_generator.h +++ b/compiler/optimizing/code_generator.h @@ -25,6 +25,8 @@ namespace art { +class DexCompilationUnit; + class CodeAllocator { public: CodeAllocator() { } @@ -135,7 +137,8 @@ class CodeGenerator : public ArenaObject { void BuildMappingTable(std::vector* vector) const { } void BuildVMapTable(std::vector* vector) const { } - void BuildNativeGCMap(std::vector* vector) const { } + void BuildNativeGCMap( + std::vector* vector, const DexCompilationUnit& dex_compilation_unit) const; protected: explicit CodeGenerator(HGraph* graph) diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc index cc36bbeb0a..334b185b44 100644 --- a/compiler/optimizing/optimizing_compiler.cc +++ b/compiler/optimizing/optimizing_compiler.cc @@ -20,6 +20,7 @@ #include "code_generator.h" #include "compilers.h" #include "driver/compiler_driver.h" +#include "driver/dex_compilation_unit.h" #include "nodes.h" #include "utils/arena_allocator.h" @@ -34,12 +35,12 @@ class CodeVectorAllocator FINAL : public CodeAllocator { virtual uint8_t* Allocate(size_t size) { size_ = size; - memory_.reserve(size); + memory_.resize(size); return &memory_[0]; } size_t GetSize() const { return size_; } - std::vector* GetMemory() { return &memory_; } + const std::vector& GetMemory() const { return memory_; } private: std::vector memory_; @@ -57,6 +58,10 @@ CompiledMethod* OptimizingCompiler::TryCompile(CompilerDriver& driver, uint32_t method_idx, jobject class_loader, const DexFile& dex_file) const { + DexCompilationUnit dex_compilation_unit( + nullptr, class_loader, art::Runtime::Current()->GetClassLinker(), dex_file, code_item, + class_def_idx, method_idx, access_flags, driver.GetVerifiedMethod(&dex_file, method_idx)); + ArenaPool pool; ArenaAllocator arena(&pool); HGraphBuilder builder(&arena); @@ -79,11 +84,11 @@ CompiledMethod* OptimizingCompiler::TryCompile(CompilerDriver& driver, std::vector vmap_table; codegen->BuildVMapTable(&vmap_table); std::vector gc_map; - codegen->BuildNativeGCMap(&gc_map); + codegen->BuildNativeGCMap(&gc_map, dex_compilation_unit); return new CompiledMethod(driver, instruction_set, - *allocator.GetMemory(), + allocator.GetMemory(), codegen->GetFrameSize(), 0, /* GPR spill mask, unused */ 0, /* FPR spill mask, unused */ -- cgit v1.2.3-59-g8ed1b