1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/src/share/vm/gc_implementation/g1/g1ParScanThreadState.inline.hpp Mon Jul 21 09:41:04 2014 +0200 1.3 @@ -0,0 +1,117 @@ 1.4 +/* 1.5 + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. 1.6 + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 1.7 + * 1.8 + * This code is free software; you can redistribute it and/or modify it 1.9 + * under the terms of the GNU General Public License version 2 only, as 1.10 + * published by the Free Software Foundation. 1.11 + * 1.12 + * This code is distributed in the hope that it will be useful, but WITHOUT 1.13 + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 1.14 + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License 1.15 + * version 2 for more details (a copy is included in the LICENSE file that 1.16 + * accompanied this code). 1.17 + * 1.18 + * You should have received a copy of the GNU General Public License version 1.19 + * 2 along with this work; if not, write to the Free Software Foundation, 1.20 + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 1.21 + * 1.22 + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 1.23 + * or visit www.oracle.com if you need additional information or have any 1.24 + * questions. 1.25 + * 1.26 + */ 1.27 + 1.28 +#ifndef SHARE_VM_GC_IMPLEMENTATION_G1_G1PARSCANTHREADSTATE_INLINE_HPP 1.29 +#define SHARE_VM_GC_IMPLEMENTATION_G1_G1PARSCANTHREADSTATE_INLINE_HPP 1.30 + 1.31 +#include "gc_implementation/g1/g1ParScanThreadState.hpp" 1.32 +#include "gc_implementation/g1/g1RemSet.inline.hpp" 1.33 +#include "oops/oop.inline.hpp" 1.34 + 1.35 +template <class T> inline void G1ParScanThreadState::immediate_rs_update(HeapRegion* from, T* p, int tid) { 1.36 + if (!from->is_survivor()) { 1.37 + _g1_rem->par_write_ref(from, p, tid); 1.38 + } 1.39 +} 1.40 + 1.41 +template <class T> void G1ParScanThreadState::update_rs(HeapRegion* from, T* p, int tid) { 1.42 + if (G1DeferredRSUpdate) { 1.43 + deferred_rs_update(from, p, tid); 1.44 + } else { 1.45 + immediate_rs_update(from, p, tid); 1.46 + } 1.47 +} 1.48 + 1.49 +inline void G1ParScanThreadState::do_oop_partial_array(oop* p) { 1.50 + assert(has_partial_array_mask(p), "invariant"); 1.51 + oop from_obj = clear_partial_array_mask(p); 1.52 + 1.53 + assert(Universe::heap()->is_in_reserved(from_obj), "must be in heap."); 1.54 + assert(from_obj->is_objArray(), "must be obj array"); 1.55 + objArrayOop from_obj_array = objArrayOop(from_obj); 1.56 + // The from-space object contains the real length. 1.57 + int length = from_obj_array->length(); 1.58 + 1.59 + assert(from_obj->is_forwarded(), "must be forwarded"); 1.60 + oop to_obj = from_obj->forwardee(); 1.61 + assert(from_obj != to_obj, "should not be chunking self-forwarded objects"); 1.62 + objArrayOop to_obj_array = objArrayOop(to_obj); 1.63 + // We keep track of the next start index in the length field of the 1.64 + // to-space object. 1.65 + int next_index = to_obj_array->length(); 1.66 + assert(0 <= next_index && next_index < length, 1.67 + err_msg("invariant, next index: %d, length: %d", next_index, length)); 1.68 + 1.69 + int start = next_index; 1.70 + int end = length; 1.71 + int remainder = end - start; 1.72 + // We'll try not to push a range that's smaller than ParGCArrayScanChunk. 1.73 + if (remainder > 2 * ParGCArrayScanChunk) { 1.74 + end = start + ParGCArrayScanChunk; 1.75 + to_obj_array->set_length(end); 1.76 + // Push the remainder before we process the range in case another 1.77 + // worker has run out of things to do and can steal it. 1.78 + oop* from_obj_p = set_partial_array_mask(from_obj); 1.79 + push_on_queue(from_obj_p); 1.80 + } else { 1.81 + assert(length == end, "sanity"); 1.82 + // We'll process the final range for this object. Restore the length 1.83 + // so that the heap remains parsable in case of evacuation failure. 1.84 + to_obj_array->set_length(end); 1.85 + } 1.86 + _scanner.set_region(_g1h->heap_region_containing_raw(to_obj)); 1.87 + // Process indexes [start,end). It will also process the header 1.88 + // along with the first chunk (i.e., the chunk with start == 0). 1.89 + // Note that at this point the length field of to_obj_array is not 1.90 + // correct given that we are using it to keep track of the next 1.91 + // start index. oop_iterate_range() (thankfully!) ignores the length 1.92 + // field and only relies on the start / end parameters. It does 1.93 + // however return the size of the object which will be incorrect. So 1.94 + // we have to ignore it even if we wanted to use it. 1.95 + to_obj_array->oop_iterate_range(&_scanner, start, end); 1.96 +} 1.97 + 1.98 +template <class T> inline void G1ParScanThreadState::deal_with_reference(T* ref_to_scan) { 1.99 + if (!has_partial_array_mask(ref_to_scan)) { 1.100 + // Note: we can use "raw" versions of "region_containing" because 1.101 + // "obj_to_scan" is definitely in the heap, and is not in a 1.102 + // humongous region. 1.103 + HeapRegion* r = _g1h->heap_region_containing_raw(ref_to_scan); 1.104 + do_oop_evac(ref_to_scan, r); 1.105 + } else { 1.106 + do_oop_partial_array((oop*)ref_to_scan); 1.107 + } 1.108 +} 1.109 + 1.110 +inline void G1ParScanThreadState::deal_with_reference(StarTask ref) { 1.111 + assert(verify_task(ref), "sanity"); 1.112 + if (ref.is_narrow()) { 1.113 + deal_with_reference((narrowOop*)ref); 1.114 + } else { 1.115 + deal_with_reference((oop*)ref); 1.116 + } 1.117 +} 1.118 + 1.119 +#endif /* SHARE_VM_GC_IMPLEMENTATION_G1_G1PARSCANTHREADSTATE_INLINE_HPP */ 1.120 +