| 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/objects-visiting.h" | 9 #include "src/heap/objects-visiting.h" |
| 10 #include "src/ic/ic-state.h" | 10 #include "src/ic/ic-state.h" |
| (...skipping 430 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 441 shared->ResetForNewContext(heap->global_ic_age()); | 441 shared->ResetForNewContext(heap->global_ic_age()); |
| 442 } | 442 } |
| 443 if (FLAG_cleanup_code_caches_at_gc) { | 443 if (FLAG_cleanup_code_caches_at_gc) { |
| 444 shared->ClearTypeFeedbackInfoAtGCTime(); | 444 shared->ClearTypeFeedbackInfoAtGCTime(); |
| 445 } | 445 } |
| 446 if (FLAG_flush_optimized_code_cache) { | 446 if (FLAG_flush_optimized_code_cache) { |
| 447 if (!shared->OptimizedCodeMapIsCleared()) { | 447 if (!shared->OptimizedCodeMapIsCleared()) { |
| 448 // Always flush the optimized code map if requested by flag. | 448 // Always flush the optimized code map if requested by flag. |
| 449 shared->ClearOptimizedCodeMap(); | 449 shared->ClearOptimizedCodeMap(); |
| 450 } | 450 } |
| 451 } else { | |
| 452 if (!shared->OptimizedCodeMapIsCleared()) { | |
| 453 // Treat some references within the code map weakly by marking the | |
| 454 // code map itself but not pushing it onto the marking deque. The | |
| 455 // map will be processed after marking. | |
| 456 FixedArray* code_map = shared->optimized_code_map(); | |
| 457 MarkOptimizedCodeMap(heap, code_map); | |
| 458 } | |
| 459 } | 451 } |
| 460 MarkCompactCollector* collector = heap->mark_compact_collector(); | 452 MarkCompactCollector* collector = heap->mark_compact_collector(); |
| 461 if (collector->is_code_flushing_enabled()) { | 453 if (collector->is_code_flushing_enabled()) { |
| 462 if (IsFlushable(heap, shared)) { | 454 if (IsFlushable(heap, shared)) { |
| 463 // This function's code looks flushable. But we have to postpone | 455 // This function's code looks flushable. But we have to postpone |
| 464 // the decision until we see all functions that point to the same | 456 // the decision until we see all functions that point to the same |
| 465 // SharedFunctionInfo because some of them might be optimized. | 457 // SharedFunctionInfo because some of them might be optimized. |
| 466 // That would also make the non-optimized version of the code | 458 // That would also make the non-optimized version of the code |
| 467 // non-flushable, because it is required for bailing out from | 459 // non-flushable, because it is required for bailing out from |
| 468 // optimized code. | 460 // optimized code. |
| (...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 587 transitions->GetPrototypeTransitionsSlot()); | 579 transitions->GetPrototypeTransitionsSlot()); |
| 588 } | 580 } |
| 589 | 581 |
| 590 int num_transitions = TransitionArray::NumberOfTransitions(transitions); | 582 int num_transitions = TransitionArray::NumberOfTransitions(transitions); |
| 591 for (int i = 0; i < num_transitions; ++i) { | 583 for (int i = 0; i < num_transitions; ++i) { |
| 592 StaticVisitor::VisitPointer(heap, transitions, transitions->GetKeySlot(i)); | 584 StaticVisitor::VisitPointer(heap, transitions, transitions->GetKeySlot(i)); |
| 593 } | 585 } |
| 594 } | 586 } |
| 595 | 587 |
| 596 | 588 |
| 597 template <typename StaticVisitor> | |
| 598 void StaticMarkingVisitor<StaticVisitor>::MarkOptimizedCodeMap( | |
| 599 Heap* heap, FixedArray* code_map) { | |
| 600 if (!StaticVisitor::MarkObjectWithoutPush(heap, code_map)) return; | |
| 601 | |
| 602 // Mark the context-independent entry in the optimized code map. Depending on | |
| 603 // the age of the code object, we treat it as a strong or a weak reference. | |
| 604 Object* shared_object = code_map->get(SharedFunctionInfo::kSharedCodeIndex); | |
| 605 if (FLAG_turbo_preserve_shared_code && shared_object->IsCode() && | |
| 606 FLAG_age_code && !Code::cast(shared_object)->IsOld()) { | |
| 607 StaticVisitor::VisitPointer( | |
| 608 heap, code_map, | |
| 609 code_map->RawFieldOfElementAt(SharedFunctionInfo::kSharedCodeIndex)); | |
| 610 } | |
| 611 } | |
| 612 | |
| 613 | |
| 614 inline static bool HasSourceCode(Heap* heap, SharedFunctionInfo* info) { | 589 inline static bool HasSourceCode(Heap* heap, SharedFunctionInfo* info) { |
| 615 Object* undefined = heap->undefined_value(); | 590 Object* undefined = heap->undefined_value(); |
| 616 return (info->script() != undefined) && | 591 return (info->script() != undefined) && |
| 617 (reinterpret_cast<Script*>(info->script())->source() != undefined); | 592 (reinterpret_cast<Script*>(info->script())->source() != undefined); |
| 618 } | 593 } |
| 619 | 594 |
| 620 | 595 |
| 621 template <typename StaticVisitor> | 596 template <typename StaticVisitor> |
| 622 bool StaticMarkingVisitor<StaticVisitor>::IsFlushable(Heap* heap, | 597 bool StaticMarkingVisitor<StaticVisitor>::IsFlushable(Heap* heap, |
| 623 JSFunction* function) { | 598 JSFunction* function) { |
| (...skipping 136 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 760 typedef FlexibleBodyVisitor<StaticVisitor, JSFunction::BodyDescriptorWeakCode, | 735 typedef FlexibleBodyVisitor<StaticVisitor, JSFunction::BodyDescriptorWeakCode, |
| 761 void> JSFunctionWeakCodeBodyVisitor; | 736 void> JSFunctionWeakCodeBodyVisitor; |
| 762 JSFunctionWeakCodeBodyVisitor::Visit(map, object); | 737 JSFunctionWeakCodeBodyVisitor::Visit(map, object); |
| 763 } | 738 } |
| 764 | 739 |
| 765 | 740 |
| 766 } // namespace internal | 741 } // namespace internal |
| 767 } // namespace v8 | 742 } // namespace v8 |
| 768 | 743 |
| 769 #endif // V8_OBJECTS_VISITING_INL_H_ | 744 #endif // V8_OBJECTS_VISITING_INL_H_ |
| OLD | NEW |