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 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
269 | 280 |
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 } |
| 290 if (FLAG_age_code && !Serializer::enabled()) { |
| 291 code->MakeOlder(heap->mark_compact_collector()->marking_parity()); |
| 292 } |
279 code->CodeIterateBody<StaticVisitor>(heap); | 293 code->CodeIterateBody<StaticVisitor>(heap); |
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()) { |
(...skipping 153 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 // We do not (yet) flush code for optimized functions. |
464 if (function->code() != shared_info->code()) { | 480 if (function->code() != shared_info->code()) { |
465 return false; | 481 return false; |
466 } | 482 } |
467 | 483 |
| 484 // Check age of optimized code. |
| 485 if (FLAG_age_code && !function->code()->IsOld()) { |
| 486 return false; |
| 487 } |
| 488 |
468 return IsFlushable(heap, shared_info); | 489 return IsFlushable(heap, shared_info); |
469 } | 490 } |
470 | 491 |
471 | 492 |
472 template<typename StaticVisitor> | 493 template<typename StaticVisitor> |
473 bool StaticMarkingVisitor<StaticVisitor>::IsFlushable( | 494 bool StaticMarkingVisitor<StaticVisitor>::IsFlushable( |
474 Heap* heap, SharedFunctionInfo* shared_info) { | 495 Heap* heap, SharedFunctionInfo* shared_info) { |
475 // Code is either on stack, in compilation cache or referenced | 496 // Code is either on stack, in compilation cache or referenced |
476 // by optimized version of function. | 497 // by optimized version of function. |
477 MarkBit code_mark = Marking::MarkBitFrom(shared_info->code()); | 498 MarkBit code_mark = Marking::MarkBitFrom(shared_info->code()); |
(...skipping 21 matching lines...) Expand all Loading... |
499 // Function must be lazy compilable. | 520 // Function must be lazy compilable. |
500 if (!shared_info->allows_lazy_compilation()) { | 521 if (!shared_info->allows_lazy_compilation()) { |
501 return false; | 522 return false; |
502 } | 523 } |
503 | 524 |
504 // If this is a full script wrapped in a function we do no flush the code. | 525 // If this is a full script wrapped in a function we do no flush the code. |
505 if (shared_info->is_toplevel()) { | 526 if (shared_info->is_toplevel()) { |
506 return false; | 527 return false; |
507 } | 528 } |
508 | 529 |
509 // TODO(mstarzinger): The following will soon be replaced by a new way of | 530 if (FLAG_age_code) { |
510 // aging code, that is based on an aging stub in the function prologue. | 531 return shared_info->code()->IsOld(); |
| 532 } else { |
| 533 // How many collections newly compiled code object will survive before being |
| 534 // flushed. |
| 535 static const int kCodeAgeThreshold = 5; |
511 | 536 |
512 // How many collections newly compiled code object will survive before being | 537 // Age this shared function info. |
513 // flushed. | 538 if (shared_info->code_age() < kCodeAgeThreshold) { |
514 static const int kCodeAgeThreshold = 5; | 539 shared_info->set_code_age(shared_info->code_age() + 1); |
515 | 540 return false; |
516 // Age this shared function info. | 541 } |
517 if (shared_info->code_age() < kCodeAgeThreshold) { | 542 return true; |
518 shared_info->set_code_age(shared_info->code_age() + 1); | |
519 return false; | |
520 } | 543 } |
521 | |
522 return true; | |
523 } | 544 } |
524 | 545 |
525 | 546 |
526 template<typename StaticVisitor> | 547 template<typename StaticVisitor> |
527 void StaticMarkingVisitor<StaticVisitor>::VisitSharedFunctionInfoStrongCode( | 548 void StaticMarkingVisitor<StaticVisitor>::VisitSharedFunctionInfoStrongCode( |
528 Heap* heap, HeapObject* object) { | 549 Heap* heap, HeapObject* object) { |
529 StaticVisitor::BeforeVisitingSharedFunctionInfo(object); | 550 StaticVisitor::BeforeVisitingSharedFunctionInfo(object); |
530 Object** start_slot = | 551 Object** start_slot = |
531 HeapObject::RawField(object, | 552 HeapObject::RawField(object, |
532 SharedFunctionInfo::BodyDescriptor::kStartOffset); | 553 SharedFunctionInfo::BodyDescriptor::kStartOffset); |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
654 RelocIterator it(this, mode_mask); | 675 RelocIterator it(this, mode_mask); |
655 for (; !it.done(); it.next()) { | 676 for (; !it.done(); it.next()) { |
656 it.rinfo()->template Visit<StaticVisitor>(heap); | 677 it.rinfo()->template Visit<StaticVisitor>(heap); |
657 } | 678 } |
658 } | 679 } |
659 | 680 |
660 | 681 |
661 } } // namespace v8::internal | 682 } } // namespace v8::internal |
662 | 683 |
663 #endif // V8_OBJECTS_VISITING_INL_H_ | 684 #endif // V8_OBJECTS_VISITING_INL_H_ |
OLD | NEW |