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/utils/assembler.h | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) (limited to 'compiler/utils/assembler.h') diff --git a/compiler/utils/assembler.h b/compiler/utils/assembler.h index 63747bee58..f3fa711dbb 100644 --- a/compiler/utils/assembler.h +++ b/compiler/utils/assembler.h @@ -163,9 +163,8 @@ class AssemblerBuffer { uint8_t* contents() const { return contents_; } - // Copy the assembled instructions into the specified memory block - // and apply all fixups. - void FinalizeInstructions(const MemoryRegion& region); + // Copy the assembled instructions into the specified memory block. + void CopyInstructions(const MemoryRegion& region); // To emit an instruction to the assembler buffer, the EnsureCapacity helper // must be used to guarantee that the underlying data area is big enough to @@ -246,6 +245,8 @@ class AssemblerBuffer { // The provided `min_capacity` must be higher than current `Capacity()`. void ExtendCapacity(size_t min_capacity); + void ProcessFixups(); + private: // The limit is set to kMinimumGap bytes before the end of the data area. // This leaves enough space for the longest possible instruction and allows @@ -357,7 +358,10 @@ class DebugFrameOpCodeWriterForAssembler final class Assembler : public DeletableArenaObject { public: // Finalize the code; emit slow paths, fixup branches, add literal pool, etc. - virtual void FinalizeCode() { buffer_.EmitSlowPaths(this); } + virtual void FinalizeCode() { + buffer_.EmitSlowPaths(this); + buffer_.ProcessFixups(); + } // Size of generated code virtual size_t CodeSize() const { return buffer_.Size(); } @@ -375,8 +379,8 @@ class Assembler : public DeletableArenaObject { virtual size_t CodePosition() { return CodeSize(); } // Copy instructions out of assembly buffer into the given region of memory - virtual void FinalizeInstructions(const MemoryRegion& region) { - buffer_.FinalizeInstructions(region); + virtual void CopyInstructions(const MemoryRegion& region) { + buffer_.CopyInstructions(region); } // TODO: Implement with disassembler. -- cgit v1.2.3-59-g8ed1b