From e21dc3db191df04c100620965bee4617b3b24397 Mon Sep 17 00:00:00 2001 From: Andreas Gampe Date: Mon, 8 Dec 2014 16:59:43 -0800 Subject: ART: Swap-space in the compiler Introduce a swap-space and corresponding allocator to transparently switch native allocations to memory backed by a file. Bug: 18596910 (cherry picked from commit 62746d8d9c4400e4764f162b22bfb1a32be287a9) Change-Id: I131448f3907115054a592af73db86d2b9257ea33 --- compiler/optimizing/optimizing_compiler.cc | 43 +++++++++++++++--------------- 1 file changed, 22 insertions(+), 21 deletions(-) (limited to 'compiler/optimizing/optimizing_compiler.cc') diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc index 94751f876c..87f2b90775 100644 --- a/compiler/optimizing/optimizing_compiler.cc +++ b/compiler/optimizing/optimizing_compiler.cc @@ -225,13 +225,13 @@ static void RunOptimizations(HGraph* graph, // 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 std::vector& AlignVectorSize(std::vector& vector) { +static ArrayRef AlignVectorSize(std::vector& vector) { size_t size = vector.size(); size_t aligned_size = RoundUp(size, 4); for (; size < aligned_size; ++size) { vector.push_back(0); } - return vector; + return ArrayRef(vector); } CompiledMethod* OptimizingCompiler::Compile(const DexFile::CodeItem* code_item, @@ -332,13 +332,14 @@ CompiledMethod* OptimizingCompiler::Compile(const DexFile::CodeItem* code_item, codegen->BuildStackMaps(&stack_map); compilation_stats_.RecordStat(MethodCompilationStat::kCompiledOptimized); - return new CompiledMethod(GetCompilerDriver(), - instruction_set, - allocator.GetMemory(), - codegen->GetFrameSize(), - codegen->GetCoreSpillMask(), - 0, /* FPR spill mask, unused */ - stack_map); + return CompiledMethod::SwapAllocCompiledMethodStackMap( + GetCompilerDriver(), + instruction_set, + ArrayRef(allocator.GetMemory()), + codegen->GetFrameSize(), + codegen->GetCoreSpillMask(), + 0, /* FPR spill mask, unused */ + ArrayRef(stack_map)); } else if (shouldOptimize && RegisterAllocator::Supports(instruction_set)) { LOG(FATAL) << "Could not allocate registers in optimizing compiler"; UNREACHABLE(); @@ -356,7 +357,7 @@ CompiledMethod* OptimizingCompiler::Compile(const DexFile::CodeItem* code_item, codegen->CompileBaseline(&allocator); std::vector mapping_table; - SrcMap src_mapping_table; + DefaultSrcMap src_mapping_table; codegen->BuildMappingTable(&mapping_table, GetCompilerDriver()->GetCompilerOptions().GetIncludeDebugSymbols() ? &src_mapping_table : nullptr); @@ -366,17 +367,17 @@ CompiledMethod* OptimizingCompiler::Compile(const DexFile::CodeItem* code_item, codegen->BuildNativeGCMap(&gc_map, dex_compilation_unit); compilation_stats_.RecordStat(MethodCompilationStat::kCompiledBaseline); - return new CompiledMethod(GetCompilerDriver(), - instruction_set, - allocator.GetMemory(), - codegen->GetFrameSize(), - codegen->GetCoreSpillMask(), - 0, /* FPR spill mask, unused */ - &src_mapping_table, - AlignVectorSize(mapping_table), - AlignVectorSize(vmap_table), - AlignVectorSize(gc_map), - nullptr); + return CompiledMethod::SwapAllocCompiledMethod(GetCompilerDriver(), + instruction_set, + ArrayRef(allocator.GetMemory()), + codegen->GetFrameSize(), + codegen->GetCoreSpillMask(), + 0, /* FPR spill mask, unused */ + &src_mapping_table, + AlignVectorSize(mapping_table), + AlignVectorSize(vmap_table), + AlignVectorSize(gc_map), + ArrayRef()); } } -- cgit v1.2.3-59-g8ed1b