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

Side by Side Diff: src/objects.cc

Issue 10837037: Age code to allow reclaiming old unexecuted functions (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Nits Created 8 years, 1 month 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
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 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 7619 matching lines...) Expand 10 before | Expand all | Expand 10 after
7630 FixedArray* code_map = FixedArray::cast(optimized_code_map()); 7630 FixedArray* code_map = FixedArray::cast(optimized_code_map());
7631 if (!bound()) { 7631 if (!bound()) {
7632 FixedArray* cached_literals = FixedArray::cast(code_map->get(index + 1)); 7632 FixedArray* cached_literals = FixedArray::cast(code_map->get(index + 1));
7633 ASSERT(cached_literals != NULL); 7633 ASSERT(cached_literals != NULL);
7634 function->set_literals(cached_literals); 7634 function->set_literals(cached_literals);
7635 } 7635 }
7636 Code* code = Code::cast(code_map->get(index)); 7636 Code* code = Code::cast(code_map->get(index));
7637 ASSERT(code != NULL); 7637 ASSERT(code != NULL);
7638 ASSERT(function->context()->native_context() == code_map->get(index - 1)); 7638 ASSERT(function->context()->native_context() == code_map->get(index - 1));
7639 function->ReplaceCode(code); 7639 function->ReplaceCode(code);
7640 code->MakeYoung();
7640 } 7641 }
7641 7642
7642 7643
7643 bool JSFunction::CompileLazy(Handle<JSFunction> function, 7644 bool JSFunction::CompileLazy(Handle<JSFunction> function,
7644 ClearExceptionFlag flag) { 7645 ClearExceptionFlag flag) {
7645 bool result = true; 7646 bool result = true;
7646 if (function->shared()->is_compiled()) { 7647 if (function->shared()->is_compiled()) {
7647 function->ReplaceCode(function->shared()->code()); 7648 function->ReplaceCode(function->shared()->code());
7648 function->shared()->set_code_age(0); 7649 function->shared()->set_code_age(0);
7649 } else { 7650 } else {
(...skipping 576 matching lines...) Expand 10 before | Expand all | Expand 10 after
8226 8227
8227 void ObjectVisitor::VisitCodeTarget(RelocInfo* rinfo) { 8228 void ObjectVisitor::VisitCodeTarget(RelocInfo* rinfo) {
8228 ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode())); 8229 ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode()));
8229 Object* target = Code::GetCodeFromTargetAddress(rinfo->target_address()); 8230 Object* target = Code::GetCodeFromTargetAddress(rinfo->target_address());
8230 Object* old_target = target; 8231 Object* old_target = target;
8231 VisitPointer(&target); 8232 VisitPointer(&target);
8232 CHECK_EQ(target, old_target); // VisitPointer doesn't change Code* *target. 8233 CHECK_EQ(target, old_target); // VisitPointer doesn't change Code* *target.
8233 } 8234 }
8234 8235
8235 8236
8237 void ObjectVisitor::VisitCodeAgeSequence(RelocInfo* rinfo) {
8238 ASSERT(RelocInfo::IsCodeAgeSequence(rinfo->rmode()));
8239 Object* stub = rinfo->code_age_stub();
8240 if (stub) {
8241 VisitPointer(&stub);
8242 }
8243 }
8244
8245
8236 void ObjectVisitor::VisitCodeEntry(Address entry_address) { 8246 void ObjectVisitor::VisitCodeEntry(Address entry_address) {
8237 Object* code = Code::GetObjectFromEntryAddress(entry_address); 8247 Object* code = Code::GetObjectFromEntryAddress(entry_address);
8238 Object* old_code = code; 8248 Object* old_code = code;
8239 VisitPointer(&code); 8249 VisitPointer(&code);
8240 if (code != old_code) { 8250 if (code != old_code) {
8241 Memory::Address_at(entry_address) = reinterpret_cast<Code*>(code)->entry(); 8251 Memory::Address_at(entry_address) = reinterpret_cast<Code*>(code)->entry();
8242 } 8252 }
8243 } 8253 }
8244 8254
8245 8255
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
8438 } 8448 }
8439 } 8449 }
8440 8450
8441 8451
8442 bool Code::allowed_in_shared_map_code_cache() { 8452 bool Code::allowed_in_shared_map_code_cache() {
8443 return is_keyed_load_stub() || is_keyed_store_stub() || 8453 return is_keyed_load_stub() || is_keyed_store_stub() ||
8444 (is_compare_ic_stub() && compare_state() == CompareIC::KNOWN_OBJECTS); 8454 (is_compare_ic_stub() && compare_state() == CompareIC::KNOWN_OBJECTS);
8445 } 8455 }
8446 8456
8447 8457
8458 void Code::MakeCodeAgeSequenceYoung(byte* sequence) {
8459 PatchPlatformCodeAge(sequence, kNoAge, NO_MARKING_PARITY);
8460 }
8461
8462
8463 void Code::MakeYoung() {
8464 byte* sequence = FindCodeAgeSequence();
8465 if (sequence != NULL) {
8466 PatchPlatformCodeAge(sequence, kNoAge, NO_MARKING_PARITY);
8467 }
8468 }
8469
8470
8471 void Code::MakeOlder(MarkingParity current_parity) {
8472 byte* sequence = FindCodeAgeSequence();
8473 if (sequence != NULL) {
8474 Age age;
8475 MarkingParity code_parity;
8476 GetCodeAgeAndParity(sequence, &age, &code_parity);
8477 if (age != kLastCodeAge && code_parity != current_parity) {
8478 PatchPlatformCodeAge(sequence, static_cast<Age>(age + 1),
8479 current_parity);
8480 }
8481 }
8482 }
8483
8484
8485 bool Code::IsOld() {
8486 byte* sequence = FindCodeAgeSequence();
8487 if (sequence == NULL) return false;
8488 Age age;
8489 MarkingParity parity;
8490 GetCodeAgeAndParity(sequence, &age, &parity);
8491 return age >= kSexagenarianCodeAge;
8492 }
8493
8494
8495 byte* Code::FindCodeAgeSequence() {
8496 if (kind() != FUNCTION && kind() != OPTIMIZED_FUNCTION) return NULL;
8497 if (strlen(FLAG_stop_at) == 0 &&
8498 !ProfileEntryHookStub::HasEntryHook() &&
8499 (kind() == FUNCTION && !has_debug_break_slots())) {
8500 return FindPlatformCodeAgeSequence();
8501 }
8502 return NULL;
8503 }
8504
8505
8506 void Code::GetCodeAgeAndParity(Code* code, Age* age,
8507 MarkingParity* parity) {
8508 Isolate* isolate = Isolate::Current();
8509 Builtins* builtins = isolate->builtins();
8510 Code* stub = NULL;
8511 #define HANDLE_CODE_AGE(AGE) \
8512 stub = *builtins->Make##AGE##CodeYoungAgainEvenMarking(); \
8513 if (code == stub) { \
8514 *age = k##AGE##CodeAge; \
8515 *parity = EVEN_MARKING_PARITY; \
8516 return; \
8517 } \
8518 stub = *builtins->Make##AGE##CodeYoungAgainOddMarking(); \
8519 if (code == stub) { \
8520 *age = k##AGE##CodeAge; \
8521 *parity = ODD_MARKING_PARITY; \
8522 return; \
8523 }
8524 CODE_AGE_LIST(HANDLE_CODE_AGE)
8525 #undef HANDLE_CODE_AGE
8526 UNREACHABLE();
8527 }
8528
8529
8530 Code* Code::GetCodeAgeStub(Age age, MarkingParity parity) {
8531 Isolate* isolate = Isolate::Current();
8532 Builtins* builtins = isolate->builtins();
8533 switch (age) {
8534 #define HANDLE_CODE_AGE(AGE) \
8535 case k##AGE##CodeAge: { \
8536 Code* stub = parity == EVEN_MARKING_PARITY \
8537 ? *builtins->Make##AGE##CodeYoungAgainEvenMarking() \
8538 : *builtins->Make##AGE##CodeYoungAgainOddMarking(); \
8539 return stub; \
8540 }
8541 CODE_AGE_LIST(HANDLE_CODE_AGE)
8542 #undef HANDLE_CODE_AGE
8543 default:
8544 UNREACHABLE();
8545 break;
8546 }
8547 return NULL;
8548 }
8549
8550
8448 #ifdef ENABLE_DISASSEMBLER 8551 #ifdef ENABLE_DISASSEMBLER
8449 8552
8450 void DeoptimizationInputData::DeoptimizationInputDataPrint(FILE* out) { 8553 void DeoptimizationInputData::DeoptimizationInputDataPrint(FILE* out) {
8451 disasm::NameConverter converter; 8554 disasm::NameConverter converter;
8452 int deopt_count = DeoptCount(); 8555 int deopt_count = DeoptCount();
8453 PrintF(out, "Deoptimization Input Data (deopt points = %d)\n", deopt_count); 8556 PrintF(out, "Deoptimization Input Data (deopt points = %d)\n", deopt_count);
8454 if (0 == deopt_count) return; 8557 if (0 == deopt_count) return;
8455 8558
8456 PrintF(out, "%6s %6s %6s %6s %12s\n", "index", "ast id", "argc", "pc", 8559 PrintF(out, "%6s %6s %6s %6s %12s\n", "index", "ast id", "argc", "pc",
8457 FLAG_print_code_verbose ? "commands" : ""); 8560 FLAG_print_code_verbose ? "commands" : "");
(...skipping 5015 matching lines...) Expand 10 before | Expand all | Expand 10 after
13473 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 13576 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
13474 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 13577 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
13475 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 13578 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
13476 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 13579 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
13477 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 13580 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
13478 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 13581 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
13479 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 13582 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
13480 } 13583 }
13481 13584
13482 } } // namespace v8::internal 13585 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698