Chromium Code Reviews| Index: src/objects.cc |
| diff --git a/src/objects.cc b/src/objects.cc |
| index cbef145d971a84c9c601234b0241337b3dae2f2e..2ba0ed2411d23f3e2d2431316f8ebf396c1135c5 100644 |
| --- a/src/objects.cc |
| +++ b/src/objects.cc |
| @@ -7696,7 +7696,6 @@ bool JSFunction::CompileLazy(Handle<JSFunction> function, |
| bool result = true; |
| if (function->shared()->is_compiled()) { |
| function->ReplaceCode(function->shared()->code()); |
| - function->shared()->set_code_age(0); |
| } else { |
| ASSERT(function->shared()->allows_lazy_compilation()); |
| CompilationInfoWithZone info(function); |
| @@ -8284,6 +8283,15 @@ void ObjectVisitor::VisitCodeTarget(RelocInfo* rinfo) { |
| } |
| +void ObjectVisitor::VisitCodeAgeSequence(RelocInfo* rinfo) { |
| + ASSERT(RelocInfo::IsCodeAgeSequence(rinfo->rmode())); |
| + Object* stub = rinfo->code_age_stub(); |
| + if (stub) { |
| + VisitPointer(&stub); |
| + } |
| +} |
| + |
| + |
| void ObjectVisitor::VisitCodeEntry(Address entry_address) { |
| Object* code = Code::GetObjectFromEntryAddress(entry_address); |
| Object* old_code = code; |
| @@ -8496,6 +8504,100 @@ bool Code::allowed_in_shared_map_code_cache() { |
| } |
| +void Code::MakeCodeAgeSequenceYoung(byte* sequence) { |
| + PatchPlatformCodeAge(sequence, kNoAge, NO_MARKING_PARITY); |
| +} |
| + |
| + |
| +void Code::MakeYoung() { |
| + byte* sequence = FindCodeAgeSequence(); |
| + if (sequence != NULL) { |
| + PatchPlatformCodeAge(sequence, kNoAge, NO_MARKING_PARITY); |
| + } |
| +} |
| + |
| + |
| +void Code::MakeOlder() { |
|
Michael Starzinger
2012/09/21 09:43:19
I think MakeOlder should only be called from the G
danno
2012/10/25 10:07:23
Done.
|
| + byte* sequence = FindCodeAgeSequence(); |
| + if (sequence != NULL) { |
| + Age age; |
| + MarkingParity code_parity; |
| + MarkingParity current_parity = GetHeap()->marking_parity(); |
|
Michael Starzinger
2012/09/21 09:43:19
Can we remove the marking_parity getter in Heap?
danno
2012/10/25 10:07:23
Done.
|
| + GetCodeAgeAndParity(sequence, &age, &code_parity); |
| + if (age != kLastCodeAge && code_parity != current_parity) { |
| + PatchPlatformCodeAge(sequence, static_cast<Age>(age + 1), |
| + current_parity); |
| + } |
| + } |
| +} |
| + |
| + |
| +bool Code::IsOld() { |
| + byte* sequence = FindCodeAgeSequence(); |
| + if (sequence == NULL) return false; |
| + Age age; |
| + MarkingParity parity; |
| + GetCodeAgeAndParity(sequence, &age, &parity); |
| + return age >= kSexagenarianCodeAge; |
| +} |
| + |
| + |
| +byte* Code::FindCodeAgeSequence() { |
| + if (kind() != FUNCTION && kind() != OPTIMIZED_FUNCTION) return NULL; |
| + if (strlen(FLAG_stop_at) == 0 && |
| + !ProfileEntryHookStub::HasEntryHook() && |
| + (kind() == FUNCTION && !has_debug_break_slots())) { |
| + return FindPlatformCodeAgeSequence(); |
| + } |
| + return NULL; |
| +} |
| + |
| + |
| +void Code::GetCodeAgeAndParity(Code* code, Age* age, |
| + MarkingParity* parity) { |
| + Isolate* isolate = Isolate::Current(); |
| + Builtins* builtins = isolate->builtins(); |
| + Code* stub = NULL; |
| +#define HANDLE_CODE_AGE(AGE) \ |
| + stub = *builtins->Make##AGE##CodeYoungAgainEvenMarking(); \ |
| + if (code == stub) { \ |
| + *age = k##AGE##CodeAge; \ |
| + *parity = EVEN_MARKING_PARITY; \ |
| + return; \ |
| + } \ |
| + stub = *builtins->Make##AGE##CodeYoungAgainOddMarking(); \ |
| + if (code == stub) { \ |
| + *age = k##AGE##CodeAge; \ |
| + *parity = ODD_MARKING_PARITY; \ |
| + return; \ |
| + } |
| + CODE_AGE_LIST(HANDLE_CODE_AGE) |
| +#undef HANDLE_CODE_AGE |
| + UNREACHABLE(); |
| +} |
| + |
| + |
| +Code* Code::GetCodeAgeStub(Age age, MarkingParity parity) { |
| + Isolate* isolate = Isolate::Current(); |
| + Builtins* builtins = isolate->builtins(); |
| + switch (age) { |
| +#define HANDLE_CODE_AGE(AGE) \ |
| + case k##AGE##CodeAge: { \ |
| + Code* stub = parity == EVEN_MARKING_PARITY \ |
| + ? *builtins->Make##AGE##CodeYoungAgainEvenMarking() \ |
| + : *builtins->Make##AGE##CodeYoungAgainOddMarking(); \ |
| + return stub; \ |
| + } |
| + CODE_AGE_LIST(HANDLE_CODE_AGE) |
| +#undef HANDLE_CODE_AGE |
| + default: |
| + UNREACHABLE(); |
| + break; |
| + } |
| + return NULL; |
| +} |
| + |
| + |
| #ifdef ENABLE_DISASSEMBLER |
| void DeoptimizationInputData::DeoptimizationInputDataPrint(FILE* out) { |