Mercurial > hg > graal-compiler
comparison src/share/vm/gc_implementation/parallelScavenge/psParallelCompact.cpp @ 113:ba764ed4b6f2
6420645: Create a vm that uses compressed oops for up to 32gb heapsizes
Summary: Compressed oops in instances, arrays, and headers. Code contributors are coleenp, phh, never, swamyv
Reviewed-by: jmasa, kamg, acorn, tbell, kvn, rasbold
author | coleenp |
---|---|
date | Sun, 13 Apr 2008 17:43:42 -0400 |
parents | 82db0859acbe |
children | 8bd1e4487c18 |
comparison
equal
deleted
inserted
replaced
110:a49a647afe9a | 113:ba764ed4b6f2 |
---|---|
79 #ifdef ASSERT | 79 #ifdef ASSERT |
80 bool PSParallelCompact::_dwl_initialized = false; | 80 bool PSParallelCompact::_dwl_initialized = false; |
81 #endif // #ifdef ASSERT | 81 #endif // #ifdef ASSERT |
82 | 82 |
83 #ifdef VALIDATE_MARK_SWEEP | 83 #ifdef VALIDATE_MARK_SWEEP |
84 GrowableArray<oop*>* PSParallelCompact::_root_refs_stack = NULL; | 84 GrowableArray<void*>* PSParallelCompact::_root_refs_stack = NULL; |
85 GrowableArray<oop> * PSParallelCompact::_live_oops = NULL; | 85 GrowableArray<oop> * PSParallelCompact::_live_oops = NULL; |
86 GrowableArray<oop> * PSParallelCompact::_live_oops_moved_to = NULL; | 86 GrowableArray<oop> * PSParallelCompact::_live_oops_moved_to = NULL; |
87 GrowableArray<size_t>* PSParallelCompact::_live_oops_size = NULL; | 87 GrowableArray<size_t>* PSParallelCompact::_live_oops_size = NULL; |
88 size_t PSParallelCompact::_live_oops_index = 0; | 88 size_t PSParallelCompact::_live_oops_index = 0; |
89 size_t PSParallelCompact::_live_oops_index_at_perm = 0; | 89 size_t PSParallelCompact::_live_oops_index_at_perm = 0; |
90 GrowableArray<oop*>* PSParallelCompact::_other_refs_stack = NULL; | 90 GrowableArray<void*>* PSParallelCompact::_other_refs_stack = NULL; |
91 GrowableArray<oop*>* PSParallelCompact::_adjusted_pointers = NULL; | 91 GrowableArray<void*>* PSParallelCompact::_adjusted_pointers = NULL; |
92 bool PSParallelCompact::_pointer_tracking = false; | 92 bool PSParallelCompact::_pointer_tracking = false; |
93 bool PSParallelCompact::_root_tracking = true; | 93 bool PSParallelCompact::_root_tracking = true; |
94 | 94 |
95 GrowableArray<HeapWord*>* PSParallelCompact::_cur_gc_live_oops = NULL; | 95 GrowableArray<HeapWord*>* PSParallelCompact::_cur_gc_live_oops = NULL; |
96 GrowableArray<HeapWord*>* PSParallelCompact::_cur_gc_live_oops_moved_to = NULL; | 96 GrowableArray<HeapWord*>* PSParallelCompact::_cur_gc_live_oops_moved_to = NULL; |
809 CollectorCounters* PSParallelCompact::_counters = NULL; | 809 CollectorCounters* PSParallelCompact::_counters = NULL; |
810 ParMarkBitMap PSParallelCompact::_mark_bitmap; | 810 ParMarkBitMap PSParallelCompact::_mark_bitmap; |
811 ParallelCompactData PSParallelCompact::_summary_data; | 811 ParallelCompactData PSParallelCompact::_summary_data; |
812 | 812 |
813 PSParallelCompact::IsAliveClosure PSParallelCompact::_is_alive_closure; | 813 PSParallelCompact::IsAliveClosure PSParallelCompact::_is_alive_closure; |
814 | |
815 void PSParallelCompact::IsAliveClosure::do_object(oop p) { ShouldNotReachHere(); } | |
816 bool PSParallelCompact::IsAliveClosure::do_object_b(oop p) { return mark_bitmap()->is_marked(p); } | |
817 | |
818 void PSParallelCompact::KeepAliveClosure::do_oop(oop* p) { PSParallelCompact::KeepAliveClosure::do_oop_work(p); } | |
819 void PSParallelCompact::KeepAliveClosure::do_oop(narrowOop* p) { PSParallelCompact::KeepAliveClosure::do_oop_work(p); } | |
820 | |
814 PSParallelCompact::AdjustPointerClosure PSParallelCompact::_adjust_root_pointer_closure(true); | 821 PSParallelCompact::AdjustPointerClosure PSParallelCompact::_adjust_root_pointer_closure(true); |
815 PSParallelCompact::AdjustPointerClosure PSParallelCompact::_adjust_pointer_closure(false); | 822 PSParallelCompact::AdjustPointerClosure PSParallelCompact::_adjust_pointer_closure(false); |
816 | 823 |
817 void PSParallelCompact::KeepAliveClosure::do_oop(oop* p) { | 824 void PSParallelCompact::AdjustPointerClosure::do_oop(oop* p) { adjust_pointer(p, _is_root); } |
818 #ifdef VALIDATE_MARK_SWEEP | 825 void PSParallelCompact::AdjustPointerClosure::do_oop(narrowOop* p) { adjust_pointer(p, _is_root); } |
819 if (ValidateMarkSweep) { | 826 |
820 if (!Universe::heap()->is_in_reserved(p)) { | 827 void PSParallelCompact::FollowStackClosure::do_void() { follow_stack(_compaction_manager); } |
821 _root_refs_stack->push(p); | 828 |
822 } else { | 829 void PSParallelCompact::MarkAndPushClosure::do_oop(oop* p) { mark_and_push(_compaction_manager, p); } |
823 _other_refs_stack->push(p); | 830 void PSParallelCompact::MarkAndPushClosure::do_oop(narrowOop* p) { mark_and_push(_compaction_manager, p); } |
824 } | |
825 } | |
826 #endif | |
827 mark_and_push(_compaction_manager, p); | |
828 } | |
829 | |
830 void PSParallelCompact::mark_and_follow(ParCompactionManager* cm, | |
831 oop* p) { | |
832 assert(Universe::heap()->is_in_reserved(p), | |
833 "we should only be traversing objects here"); | |
834 oop m = *p; | |
835 if (m != NULL && mark_bitmap()->is_unmarked(m)) { | |
836 if (mark_obj(m)) { | |
837 m->follow_contents(cm); // Follow contents of the marked object | |
838 } | |
839 } | |
840 } | |
841 | |
842 // Anything associated with this variable is temporary. | |
843 | |
844 void PSParallelCompact::mark_and_push_internal(ParCompactionManager* cm, | |
845 oop* p) { | |
846 // Push marked object, contents will be followed later | |
847 oop m = *p; | |
848 if (mark_obj(m)) { | |
849 // This thread marked the object and | |
850 // owns the subsequent processing of it. | |
851 cm->save_for_scanning(m); | |
852 } | |
853 } | |
854 | 831 |
855 void PSParallelCompact::post_initialize() { | 832 void PSParallelCompact::post_initialize() { |
856 ParallelScavengeHeap* heap = gc_heap(); | 833 ParallelScavengeHeap* heap = gc_heap(); |
857 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity"); | 834 assert(heap->kind() == CollectedHeap::ParallelScavengeHeap, "Sanity"); |
858 | 835 |
2749 old_gen->start_array()->reset(); | 2726 old_gen->start_array()->reset(); |
2750 old_gen->move_and_update(cm); | 2727 old_gen->move_and_update(cm); |
2751 young_gen->move_and_update(cm); | 2728 young_gen->move_and_update(cm); |
2752 } | 2729 } |
2753 | 2730 |
2754 void PSParallelCompact::follow_root(ParCompactionManager* cm, oop* p) { | |
2755 assert(!Universe::heap()->is_in_reserved(p), | |
2756 "roots shouldn't be things within the heap"); | |
2757 #ifdef VALIDATE_MARK_SWEEP | |
2758 if (ValidateMarkSweep) { | |
2759 guarantee(!_root_refs_stack->contains(p), "should only be in here once"); | |
2760 _root_refs_stack->push(p); | |
2761 } | |
2762 #endif | |
2763 oop m = *p; | |
2764 if (m != NULL && mark_bitmap()->is_unmarked(m)) { | |
2765 if (mark_obj(m)) { | |
2766 m->follow_contents(cm); // Follow contents of the marked object | |
2767 } | |
2768 } | |
2769 follow_stack(cm); | |
2770 } | |
2771 | 2731 |
2772 void PSParallelCompact::follow_stack(ParCompactionManager* cm) { | 2732 void PSParallelCompact::follow_stack(ParCompactionManager* cm) { |
2773 while(!cm->overflow_stack()->is_empty()) { | 2733 while(!cm->overflow_stack()->is_empty()) { |
2774 oop obj = cm->overflow_stack()->pop(); | 2734 oop obj = cm->overflow_stack()->pop(); |
2775 obj->follow_contents(cm); | 2735 obj->follow_contents(cm); |
2805 cm->revisit_klass_stack()->push(k); | 2765 cm->revisit_klass_stack()->push(k); |
2806 } | 2766 } |
2807 | 2767 |
2808 #ifdef VALIDATE_MARK_SWEEP | 2768 #ifdef VALIDATE_MARK_SWEEP |
2809 | 2769 |
2810 void PSParallelCompact::track_adjusted_pointer(oop* p, oop newobj, bool isroot) { | 2770 void PSParallelCompact::track_adjusted_pointer(void* p, bool isroot) { |
2811 if (!ValidateMarkSweep) | 2771 if (!ValidateMarkSweep) |
2812 return; | 2772 return; |
2813 | 2773 |
2814 if (!isroot) { | 2774 if (!isroot) { |
2815 if (_pointer_tracking) { | 2775 if (_pointer_tracking) { |
2819 } else { | 2779 } else { |
2820 ptrdiff_t index = _root_refs_stack->find(p); | 2780 ptrdiff_t index = _root_refs_stack->find(p); |
2821 if (index != -1) { | 2781 if (index != -1) { |
2822 int l = _root_refs_stack->length(); | 2782 int l = _root_refs_stack->length(); |
2823 if (l > 0 && l - 1 != index) { | 2783 if (l > 0 && l - 1 != index) { |
2824 oop* last = _root_refs_stack->pop(); | 2784 void* last = _root_refs_stack->pop(); |
2825 assert(last != p, "should be different"); | 2785 assert(last != p, "should be different"); |
2826 _root_refs_stack->at_put(index, last); | 2786 _root_refs_stack->at_put(index, last); |
2827 } else { | 2787 } else { |
2828 _root_refs_stack->remove(p); | 2788 _root_refs_stack->remove(p); |
2829 } | 2789 } |
2830 } | 2790 } |
2831 } | 2791 } |
2832 } | 2792 } |
2833 | 2793 |
2834 | 2794 |
2835 void PSParallelCompact::check_adjust_pointer(oop* p) { | 2795 void PSParallelCompact::check_adjust_pointer(void* p) { |
2836 _adjusted_pointers->push(p); | 2796 _adjusted_pointers->push(p); |
2837 } | 2797 } |
2838 | 2798 |
2839 | 2799 |
2840 class AdjusterTracker: public OopClosure { | 2800 class AdjusterTracker: public OopClosure { |
2841 public: | 2801 public: |
2842 AdjusterTracker() {}; | 2802 AdjusterTracker() {}; |
2843 void do_oop(oop* o) { PSParallelCompact::check_adjust_pointer(o); } | 2803 void do_oop(oop* o) { PSParallelCompact::check_adjust_pointer(o); } |
2804 void do_oop(narrowOop* o) { PSParallelCompact::check_adjust_pointer(o); } | |
2844 }; | 2805 }; |
2845 | 2806 |
2846 | 2807 |
2847 void PSParallelCompact::track_interior_pointers(oop obj) { | 2808 void PSParallelCompact::track_interior_pointers(oop obj) { |
2848 if (ValidateMarkSweep) { | 2809 if (ValidateMarkSweep) { |
2945 } | 2906 } |
2946 | 2907 |
2947 tty->print_cr("Address " PTR_FORMAT " not found in live oop information from last GC", q); | 2908 tty->print_cr("Address " PTR_FORMAT " not found in live oop information from last GC", q); |
2948 } | 2909 } |
2949 #endif //VALIDATE_MARK_SWEEP | 2910 #endif //VALIDATE_MARK_SWEEP |
2950 | |
2951 void PSParallelCompact::adjust_pointer(oop* p, bool isroot) { | |
2952 oop obj = *p; | |
2953 VALIDATE_MARK_SWEEP_ONLY(oop saved_new_pointer = NULL); | |
2954 if (obj != NULL) { | |
2955 oop new_pointer = (oop) summary_data().calc_new_pointer(obj); | |
2956 assert(new_pointer != NULL || // is forwarding ptr? | |
2957 obj->is_shared(), // never forwarded? | |
2958 "should have a new location"); | |
2959 // Just always do the update unconditionally? | |
2960 if (new_pointer != NULL) { | |
2961 *p = new_pointer; | |
2962 assert(Universe::heap()->is_in_reserved(new_pointer), | |
2963 "should be in object space"); | |
2964 VALIDATE_MARK_SWEEP_ONLY(saved_new_pointer = new_pointer); | |
2965 } | |
2966 } | |
2967 VALIDATE_MARK_SWEEP_ONLY(track_adjusted_pointer(p, saved_new_pointer, isroot)); | |
2968 } | |
2969 | 2911 |
2970 // Update interior oops in the ranges of chunks [beg_chunk, end_chunk). | 2912 // Update interior oops in the ranges of chunks [beg_chunk, end_chunk). |
2971 void | 2913 void |
2972 PSParallelCompact::update_and_deadwood_in_dense_prefix(ParCompactionManager* cm, | 2914 PSParallelCompact::update_and_deadwood_in_dense_prefix(ParCompactionManager* cm, |
2973 SpaceId space_id, | 2915 SpaceId space_id, |