Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 218 Serializer::enabled() || target->ic_age() != heap->global_ic_age())) { | 218 Serializer::enabled() || target->ic_age() != heap->global_ic_age())) { |
| 219 IC::Clear(rinfo->pc()); | 219 IC::Clear(rinfo->pc()); |
| 220 target = Code::GetCodeFromTargetAddress(rinfo->target_address()); | 220 target = Code::GetCodeFromTargetAddress(rinfo->target_address()); |
| 221 } | 221 } |
| 222 heap->mark_compact_collector()->RecordRelocSlot(rinfo, target); | 222 heap->mark_compact_collector()->RecordRelocSlot(rinfo, target); |
| 223 StaticVisitor::MarkObject(heap, target); | 223 StaticVisitor::MarkObject(heap, target); |
| 224 } | 224 } |
| 225 | 225 |
| 226 | 226 |
| 227 template<typename StaticVisitor> | 227 template<typename StaticVisitor> |
| 228 void StaticMarkingVisitor<StaticVisitor>::VisitCodeAgeSequence( | |
| 229 Heap* heap, RelocInfo* rinfo) { | |
| 230 ASSERT(RelocInfo::IsCodeAgeSequence(rinfo->rmode())); | |
| 231 Code* target = rinfo->code_age_stub(); | |
| 232 ASSERT(target != NULL); | |
| 233 heap->mark_compact_collector()->RecordRelocSlot(rinfo, target); | |
| 234 StaticVisitor::MarkObject(heap, target); | |
| 235 } | |
| 236 | |
| 237 | |
| 238 template<typename StaticVisitor> | |
| 228 void StaticMarkingVisitor<StaticVisitor>::VisitNativeContext( | 239 void StaticMarkingVisitor<StaticVisitor>::VisitNativeContext( |
| 229 Map* map, HeapObject* object) { | 240 Map* map, HeapObject* object) { |
| 230 FixedBodyVisitor<StaticVisitor, | 241 FixedBodyVisitor<StaticVisitor, |
| 231 Context::MarkCompactBodyDescriptor, | 242 Context::MarkCompactBodyDescriptor, |
| 232 void>::Visit(map, object); | 243 void>::Visit(map, object); |
| 233 | 244 |
| 234 MarkCompactCollector* collector = map->GetHeap()->mark_compact_collector(); | 245 MarkCompactCollector* collector = map->GetHeap()->mark_compact_collector(); |
| 235 for (int idx = Context::FIRST_WEAK_SLOT; | 246 for (int idx = Context::FIRST_WEAK_SLOT; |
| 236 idx < Context::NATIVE_CONTEXT_SLOTS; | 247 idx < Context::NATIVE_CONTEXT_SLOTS; |
| 237 ++idx) { | 248 ++idx) { |
| (...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 270 | 281 |
| 271 template<typename StaticVisitor> | 282 template<typename StaticVisitor> |
| 272 void StaticMarkingVisitor<StaticVisitor>::VisitCode( | 283 void StaticMarkingVisitor<StaticVisitor>::VisitCode( |
| 273 Map* map, HeapObject* object) { | 284 Map* map, HeapObject* object) { |
| 274 Heap* heap = map->GetHeap(); | 285 Heap* heap = map->GetHeap(); |
| 275 Code* code = Code::cast(object); | 286 Code* code = Code::cast(object); |
| 276 if (FLAG_cleanup_code_caches_at_gc) { | 287 if (FLAG_cleanup_code_caches_at_gc) { |
| 277 code->ClearTypeFeedbackCells(heap); | 288 code->ClearTypeFeedbackCells(heap); |
| 278 } | 289 } |
| 279 code->CodeIterateBody<StaticVisitor>(heap); | 290 code->CodeIterateBody<StaticVisitor>(heap); |
| 291 if (FLAG_age_code && !Serializer::enabled()) { | |
|
Michael Starzinger
2012/11/02 15:29:34
Technically it shouldn't make any difference in th
danno
2012/11/09 13:05:30
Done.
| |
| 292 code->MakeOlder(heap->mark_compact_collector()->marking_parity()); | |
| 293 } | |
| 280 } | 294 } |
| 281 | 295 |
| 282 | 296 |
| 283 template<typename StaticVisitor> | 297 template<typename StaticVisitor> |
| 284 void StaticMarkingVisitor<StaticVisitor>::VisitSharedFunctionInfo( | 298 void StaticMarkingVisitor<StaticVisitor>::VisitSharedFunctionInfo( |
| 285 Map* map, HeapObject* object) { | 299 Map* map, HeapObject* object) { |
| 286 Heap* heap = map->GetHeap(); | 300 Heap* heap = map->GetHeap(); |
| 287 SharedFunctionInfo* shared = SharedFunctionInfo::cast(object); | 301 SharedFunctionInfo* shared = SharedFunctionInfo::cast(object); |
| 288 if (shared->ic_age() != heap->global_ic_age()) { | 302 if (shared->ic_age() != heap->global_ic_age()) { |
| 289 shared->ResetForNewContext(heap->global_ic_age()); | 303 shared->ResetForNewContext(heap->global_ic_age()); |
| (...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 442 | 456 |
| 443 template<typename StaticVisitor> | 457 template<typename StaticVisitor> |
| 444 bool StaticMarkingVisitor<StaticVisitor>::IsFlushable( | 458 bool StaticMarkingVisitor<StaticVisitor>::IsFlushable( |
| 445 Heap* heap, JSFunction* function) { | 459 Heap* heap, JSFunction* function) { |
| 446 SharedFunctionInfo* shared_info = function->unchecked_shared(); | 460 SharedFunctionInfo* shared_info = function->unchecked_shared(); |
| 447 | 461 |
| 448 // Code is either on stack, in compilation cache or referenced | 462 // Code is either on stack, in compilation cache or referenced |
| 449 // by optimized version of function. | 463 // by optimized version of function. |
| 450 MarkBit code_mark = Marking::MarkBitFrom(function->code()); | 464 MarkBit code_mark = Marking::MarkBitFrom(function->code()); |
| 451 if (code_mark.Get()) { | 465 if (code_mark.Get()) { |
| 452 if (!Marking::MarkBitFrom(shared_info).Get()) { | 466 if (!FLAG_age_code) { |
| 453 shared_info->set_code_age(0); | 467 if (!Marking::MarkBitFrom(shared_info).Get()) { |
| 468 shared_info->set_code_age(0); | |
| 469 } | |
| 454 } | 470 } |
| 455 return false; | 471 return false; |
| 456 } | 472 } |
| 457 | 473 |
| 458 // The function must have a valid context and not be a builtin. | 474 // The function must have a valid context and not be a builtin. |
| 459 if (!IsValidNonBuiltinContext(function->unchecked_context())) { | 475 if (!IsValidNonBuiltinContext(function->unchecked_context())) { |
| 460 return false; | 476 return false; |
| 461 } | 477 } |
| 462 | 478 |
| 463 // We do not flush code for optimized functions. | 479 if (FLAG_age_code) { |
| 464 if (function->code() != shared_info->code()) { | 480 return function->code()->IsOld() && IsFlushable(heap, shared_info); |
|
Michael Starzinger
2012/11/02 15:29:34
We cannot yet flush optimized code because they ar
danno
2012/11/09 13:05:30
Done.
| |
| 465 return false; | 481 } else { |
| 482 // We do not flush code for optimized functions. | |
| 483 if (function->code() != shared_info->code()) { | |
| 484 return false; | |
| 485 } | |
| 486 | |
| 487 return IsFlushable(heap, shared_info); | |
| 466 } | 488 } |
| 467 | |
| 468 return IsFlushable(heap, shared_info); | |
| 469 } | 489 } |
| 470 | 490 |
| 471 | 491 |
| 472 template<typename StaticVisitor> | 492 template<typename StaticVisitor> |
| 473 bool StaticMarkingVisitor<StaticVisitor>::IsFlushable( | 493 bool StaticMarkingVisitor<StaticVisitor>::IsFlushable( |
| 474 Heap* heap, SharedFunctionInfo* shared_info) { | 494 Heap* heap, SharedFunctionInfo* shared_info) { |
| 475 // Code is either on stack, in compilation cache or referenced | 495 // Code is either on stack, in compilation cache or referenced |
| 476 // by optimized version of function. | 496 // by optimized version of function. |
| 477 MarkBit code_mark = Marking::MarkBitFrom(shared_info->code()); | 497 MarkBit code_mark = Marking::MarkBitFrom(shared_info->code()); |
| 478 if (code_mark.Get()) { | 498 if (code_mark.Get()) { |
| (...skipping 20 matching lines...) Expand all Loading... | |
| 499 // Function must be lazy compilable. | 519 // Function must be lazy compilable. |
| 500 if (!shared_info->allows_lazy_compilation()) { | 520 if (!shared_info->allows_lazy_compilation()) { |
| 501 return false; | 521 return false; |
| 502 } | 522 } |
| 503 | 523 |
| 504 // If this is a full script wrapped in a function we do no flush the code. | 524 // If this is a full script wrapped in a function we do no flush the code. |
| 505 if (shared_info->is_toplevel()) { | 525 if (shared_info->is_toplevel()) { |
| 506 return false; | 526 return false; |
| 507 } | 527 } |
| 508 | 528 |
| 509 // TODO(mstarzinger): The following will soon be replaced by a new way of | 529 if (FLAG_age_code) { |
| 510 // aging code, that is based on an aging stub in the function prologue. | 530 return shared_info->code()->IsOld(); |
| 531 } else { | |
| 532 // How many collections newly compiled code object will survive before being | |
| 533 // flushed. | |
| 534 static const int kCodeAgeThreshold = 5; | |
| 511 | 535 |
| 512 // How many collections newly compiled code object will survive before being | 536 // Age this shared function info. |
| 513 // flushed. | 537 if (shared_info->code_age() < kCodeAgeThreshold) { |
| 514 static const int kCodeAgeThreshold = 5; | 538 shared_info->set_code_age(shared_info->code_age() + 1); |
| 515 | 539 return false; |
| 516 // Age this shared function info. | 540 } |
| 517 if (shared_info->code_age() < kCodeAgeThreshold) { | 541 return true; |
| 518 shared_info->set_code_age(shared_info->code_age() + 1); | |
| 519 return false; | |
| 520 } | 542 } |
| 521 | |
| 522 return true; | |
| 523 } | 543 } |
| 524 | 544 |
| 525 | 545 |
| 526 template<typename StaticVisitor> | 546 template<typename StaticVisitor> |
| 527 void StaticMarkingVisitor<StaticVisitor>::VisitSharedFunctionInfoStrongCode( | 547 void StaticMarkingVisitor<StaticVisitor>::VisitSharedFunctionInfoStrongCode( |
| 528 Heap* heap, HeapObject* object) { | 548 Heap* heap, HeapObject* object) { |
| 529 StaticVisitor::BeforeVisitingSharedFunctionInfo(object); | 549 StaticVisitor::BeforeVisitingSharedFunctionInfo(object); |
| 530 Object** start_slot = | 550 Object** start_slot = |
| 531 HeapObject::RawField(object, | 551 HeapObject::RawField(object, |
| 532 SharedFunctionInfo::BodyDescriptor::kStartOffset); | 552 SharedFunctionInfo::BodyDescriptor::kStartOffset); |
| (...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 654 RelocIterator it(this, mode_mask); | 674 RelocIterator it(this, mode_mask); |
| 655 for (; !it.done(); it.next()) { | 675 for (; !it.done(); it.next()) { |
| 656 it.rinfo()->template Visit<StaticVisitor>(heap); | 676 it.rinfo()->template Visit<StaticVisitor>(heap); |
| 657 } | 677 } |
| 658 } | 678 } |
| 659 | 679 |
| 660 | 680 |
| 661 } } // namespace v8::internal | 681 } } // namespace v8::internal |
| 662 | 682 |
| 663 #endif // V8_OBJECTS_VISITING_INL_H_ | 683 #endif // V8_OBJECTS_VISITING_INL_H_ |
| OLD | NEW |