From 5806a9ec99b5494b511e84c74f494f0b3a8ebec5 Mon Sep 17 00:00:00 2001 From: Vladimir Marko Date: Wed, 4 Apr 2018 17:23:28 +0000 Subject: Revert "Compile link-time thunks in codegen." Reason for revert: This caused clang linker crash in several branches. Bug: 77581732 This reverts commit c9dd2207dfdab42586b1d6a5e7f11cf2fcea3a7a. Change-Id: I1923809083cf41c4f19e3e60df03ae80517aaedb --- compiler/optimizing/optimizing_compiler.cc | 26 ++++++++++---------------- 1 file changed, 10 insertions(+), 16 deletions(-) (limited to 'compiler/optimizing/optimizing_compiler.cc') diff --git a/compiler/optimizing/optimizing_compiler.cc b/compiler/optimizing/optimizing_compiler.cc index 79165826d1..e42dfc10ba 100644 --- a/compiler/optimizing/optimizing_compiler.cc +++ b/compiler/optimizing/optimizing_compiler.cc @@ -75,18 +75,22 @@ static constexpr const char* kPassNameSeparator = "$"; class CodeVectorAllocator FINAL : public CodeAllocator { public: explicit CodeVectorAllocator(ArenaAllocator* allocator) - : memory_(allocator->Adapter(kArenaAllocCodeBuffer)) {} + : memory_(allocator->Adapter(kArenaAllocCodeBuffer)), + size_(0) {} virtual uint8_t* Allocate(size_t size) { + size_ = size; memory_.resize(size); return &memory_[0]; } - ArrayRef GetMemory() const OVERRIDE { return ArrayRef(memory_); } + size_t GetSize() const { return size_; } + const ArenaVector& GetMemory() const { return memory_; } uint8_t* GetData() { return memory_.data(); } private: ArenaVector memory_; + size_t size_; DISALLOW_COPY_AND_ASSIGN(CodeVectorAllocator); }; @@ -715,7 +719,7 @@ CompiledMethod* OptimizingCompiler::Emit(ArenaAllocator* allocator, CompiledMethod* compiled_method = CompiledMethod::SwapAllocCompiledMethod( GetCompilerDriver(), codegen->GetInstructionSet(), - code_allocator->GetMemory(), + 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). @@ -727,16 +731,6 @@ CompiledMethod* OptimizingCompiler::Emit(ArenaAllocator* allocator, ArrayRef(*codegen->GetAssembler()->cfi().data()), ArrayRef(linker_patches)); - CompiledMethodStorage* storage = GetCompilerDriver()->GetCompiledMethodStorage(); - for (const linker::LinkerPatch& patch : linker_patches) { - if (codegen->NeedsThunkCode(patch) && storage->GetThunkCode(patch).empty()) { - ArenaVector code(allocator->Adapter()); - std::string debug_name; - codegen->EmitThunkCode(patch, &code, &debug_name); - storage->SetThunkCode(patch, ArrayRef(code), debug_name); - } - } - return compiled_method; } @@ -1345,7 +1339,7 @@ bool OptimizingCompiler::JitCompile(Thread* self, codegen->GetCoreSpillMask(), codegen->GetFpuSpillMask(), code_allocator.GetMemory().data(), - code_allocator.GetMemory().size(), + code_allocator.GetSize(), data_size, osr, roots, @@ -1375,7 +1369,7 @@ bool OptimizingCompiler::JitCompile(Thread* self, info.is_optimized = true; info.is_code_address_text_relative = false; info.code_address = code_address; - info.code_size = code_allocator.GetMemory().size(); + info.code_size = code_allocator.GetSize(); info.frame_size_in_bytes = method_header->GetFrameSizeInBytes(); info.code_info = stack_map_size == 0 ? nullptr : stack_map_data; info.cfi = ArrayRef(*codegen->GetAssembler()->cfi().data()); @@ -1384,7 +1378,7 @@ bool OptimizingCompiler::JitCompile(Thread* self, Runtime::Current()->GetJit()->AddMemoryUsage(method, allocator.BytesUsed()); if (jit_logger != nullptr) { - jit_logger->WriteLog(code, code_allocator.GetMemory().size(), method); + jit_logger->WriteLog(code, code_allocator.GetSize(), method); } if (kArenaAllocatorCountAllocations) { -- cgit v1.2.3-59-g8ed1b