From 70bba9c9f5fbba03c62a4542411e1d938375f14e Mon Sep 17 00:00:00 2001 From: Nicolas Geoffray Date: Fri, 16 Jun 2023 12:18:27 +0100 Subject: Remove CodeAllocator and the extra copy of generated code. The code used to copy the final generated code twice: from assembler to CodeAllocator, and then to CodeAllocator to SwapAllocator/JitMemory. The assemblers never depended on the exact location of the generated code, so just drop that feature. Test: test.py Change-Id: I8dc82e4926097092b9aac336a5a5d40f79dc62ca --- compiler/optimizing/codegen_test_utils.h | 32 ++++---------------------------- 1 file changed, 4 insertions(+), 28 deletions(-) (limited to 'compiler/optimizing/codegen_test_utils.h') diff --git a/compiler/optimizing/codegen_test_utils.h b/compiler/optimizing/codegen_test_utils.h index 53163daabb..a8425c9915 100644 --- a/compiler/optimizing/codegen_test_utils.h +++ b/compiler/optimizing/codegen_test_utils.h @@ -167,28 +167,6 @@ class TestCodeGeneratorX86 : public x86::CodeGeneratorX86 { }; #endif -class InternalCodeAllocator : public CodeAllocator { - public: - InternalCodeAllocator() : size_(0) { } - - uint8_t* Allocate(size_t size) override { - size_ = size; - memory_.reset(new uint8_t[size]); - return memory_.get(); - } - - size_t GetSize() const { return size_; } - ArrayRef GetMemory() const override { - return ArrayRef(memory_.get(), size_); - } - - private: - size_t size_; - std::unique_ptr memory_; - - DISALLOW_COPY_AND_ASSIGN(InternalCodeAllocator); -}; - static bool CanExecuteOnHardware(InstructionSet target_isa) { return (target_isa == kRuntimeISA) // Handle the special case of ARM, with two instructions sets (ARM32 and Thumb-2). @@ -247,8 +225,7 @@ static void VerifyGeneratedCode(InstructionSet target_isa, } template -static void Run(const InternalCodeAllocator& allocator, - const CodeGenerator& codegen, +static void Run(const CodeGenerator& codegen, bool has_result, Expected expected) { InstructionSet target_isa = codegen.GetInstructionSet(); @@ -260,7 +237,7 @@ static void Run(const InternalCodeAllocator& allocator, }; CodeHolder code_holder; const void* method_code = - code_holder.MakeExecutable(allocator.GetMemory(), ArrayRef(), target_isa); + code_holder.MakeExecutable(codegen.GetCode(), ArrayRef(), target_isa); using fptr = Expected (*)(); fptr f = reinterpret_cast(reinterpret_cast(method_code)); @@ -294,9 +271,8 @@ static void RunCodeNoCheck(CodeGenerator* codegen, register_allocator->AllocateRegisters(); } hook_before_codegen(graph); - InternalCodeAllocator allocator; - codegen->Compile(&allocator); - Run(allocator, *codegen, has_result, expected); + codegen->Compile(); + Run(*codegen, has_result, expected); } template -- cgit v1.2.3-59-g8ed1b