62 assert(Universe::heap()->is_in(p), "pointer outside heap"); |
62 assert(Universe::heap()->is_in(p), "pointer outside heap"); |
63 |
63 |
64 claim_or_forward_internal_depth(p); |
64 claim_or_forward_internal_depth(p); |
65 } |
65 } |
66 |
66 |
|
67 inline void PSPromotionManager::promotion_trace_event(oop new_obj, oop old_obj, |
|
68 size_t obj_size, |
|
69 uint age, bool tenured, |
|
70 const PSPromotionLAB* lab) { |
|
71 // Skip if memory allocation failed |
|
72 if (new_obj != NULL) { |
|
73 const ParallelScavengeTracer* gc_tracer = PSScavenge::gc_tracer(); |
|
74 |
|
75 if (lab != NULL) { |
|
76 // Promotion of object through newly allocated PLAB |
|
77 if (gc_tracer->should_report_promotion_in_new_plab_event()) { |
|
78 size_t obj_bytes = obj_size * HeapWordSize; |
|
79 size_t lab_size = lab->capacity(); |
|
80 gc_tracer->report_promotion_in_new_plab_event(old_obj->klass(), obj_bytes, |
|
81 age, tenured, lab_size); |
|
82 } |
|
83 } else { |
|
84 // Promotion of object directly to heap |
|
85 if (gc_tracer->should_report_promotion_outside_plab_event()) { |
|
86 size_t obj_bytes = obj_size * HeapWordSize; |
|
87 gc_tracer->report_promotion_outside_plab_event(old_obj->klass(), obj_bytes, |
|
88 age, tenured); |
|
89 } |
|
90 } |
|
91 } |
|
92 } |
|
93 |
67 // |
94 // |
68 // This method is pretty bulky. It would be nice to split it up |
95 // This method is pretty bulky. It would be nice to split it up |
69 // into smaller submethods, but we need to be careful not to hurt |
96 // into smaller submethods, but we need to be careful not to hurt |
70 // performance. |
97 // performance. |
71 // |
98 // |
83 // The same test as "o->is_forwarded()" |
110 // The same test as "o->is_forwarded()" |
84 if (!test_mark->is_marked()) { |
111 if (!test_mark->is_marked()) { |
85 bool new_obj_is_tenured = false; |
112 bool new_obj_is_tenured = false; |
86 size_t new_obj_size = o->size(); |
113 size_t new_obj_size = o->size(); |
87 |
114 |
|
115 // Find the objects age, MT safe. |
|
116 uint age = (test_mark->has_displaced_mark_helper() /* o->has_displaced_mark() */) ? |
|
117 test_mark->displaced_mark_helper()->age() : test_mark->age(); |
|
118 |
88 if (!promote_immediately) { |
119 if (!promote_immediately) { |
89 // Find the objects age, MT safe. |
|
90 uint age = (test_mark->has_displaced_mark_helper() /* o->has_displaced_mark() */) ? |
|
91 test_mark->displaced_mark_helper()->age() : test_mark->age(); |
|
92 |
|
93 // Try allocating obj in to-space (unless too old) |
120 // Try allocating obj in to-space (unless too old) |
94 if (age < PSScavenge::tenuring_threshold()) { |
121 if (age < PSScavenge::tenuring_threshold()) { |
95 new_obj = (oop) _young_lab.allocate(new_obj_size); |
122 new_obj = (oop) _young_lab.allocate(new_obj_size); |
96 if (new_obj == NULL && !_young_gen_is_full) { |
123 if (new_obj == NULL && !_young_gen_is_full) { |
97 // Do we allocate directly, or flush and refill? |
124 // Do we allocate directly, or flush and refill? |
98 if (new_obj_size > (YoungPLABSize / 2)) { |
125 if (new_obj_size > (YoungPLABSize / 2)) { |
99 // Allocate this object directly |
126 // Allocate this object directly |
100 new_obj = (oop)young_space()->cas_allocate(new_obj_size); |
127 new_obj = (oop)young_space()->cas_allocate(new_obj_size); |
|
128 promotion_trace_event(new_obj, o, new_obj_size, age, false, NULL); |
101 } else { |
129 } else { |
102 // Flush and fill |
130 // Flush and fill |
103 _young_lab.flush(); |
131 _young_lab.flush(); |
104 |
132 |
105 HeapWord* lab_base = young_space()->cas_allocate(YoungPLABSize); |
133 HeapWord* lab_base = young_space()->cas_allocate(YoungPLABSize); |
106 if (lab_base != NULL) { |
134 if (lab_base != NULL) { |
107 _young_lab.initialize(MemRegion(lab_base, YoungPLABSize)); |
135 _young_lab.initialize(MemRegion(lab_base, YoungPLABSize)); |
108 // Try the young lab allocation again. |
136 // Try the young lab allocation again. |
109 new_obj = (oop) _young_lab.allocate(new_obj_size); |
137 new_obj = (oop) _young_lab.allocate(new_obj_size); |
|
138 promotion_trace_event(new_obj, o, new_obj_size, age, false, &_young_lab); |
110 } else { |
139 } else { |
111 _young_gen_is_full = true; |
140 _young_gen_is_full = true; |
112 } |
141 } |
113 } |
142 } |
114 } |
143 } |
130 if (!_old_gen_is_full) { |
159 if (!_old_gen_is_full) { |
131 // Do we allocate directly, or flush and refill? |
160 // Do we allocate directly, or flush and refill? |
132 if (new_obj_size > (OldPLABSize / 2)) { |
161 if (new_obj_size > (OldPLABSize / 2)) { |
133 // Allocate this object directly |
162 // Allocate this object directly |
134 new_obj = (oop)old_gen()->cas_allocate(new_obj_size); |
163 new_obj = (oop)old_gen()->cas_allocate(new_obj_size); |
|
164 promotion_trace_event(new_obj, o, new_obj_size, age, true, NULL); |
135 } else { |
165 } else { |
136 // Flush and fill |
166 // Flush and fill |
137 _old_lab.flush(); |
167 _old_lab.flush(); |
138 |
168 |
139 HeapWord* lab_base = old_gen()->cas_allocate(OldPLABSize); |
169 HeapWord* lab_base = old_gen()->cas_allocate(OldPLABSize); |
146 } |
176 } |
147 #endif |
177 #endif |
148 _old_lab.initialize(MemRegion(lab_base, OldPLABSize)); |
178 _old_lab.initialize(MemRegion(lab_base, OldPLABSize)); |
149 // Try the old lab allocation again. |
179 // Try the old lab allocation again. |
150 new_obj = (oop) _old_lab.allocate(new_obj_size); |
180 new_obj = (oop) _old_lab.allocate(new_obj_size); |
|
181 promotion_trace_event(new_obj, o, new_obj_size, age, true, &_old_lab); |
151 } |
182 } |
152 } |
183 } |
153 } |
184 } |
154 |
185 |
155 // This is the promotion failed test, and code handling. |
186 // This is the promotion failed test, and code handling. |