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 10147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10158 } else if (RelocInfo::IsCodeTarget(mode)) { | 10158 } else if (RelocInfo::IsCodeTarget(mode)) { |
10159 // rewrite code handles in inline cache targets to direct | 10159 // rewrite code handles in inline cache targets to direct |
10160 // pointers to the first instruction in the code object | 10160 // pointers to the first instruction in the code object |
10161 Handle<Object> p = it.rinfo()->target_object_handle(origin); | 10161 Handle<Object> p = it.rinfo()->target_object_handle(origin); |
10162 Code* code = Code::cast(*p); | 10162 Code* code = Code::cast(*p); |
10163 it.rinfo()->set_target_address(code->instruction_start(), | 10163 it.rinfo()->set_target_address(code->instruction_start(), |
10164 SKIP_WRITE_BARRIER); | 10164 SKIP_WRITE_BARRIER); |
10165 } else if (RelocInfo::IsRuntimeEntry(mode)) { | 10165 } else if (RelocInfo::IsRuntimeEntry(mode)) { |
10166 Address p = it.rinfo()->target_runtime_entry(origin); | 10166 Address p = it.rinfo()->target_runtime_entry(origin); |
10167 it.rinfo()->set_target_runtime_entry(p, SKIP_WRITE_BARRIER); | 10167 it.rinfo()->set_target_runtime_entry(p, SKIP_WRITE_BARRIER); |
| 10168 } else if (mode == RelocInfo::CODE_AGE_SEQUENCE) { |
| 10169 Handle<Object> p = it.rinfo()->code_age_stub_handle(origin); |
| 10170 Code* code = Code::cast(*p); |
| 10171 it.rinfo()->set_code_age_stub(code); |
10168 } else { | 10172 } else { |
10169 it.rinfo()->apply(delta); | 10173 it.rinfo()->apply(delta); |
10170 } | 10174 } |
10171 } | 10175 } |
10172 CPU::FlushICache(instruction_start(), instruction_size()); | 10176 CPU::FlushICache(instruction_start(), instruction_size()); |
10173 } | 10177 } |
10174 | 10178 |
10175 | 10179 |
10176 // Locate the source position which is closest to the address in the code. This | 10180 // Locate the source position which is closest to the address in the code. This |
10177 // is using the source position information embedded in the relocation info. | 10181 // is using the source position information embedded in the relocation info. |
(...skipping 224 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
10402 (is_compare_ic_stub() && | 10406 (is_compare_ic_stub() && |
10403 ICCompareStub::CompareState(stub_info()) == CompareIC::KNOWN_OBJECT); | 10407 ICCompareStub::CompareState(stub_info()) == CompareIC::KNOWN_OBJECT); |
10404 } | 10408 } |
10405 | 10409 |
10406 | 10410 |
10407 void Code::MakeCodeAgeSequenceYoung(byte* sequence, Isolate* isolate) { | 10411 void Code::MakeCodeAgeSequenceYoung(byte* sequence, Isolate* isolate) { |
10408 PatchPlatformCodeAge(isolate, sequence, kNoAge, NO_MARKING_PARITY); | 10412 PatchPlatformCodeAge(isolate, sequence, kNoAge, NO_MARKING_PARITY); |
10409 } | 10413 } |
10410 | 10414 |
10411 | 10415 |
| 10416 void Code::MarkCodeAsExecuted(byte* sequence, Isolate* isolate) { |
| 10417 PatchPlatformCodeAge(isolate, sequence, kExecutedOnceCodeAge, |
| 10418 NO_MARKING_PARITY); |
| 10419 } |
| 10420 |
| 10421 |
10412 void Code::MakeOlder(MarkingParity current_parity) { | 10422 void Code::MakeOlder(MarkingParity current_parity) { |
10413 byte* sequence = FindCodeAgeSequence(); | 10423 byte* sequence = FindCodeAgeSequence(); |
10414 if (sequence != NULL) { | 10424 if (sequence != NULL) { |
10415 Age age; | 10425 Age age; |
10416 MarkingParity code_parity; | 10426 MarkingParity code_parity; |
10417 GetCodeAgeAndParity(sequence, &age, &code_parity); | 10427 GetCodeAgeAndParity(sequence, &age, &code_parity); |
10418 if (age != kLastCodeAge && code_parity != current_parity) { | 10428 if (age != kLastCodeAge && code_parity != current_parity) { |
10419 PatchPlatformCodeAge(GetIsolate(), | 10429 PatchPlatformCodeAge(GetIsolate(), |
10420 sequence, | 10430 sequence, |
10421 static_cast<Age>(age + 1), | 10431 static_cast<Age>(age + 1), |
10422 current_parity); | 10432 current_parity); |
10423 } | 10433 } |
10424 } | 10434 } |
10425 } | 10435 } |
10426 | 10436 |
10427 | 10437 |
10428 bool Code::IsOld() { | 10438 bool Code::IsOld() { |
10429 byte* sequence = FindCodeAgeSequence(); | 10439 Age age = GetAge(); |
10430 if (sequence == NULL) return false; | 10440 return age >= kIsOldCodeAge; |
10431 Age age; | |
10432 MarkingParity parity; | |
10433 GetCodeAgeAndParity(sequence, &age, &parity); | |
10434 return age >= kSexagenarianCodeAge; | |
10435 } | 10441 } |
10436 | 10442 |
10437 | 10443 |
10438 byte* Code::FindCodeAgeSequence() { | 10444 byte* Code::FindCodeAgeSequence() { |
10439 return FLAG_age_code && | 10445 return FLAG_age_code && |
10440 prologue_offset() != kPrologueOffsetNotSet && | 10446 prologue_offset() != kPrologueOffsetNotSet && |
10441 (kind() == OPTIMIZED_FUNCTION || | 10447 (kind() == OPTIMIZED_FUNCTION || |
10442 (kind() == FUNCTION && !has_debug_break_slots())) | 10448 (kind() == FUNCTION && !has_debug_break_slots())) |
10443 ? instruction_start() + prologue_offset() | 10449 ? instruction_start() + prologue_offset() |
10444 : NULL; | 10450 : NULL; |
10445 } | 10451 } |
10446 | 10452 |
10447 | 10453 |
10448 int Code::GetAge() { | 10454 Code::Age Code::GetAge() { |
10449 byte* sequence = FindCodeAgeSequence(); | 10455 byte* sequence = FindCodeAgeSequence(); |
10450 if (sequence == NULL) { | 10456 if (sequence == NULL) { |
10451 return Code::kNoAge; | 10457 return Code::kNoAge; |
10452 } | 10458 } |
10453 Age age; | 10459 Age age; |
10454 MarkingParity parity; | 10460 MarkingParity parity; |
10455 GetCodeAgeAndParity(sequence, &age, &parity); | 10461 GetCodeAgeAndParity(sequence, &age, &parity); |
10456 return age; | 10462 return age; |
10457 } | 10463 } |
10458 | 10464 |
(...skipping 11 matching lines...) Expand all Loading... |
10470 return; \ | 10476 return; \ |
10471 } \ | 10477 } \ |
10472 stub = *builtins->Make##AGE##CodeYoungAgainOddMarking(); \ | 10478 stub = *builtins->Make##AGE##CodeYoungAgainOddMarking(); \ |
10473 if (code == stub) { \ | 10479 if (code == stub) { \ |
10474 *age = k##AGE##CodeAge; \ | 10480 *age = k##AGE##CodeAge; \ |
10475 *parity = ODD_MARKING_PARITY; \ | 10481 *parity = ODD_MARKING_PARITY; \ |
10476 return; \ | 10482 return; \ |
10477 } | 10483 } |
10478 CODE_AGE_LIST(HANDLE_CODE_AGE) | 10484 CODE_AGE_LIST(HANDLE_CODE_AGE) |
10479 #undef HANDLE_CODE_AGE | 10485 #undef HANDLE_CODE_AGE |
| 10486 stub = *builtins->MarkCodeAsExecutedOnce(); |
| 10487 if (code == stub) { |
| 10488 // Treat that's never been executed as old immediatly. |
| 10489 *age = kIsOldCodeAge; |
| 10490 *parity = NO_MARKING_PARITY; |
| 10491 return; |
| 10492 } |
| 10493 stub = *builtins->MarkCodeAsExecutedTwice(); |
| 10494 if (code == stub) { |
| 10495 // Pre-age code that has only been executed once. |
| 10496 *age = kPreAgedCodeAge; |
| 10497 *parity = NO_MARKING_PARITY; |
| 10498 return; |
| 10499 } |
10480 UNREACHABLE(); | 10500 UNREACHABLE(); |
10481 } | 10501 } |
10482 | 10502 |
10483 | 10503 |
10484 Code* Code::GetCodeAgeStub(Isolate* isolate, Age age, MarkingParity parity) { | 10504 Code* Code::GetCodeAgeStub(Isolate* isolate, Age age, MarkingParity parity) { |
10485 Builtins* builtins = isolate->builtins(); | 10505 Builtins* builtins = isolate->builtins(); |
10486 switch (age) { | 10506 switch (age) { |
10487 #define HANDLE_CODE_AGE(AGE) \ | 10507 #define HANDLE_CODE_AGE(AGE) \ |
10488 case k##AGE##CodeAge: { \ | 10508 case k##AGE##CodeAge: { \ |
10489 Code* stub = parity == EVEN_MARKING_PARITY \ | 10509 Code* stub = parity == EVEN_MARKING_PARITY \ |
10490 ? *builtins->Make##AGE##CodeYoungAgainEvenMarking() \ | 10510 ? *builtins->Make##AGE##CodeYoungAgainEvenMarking() \ |
10491 : *builtins->Make##AGE##CodeYoungAgainOddMarking(); \ | 10511 : *builtins->Make##AGE##CodeYoungAgainOddMarking(); \ |
10492 return stub; \ | 10512 return stub; \ |
10493 } | 10513 } |
10494 CODE_AGE_LIST(HANDLE_CODE_AGE) | 10514 CODE_AGE_LIST(HANDLE_CODE_AGE) |
10495 #undef HANDLE_CODE_AGE | 10515 #undef HANDLE_CODE_AGE |
| 10516 case kNotExecutedCodeAge: { |
| 10517 ASSERT(parity == NO_MARKING_PARITY); |
| 10518 return *builtins->MarkCodeAsExecutedOnce(); |
| 10519 } |
| 10520 case kExecutedOnceCodeAge: { |
| 10521 ASSERT(parity == NO_MARKING_PARITY); |
| 10522 return *builtins->MarkCodeAsExecutedTwice(); |
| 10523 } |
10496 default: | 10524 default: |
10497 UNREACHABLE(); | 10525 UNREACHABLE(); |
10498 break; | 10526 break; |
10499 } | 10527 } |
10500 return NULL; | 10528 return NULL; |
10501 } | 10529 } |
10502 | 10530 |
10503 | 10531 |
10504 void Code::PrintDeoptLocation(int bailout_id) { | 10532 void Code::PrintDeoptLocation(int bailout_id) { |
10505 const char* last_comment = NULL; | 10533 const char* last_comment = NULL; |
(...skipping 5613 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
16119 #define ERROR_MESSAGES_TEXTS(C, T) T, | 16147 #define ERROR_MESSAGES_TEXTS(C, T) T, |
16120 static const char* error_messages_[] = { | 16148 static const char* error_messages_[] = { |
16121 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) | 16149 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) |
16122 }; | 16150 }; |
16123 #undef ERROR_MESSAGES_TEXTS | 16151 #undef ERROR_MESSAGES_TEXTS |
16124 return error_messages_[reason]; | 16152 return error_messages_[reason]; |
16125 } | 16153 } |
16126 | 16154 |
16127 | 16155 |
16128 } } // namespace v8::internal | 16156 } } // namespace v8::internal |
OLD | NEW |