comparison src/share/vm/gc_implementation/parallelScavenge/psScavenge.inline.hpp @ 4909:95f6641e38e0

7144296: PS: Optimize nmethods processing Summary: Prunes scavenge roots in code list every young GC, promote objects directly pointed by the code immediately Reviewed-by: johnc, jcoomes
author iveresov
date Fri, 10 Feb 2012 17:40:20 -0800
parents 1d1603768966
children da91efe96a93
comparison
equal deleted inserted replaced
4888:3c4621be5149 4909:95f6641e38e0
1 /* 1 /*
2 * Copyright (c) 2002, 2011, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2002, 2012, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 * 4 *
5 * This code is free software; you can redistribute it and/or modify it 5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as 6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation. 7 * published by the Free Software Foundation.
26 #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_INLINE_HPP 26 #define SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_INLINE_HPP
27 27
28 #include "gc_implementation/parallelScavenge/cardTableExtension.hpp" 28 #include "gc_implementation/parallelScavenge/cardTableExtension.hpp"
29 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp" 29 #include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp"
30 #include "gc_implementation/parallelScavenge/psPromotionManager.hpp" 30 #include "gc_implementation/parallelScavenge/psPromotionManager.hpp"
31 #include "gc_implementation/parallelScavenge/psPromotionManager.inline.hpp"
31 #include "gc_implementation/parallelScavenge/psScavenge.hpp" 32 #include "gc_implementation/parallelScavenge/psScavenge.hpp"
32 33
33 inline void PSScavenge::save_to_space_top_before_gc() { 34 inline void PSScavenge::save_to_space_top_before_gc() {
34 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap(); 35 ParallelScavengeHeap* heap = (ParallelScavengeHeap*)Universe::heap();
35 _to_space_top_before_gc = heap->young_gen()->to_space()->top(); 36 _to_space_top_before_gc = heap->young_gen()->to_space()->top();
63 } 64 }
64 65
65 // Attempt to "claim" oop at p via CAS, push the new obj if successful 66 // Attempt to "claim" oop at p via CAS, push the new obj if successful
66 // This version tests the oop* to make sure it is within the heap before 67 // This version tests the oop* to make sure it is within the heap before
67 // attempting marking. 68 // attempting marking.
68 template <class T> 69 template <class T, bool promote_immediately>
69 inline void PSScavenge::copy_and_push_safe_barrier(PSPromotionManager* pm, 70 inline void PSScavenge::copy_and_push_safe_barrier(PSPromotionManager* pm,
70 T* p) { 71 T* p) {
71 assert(should_scavenge(p, true), "revisiting object?"); 72 assert(should_scavenge(p, true), "revisiting object?");
72 73
73 oop o = oopDesc::load_decode_heap_oop_not_null(p); 74 oop o = oopDesc::load_decode_heap_oop_not_null(p);
74 oop new_obj = o->is_forwarded() 75 oop new_obj = o->is_forwarded()
75 ? o->forwardee() 76 ? o->forwardee()
76 : pm->copy_to_survivor_space(o); 77 : pm->copy_to_survivor_space<promote_immediately>(o);
77 oopDesc::encode_store_heap_oop_not_null(p, new_obj); 78 oopDesc::encode_store_heap_oop_not_null(p, new_obj);
78 79
79 // We cannot mark without test, as some code passes us pointers 80 // We cannot mark without test, as some code passes us pointers
80 // that are outside the heap. 81 // that are outside the heap.
81 if ((!PSScavenge::is_obj_in_young((HeapWord*)p)) && 82 if ((!PSScavenge::is_obj_in_young((HeapWord*)p)) &&
84 card_table()->inline_write_ref_field_gc(p, new_obj); 85 card_table()->inline_write_ref_field_gc(p, new_obj);
85 } 86 }
86 } 87 }
87 } 88 }
88 89
89 class PSScavengeRootsClosure: public OopClosure { 90 template<bool promote_immediately>
91 class PSRootsClosure: public OopClosure {
90 private: 92 private:
91 PSPromotionManager* _promotion_manager; 93 PSPromotionManager* _promotion_manager;
92 94
93 protected: 95 protected:
94 template <class T> void do_oop_work(T *p) { 96 template <class T> void do_oop_work(T *p) {
95 if (PSScavenge::should_scavenge(p)) { 97 if (PSScavenge::should_scavenge(p)) {
96 // We never card mark roots, maybe call a func without test? 98 // We never card mark roots, maybe call a func without test?
97 PSScavenge::copy_and_push_safe_barrier(_promotion_manager, p); 99 PSScavenge::copy_and_push_safe_barrier<T, promote_immediately>(_promotion_manager, p);
98 } 100 }
99 } 101 }
100 public: 102 public:
101 PSScavengeRootsClosure(PSPromotionManager* pm) : _promotion_manager(pm) { } 103 PSRootsClosure(PSPromotionManager* pm) : _promotion_manager(pm) { }
102 void do_oop(oop* p) { PSScavengeRootsClosure::do_oop_work(p); } 104 void do_oop(oop* p) { PSRootsClosure::do_oop_work(p); }
103 void do_oop(narrowOop* p) { PSScavengeRootsClosure::do_oop_work(p); } 105 void do_oop(narrowOop* p) { PSRootsClosure::do_oop_work(p); }
104 }; 106 };
105 107
108 typedef PSRootsClosure</*promote_immediately=*/false> PSScavengeRootsClosure;
109 typedef PSRootsClosure</*promote_immediately=*/true> PSPromoteRootsClosure;
110
106 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_INLINE_HPP 111 #endif // SHARE_VM_GC_IMPLEMENTATION_PARALLELSCAVENGE_PSSCAVENGE_INLINE_HPP