| 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 10253 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10264 } else if (RelocInfo::IsCodeTarget(mode)) { | 10264 } else if (RelocInfo::IsCodeTarget(mode)) { |
| 10265 // rewrite code handles in inline cache targets to direct | 10265 // rewrite code handles in inline cache targets to direct |
| 10266 // pointers to the first instruction in the code object | 10266 // pointers to the first instruction in the code object |
| 10267 Handle<Object> p = it.rinfo()->target_object_handle(origin); | 10267 Handle<Object> p = it.rinfo()->target_object_handle(origin); |
| 10268 Code* code = Code::cast(*p); | 10268 Code* code = Code::cast(*p); |
| 10269 it.rinfo()->set_target_address(code->instruction_start(), | 10269 it.rinfo()->set_target_address(code->instruction_start(), |
| 10270 SKIP_WRITE_BARRIER); | 10270 SKIP_WRITE_BARRIER); |
| 10271 } else if (RelocInfo::IsRuntimeEntry(mode)) { | 10271 } else if (RelocInfo::IsRuntimeEntry(mode)) { |
| 10272 Address p = it.rinfo()->target_runtime_entry(origin); | 10272 Address p = it.rinfo()->target_runtime_entry(origin); |
| 10273 it.rinfo()->set_target_runtime_entry(p, SKIP_WRITE_BARRIER); | 10273 it.rinfo()->set_target_runtime_entry(p, SKIP_WRITE_BARRIER); |
| 10274 } else if (mode == RelocInfo::CODE_AGE_SEQUENCE) { |
| 10275 Handle<Object> p = it.rinfo()->code_age_stub_handle(origin); |
| 10276 Code* code = Code::cast(*p); |
| 10277 it.rinfo()->set_code_age_stub(code); |
| 10274 } else { | 10278 } else { |
| 10275 it.rinfo()->apply(delta); | 10279 it.rinfo()->apply(delta); |
| 10276 } | 10280 } |
| 10277 } | 10281 } |
| 10278 CPU::FlushICache(instruction_start(), instruction_size()); | 10282 CPU::FlushICache(instruction_start(), instruction_size()); |
| 10279 } | 10283 } |
| 10280 | 10284 |
| 10281 | 10285 |
| 10282 // Locate the source position which is closest to the address in the code. This | 10286 // Locate the source position which is closest to the address in the code. This |
| 10283 // is using the source position information embedded in the relocation info. | 10287 // is using the source position information embedded in the relocation info. |
| (...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 10505 } | 10509 } |
| 10506 return BailoutId::None(); | 10510 return BailoutId::None(); |
| 10507 } | 10511 } |
| 10508 | 10512 |
| 10509 | 10513 |
| 10510 void Code::MakeCodeAgeSequenceYoung(byte* sequence, Isolate* isolate) { | 10514 void Code::MakeCodeAgeSequenceYoung(byte* sequence, Isolate* isolate) { |
| 10511 PatchPlatformCodeAge(isolate, sequence, kNoAge, NO_MARKING_PARITY); | 10515 PatchPlatformCodeAge(isolate, sequence, kNoAge, NO_MARKING_PARITY); |
| 10512 } | 10516 } |
| 10513 | 10517 |
| 10514 | 10518 |
| 10519 void Code::MarkCodeAsExecuted(byte* sequence, Isolate* isolate) { |
| 10520 PatchPlatformCodeAge(isolate, sequence, kExecutedOnceCodeAge, |
| 10521 NO_MARKING_PARITY); |
| 10522 } |
| 10523 |
| 10524 |
| 10515 void Code::MakeOlder(MarkingParity current_parity) { | 10525 void Code::MakeOlder(MarkingParity current_parity) { |
| 10516 byte* sequence = FindCodeAgeSequence(); | 10526 byte* sequence = FindCodeAgeSequence(); |
| 10517 if (sequence != NULL) { | 10527 if (sequence != NULL) { |
| 10518 Age age; | 10528 Age age; |
| 10519 MarkingParity code_parity; | 10529 MarkingParity code_parity; |
| 10520 GetCodeAgeAndParity(sequence, &age, &code_parity); | 10530 GetCodeAgeAndParity(sequence, &age, &code_parity); |
| 10521 if (age != kLastCodeAge && code_parity != current_parity) { | 10531 if (age != kLastCodeAge && code_parity != current_parity) { |
| 10522 PatchPlatformCodeAge(GetIsolate(), | 10532 PatchPlatformCodeAge(GetIsolate(), |
| 10523 sequence, | 10533 sequence, |
| 10524 static_cast<Age>(age + 1), | 10534 static_cast<Age>(age + 1), |
| 10525 current_parity); | 10535 current_parity); |
| 10526 } | 10536 } |
| 10527 } | 10537 } |
| 10528 } | 10538 } |
| 10529 | 10539 |
| 10530 | 10540 |
| 10531 bool Code::IsOld() { | 10541 bool Code::IsOld() { |
| 10532 byte* sequence = FindCodeAgeSequence(); | 10542 Age age = GetAge(); |
| 10533 if (sequence == NULL) return false; | 10543 return age >= kIsOldCodeAge; |
| 10534 Age age; | |
| 10535 MarkingParity parity; | |
| 10536 GetCodeAgeAndParity(sequence, &age, &parity); | |
| 10537 return age >= kSexagenarianCodeAge; | |
| 10538 } | 10544 } |
| 10539 | 10545 |
| 10540 | 10546 |
| 10541 byte* Code::FindCodeAgeSequence() { | 10547 byte* Code::FindCodeAgeSequence() { |
| 10542 return FLAG_age_code && | 10548 return FLAG_age_code && |
| 10543 prologue_offset() != kPrologueOffsetNotSet && | 10549 prologue_offset() != Code::kPrologueOffsetNotSet && |
| 10544 (kind() == OPTIMIZED_FUNCTION || | 10550 (kind() == OPTIMIZED_FUNCTION || |
| 10545 (kind() == FUNCTION && !has_debug_break_slots())) | 10551 (kind() == FUNCTION && !has_debug_break_slots())) |
| 10546 ? instruction_start() + prologue_offset() | 10552 ? instruction_start() + prologue_offset() |
| 10547 : NULL; | 10553 : NULL; |
| 10548 } | 10554 } |
| 10549 | 10555 |
| 10550 | 10556 |
| 10551 int Code::GetAge() { | 10557 Code::Age Code::GetAge() { |
| 10552 byte* sequence = FindCodeAgeSequence(); | 10558 byte* sequence = FindCodeAgeSequence(); |
| 10553 if (sequence == NULL) { | 10559 if (sequence == NULL) { |
| 10554 return Code::kNoAge; | 10560 return Code::kNoAge; |
| 10555 } | 10561 } |
| 10556 Age age; | 10562 Age age; |
| 10557 MarkingParity parity; | 10563 MarkingParity parity; |
| 10558 GetCodeAgeAndParity(sequence, &age, &parity); | 10564 GetCodeAgeAndParity(sequence, &age, &parity); |
| 10559 return age; | 10565 return age; |
| 10560 } | 10566 } |
| 10561 | 10567 |
| (...skipping 11 matching lines...) Expand all Loading... |
| 10573 return; \ | 10579 return; \ |
| 10574 } \ | 10580 } \ |
| 10575 stub = *builtins->Make##AGE##CodeYoungAgainOddMarking(); \ | 10581 stub = *builtins->Make##AGE##CodeYoungAgainOddMarking(); \ |
| 10576 if (code == stub) { \ | 10582 if (code == stub) { \ |
| 10577 *age = k##AGE##CodeAge; \ | 10583 *age = k##AGE##CodeAge; \ |
| 10578 *parity = ODD_MARKING_PARITY; \ | 10584 *parity = ODD_MARKING_PARITY; \ |
| 10579 return; \ | 10585 return; \ |
| 10580 } | 10586 } |
| 10581 CODE_AGE_LIST(HANDLE_CODE_AGE) | 10587 CODE_AGE_LIST(HANDLE_CODE_AGE) |
| 10582 #undef HANDLE_CODE_AGE | 10588 #undef HANDLE_CODE_AGE |
| 10589 stub = *builtins->MarkCodeAsExecutedOnce(); |
| 10590 if (code == stub) { |
| 10591 // Treat that's never been executed as old immediatly. |
| 10592 *age = kIsOldCodeAge; |
| 10593 *parity = NO_MARKING_PARITY; |
| 10594 return; |
| 10595 } |
| 10596 stub = *builtins->MarkCodeAsExecutedTwice(); |
| 10597 if (code == stub) { |
| 10598 // Pre-age code that has only been executed once. |
| 10599 *age = kPreAgedCodeAge; |
| 10600 *parity = NO_MARKING_PARITY; |
| 10601 return; |
| 10602 } |
| 10583 UNREACHABLE(); | 10603 UNREACHABLE(); |
| 10584 } | 10604 } |
| 10585 | 10605 |
| 10586 | 10606 |
| 10587 Code* Code::GetCodeAgeStub(Isolate* isolate, Age age, MarkingParity parity) { | 10607 Code* Code::GetCodeAgeStub(Isolate* isolate, Age age, MarkingParity parity) { |
| 10588 Builtins* builtins = isolate->builtins(); | 10608 Builtins* builtins = isolate->builtins(); |
| 10589 switch (age) { | 10609 switch (age) { |
| 10590 #define HANDLE_CODE_AGE(AGE) \ | 10610 #define HANDLE_CODE_AGE(AGE) \ |
| 10591 case k##AGE##CodeAge: { \ | 10611 case k##AGE##CodeAge: { \ |
| 10592 Code* stub = parity == EVEN_MARKING_PARITY \ | 10612 Code* stub = parity == EVEN_MARKING_PARITY \ |
| 10593 ? *builtins->Make##AGE##CodeYoungAgainEvenMarking() \ | 10613 ? *builtins->Make##AGE##CodeYoungAgainEvenMarking() \ |
| 10594 : *builtins->Make##AGE##CodeYoungAgainOddMarking(); \ | 10614 : *builtins->Make##AGE##CodeYoungAgainOddMarking(); \ |
| 10595 return stub; \ | 10615 return stub; \ |
| 10596 } | 10616 } |
| 10597 CODE_AGE_LIST(HANDLE_CODE_AGE) | 10617 CODE_AGE_LIST(HANDLE_CODE_AGE) |
| 10598 #undef HANDLE_CODE_AGE | 10618 #undef HANDLE_CODE_AGE |
| 10619 case kNotExecutedCodeAge: { |
| 10620 ASSERT(parity == NO_MARKING_PARITY); |
| 10621 return *builtins->MarkCodeAsExecutedOnce(); |
| 10622 } |
| 10623 case kExecutedOnceCodeAge: { |
| 10624 ASSERT(parity == NO_MARKING_PARITY); |
| 10625 return *builtins->MarkCodeAsExecutedTwice(); |
| 10626 } |
| 10599 default: | 10627 default: |
| 10600 UNREACHABLE(); | 10628 UNREACHABLE(); |
| 10601 break; | 10629 break; |
| 10602 } | 10630 } |
| 10603 return NULL; | 10631 return NULL; |
| 10604 } | 10632 } |
| 10605 | 10633 |
| 10606 | 10634 |
| 10607 void Code::PrintDeoptLocation(int bailout_id) { | 10635 void Code::PrintDeoptLocation(int bailout_id) { |
| 10608 const char* last_comment = NULL; | 10636 const char* last_comment = NULL; |
| (...skipping 5652 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 16261 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16289 #define ERROR_MESSAGES_TEXTS(C, T) T, |
| 16262 static const char* error_messages_[] = { | 16290 static const char* error_messages_[] = { |
| 16263 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16291 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
| 16264 }; | 16292 }; |
| 16265 #undef ERROR_MESSAGES_TEXTS | 16293 #undef ERROR_MESSAGES_TEXTS |
| 16266 return error_messages_[reason]; | 16294 return error_messages_[reason]; |
| 16267 } | 16295 } |
| 16268 | 16296 |
| 16269 | 16297 |
| 16270 } } // namespace v8::internal | 16298 } } // namespace v8::internal |
| OLD | NEW |