Index: src/mips/full-codegen-mips.cc |
diff --git a/src/mips/full-codegen-mips.cc b/src/mips/full-codegen-mips.cc |
index b9e282f760d3c06ecffc8ea47aed555e8761b918..f85c0f3dd33d17e46f69608ff7312b0ddaf3164b 100644 |
--- a/src/mips/full-codegen-mips.cc |
+++ b/src/mips/full-codegen-mips.cc |
@@ -171,12 +171,31 @@ void FullCodeGenerator::Generate() { |
FrameScope frame_scope(masm_, StackFrame::MANUAL); |
info->set_prologue_offset(masm_->pc_offset()); |
- // The following three instructions must remain together and unmodified for |
- // code aging to work properly. |
- __ 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)); |
+ { |
+ PredictableCodeSizeScope predictible_code_size_scope( |
+ masm_, kNoCodeAgeSequenceLength * Assembler::kInstrSize); |
+ // The following three instructions must remain together and unmodified |
+ // for code aging to work properly. |
+ 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)); |
+ } |
+ } |
info->AddNoFrameRange(0, masm_->pc_offset()); |
{ Comment cmnt(masm_, "[ Allocate locals"); |