Index: src/mips/lithium-codegen-mips.cc |
diff --git a/src/mips/lithium-codegen-mips.cc b/src/mips/lithium-codegen-mips.cc |
index 7fabb9ff2e56a8521e500d83f144c7607cdc450b..984d0a0e65cbf49e48d45bc4ec3b9d1870a1431d 100644 |
--- a/src/mips/lithium-codegen-mips.cc |
+++ b/src/mips/lithium-codegen-mips.cc |
@@ -139,14 +139,29 @@ bool LCodeGen::GeneratePrologue() { |
// Adjust FP to point to saved FP. |
__ Addu(fp, sp, Operand(2 * kPointerSize)); |
} else { |
+ PredictableCodeSizeScope predictible_code_size_scope( |
+ masm_, kNoCodeAgeSequenceLength * Assembler::kInstrSize); |
// The following three instructions must remain together and unmodified |
// for code aging to work properly. |
- __ Push(ra, fp, cp, a1); |
- // Add unused nop to ensure prologue sequence is identical for |
- // full-codegen and lithium-codegen. |
- __ nop(Assembler::CODE_AGE_SEQUENCE_NOP); |
- // Adj. FP to point to saved FP. |
- __ Addu(fp, sp, Operand(2 * kPointerSize)); |
+ if (FLAG_optimize_for_size && FLAG_age_code) { |
+ // Pre-age the code. |
+ 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)) |
+ __ mov(at, ra); |
+ // Load the stub address to t9 and call it |
+ __ li(t9, |
+ Operand(reinterpret_cast<uint32_t>(stub->instruction_start()))); |
+ __ Call(t9); |
+ // Record the stub address in the empty space for GetCodeAgeAndParity() |
+ __ dd(reinterpret_cast<uint32_t>(stub->instruction_start())); |
+ } else { |
+ __ Push(ra, fp, cp, a1); |
+ __ nop(Assembler::CODE_AGE_SEQUENCE_NOP); |
+ // Adjust fp to point to caller's fp. |
+ __ Addu(fp, sp, Operand(2 * kPointerSize)); |
+ } |
} |
frame_is_built_ = true; |
info_->AddNoFrameRange(0, masm_->pc_offset()); |