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 424 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
435 shared->ResetForNewContext(heap->global_ic_age()); | 435 shared->ResetForNewContext(heap->global_ic_age()); |
436 } | 436 } |
437 if (FLAG_cleanup_code_caches_at_gc) { | 437 if (FLAG_cleanup_code_caches_at_gc) { |
438 shared->ClearTypeFeedbackInfoAtGCTime(); | 438 shared->ClearTypeFeedbackInfoAtGCTime(); |
439 } | 439 } |
440 if (FLAG_flush_optimized_code_cache) { | 440 if (FLAG_flush_optimized_code_cache) { |
441 if (!shared->OptimizedCodeMapIsCleared()) { | 441 if (!shared->OptimizedCodeMapIsCleared()) { |
442 // Always flush the optimized code map if requested by flag. | 442 // Always flush the optimized code map if requested by flag. |
443 shared->ClearOptimizedCodeMap(); | 443 shared->ClearOptimizedCodeMap(); |
444 } | 444 } |
445 } else { | |
446 if (!shared->OptimizedCodeMapIsCleared()) { | |
447 // Treat some references within the code map weakly by marking the | |
448 // code map itself but not pushing it onto the marking deque. The | |
449 // map will be processed after marking. | |
450 FixedArray* code_map = shared->optimized_code_map(); | |
451 MarkOptimizedCodeMap(heap, code_map); | |
452 } | |
453 } | 445 } |
454 MarkCompactCollector* collector = heap->mark_compact_collector(); | 446 MarkCompactCollector* collector = heap->mark_compact_collector(); |
455 if (collector->is_code_flushing_enabled()) { | 447 if (collector->is_code_flushing_enabled()) { |
456 if (IsFlushable(heap, shared)) { | 448 if (IsFlushable(heap, shared)) { |
457 // This function's code looks flushable. But we have to postpone | 449 // This function's code looks flushable. But we have to postpone |
458 // the decision until we see all functions that point to the same | 450 // the decision until we see all functions that point to the same |
459 // SharedFunctionInfo because some of them might be optimized. | 451 // SharedFunctionInfo because some of them might be optimized. |
460 // That would also make the non-optimized version of the code | 452 // That would also make the non-optimized version of the code |
461 // non-flushable, because it is required for bailing out from | 453 // non-flushable, because it is required for bailing out from |
462 // optimized code. | 454 // optimized code. |
(...skipping 119 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
582 } | 574 } |
583 | 575 |
584 int num_transitions = TransitionArray::NumberOfTransitions(transitions); | 576 int num_transitions = TransitionArray::NumberOfTransitions(transitions); |
585 for (int i = 0; i < num_transitions; ++i) { | 577 for (int i = 0; i < num_transitions; ++i) { |
586 StaticVisitor::VisitPointer(heap, transitions, transitions->GetKeySlot(i)); | 578 StaticVisitor::VisitPointer(heap, transitions, transitions->GetKeySlot(i)); |
587 } | 579 } |
588 } | 580 } |
589 | 581 |
590 | 582 |
591 template <typename StaticVisitor> | 583 template <typename StaticVisitor> |
592 void StaticMarkingVisitor<StaticVisitor>::MarkOptimizedCodeMap( | |
593 Heap* heap, FixedArray* code_map) { | |
594 if (!StaticVisitor::MarkObjectWithoutPush(heap, code_map)) return; | |
595 | |
596 // Mark the context-independent entry in the optimized code map. Depending on | |
597 // the age of the code object, we treat it as a strong or a weak reference. | |
598 Object* shared_object = code_map->get(SharedFunctionInfo::kSharedCodeIndex); | |
599 if (FLAG_turbo_preserve_shared_code && shared_object->IsCode() && | |
600 FLAG_age_code && !Code::cast(shared_object)->IsOld()) { | |
601 StaticVisitor::VisitPointer( | |
602 heap, code_map, | |
603 code_map->RawFieldOfElementAt(SharedFunctionInfo::kSharedCodeIndex)); | |
604 } | |
605 } | |
606 | |
607 | |
608 template <typename StaticVisitor> | |
609 void StaticMarkingVisitor<StaticVisitor>::MarkInlinedFunctionsCode(Heap* heap, | 584 void StaticMarkingVisitor<StaticVisitor>::MarkInlinedFunctionsCode(Heap* heap, |
610 Code* code) { | 585 Code* code) { |
611 // For optimized functions we should retain both non-optimized version | 586 // For optimized functions we should retain both non-optimized version |
612 // of its code and non-optimized version of all inlined functions. | 587 // of its code and non-optimized version of all inlined functions. |
613 // This is required to support bailing out from inlined code. | 588 // This is required to support bailing out from inlined code. |
614 if (code->deoptimization_data() != heap->empty_fixed_array()) { | 589 if (code->deoptimization_data() != heap->empty_fixed_array()) { |
615 DeoptimizationInputData* const data = | 590 DeoptimizationInputData* const data = |
616 DeoptimizationInputData::cast(code->deoptimization_data()); | 591 DeoptimizationInputData::cast(code->deoptimization_data()); |
617 FixedArray* const literals = data->LiteralArray(); | 592 FixedArray* const literals = data->LiteralArray(); |
618 int const inlined_count = data->InlinedFunctionCount()->value(); | 593 int const inlined_count = data->InlinedFunctionCount()->value(); |
(...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
773 typedef FlexibleBodyVisitor<StaticVisitor, JSFunction::BodyDescriptorWeakCode, | 748 typedef FlexibleBodyVisitor<StaticVisitor, JSFunction::BodyDescriptorWeakCode, |
774 void> JSFunctionWeakCodeBodyVisitor; | 749 void> JSFunctionWeakCodeBodyVisitor; |
775 JSFunctionWeakCodeBodyVisitor::Visit(map, object); | 750 JSFunctionWeakCodeBodyVisitor::Visit(map, object); |
776 } | 751 } |
777 | 752 |
778 | 753 |
779 } // namespace internal | 754 } // namespace internal |
780 } // namespace v8 | 755 } // namespace v8 |
781 | 756 |
782 #endif // V8_OBJECTS_VISITING_INL_H_ | 757 #endif // V8_OBJECTS_VISITING_INL_H_ |
OLD | NEW |