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/code_generator.h | 21 +++++++-------------- 1 file changed, 7 insertions(+), 14 deletions(-) (limited to 'compiler/optimizing/code_generator.h') diff --git a/compiler/optimizing/code_generator.h b/compiler/optimizing/code_generator.h index 5f4f377a27..bcbffe49fe 100644 --- a/compiler/optimizing/code_generator.h +++ b/compiler/optimizing/code_generator.h @@ -87,18 +87,6 @@ namespace linker { class LinkerPatch; } // namespace linker -class CodeAllocator { - public: - CodeAllocator() {} - virtual ~CodeAllocator() {} - - virtual uint8_t* Allocate(size_t size) = 0; - virtual ArrayRef GetMemory() const = 0; - - private: - DISALLOW_COPY_AND_ASSIGN(CodeAllocator); -}; - class SlowPathCode : public DeletableArenaObject { public: explicit SlowPathCode(HInstruction* instruction) : instruction_(instruction) { @@ -205,7 +193,7 @@ class FieldAccessCallingConvention { class CodeGenerator : public DeletableArenaObject { public: // Compiles the graph to executable instructions. - void Compile(CodeAllocator* allocator); + void Compile(); static std::unique_ptr Create(HGraph* graph, const CompilerOptions& compiler_options, OptimizingCompilerStats* stats = nullptr); @@ -226,7 +214,7 @@ class CodeGenerator : public DeletableArenaObject { } virtual void Initialize() = 0; - virtual void Finalize(CodeAllocator* allocator); + virtual void Finalize(); virtual void EmitLinkerPatches(ArenaVector* linker_patches); virtual bool NeedsThunkCode(const linker::LinkerPatch& patch) const; virtual void EmitThunkCode(const linker::LinkerPatch& patch, @@ -736,6 +724,11 @@ class CodeGenerator : public DeletableArenaObject { static QuickEntrypointEnum GetArrayAllocationEntrypoint(HNewArray* new_array); static ScaleFactor ScaleFactorForType(DataType::Type type); + ArrayRef GetCode() const { + return ArrayRef(GetAssembler().CodeBufferBaseAddress(), + GetAssembler().CodeSize()); + } + protected: // Patch info used for recording locations of required linker patches and their targets, // i.e. target method, string, type or code identified by their dex file and index, -- cgit v1.2.3-59-g8ed1b