OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #ifndef V8_OBJECTS_VISITING_INL_H_ | 5 #ifndef V8_OBJECTS_VISITING_INL_H_ |
6 #define V8_OBJECTS_VISITING_INL_H_ | 6 #define V8_OBJECTS_VISITING_INL_H_ |
7 | 7 |
8 #include "src/heap/array-buffer-tracker.h" | 8 #include "src/heap/array-buffer-tracker.h" |
9 #include "src/heap/mark-compact.h" | 9 #include "src/heap/mark-compact.h" |
10 #include "src/heap/objects-visiting.h" | 10 #include "src/heap/objects-visiting.h" |
(...skipping 315 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
326 template <typename StaticVisitor> | 326 template <typename StaticVisitor> |
327 void StaticMarkingVisitor<StaticVisitor>::VisitWeakCell(Map* map, | 327 void StaticMarkingVisitor<StaticVisitor>::VisitWeakCell(Map* map, |
328 HeapObject* object) { | 328 HeapObject* object) { |
329 Heap* heap = map->GetHeap(); | 329 Heap* heap = map->GetHeap(); |
330 WeakCell* weak_cell = reinterpret_cast<WeakCell*>(object); | 330 WeakCell* weak_cell = reinterpret_cast<WeakCell*>(object); |
331 // Enqueue weak cell in linked list of encountered weak collections. | 331 // Enqueue weak cell in linked list of encountered weak collections. |
332 // We can ignore weak cells with cleared values because they will always | 332 // We can ignore weak cells with cleared values because they will always |
333 // contain smi zero. | 333 // contain smi zero. |
334 if (weak_cell->next_cleared() && !weak_cell->cleared()) { | 334 if (weak_cell->next_cleared() && !weak_cell->cleared()) { |
335 HeapObject* value = HeapObject::cast(weak_cell->value()); | 335 HeapObject* value = HeapObject::cast(weak_cell->value()); |
336 if (ObjectMarking::IsBlackOrGrey(value)) { | 336 if (ObjectMarking::IsBlackOrGrey(value, MarkingState::Internal(value))) { |
337 // Weak cells with live values are directly processed here to reduce | 337 // Weak cells with live values are directly processed here to reduce |
338 // the processing time of weak cells during the main GC pause. | 338 // the processing time of weak cells during the main GC pause. |
339 Object** slot = HeapObject::RawField(weak_cell, WeakCell::kValueOffset); | 339 Object** slot = HeapObject::RawField(weak_cell, WeakCell::kValueOffset); |
340 map->GetHeap()->mark_compact_collector()->RecordSlot(weak_cell, slot, | 340 map->GetHeap()->mark_compact_collector()->RecordSlot(weak_cell, slot, |
341 *slot); | 341 *slot); |
342 } else { | 342 } else { |
343 // If we do not know about liveness of values of weak cells, we have to | 343 // If we do not know about liveness of values of weak cells, we have to |
344 // process them when we know the liveness of the whole transitive | 344 // process them when we know the liveness of the whole transitive |
345 // closure. | 345 // closure. |
346 weak_cell->set_next(heap->encountered_weak_cells(), | 346 weak_cell->set_next(heap->encountered_weak_cells(), |
(...skipping 168 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
515 } | 515 } |
516 | 516 |
517 | 517 |
518 template <typename StaticVisitor> | 518 template <typename StaticVisitor> |
519 bool StaticMarkingVisitor<StaticVisitor>::IsFlushable(Heap* heap, | 519 bool StaticMarkingVisitor<StaticVisitor>::IsFlushable(Heap* heap, |
520 JSFunction* function) { | 520 JSFunction* function) { |
521 SharedFunctionInfo* shared_info = function->shared(); | 521 SharedFunctionInfo* shared_info = function->shared(); |
522 | 522 |
523 // Code is either on stack, in compilation cache or referenced | 523 // Code is either on stack, in compilation cache or referenced |
524 // by optimized version of function. | 524 // by optimized version of function. |
525 if (ObjectMarking::IsBlackOrGrey(function->code())) { | 525 if (ObjectMarking::IsBlackOrGrey(function->code(), |
| 526 MarkingState::Internal(function->code()))) { |
526 return false; | 527 return false; |
527 } | 528 } |
528 | 529 |
529 // We do not (yet) flush code for optimized functions. | 530 // We do not (yet) flush code for optimized functions. |
530 if (function->code() != shared_info->code()) { | 531 if (function->code() != shared_info->code()) { |
531 return false; | 532 return false; |
532 } | 533 } |
533 | 534 |
534 // Check age of optimized code. | 535 // Check age of optimized code. |
535 if (FLAG_age_code && !function->code()->IsOld()) { | 536 if (FLAG_age_code && !function->code()->IsOld()) { |
536 return false; | 537 return false; |
537 } | 538 } |
538 | 539 |
539 return IsFlushable(heap, shared_info); | 540 return IsFlushable(heap, shared_info); |
540 } | 541 } |
541 | 542 |
542 | 543 |
543 template <typename StaticVisitor> | 544 template <typename StaticVisitor> |
544 bool StaticMarkingVisitor<StaticVisitor>::IsFlushable( | 545 bool StaticMarkingVisitor<StaticVisitor>::IsFlushable( |
545 Heap* heap, SharedFunctionInfo* shared_info) { | 546 Heap* heap, SharedFunctionInfo* shared_info) { |
546 // Code is either on stack, in compilation cache or referenced | 547 // Code is either on stack, in compilation cache or referenced |
547 // by optimized version of function. | 548 // by optimized version of function. |
548 if (ObjectMarking::IsBlackOrGrey(shared_info->code())) { | 549 if (ObjectMarking::IsBlackOrGrey( |
| 550 shared_info->code(), MarkingState::Internal(shared_info->code()))) { |
549 return false; | 551 return false; |
550 } | 552 } |
551 | 553 |
552 // The function must be compiled and have the source code available, | 554 // The function must be compiled and have the source code available, |
553 // to be able to recompile it in case we need the function again. | 555 // to be able to recompile it in case we need the function again. |
554 if (!(shared_info->is_compiled() && HasSourceCode(heap, shared_info))) { | 556 if (!(shared_info->is_compiled() && HasSourceCode(heap, shared_info))) { |
555 return false; | 557 return false; |
556 } | 558 } |
557 | 559 |
558 // We never flush code for API functions. | 560 // We never flush code for API functions. |
(...skipping 80 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
639 typedef FlexibleBodyVisitor<StaticVisitor, JSFunction::BodyDescriptorWeakCode, | 641 typedef FlexibleBodyVisitor<StaticVisitor, JSFunction::BodyDescriptorWeakCode, |
640 void> JSFunctionWeakCodeBodyVisitor; | 642 void> JSFunctionWeakCodeBodyVisitor; |
641 JSFunctionWeakCodeBodyVisitor::Visit(map, object); | 643 JSFunctionWeakCodeBodyVisitor::Visit(map, object); |
642 } | 644 } |
643 | 645 |
644 | 646 |
645 } // namespace internal | 647 } // namespace internal |
646 } // namespace v8 | 648 } // namespace v8 |
647 | 649 |
648 #endif // V8_OBJECTS_VISITING_INL_H_ | 650 #endif // V8_OBJECTS_VISITING_INL_H_ |
OLD | NEW |