12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_INLINE_HPP
26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_INLINE_HPP
27
28 #include "gc_implementation/g1/concurrentMark.hpp"
29 #include "gc_implementation/g1/g1CollectedHeap.hpp"
30 #include "gc_implementation/g1/g1AllocRegion.inline.hpp"
31 #include "gc_implementation/g1/g1CollectorPolicy.hpp"
32 #include "gc_implementation/g1/g1RemSet.inline.hpp"
33 #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
34 #include "gc_implementation/g1/heapRegionSet.inline.hpp"
35 #include "gc_implementation/g1/heapRegionSeq.inline.hpp"
36 #include "runtime/orderAccess.inline.hpp"
37 #include "utilities/taskqueue.hpp"
38
39 // Inline functions for G1CollectedHeap
40
41 // Return the region with the given index. It assumes the index is valid.
42 inline HeapRegion* G1CollectedHeap::region_at(uint index) const { return _hrs.at(index); }
43
44 template <class T>
45 inline HeapRegion*
46 G1CollectedHeap::heap_region_containing(const T addr) const {
47 HeapRegion* hr = _hrs.addr_to_region((HeapWord*) addr);
48 // hr can be null if addr in perm_gen
49 if (hr != NULL && hr->continuesHumongous()) {
50 hr = hr->humongous_start_region();
51 }
52 return hr;
274 }
275
276 inline bool G1CollectedHeap::is_obj_dead(const oop obj) const {
277 const HeapRegion* hr = heap_region_containing(obj);
278 if (hr == NULL) {
279 if (obj == NULL) return false;
280 else return true;
281 }
282 else return is_obj_dead(obj, hr);
283 }
284
285 inline bool G1CollectedHeap::is_obj_ill(const oop obj) const {
286 const HeapRegion* hr = heap_region_containing(obj);
287 if (hr == NULL) {
288 if (obj == NULL) return false;
289 else return true;
290 }
291 else return is_obj_ill(obj, hr);
292 }
293
294 template <class T> inline void G1ParScanThreadState::immediate_rs_update(HeapRegion* from, T* p, int tid) {
295 if (!from->is_survivor()) {
296 _g1_rem->par_write_ref(from, p, tid);
297 }
298 }
299
300 template <class T> void G1ParScanThreadState::update_rs(HeapRegion* from, T* p, int tid) {
301 if (G1DeferredRSUpdate) {
302 deferred_rs_update(from, p, tid);
303 } else {
304 immediate_rs_update(from, p, tid);
305 }
306 }
307
308
309 inline void G1ParScanThreadState::do_oop_partial_array(oop* p) {
310 assert(has_partial_array_mask(p), "invariant");
311 oop from_obj = clear_partial_array_mask(p);
312
313 assert(Universe::heap()->is_in_reserved(from_obj), "must be in heap.");
314 assert(from_obj->is_objArray(), "must be obj array");
315 objArrayOop from_obj_array = objArrayOop(from_obj);
316 // The from-space object contains the real length.
317 int length = from_obj_array->length();
318
319 assert(from_obj->is_forwarded(), "must be forwarded");
320 oop to_obj = from_obj->forwardee();
321 assert(from_obj != to_obj, "should not be chunking self-forwarded objects");
322 objArrayOop to_obj_array = objArrayOop(to_obj);
323 // We keep track of the next start index in the length field of the
324 // to-space object.
325 int next_index = to_obj_array->length();
326 assert(0 <= next_index && next_index < length,
327 err_msg("invariant, next index: %d, length: %d", next_index, length));
328
329 int start = next_index;
330 int end = length;
331 int remainder = end - start;
332 // We'll try not to push a range that's smaller than ParGCArrayScanChunk.
333 if (remainder > 2 * ParGCArrayScanChunk) {
334 end = start + ParGCArrayScanChunk;
335 to_obj_array->set_length(end);
336 // Push the remainder before we process the range in case another
337 // worker has run out of things to do and can steal it.
338 oop* from_obj_p = set_partial_array_mask(from_obj);
339 push_on_queue(from_obj_p);
340 } else {
341 assert(length == end, "sanity");
342 // We'll process the final range for this object. Restore the length
343 // so that the heap remains parsable in case of evacuation failure.
344 to_obj_array->set_length(end);
345 }
346 _scanner.set_region(_g1h->heap_region_containing_raw(to_obj));
347 // Process indexes [start,end). It will also process the header
348 // along with the first chunk (i.e., the chunk with start == 0).
349 // Note that at this point the length field of to_obj_array is not
350 // correct given that we are using it to keep track of the next
351 // start index. oop_iterate_range() (thankfully!) ignores the length
352 // field and only relies on the start / end parameters. It does
353 // however return the size of the object which will be incorrect. So
354 // we have to ignore it even if we wanted to use it.
355 to_obj_array->oop_iterate_range(&_scanner, start, end);
356 }
357
358 template <class T> inline void G1ParScanThreadState::deal_with_reference(T* ref_to_scan) {
359 if (!has_partial_array_mask(ref_to_scan)) {
360 // Note: we can use "raw" versions of "region_containing" because
361 // "obj_to_scan" is definitely in the heap, and is not in a
362 // humongous region.
363 HeapRegion* r = _g1h->heap_region_containing_raw(ref_to_scan);
364 do_oop_evac(ref_to_scan, r);
365 } else {
366 do_oop_partial_array((oop*)ref_to_scan);
367 }
368 }
369
370 inline void G1ParScanThreadState::deal_with_reference(StarTask ref) {
371 assert(verify_task(ref), "sanity");
372 if (ref.is_narrow()) {
373 deal_with_reference((narrowOop*)ref);
374 } else {
375 deal_with_reference((oop*)ref);
376 }
377 }
378
379 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_INLINE_HPP
|
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_INLINE_HPP
26 #define SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_INLINE_HPP
27
28 #include "gc_implementation/g1/concurrentMark.hpp"
29 #include "gc_implementation/g1/g1CollectedHeap.hpp"
30 #include "gc_implementation/g1/g1AllocRegion.inline.hpp"
31 #include "gc_implementation/g1/g1CollectorPolicy.hpp"
32 #include "gc_implementation/g1/g1SATBCardTableModRefBS.hpp"
33 #include "gc_implementation/g1/heapRegionSet.inline.hpp"
34 #include "gc_implementation/g1/heapRegionSeq.inline.hpp"
35 #include "runtime/orderAccess.inline.hpp"
36 #include "utilities/taskqueue.hpp"
37
38 // Inline functions for G1CollectedHeap
39
40 // Return the region with the given index. It assumes the index is valid.
41 inline HeapRegion* G1CollectedHeap::region_at(uint index) const { return _hrs.at(index); }
42
43 template <class T>
44 inline HeapRegion*
45 G1CollectedHeap::heap_region_containing(const T addr) const {
46 HeapRegion* hr = _hrs.addr_to_region((HeapWord*) addr);
47 // hr can be null if addr in perm_gen
48 if (hr != NULL && hr->continuesHumongous()) {
49 hr = hr->humongous_start_region();
50 }
51 return hr;
273 }
274
275 inline bool G1CollectedHeap::is_obj_dead(const oop obj) const {
276 const HeapRegion* hr = heap_region_containing(obj);
277 if (hr == NULL) {
278 if (obj == NULL) return false;
279 else return true;
280 }
281 else return is_obj_dead(obj, hr);
282 }
283
284 inline bool G1CollectedHeap::is_obj_ill(const oop obj) const {
285 const HeapRegion* hr = heap_region_containing(obj);
286 if (hr == NULL) {
287 if (obj == NULL) return false;
288 else return true;
289 }
290 else return is_obj_ill(obj, hr);
291 }
292
293 #endif // SHARE_VM_GC_IMPLEMENTATION_G1_G1COLLECTEDHEAP_INLINE_HPP
|