Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(604)

Side by Side Diff: src/objects.cc

Issue 23480031: Enable preaging of code objects when --optimize-for-size. (Closed) Base URL: https://v8.googlecode.com/svn/trunk
Patch Set: bool -> enum Created 7 years, 2 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/objects.h ('k') | src/serialize.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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 10349 matching lines...) Expand 10 before | Expand all | Expand 10 after
10360 } else if (RelocInfo::IsCodeTarget(mode)) { 10360 } else if (RelocInfo::IsCodeTarget(mode)) {
10361 // rewrite code handles in inline cache targets to direct 10361 // rewrite code handles in inline cache targets to direct
10362 // pointers to the first instruction in the code object 10362 // pointers to the first instruction in the code object
10363 Handle<Object> p = it.rinfo()->target_object_handle(origin); 10363 Handle<Object> p = it.rinfo()->target_object_handle(origin);
10364 Code* code = Code::cast(*p); 10364 Code* code = Code::cast(*p);
10365 it.rinfo()->set_target_address(code->instruction_start(), 10365 it.rinfo()->set_target_address(code->instruction_start(),
10366 SKIP_WRITE_BARRIER); 10366 SKIP_WRITE_BARRIER);
10367 } else if (RelocInfo::IsRuntimeEntry(mode)) { 10367 } else if (RelocInfo::IsRuntimeEntry(mode)) {
10368 Address p = it.rinfo()->target_runtime_entry(origin); 10368 Address p = it.rinfo()->target_runtime_entry(origin);
10369 it.rinfo()->set_target_runtime_entry(p, SKIP_WRITE_BARRIER); 10369 it.rinfo()->set_target_runtime_entry(p, SKIP_WRITE_BARRIER);
10370 } else if (mode == RelocInfo::CODE_AGE_SEQUENCE) {
10371 Handle<Object> p = it.rinfo()->code_age_stub_handle(origin);
10372 Code* code = Code::cast(*p);
10373 it.rinfo()->set_code_age_stub(code);
10370 } else { 10374 } else {
10371 it.rinfo()->apply(delta); 10375 it.rinfo()->apply(delta);
10372 } 10376 }
10373 } 10377 }
10374 CPU::FlushICache(instruction_start(), instruction_size()); 10378 CPU::FlushICache(instruction_start(), instruction_size());
10375 } 10379 }
10376 10380
10377 10381
10378 // Locate the source position which is closest to the address in the code. This 10382 // Locate the source position which is closest to the address in the code. This
10379 // is using the source position information embedded in the relocation info. 10383 // is using the source position information embedded in the relocation info.
(...skipping 221 matching lines...) Expand 10 before | Expand all | Expand 10 after
10601 } 10605 }
10602 return BailoutId::None(); 10606 return BailoutId::None();
10603 } 10607 }
10604 10608
10605 10609
10606 void Code::MakeCodeAgeSequenceYoung(byte* sequence, Isolate* isolate) { 10610 void Code::MakeCodeAgeSequenceYoung(byte* sequence, Isolate* isolate) {
10607 PatchPlatformCodeAge(isolate, sequence, kNoAge, NO_MARKING_PARITY); 10611 PatchPlatformCodeAge(isolate, sequence, kNoAge, NO_MARKING_PARITY);
10608 } 10612 }
10609 10613
10610 10614
10615 void Code::MarkCodeAsExecuted(byte* sequence, Isolate* isolate) {
10616 PatchPlatformCodeAge(isolate, sequence, kExecutedOnceCodeAge,
10617 NO_MARKING_PARITY);
10618 }
10619
10620
10611 void Code::MakeOlder(MarkingParity current_parity) { 10621 void Code::MakeOlder(MarkingParity current_parity) {
10612 byte* sequence = FindCodeAgeSequence(); 10622 byte* sequence = FindCodeAgeSequence();
10613 if (sequence != NULL) { 10623 if (sequence != NULL) {
10614 Age age; 10624 Age age;
10615 MarkingParity code_parity; 10625 MarkingParity code_parity;
10616 GetCodeAgeAndParity(sequence, &age, &code_parity); 10626 GetCodeAgeAndParity(sequence, &age, &code_parity);
10617 if (age != kLastCodeAge && code_parity != current_parity) { 10627 if (age != kLastCodeAge && code_parity != current_parity) {
10618 PatchPlatformCodeAge(GetIsolate(), 10628 PatchPlatformCodeAge(GetIsolate(),
10619 sequence, 10629 sequence,
10620 static_cast<Age>(age + 1), 10630 static_cast<Age>(age + 1),
10621 current_parity); 10631 current_parity);
10622 } 10632 }
10623 } 10633 }
10624 } 10634 }
10625 10635
10626 10636
10627 bool Code::IsOld() { 10637 bool Code::IsOld() {
10628 byte* sequence = FindCodeAgeSequence(); 10638 Age age = GetAge();
10629 if (sequence == NULL) return false; 10639 return age >= kIsOldCodeAge;
10630 Age age;
10631 MarkingParity parity;
10632 GetCodeAgeAndParity(sequence, &age, &parity);
10633 return age >= kSexagenarianCodeAge;
10634 } 10640 }
10635 10641
10636 10642
10637 byte* Code::FindCodeAgeSequence() { 10643 byte* Code::FindCodeAgeSequence() {
10638 return FLAG_age_code && 10644 return FLAG_age_code &&
10639 prologue_offset() != kPrologueOffsetNotSet && 10645 prologue_offset() != Code::kPrologueOffsetNotSet &&
10640 (kind() == OPTIMIZED_FUNCTION || 10646 (kind() == OPTIMIZED_FUNCTION ||
10641 (kind() == FUNCTION && !has_debug_break_slots())) 10647 (kind() == FUNCTION && !has_debug_break_slots()))
10642 ? instruction_start() + prologue_offset() 10648 ? instruction_start() + prologue_offset()
10643 : NULL; 10649 : NULL;
10644 } 10650 }
10645 10651
10646 10652
10647 int Code::GetAge() { 10653 Code::Age Code::GetAge() {
10648 byte* sequence = FindCodeAgeSequence(); 10654 byte* sequence = FindCodeAgeSequence();
10649 if (sequence == NULL) { 10655 if (sequence == NULL) {
10650 return Code::kNoAge; 10656 return Code::kNoAge;
10651 } 10657 }
10652 Age age; 10658 Age age;
10653 MarkingParity parity; 10659 MarkingParity parity;
10654 GetCodeAgeAndParity(sequence, &age, &parity); 10660 GetCodeAgeAndParity(sequence, &age, &parity);
10655 return age; 10661 return age;
10656 } 10662 }
10657 10663
(...skipping 11 matching lines...) Expand all
10669 return; \ 10675 return; \
10670 } \ 10676 } \
10671 stub = *builtins->Make##AGE##CodeYoungAgainOddMarking(); \ 10677 stub = *builtins->Make##AGE##CodeYoungAgainOddMarking(); \
10672 if (code == stub) { \ 10678 if (code == stub) { \
10673 *age = k##AGE##CodeAge; \ 10679 *age = k##AGE##CodeAge; \
10674 *parity = ODD_MARKING_PARITY; \ 10680 *parity = ODD_MARKING_PARITY; \
10675 return; \ 10681 return; \
10676 } 10682 }
10677 CODE_AGE_LIST(HANDLE_CODE_AGE) 10683 CODE_AGE_LIST(HANDLE_CODE_AGE)
10678 #undef HANDLE_CODE_AGE 10684 #undef HANDLE_CODE_AGE
10685 stub = *builtins->MarkCodeAsExecutedOnce();
10686 if (code == stub) {
10687 // Treat that's never been executed as old immediatly.
10688 *age = kIsOldCodeAge;
10689 *parity = NO_MARKING_PARITY;
10690 return;
10691 }
10692 stub = *builtins->MarkCodeAsExecutedTwice();
10693 if (code == stub) {
10694 // Pre-age code that has only been executed once.
10695 *age = kPreAgedCodeAge;
10696 *parity = NO_MARKING_PARITY;
10697 return;
10698 }
10679 UNREACHABLE(); 10699 UNREACHABLE();
10680 } 10700 }
10681 10701
10682 10702
10683 Code* Code::GetCodeAgeStub(Isolate* isolate, Age age, MarkingParity parity) { 10703 Code* Code::GetCodeAgeStub(Isolate* isolate, Age age, MarkingParity parity) {
10684 Builtins* builtins = isolate->builtins(); 10704 Builtins* builtins = isolate->builtins();
10685 switch (age) { 10705 switch (age) {
10686 #define HANDLE_CODE_AGE(AGE) \ 10706 #define HANDLE_CODE_AGE(AGE) \
10687 case k##AGE##CodeAge: { \ 10707 case k##AGE##CodeAge: { \
10688 Code* stub = parity == EVEN_MARKING_PARITY \ 10708 Code* stub = parity == EVEN_MARKING_PARITY \
10689 ? *builtins->Make##AGE##CodeYoungAgainEvenMarking() \ 10709 ? *builtins->Make##AGE##CodeYoungAgainEvenMarking() \
10690 : *builtins->Make##AGE##CodeYoungAgainOddMarking(); \ 10710 : *builtins->Make##AGE##CodeYoungAgainOddMarking(); \
10691 return stub; \ 10711 return stub; \
10692 } 10712 }
10693 CODE_AGE_LIST(HANDLE_CODE_AGE) 10713 CODE_AGE_LIST(HANDLE_CODE_AGE)
10694 #undef HANDLE_CODE_AGE 10714 #undef HANDLE_CODE_AGE
10715 case kNotExecutedCodeAge: {
10716 ASSERT(parity == NO_MARKING_PARITY);
10717 return *builtins->MarkCodeAsExecutedOnce();
10718 }
10719 case kExecutedOnceCodeAge: {
10720 ASSERT(parity == NO_MARKING_PARITY);
10721 return *builtins->MarkCodeAsExecutedTwice();
10722 }
10695 default: 10723 default:
10696 UNREACHABLE(); 10724 UNREACHABLE();
10697 break; 10725 break;
10698 } 10726 }
10699 return NULL; 10727 return NULL;
10700 } 10728 }
10701 10729
10702 10730
10703 void Code::PrintDeoptLocation(int bailout_id) { 10731 void Code::PrintDeoptLocation(int bailout_id) {
10704 const char* last_comment = NULL; 10732 const char* last_comment = NULL;
(...skipping 5664 matching lines...) Expand 10 before | Expand all | Expand 10 after
16369 #define ERROR_MESSAGES_TEXTS(C, T) T, 16397 #define ERROR_MESSAGES_TEXTS(C, T) T,
16370 static const char* error_messages_[] = { 16398 static const char* error_messages_[] = {
16371 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS) 16399 ERROR_MESSAGES_LIST(ERROR_MESSAGES_TEXTS)
16372 }; 16400 };
16373 #undef ERROR_MESSAGES_TEXTS 16401 #undef ERROR_MESSAGES_TEXTS
16374 return error_messages_[reason]; 16402 return error_messages_[reason];
16375 } 16403 }
16376 16404
16377 16405
16378 } } // namespace v8::internal 16406 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/objects.h ('k') | src/serialize.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698