OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 the V8 project authors. All rights reserved. |
2 // Redistribution and use in source and binary forms, with or without | 2 // Redistribution and use in source and binary forms, with or without |
3 // modification, are permitted provided that the following conditions are | 3 // modification, are permitted provided that the following conditions are |
4 // met: | 4 // met: |
5 // | 5 // |
6 // * Redistributions of source code must retain the above copyright | 6 // * Redistributions of source code must retain the above copyright |
7 // notice, this list of conditions and the following disclaimer. | 7 // notice, this list of conditions and the following disclaimer. |
8 // * Redistributions in binary form must reproduce the above | 8 // * Redistributions in binary form must reproduce the above |
9 // copyright notice, this list of conditions and the following | 9 // copyright notice, this list of conditions and the following |
10 // disclaimer in the documentation and/or other materials provided | 10 // disclaimer in the documentation and/or other materials provided |
(...skipping 10616 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10627 PatchPlatformCodeAge(isolate, sequence, kNoAgeCodeAge, NO_MARKING_PARITY); | 10627 PatchPlatformCodeAge(isolate, sequence, kNoAgeCodeAge, NO_MARKING_PARITY); |
10628 } | 10628 } |
10629 | 10629 |
10630 | 10630 |
10631 void Code::MarkCodeAsExecuted(byte* sequence, Isolate* isolate) { | 10631 void Code::MarkCodeAsExecuted(byte* sequence, Isolate* isolate) { |
10632 PatchPlatformCodeAge(isolate, sequence, kExecutedOnceCodeAge, | 10632 PatchPlatformCodeAge(isolate, sequence, kExecutedOnceCodeAge, |
10633 NO_MARKING_PARITY); | 10633 NO_MARKING_PARITY); |
10634 } | 10634 } |
10635 | 10635 |
10636 | 10636 |
| 10637 static Code::Age EffectiveAge(Code::Age age) { |
| 10638 if (age == Code::kNotExecutedCodeAge) { |
| 10639 // Treat that's never been executed as old immediately. |
| 10640 age = Code::kIsOldCodeAge; |
| 10641 } else if (age == Code::kExecutedOnceCodeAge) { |
| 10642 // Pre-age code that has only been executed once. |
| 10643 age = Code::kPreAgedCodeAge; |
| 10644 } |
| 10645 return age; |
| 10646 } |
| 10647 |
| 10648 |
10637 void Code::MakeOlder(MarkingParity current_parity) { | 10649 void Code::MakeOlder(MarkingParity current_parity) { |
10638 byte* sequence = FindCodeAgeSequence(); | 10650 byte* sequence = FindCodeAgeSequence(); |
10639 if (sequence != NULL) { | 10651 if (sequence != NULL) { |
10640 Age age; | 10652 Age age; |
10641 MarkingParity code_parity; | 10653 MarkingParity code_parity; |
10642 GetCodeAgeAndParity(sequence, &age, &code_parity); | 10654 GetCodeAgeAndParity(sequence, &age, &code_parity); |
| 10655 age = EffectiveAge(age); |
10643 if (age != kLastCodeAge && code_parity != current_parity) { | 10656 if (age != kLastCodeAge && code_parity != current_parity) { |
10644 PatchPlatformCodeAge(GetIsolate(), | 10657 PatchPlatformCodeAge(GetIsolate(), |
10645 sequence, | 10658 sequence, |
10646 static_cast<Age>(age + 1), | 10659 static_cast<Age>(age + 1), |
10647 current_parity); | 10660 current_parity); |
10648 } | 10661 } |
10649 } | 10662 } |
10650 } | 10663 } |
10651 | 10664 |
10652 | 10665 |
10653 bool Code::IsOld() { | 10666 bool Code::IsOld() { |
10654 Age age = GetAge(); | 10667 return GetAge() >= kIsOldCodeAge; |
10655 return age >= kIsOldCodeAge; | |
10656 } | 10668 } |
10657 | 10669 |
10658 | 10670 |
10659 byte* Code::FindCodeAgeSequence() { | 10671 byte* Code::FindCodeAgeSequence() { |
10660 return FLAG_age_code && | 10672 return FLAG_age_code && |
10661 prologue_offset() != Code::kPrologueOffsetNotSet && | 10673 prologue_offset() != Code::kPrologueOffsetNotSet && |
10662 (kind() == OPTIMIZED_FUNCTION || | 10674 (kind() == OPTIMIZED_FUNCTION || |
10663 (kind() == FUNCTION && !has_debug_break_slots())) | 10675 (kind() == FUNCTION && !has_debug_break_slots())) |
10664 ? instruction_start() + prologue_offset() | 10676 ? instruction_start() + prologue_offset() |
10665 : NULL; | 10677 : NULL; |
10666 } | 10678 } |
10667 | 10679 |
10668 | 10680 |
10669 Code::Age Code::GetAge() { | 10681 Code::Age Code::GetAge() { |
| 10682 return EffectiveAge(GetRawAge()); |
| 10683 } |
| 10684 |
| 10685 |
| 10686 Code::Age Code::GetRawAge() { |
10670 byte* sequence = FindCodeAgeSequence(); | 10687 byte* sequence = FindCodeAgeSequence(); |
10671 if (sequence == NULL) { | 10688 if (sequence == NULL) { |
10672 return Code::kNoAgeCodeAge; | 10689 return kNoAgeCodeAge; |
10673 } | 10690 } |
10674 Age age; | 10691 Age age; |
10675 MarkingParity parity; | 10692 MarkingParity parity; |
10676 GetCodeAgeAndParity(sequence, &age, &parity); | 10693 GetCodeAgeAndParity(sequence, &age, &parity); |
10677 return age; | 10694 return age; |
10678 } | 10695 } |
10679 | 10696 |
10680 | 10697 |
10681 void Code::GetCodeAgeAndParity(Code* code, Age* age, | 10698 void Code::GetCodeAgeAndParity(Code* code, Age* age, |
10682 MarkingParity* parity) { | 10699 MarkingParity* parity) { |
(...skipping 10 matching lines...) Expand all Loading... |
10693 stub = *builtins->Make##AGE##CodeYoungAgainOddMarking(); \ | 10710 stub = *builtins->Make##AGE##CodeYoungAgainOddMarking(); \ |
10694 if (code == stub) { \ | 10711 if (code == stub) { \ |
10695 *age = k##AGE##CodeAge; \ | 10712 *age = k##AGE##CodeAge; \ |
10696 *parity = ODD_MARKING_PARITY; \ | 10713 *parity = ODD_MARKING_PARITY; \ |
10697 return; \ | 10714 return; \ |
10698 } | 10715 } |
10699 CODE_AGE_LIST(HANDLE_CODE_AGE) | 10716 CODE_AGE_LIST(HANDLE_CODE_AGE) |
10700 #undef HANDLE_CODE_AGE | 10717 #undef HANDLE_CODE_AGE |
10701 stub = *builtins->MarkCodeAsExecutedOnce(); | 10718 stub = *builtins->MarkCodeAsExecutedOnce(); |
10702 if (code == stub) { | 10719 if (code == stub) { |
10703 // Treat that's never been executed as old immediatly. | 10720 *age = kNotExecutedCodeAge; |
10704 *age = kIsOldCodeAge; | |
10705 *parity = NO_MARKING_PARITY; | 10721 *parity = NO_MARKING_PARITY; |
10706 return; | 10722 return; |
10707 } | 10723 } |
10708 stub = *builtins->MarkCodeAsExecutedTwice(); | 10724 stub = *builtins->MarkCodeAsExecutedTwice(); |
10709 if (code == stub) { | 10725 if (code == stub) { |
10710 // Pre-age code that has only been executed once. | 10726 *age = kExecutedOnceCodeAge; |
10711 *age = kPreAgedCodeAge; | |
10712 *parity = NO_MARKING_PARITY; | 10727 *parity = NO_MARKING_PARITY; |
10713 return; | 10728 return; |
10714 } | 10729 } |
10715 UNREACHABLE(); | 10730 UNREACHABLE(); |
10716 } | 10731 } |
10717 | 10732 |
10718 | 10733 |
10719 Code* Code::GetCodeAgeStub(Isolate* isolate, Age age, MarkingParity parity) { | 10734 Code* Code::GetCodeAgeStub(Isolate* isolate, Age age, MarkingParity parity) { |
10720 Builtins* builtins = isolate->builtins(); | 10735 Builtins* builtins = isolate->builtins(); |
10721 switch (age) { | 10736 switch (age) { |
(...skipping 5677 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16399 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16414 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16400 static const char* error_messages_[] = { | 16415 static const char* error_messages_[] = { |
16401 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16416 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16402 }; | 16417 }; |
16403 #undef ERROR_MESSAGES_TEXTS | 16418 #undef ERROR_MESSAGES_TEXTS |
16404 return error_messages_[reason]; | 16419 return error_messages_[reason]; |
16405 } | 16420 } |
16406 | 16421 |
16407 | 16422 |
16408 } } // namespace v8::internal | 16423 } } // namespace v8::internal |
OLD | NEW |