Index: src/mips/codegen-mips.cc |
diff --git a/src/mips/codegen-mips.cc b/src/mips/codegen-mips.cc |
index ce04dd463888667619985535b962b2bfd99019c6..adf6d37d895e42c0cd3968c4595db43759dfc06e 100644 |
--- a/src/mips/codegen-mips.cc |
+++ b/src/mips/codegen-mips.cc |
@@ -1122,42 +1122,42 @@ void MathExpGenerator::EmitMathExp(MacroAssembler* masm, |
static const uint32_t kCodeAgePatchFirstInstruction = 0x00010180; |
#endif |
-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]; |
- byte* byte_sequence = reinterpret_cast<byte*>(sequence); |
- *length = kNoCodeAgeSequenceLength * Assembler::kInstrSize; |
- if (!initialized) { |
- // Since patcher is a large object, allocate it dynamically when needed, |
- // to avoid overloading the stack in stress conditions. |
- SmartPointer<CodePatcher> |
- patcher(new CodePatcher(byte_sequence, kNoCodeAgeSequenceLength)); |
- PredictableCodeSizeScope scope(patcher->masm(), *length); |
- patcher->masm()->Push(ra, fp, cp, a1); |
- patcher->masm()->nop(Assembler::CODE_AGE_SEQUENCE_NOP); |
- patcher->masm()->Addu( |
- fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp)); |
- initialized = true; |
- } |
- return byte_sequence; |
+ |
+CodeAgingHelper::CodeAgingHelper() { |
+ ASSERT(young_sequence_.length() == kNoCodeAgeSequenceLength); |
+ // Since patcher is a large object, allocate it dynamically when needed, |
+ // to avoid overloading the stack in stress conditions. |
+ // DONT_FLUSH is used because the CodeAgingHelper is initialized early in |
+ // the process, before MIPS simulator ICache is setup. |
+ SmartPointer<CodePatcher> patcher( |
+ new CodePatcher(young_sequence_.start(), |
+ young_sequence_.length() / Assembler::kInstrSize, |
+ CodePatcher::DONT_FLUSH)); |
+ PredictableCodeSizeScope scope(patcher->masm(), young_sequence_.length()); |
+ patcher->masm()->Push(ra, fp, cp, a1); |
+ patcher->masm()->nop(Assembler::CODE_AGE_SEQUENCE_NOP); |
+ patcher->masm()->Addu( |
+ fp, sp, Operand(StandardFrameConstants::kFixedFrameSizeFromFp)); |
} |
-bool Code::IsYoungSequence(byte* sequence) { |
- uint32_t young_length; |
- byte* young_sequence = GetNoCodeAgeSequence(&young_length); |
- bool result = !memcmp(sequence, young_sequence, young_length); |
- ASSERT(result || |
- Memory::uint32_at(sequence) == kCodeAgePatchFirstInstruction); |
+#ifdef DEBUG |
+bool CodeAgingHelper::IsOld(byte* candidate) const { |
+ return Memory::uint32_at(candidate) == kCodeAgePatchFirstInstruction; |
+} |
+#endif |
+ |
+ |
+bool Code::IsYoungSequence(Isolate* isolate, byte* sequence) { |
+ bool result = isolate->code_aging_helper()->IsYoung(sequence); |
+ ASSERT(result || isolate->code_aging_helper()->IsOld(sequence)); |
return result; |
} |
-void Code::GetCodeAgeAndParity(byte* sequence, Age* age, |
+void Code::GetCodeAgeAndParity(Isolate* isolate, byte* sequence, Age* age, |
MarkingParity* parity) { |
- if (IsYoungSequence(sequence)) { |
+ if (IsYoungSequence(isolate, sequence)) { |
*age = kNoAgeCodeAge; |
*parity = NO_MARKING_PARITY; |
} else { |
@@ -1173,10 +1173,9 @@ void Code::PatchPlatformCodeAge(Isolate* isolate, |
byte* sequence, |
Code::Age age, |
MarkingParity parity) { |
- uint32_t young_length; |
- byte* young_sequence = GetNoCodeAgeSequence(&young_length); |
+ uint32_t young_length = isolate->code_aging_helper()->young_sequence_length(); |
if (age == kNoAgeCodeAge) { |
- CopyBytes(sequence, young_sequence, young_length); |
+ isolate->code_aging_helper()->CopyYoungSequenceTo(sequence); |
CPU::FlushICache(sequence, young_length); |
} else { |
Code* stub = GetCodeAgeStub(isolate, age, parity); |