From b45bb17547b627bf9738182717342b15f595d750 Mon Sep 17 00:00:00 2001 From: "plind44@gmail.com" Date: Tue, 5 Nov 2013 20:48:35 +0000 Subject: [PATCH] MIPS: Avoid using dd() in Prologue when --optimize-for-size. Port: r17485 (0d82025) Original commit message: When --optimize-for-size is true, the prologue generation outputs the pre-aging code stub address directly to the instruction stream. Previously this was done using dd() which failed if there was any pending constant pool entries left to be written. This CL introduces an emit_code_stub_address() for this purpose instead. BUG=v8:2968 Patch from Balazs Kilvady . git-svn-id: http://v8.googlecode.com/svn/branches/bleeding_edge@17508 ce2b1a6d-e550-0410-aec6-3dcde31c8c00 --- src/mips/assembler-mips.cc | 8 ++++++++ src/mips/assembler-mips.h | 3 +++ src/mips/codegen-mips.cc | 2 +- src/mips/macro-assembler-mips.cc | 8 ++++---- 4 files changed, 16 insertions(+), 5 deletions(-) diff --git a/src/mips/assembler-mips.cc b/src/mips/assembler-mips.cc index 0972a82..d84315a 100644 --- a/src/mips/assembler-mips.cc +++ b/src/mips/assembler-mips.cc @@ -2031,6 +2031,14 @@ void Assembler::dd(uint32_t data) { } +void Assembler::emit_code_stub_address(Code* stub) { + CheckBuffer(); + *reinterpret_cast(pc_) = + reinterpret_cast(stub->instruction_start()); + pc_ += sizeof(uint32_t); +} + + void Assembler::RecordRelocInfo(RelocInfo::Mode rmode, intptr_t data) { // We do not try to reuse pool constants. RelocInfo rinfo(pc_, rmode, data, NULL); diff --git a/src/mips/assembler-mips.h b/src/mips/assembler-mips.h index 2468c3c..49cce62 100644 --- a/src/mips/assembler-mips.h +++ b/src/mips/assembler-mips.h @@ -896,6 +896,9 @@ class Assembler : public AssemblerBase { void db(uint8_t data); void dd(uint32_t data); + // Emits the address of the code stub's first instruction. + void emit_code_stub_address(Code* stub); + PositionsRecorder* positions_recorder() { return &positions_recorder_; } // Postpone the generation of the trampoline pool for the specified number of diff --git a/src/mips/codegen-mips.cc b/src/mips/codegen-mips.cc index ec66495..904a37d 100644 --- a/src/mips/codegen-mips.cc +++ b/src/mips/codegen-mips.cc @@ -671,7 +671,7 @@ void Code::PatchPlatformCodeAge(Isolate* isolate, Operand(reinterpret_cast(stub->instruction_start()))); patcher.masm()->Call(t9); // Record the stub address in the empty space for GetCodeAgeAndParity() - patcher.masm()->dd(reinterpret_cast(stub->instruction_start())); + patcher.masm()->emit_code_stub_address(stub); } } diff --git a/src/mips/macro-assembler-mips.cc b/src/mips/macro-assembler-mips.cc index 0d9747b..c434c31 100644 --- a/src/mips/macro-assembler-mips.cc +++ b/src/mips/macro-assembler-mips.cc @@ -4606,14 +4606,14 @@ void MacroAssembler::Prologue(PrologueFrameMode frame_mode) { Code* stub = Code::GetPreAgedCodeAgeStub(isolate()); nop(Assembler::CODE_AGE_MARKER_NOP); // Save the function's original return address - // (it will be clobbered by Call(t9)) + // (it will be clobbered by Call(t9)). mov(at, ra); - // Load the stub address to t9 and call it + // Load the stub address to t9 and call it. li(t9, Operand(reinterpret_cast(stub->instruction_start()))); Call(t9); - // Record the stub address in the empty space for GetCodeAgeAndParity() - dd(reinterpret_cast(stub->instruction_start())); + // Record the stub address in the empty space for GetCodeAgeAndParity(). + emit_code_stub_address(stub); } else { Push(ra, fp, cp, a1); nop(Assembler::CODE_AGE_SEQUENCE_NOP); -- 2.7.4