We now leave the assembler buffer management to VIXL.
Change-Id: Ieefe83cf5cf5e1ab8c924b0e7dc03af6a55053ae
// 17. Finalize code generation
__ EmitSlowPaths();
size_t cs = __ CodeSize();
- if (instruction_set == kArm64) {
- // Test that we do not exceed the buffer size.
- CHECK(cs < arm64::kBufferSizeArm64);
- }
std::vector<uint8_t> managed_code(cs);
MemoryRegion code(&managed_code[0], managed_code.size());
__ FinalizeInstructions(code);
}
size_t Arm64Assembler::CodeSize() const {
- return ___ SizeOfCodeGenerated();
+ return vixl_masm_->BufferCapacity() - vixl_masm_->RemainingBufferSpace();
}
void Arm64Assembler::FinalizeInstructions(const MemoryRegion& region) {
// Copy the instructions from the buffer.
- MemoryRegion from(reinterpret_cast<void*>(vixl_buf_), CodeSize());
+ MemoryRegion from(vixl_masm_->GetStartAddress<void*>(), CodeSize());
region.CopyFrom(0, from);
}
class Arm64Assembler FINAL : public Assembler {
public:
- Arm64Assembler() : vixl_buf_(new byte[kBufferSizeArm64]),
- vixl_masm_(new vixl::MacroAssembler(vixl_buf_, kBufferSizeArm64)) {}
+ // We indicate the size of the initial code generation buffer to the VIXL
+ // assembler. From there we it will automatically manage the buffer.
+ Arm64Assembler() : vixl_masm_(new vixl::MacroAssembler(kArm64BaseBufferSize)) {}
virtual ~Arm64Assembler() {
delete vixl_masm_;
- delete[] vixl_buf_;
}
// Emit slow paths queued during assembly.
void AddConstant(Register rd, int32_t value, vixl::Condition cond = vixl::al);
void AddConstant(Register rd, Register rn, int32_t value, vixl::Condition cond = vixl::al);
- // Vixl buffer.
- byte* vixl_buf_;
-
// Vixl assembler.
vixl::MacroAssembler* vixl_masm_;
constexpr unsigned int kJniRefSpillRegsSize = 11;
-// Vixl buffer size.
-constexpr size_t kBufferSizeArm64 = 4096*2;
+constexpr size_t kArm64BaseBufferSize = 4096;
} // namespace arm64
} // namespace art