| Index: src/mips/codegen-mips.cc
|
| diff --git a/src/mips/codegen-mips.cc b/src/mips/codegen-mips.cc
|
| index e9148ce0aaa2b4c029ec50a150f161262473c3f5..b61784d70e022407df02c581707a2d97527cd58a 100644
|
| --- a/src/mips/codegen-mips.cc
|
| +++ b/src/mips/codegen-mips.cc
|
| @@ -600,13 +600,32 @@ static byte* GetNoCodeAgeSequence(uint32_t* length) {
|
| // The sequence of instructions that is patched out for aging code is the
|
| // following boilerplate stack-building prologue that is found in FUNCTIONS
|
| static bool initialized = false;
|
| - static uint32_t sequence[kNoCodeAgeSequenceLength];
|
| + static uint32_t sequence[kCodeAgeSequenceLength];
|
| byte* byte_sequence = reinterpret_cast<byte*>(sequence);
|
| - *length = kNoCodeAgeSequenceLength * Assembler::kInstrSize;
|
| + *length = kCodeAgeSequenceLength * Assembler::kInstrSize;
|
| if (!initialized) {
|
| - CodePatcher patcher(byte_sequence, kNoCodeAgeSequenceLength);
|
| + CodePatcher patcher(byte_sequence, kCodeAgeSequenceLength);
|
| patcher.masm()->Push(ra, fp, cp, a1);
|
| - patcher.masm()->nop(Assembler::CODE_AGE_SEQUENCE_NOP);
|
| + patcher.masm()->nop(Assembler::CODE_AGE_YOUNG_SEQUENCE_NOP);
|
| + patcher.masm()->Addu(fp, sp, Operand(2 * kPointerSize));
|
| + initialized = true;
|
| + }
|
| + return byte_sequence;
|
| +}
|
| +
|
| +
|
| +static byte* GetPreAgedCodeAgeSequence(uint32_t* length) {
|
| + // If code is "pre-aged" then this sequence of instructions is found in the
|
| + // boilerplate stack-building prologue that is found in FUNCTIONS, and is
|
| + // patched out for code aging.
|
| + static bool initialized = false;
|
| + static uint32_t sequence[kCodeAgeSequenceLength];
|
| + byte* byte_sequence = reinterpret_cast<byte*>(sequence);
|
| + *length = kCodeAgeSequenceLength * Assembler::kInstrSize;
|
| + if (!initialized) {
|
| + CodePatcher patcher(byte_sequence, kCodeAgeSequenceLength);
|
| + patcher.masm()->Push(ra, fp, cp, a1);
|
| + patcher.masm()->nop(Assembler::CODE_AGE_PRE_AGED_SEQUENCE_NOP);
|
| patcher.masm()->Addu(fp, sp, Operand(2 * kPointerSize));
|
| initialized = true;
|
| }
|
| @@ -619,7 +638,19 @@ bool Code::IsYoungSequence(byte* sequence) {
|
| byte* young_sequence = GetNoCodeAgeSequence(&young_length);
|
| bool result = !memcmp(sequence, young_sequence, young_length);
|
| ASSERT(result ||
|
| - Memory::uint32_at(sequence) == kCodeAgePatchFirstInstruction);
|
| + Memory::uint32_at(sequence) == kCodeAgePatchFirstInstruction ||
|
| + IsPreAgedSequence(sequence));
|
| + return result;
|
| +}
|
| +
|
| +
|
| +bool Code::IsPreAgedSequence(byte* sequence) {
|
| + uint32_t pre_aged_length;
|
| + byte* pre_aged_sequence = GetPreAgedCodeAgeSequence(&pre_aged_length);
|
| + bool result = !memcmp(sequence, pre_aged_sequence, pre_aged_length);
|
| + ASSERT(result ||
|
| + Memory::uint32_at(sequence) == kCodeAgePatchFirstInstruction ||
|
| + IsYoungSequence(sequence));
|
| return result;
|
| }
|
|
|
| @@ -629,9 +660,12 @@ void Code::GetCodeAgeAndParity(byte* sequence, Age* age,
|
| if (IsYoungSequence(sequence)) {
|
| *age = kNoAge;
|
| *parity = NO_MARKING_PARITY;
|
| + } else if (IsPreAgedSequence(sequence)) {
|
| + *age = kPreAgedCodeAge;
|
| + *parity = NO_MARKING_PARITY;
|
| } else {
|
| Address target_address = Memory::Address_at(
|
| - sequence + Assembler::kInstrSize * (kNoCodeAgeSequenceLength - 1));
|
| + sequence + Assembler::kInstrSize * (kCodeAgeSequenceLength - 1));
|
| Code* stub = GetCodeFromTargetAddress(target_address);
|
| GetCodeAgeAndParity(stub, age, parity);
|
| }
|
|
|