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

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: Review feedback Created 8 years, 3 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
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 7670 matching lines...) Expand 10 before | Expand all | Expand 10 after
7681 FixedArray* code_map = FixedArray::cast(optimized_code_map()); 7681 FixedArray* code_map = FixedArray::cast(optimized_code_map());
7682 if (!bound()) { 7682 if (!bound()) {
7683 FixedArray* cached_literals = FixedArray::cast(code_map->get(index + 1)); 7683 FixedArray* cached_literals = FixedArray::cast(code_map->get(index + 1));
7684 ASSERT(cached_literals != NULL); 7684 ASSERT(cached_literals != NULL);
7685 function->set_literals(cached_literals); 7685 function->set_literals(cached_literals);
7686 } 7686 }
7687 Code* code = Code::cast(code_map->get(index)); 7687 Code* code = Code::cast(code_map->get(index));
7688 ASSERT(code != NULL); 7688 ASSERT(code != NULL);
7689 ASSERT(function->context()->native_context() == code_map->get(index - 1)); 7689 ASSERT(function->context()->native_context() == code_map->get(index - 1));
7690 function->ReplaceCode(code); 7690 function->ReplaceCode(code);
7691 code->MakeYoung();
7691 } 7692 }
7692 7693
7693 7694
7694 bool JSFunction::CompileLazy(Handle<JSFunction> function, 7695 bool JSFunction::CompileLazy(Handle<JSFunction> function,
7695 ClearExceptionFlag flag) { 7696 ClearExceptionFlag flag) {
7696 bool result = true; 7697 bool result = true;
7697 if (function->shared()->is_compiled()) { 7698 if (function->shared()->is_compiled()) {
7698 function->ReplaceCode(function->shared()->code()); 7699 function->ReplaceCode(function->shared()->code());
7699 function->shared()->set_code_age(0);
7700 } else { 7700 } else {
7701 ASSERT(function->shared()->allows_lazy_compilation()); 7701 ASSERT(function->shared()->allows_lazy_compilation());
7702 CompilationInfoWithZone info(function); 7702 CompilationInfoWithZone info(function);
7703 result = CompileLazyHelper(&info, flag); 7703 result = CompileLazyHelper(&info, flag);
7704 ASSERT(!result || function->is_compiled()); 7704 ASSERT(!result || function->is_compiled());
7705 } 7705 }
7706 return result; 7706 return result;
7707 } 7707 }
7708 7708
7709 7709
(...skipping 567 matching lines...) Expand 10 before | Expand all | Expand 10 after
8277 8277
8278 void ObjectVisitor::VisitCodeTarget(RelocInfo* rinfo) { 8278 void ObjectVisitor::VisitCodeTarget(RelocInfo* rinfo) {
8279 ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode())); 8279 ASSERT(RelocInfo::IsCodeTarget(rinfo->rmode()));
8280 Object* target = Code::GetCodeFromTargetAddress(rinfo->target_address()); 8280 Object* target = Code::GetCodeFromTargetAddress(rinfo->target_address());
8281 Object* old_target = target; 8281 Object* old_target = target;
8282 VisitPointer(&target); 8282 VisitPointer(&target);
8283 CHECK_EQ(target, old_target); // VisitPointer doesn't change Code* *target. 8283 CHECK_EQ(target, old_target); // VisitPointer doesn't change Code* *target.
8284 } 8284 }
8285 8285
8286 8286
8287 void ObjectVisitor::VisitCodeAgeSequence(RelocInfo* rinfo) {
8288 ASSERT(RelocInfo::IsCodeAgeSequence(rinfo->rmode()));
8289 Object* stub = rinfo->code_age_stub();
8290 if (stub) {
8291 VisitPointer(&stub);
8292 }
8293 }
8294
8295
8287 void ObjectVisitor::VisitCodeEntry(Address entry_address) { 8296 void ObjectVisitor::VisitCodeEntry(Address entry_address) {
8288 Object* code = Code::GetObjectFromEntryAddress(entry_address); 8297 Object* code = Code::GetObjectFromEntryAddress(entry_address);
8289 Object* old_code = code; 8298 Object* old_code = code;
8290 VisitPointer(&code); 8299 VisitPointer(&code);
8291 if (code != old_code) { 8300 if (code != old_code) {
8292 Memory::Address_at(entry_address) = reinterpret_cast<Code*>(code)->entry(); 8301 Memory::Address_at(entry_address) = reinterpret_cast<Code*>(code)->entry();
8293 } 8302 }
8294 } 8303 }
8295 8304
8296 8305
(...skipping 192 matching lines...) Expand 10 before | Expand all | Expand 10 after
8489 } 8498 }
8490 } 8499 }
8491 8500
8492 8501
8493 bool Code::allowed_in_shared_map_code_cache() { 8502 bool Code::allowed_in_shared_map_code_cache() {
8494 return is_keyed_load_stub() || is_keyed_store_stub() || 8503 return is_keyed_load_stub() || is_keyed_store_stub() ||
8495 (is_compare_ic_stub() && compare_state() == CompareIC::KNOWN_OBJECTS); 8504 (is_compare_ic_stub() && compare_state() == CompareIC::KNOWN_OBJECTS);
8496 } 8505 }
8497 8506
8498 8507
8508 void Code::MakeCodeAgeSequenceYoung(byte* sequence) {
8509 PatchPlatformCodeAge(sequence, kNoAge, NO_MARKING_PARITY);
8510 }
8511
8512
8513 void Code::MakeYoung() {
8514 byte* sequence = FindCodeAgeSequence();
8515 if (sequence != NULL) {
8516 PatchPlatformCodeAge(sequence, kNoAge, NO_MARKING_PARITY);
8517 }
8518 }
8519
8520
8521 void Code::MakeOlder(MarkingParity current_parity) {
8522 byte* sequence = FindCodeAgeSequence();
8523 if (sequence != NULL) {
8524 Age age;
8525 MarkingParity code_parity;
8526 GetCodeAgeAndParity(sequence, &age, &code_parity);
8527 if (age != kLastCodeAge && code_parity != current_parity) {
8528 PatchPlatformCodeAge(sequence, static_cast<Age>(age + 1),
8529 current_parity);
8530 }
8531 }
8532 }
8533
8534
8535 bool Code::IsOld() {
8536 byte* sequence = FindCodeAgeSequence();
8537 if (sequence == NULL) return false;
8538 Age age;
8539 MarkingParity parity;
8540 GetCodeAgeAndParity(sequence, &age, &parity);
8541 return age >= kSexagenarianCodeAge;
8542 }
8543
8544
8545 byte* Code::FindCodeAgeSequence() {
8546 if (kind() != FUNCTION && kind() != OPTIMIZED_FUNCTION) return NULL;
8547 if (strlen(FLAG_stop_at) == 0 &&
8548 !ProfileEntryHookStub::HasEntryHook() &&
8549 (kind() == FUNCTION && !has_debug_break_slots())) {
8550 return FindPlatformCodeAgeSequence();
8551 }
8552 return NULL;
8553 }
8554
8555
8556 void Code::GetCodeAgeAndParity(Code* code, Age* age,
8557 MarkingParity* parity) {
8558 Isolate* isolate = Isolate::Current();
8559 Builtins* builtins = isolate->builtins();
8560 Code* stub = NULL;
8561 #define HANDLE_CODE_AGE(AGE) \
8562 stub = *builtins->Make##AGE##CodeYoungAgainEvenMarking(); \
8563 if (code == stub) { \
8564 *age = k##AGE##CodeAge; \
8565 *parity = EVEN_MARKING_PARITY; \
8566 return; \
8567 } \
8568 stub = *builtins->Make##AGE##CodeYoungAgainOddMarking(); \
8569 if (code == stub) { \
8570 *age = k##AGE##CodeAge; \
8571 *parity = ODD_MARKING_PARITY; \
8572 return; \
8573 }
8574 CODE_AGE_LIST(HANDLE_CODE_AGE)
8575 #undef HANDLE_CODE_AGE
8576 UNREACHABLE();
8577 }
8578
8579
8580 Code* Code::GetCodeAgeStub(Age age, MarkingParity parity) {
8581 Isolate* isolate = Isolate::Current();
8582 Builtins* builtins = isolate->builtins();
8583 switch (age) {
8584 #define HANDLE_CODE_AGE(AGE) \
8585 case k##AGE##CodeAge: { \
8586 Code* stub = parity == EVEN_MARKING_PARITY \
8587 ? *builtins->Make##AGE##CodeYoungAgainEvenMarking() \
8588 : *builtins->Make##AGE##CodeYoungAgainOddMarking(); \
8589 return stub; \
8590 }
8591 CODE_AGE_LIST(HANDLE_CODE_AGE)
8592 #undef HANDLE_CODE_AGE
8593 default:
8594 UNREACHABLE();
8595 break;
8596 }
8597 return NULL;
8598 }
8599
8600
8499 #ifdef ENABLE_DISASSEMBLER 8601 #ifdef ENABLE_DISASSEMBLER
8500 8602
8501 void DeoptimizationInputData::DeoptimizationInputDataPrint(FILE* out) { 8603 void DeoptimizationInputData::DeoptimizationInputDataPrint(FILE* out) {
8502 disasm::NameConverter converter; 8604 disasm::NameConverter converter;
8503 int deopt_count = DeoptCount(); 8605 int deopt_count = DeoptCount();
8504 PrintF(out, "Deoptimization Input Data (deopt points = %d)\n", deopt_count); 8606 PrintF(out, "Deoptimization Input Data (deopt points = %d)\n", deopt_count);
8505 if (0 == deopt_count) return; 8607 if (0 == deopt_count) return;
8506 8608
8507 PrintF(out, "%6s %6s %6s %6s %12s\n", "index", "ast id", "argc", "pc", 8609 PrintF(out, "%6s %6s %6s %6s %12s\n", "index", "ast id", "argc", "pc",
8508 FLAG_print_code_verbose ? "commands" : ""); 8610 FLAG_print_code_verbose ? "commands" : "");
(...skipping 4993 matching lines...) Expand 10 before | Expand all | Expand 10 after
13502 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER); 13604 set_year(Smi::FromInt(year), SKIP_WRITE_BARRIER);
13503 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER); 13605 set_month(Smi::FromInt(month), SKIP_WRITE_BARRIER);
13504 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER); 13606 set_day(Smi::FromInt(day), SKIP_WRITE_BARRIER);
13505 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER); 13607 set_weekday(Smi::FromInt(weekday), SKIP_WRITE_BARRIER);
13506 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER); 13608 set_hour(Smi::FromInt(hour), SKIP_WRITE_BARRIER);
13507 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER); 13609 set_min(Smi::FromInt(min), SKIP_WRITE_BARRIER);
13508 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER); 13610 set_sec(Smi::FromInt(sec), SKIP_WRITE_BARRIER);
13509 } 13611 }
13510 13612
13511 } } // namespace v8::internal 13613 } } // namespace v8::internal
OLDNEW
« src/mark-compact.cc ('K') | « src/objects.h ('k') | src/objects-inl.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698