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 609 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
620 MarkBit code_mark = Marking::MarkBitFrom(function->code()); | 620 MarkBit code_mark = Marking::MarkBitFrom(function->code()); |
621 if (Marking::IsBlackOrGrey(code_mark)) { | 621 if (Marking::IsBlackOrGrey(code_mark)) { |
622 return false; | 622 return false; |
623 } | 623 } |
624 | 624 |
625 // We do not (yet) flush code for optimized functions. | 625 // We do not (yet) flush code for optimized functions. |
626 if (function->code() != shared_info->code()) { | 626 if (function->code() != shared_info->code()) { |
627 return false; | 627 return false; |
628 } | 628 } |
629 | 629 |
| 630 // Check age of optimized code. |
| 631 if (FLAG_age_code && !function->code()->IsOld()) { |
| 632 return false; |
| 633 } |
| 634 |
630 return IsFlushable(heap, shared_info); | 635 return IsFlushable(heap, shared_info); |
631 } | 636 } |
632 | 637 |
633 | 638 |
634 template <typename StaticVisitor> | 639 template <typename StaticVisitor> |
635 bool StaticMarkingVisitor<StaticVisitor>::IsFlushable( | 640 bool StaticMarkingVisitor<StaticVisitor>::IsFlushable( |
636 Heap* heap, SharedFunctionInfo* shared_info) { | 641 Heap* heap, SharedFunctionInfo* shared_info) { |
637 // Code is either on stack, in compilation cache or referenced | 642 // Code is either on stack, in compilation cache or referenced |
638 // by optimized version of function. | 643 // by optimized version of function. |
639 MarkBit code_mark = Marking::MarkBitFrom(shared_info->code()); | 644 MarkBit code_mark = Marking::MarkBitFrom(shared_info->code()); |
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
678 if (shared_info->IsBuiltin()) { | 683 if (shared_info->IsBuiltin()) { |
679 return false; | 684 return false; |
680 } | 685 } |
681 | 686 |
682 // If this is a function initialized with %SetCode then the one-to-one | 687 // If this is a function initialized with %SetCode then the one-to-one |
683 // relation between SharedFunctionInfo and Code is broken. | 688 // relation between SharedFunctionInfo and Code is broken. |
684 if (shared_info->dont_flush()) { | 689 if (shared_info->dont_flush()) { |
685 return false; | 690 return false; |
686 } | 691 } |
687 | 692 |
688 // ---------------------------------------------------------------- | |
689 // The above predicates up to this line are hard invariants, below | |
690 // this line are heuristics that should not affect correctness. | |
691 // ---------------------------------------------------------------- | |
692 | |
693 // In stress mode we are aggressive. | |
694 if (FLAG_stress_compaction) { | |
695 return true; | |
696 } | |
697 | |
698 // Check age of code. If code aging is disabled we never flush. | 693 // Check age of code. If code aging is disabled we never flush. |
699 if (!FLAG_age_code || !shared_info->code()->IsOld()) { | 694 if (!FLAG_age_code || !shared_info->code()->IsOld()) { |
700 return false; | 695 return false; |
701 } | 696 } |
702 | 697 |
703 return true; | 698 return true; |
704 } | 699 } |
705 | 700 |
706 | 701 |
707 template <typename StaticVisitor> | 702 template <typename StaticVisitor> |
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
752 typedef FlexibleBodyVisitor<StaticVisitor, JSFunction::BodyDescriptorWeakCode, | 747 typedef FlexibleBodyVisitor<StaticVisitor, JSFunction::BodyDescriptorWeakCode, |
753 void> JSFunctionWeakCodeBodyVisitor; | 748 void> JSFunctionWeakCodeBodyVisitor; |
754 JSFunctionWeakCodeBodyVisitor::Visit(map, object); | 749 JSFunctionWeakCodeBodyVisitor::Visit(map, object); |
755 } | 750 } |
756 | 751 |
757 | 752 |
758 } // namespace internal | 753 } // namespace internal |
759 } // namespace v8 | 754 } // namespace v8 |
760 | 755 |
761 #endif // V8_OBJECTS_VISITING_INL_H_ | 756 #endif // V8_OBJECTS_VISITING_INL_H_ |
OLD | NEW |