< prev index next >

src/share/vm/gc/g1/g1ParScanThreadState.inline.hpp

Print this page




  84   assert(0 <= next_index && next_index < length,
  85          "invariant, next index: %d, length: %d", next_index, length);
  86 
  87   int start                  = next_index;
  88   int end                    = length;
  89   int remainder              = end - start;
  90   // We'll try not to push a range that's smaller than ParGCArrayScanChunk.
  91   if (remainder > 2 * ParGCArrayScanChunk) {
  92     end = start + ParGCArrayScanChunk;
  93     to_obj_array->set_length(end);
  94     // Push the remainder before we process the range in case another
  95     // worker has run out of things to do and can steal it.
  96     oop* from_obj_p = set_partial_array_mask(from_obj);
  97     push_on_queue(from_obj_p);
  98   } else {
  99     assert(length == end, "sanity");
 100     // We'll process the final range for this object. Restore the length
 101     // so that the heap remains parsable in case of evacuation failure.
 102     to_obj_array->set_length(end);
 103   }
 104   _scanner.set_region(_g1h->heap_region_containing_raw(to_obj));
 105   // Process indexes [start,end). It will also process the header
 106   // along with the first chunk (i.e., the chunk with start == 0).
 107   // Note that at this point the length field of to_obj_array is not
 108   // correct given that we are using it to keep track of the next
 109   // start index. oop_iterate_range() (thankfully!) ignores the length
 110   // field and only relies on the start / end parameters.  It does
 111   // however return the size of the object which will be incorrect. So
 112   // we have to ignore it even if we wanted to use it.
 113   to_obj_array->oop_iterate_range(&_scanner, start, end);
 114 }
 115 
 116 template <class T> inline void G1ParScanThreadState::deal_with_reference(T* ref_to_scan) {
 117   if (!has_partial_array_mask(ref_to_scan)) {
 118     // Note: we can use "raw" versions of "region_containing" because
 119     // "obj_to_scan" is definitely in the heap, and is not in a
 120     // humongous region.
 121     HeapRegion* r = _g1h->heap_region_containing_raw(ref_to_scan);
 122     do_oop_evac(ref_to_scan, r);
 123   } else {
 124     do_oop_partial_array((oop*)ref_to_scan);
 125   }
 126 }
 127 
 128 inline void G1ParScanThreadState::dispatch_reference(StarTask ref) {
 129   assert(verify_task(ref), "sanity");
 130   if (ref.is_narrow()) {
 131     deal_with_reference((narrowOop*)ref);
 132   } else {
 133     deal_with_reference((oop*)ref);
 134   }
 135 }
 136 
 137 void G1ParScanThreadState::steal_and_trim_queue(RefToScanQueueSet *task_queues) {
 138   StarTask stolen_task;
 139   while (task_queues->steal(_worker_id, &_hash_seed, stolen_task)) {
 140     assert(verify_task(stolen_task), "sanity");
 141     dispatch_reference(stolen_task);


  84   assert(0 <= next_index && next_index < length,
  85          "invariant, next index: %d, length: %d", next_index, length);
  86 
  87   int start                  = next_index;
  88   int end                    = length;
  89   int remainder              = end - start;
  90   // We'll try not to push a range that's smaller than ParGCArrayScanChunk.
  91   if (remainder > 2 * ParGCArrayScanChunk) {
  92     end = start + ParGCArrayScanChunk;
  93     to_obj_array->set_length(end);
  94     // Push the remainder before we process the range in case another
  95     // worker has run out of things to do and can steal it.
  96     oop* from_obj_p = set_partial_array_mask(from_obj);
  97     push_on_queue(from_obj_p);
  98   } else {
  99     assert(length == end, "sanity");
 100     // We'll process the final range for this object. Restore the length
 101     // so that the heap remains parsable in case of evacuation failure.
 102     to_obj_array->set_length(end);
 103   }
 104   _scanner.set_region(_g1h->heap_region_containing(to_obj));
 105   // Process indexes [start,end). It will also process the header
 106   // along with the first chunk (i.e., the chunk with start == 0).
 107   // Note that at this point the length field of to_obj_array is not
 108   // correct given that we are using it to keep track of the next
 109   // start index. oop_iterate_range() (thankfully!) ignores the length
 110   // field and only relies on the start / end parameters.  It does
 111   // however return the size of the object which will be incorrect. So
 112   // we have to ignore it even if we wanted to use it.
 113   to_obj_array->oop_iterate_range(&_scanner, start, end);
 114 }
 115 
 116 template <class T> inline void G1ParScanThreadState::deal_with_reference(T* ref_to_scan) {
 117   if (!has_partial_array_mask(ref_to_scan)) {
 118     HeapRegion* r = _g1h->heap_region_containing(ref_to_scan);



 119     do_oop_evac(ref_to_scan, r);
 120   } else {
 121     do_oop_partial_array((oop*)ref_to_scan);
 122   }
 123 }
 124 
 125 inline void G1ParScanThreadState::dispatch_reference(StarTask ref) {
 126   assert(verify_task(ref), "sanity");
 127   if (ref.is_narrow()) {
 128     deal_with_reference((narrowOop*)ref);
 129   } else {
 130     deal_with_reference((oop*)ref);
 131   }
 132 }
 133 
 134 void G1ParScanThreadState::steal_and_trim_queue(RefToScanQueueSet *task_queues) {
 135   StarTask stolen_task;
 136   while (task_queues->steal(_worker_id, &_hash_seed, stolen_task)) {
 137     assert(verify_task(stolen_task), "sanity");
 138     dispatch_reference(stolen_task);
< prev index next >