| 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 437 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 448 shared->ResetForNewContext(heap->global_ic_age()); | 448 shared->ResetForNewContext(heap->global_ic_age()); |
| 449 } | 449 } |
| 450 if (FLAG_cleanup_code_caches_at_gc) { | 450 if (FLAG_cleanup_code_caches_at_gc) { |
| 451 shared->ClearTypeFeedbackInfoAtGCTime(); | 451 shared->ClearTypeFeedbackInfoAtGCTime(); |
| 452 } | 452 } |
| 453 if (FLAG_flush_optimized_code_cache) { | 453 if (FLAG_flush_optimized_code_cache) { |
| 454 if (!shared->OptimizedCodeMapIsCleared()) { | 454 if (!shared->OptimizedCodeMapIsCleared()) { |
| 455 // Always flush the optimized code map if requested by flag. | 455 // Always flush the optimized code map if requested by flag. |
| 456 shared->ClearOptimizedCodeMap(); | 456 shared->ClearOptimizedCodeMap(); |
| 457 } | 457 } |
| 458 } else { | |
| 459 if (!shared->OptimizedCodeMapIsCleared()) { | |
| 460 // Treat some references within the code map weakly by marking the | |
| 461 // code map itself but not pushing it onto the marking deque. The | |
| 462 // map will be processed after marking. | |
| 463 FixedArray* code_map = shared->optimized_code_map(); | |
| 464 MarkOptimizedCodeMap(heap, code_map); | |
| 465 } | |
| 466 } | 458 } |
| 467 MarkCompactCollector* collector = heap->mark_compact_collector(); | 459 MarkCompactCollector* collector = heap->mark_compact_collector(); |
| 468 if (collector->is_code_flushing_enabled()) { | 460 if (collector->is_code_flushing_enabled()) { |
| 469 if (IsFlushable(heap, shared)) { | 461 if (IsFlushable(heap, shared)) { |
| 470 // This function's code looks flushable. But we have to postpone | 462 // This function's code looks flushable. But we have to postpone |
| 471 // the decision until we see all functions that point to the same | 463 // the decision until we see all functions that point to the same |
| 472 // SharedFunctionInfo because some of them might be optimized. | 464 // SharedFunctionInfo because some of them might be optimized. |
| 473 // That would also make the non-optimized version of the code | 465 // That would also make the non-optimized version of the code |
| 474 // non-flushable, because it is required for bailing out from | 466 // non-flushable, because it is required for bailing out from |
| 475 // optimized code. | 467 // optimized code. |
| (...skipping 147 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 } | 615 } |
| 624 | 616 |
| 625 int num_transitions = TransitionArray::NumberOfTransitions(transitions); | 617 int num_transitions = TransitionArray::NumberOfTransitions(transitions); |
| 626 for (int i = 0; i < num_transitions; ++i) { | 618 for (int i = 0; i < num_transitions; ++i) { |
| 627 StaticVisitor::VisitPointer(heap, transitions, transitions->GetKeySlot(i)); | 619 StaticVisitor::VisitPointer(heap, transitions, transitions->GetKeySlot(i)); |
| 628 } | 620 } |
| 629 } | 621 } |
| 630 | 622 |
| 631 | 623 |
| 632 template <typename StaticVisitor> | 624 template <typename StaticVisitor> |
| 633 void StaticMarkingVisitor<StaticVisitor>::MarkOptimizedCodeMap( | |
| 634 Heap* heap, FixedArray* code_map) { | |
| 635 if (!StaticVisitor::MarkObjectWithoutPush(heap, code_map)) return; | |
| 636 | |
| 637 // Mark the context-independent entry in the optimized code map. Depending on | |
| 638 // the age of the code object, we treat it as a strong or a weak reference. | |
| 639 Object* shared_object = code_map->get(SharedFunctionInfo::kSharedCodeIndex); | |
| 640 if (FLAG_turbo_preserve_shared_code && shared_object->IsCode() && | |
| 641 FLAG_age_code && !Code::cast(shared_object)->IsOld()) { | |
| 642 StaticVisitor::VisitPointer( | |
| 643 heap, code_map, | |
| 644 code_map->RawFieldOfElementAt(SharedFunctionInfo::kSharedCodeIndex)); | |
| 645 } | |
| 646 } | |
| 647 | |
| 648 | |
| 649 template <typename StaticVisitor> | |
| 650 void StaticMarkingVisitor<StaticVisitor>::MarkInlinedFunctionsCode(Heap* heap, | 625 void StaticMarkingVisitor<StaticVisitor>::MarkInlinedFunctionsCode(Heap* heap, |
| 651 Code* code) { | 626 Code* code) { |
| 652 // For optimized functions we should retain both non-optimized version | 627 // For optimized functions we should retain both non-optimized version |
| 653 // of its code and non-optimized version of all inlined functions. | 628 // of its code and non-optimized version of all inlined functions. |
| 654 // This is required to support bailing out from inlined code. | 629 // This is required to support bailing out from inlined code. |
| 655 if (code->deoptimization_data() != heap->empty_fixed_array()) { | 630 if (code->deoptimization_data() != heap->empty_fixed_array()) { |
| 656 DeoptimizationInputData* const data = | 631 DeoptimizationInputData* const data = |
| 657 DeoptimizationInputData::cast(code->deoptimization_data()); | 632 DeoptimizationInputData::cast(code->deoptimization_data()); |
| 658 FixedArray* const literals = data->LiteralArray(); | 633 FixedArray* const literals = data->LiteralArray(); |
| 659 int const inlined_count = data->InlinedFunctionCount()->value(); | 634 int const inlined_count = data->InlinedFunctionCount()->value(); |
| (...skipping 154 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 814 typedef FlexibleBodyVisitor<StaticVisitor, JSFunction::BodyDescriptorWeakCode, | 789 typedef FlexibleBodyVisitor<StaticVisitor, JSFunction::BodyDescriptorWeakCode, |
| 815 void> JSFunctionWeakCodeBodyVisitor; | 790 void> JSFunctionWeakCodeBodyVisitor; |
| 816 JSFunctionWeakCodeBodyVisitor::Visit(map, object); | 791 JSFunctionWeakCodeBodyVisitor::Visit(map, object); |
| 817 } | 792 } |
| 818 | 793 |
| 819 | 794 |
| 820 } // namespace internal | 795 } // namespace internal |
| 821 } // namespace v8 | 796 } // namespace v8 |
| 822 | 797 |
| 823 #endif // V8_OBJECTS_VISITING_INL_H_ | 798 #endif // V8_OBJECTS_VISITING_INL_H_ |
| OLD | NEW |