Mercurial > hg > truffle
comparison src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @ 14349:06dfb0e4dcb8
8033601: G1: Make array chunking use the same length field as the other young GCs
Summary: Use the old copy length instead of the length of the forwarded object for chunked arrays.
Reviewed-by: brutisso, tschatzl
author | tonyp |
---|---|
date | Wed, 05 Feb 2014 12:47:48 +0100 |
parents | 2edf6f3e191d |
children | 990d7aa2f325 |
comparison
equal
deleted
inserted
replaced
14348:6827d470020d | 14349:06dfb0e4dcb8 |
---|---|
4762 size_t* surv_young_words = _par_scan_state->surviving_young_words(); | 4762 size_t* surv_young_words = _par_scan_state->surviving_young_words(); |
4763 surv_young_words[young_index] += word_sz; | 4763 surv_young_words[young_index] += word_sz; |
4764 | 4764 |
4765 if (obj->is_objArray() && arrayOop(obj)->length() >= ParGCArrayScanChunk) { | 4765 if (obj->is_objArray() && arrayOop(obj)->length() >= ParGCArrayScanChunk) { |
4766 // We keep track of the next start index in the length field of | 4766 // We keep track of the next start index in the length field of |
4767 // the to-space object. The actual length can be found in the | 4767 // the from-space object. The actual length can be found in the |
4768 // length field of the from-space object. | 4768 // length field of the to-space object. |
4769 arrayOop(obj)->set_length(0); | 4769 arrayOop(old)->set_length(0); |
4770 oop* old_p = set_partial_array_mask(old); | 4770 oop* old_p = set_partial_array_mask(old); |
4771 _par_scan_state->push_on_queue(old_p); | 4771 _par_scan_state->push_on_queue(old_p); |
4772 } else { | 4772 } else { |
4773 // No point in using the slower heap_region_containing() method, | 4773 // No point in using the slower heap_region_containing() method, |
4774 // given that we know obj is in the heap. | 4774 // given that we know obj is in the heap. |
4838 oop from_obj = clear_partial_array_mask(p); | 4838 oop from_obj = clear_partial_array_mask(p); |
4839 | 4839 |
4840 assert(Universe::heap()->is_in_reserved(from_obj), "must be in heap."); | 4840 assert(Universe::heap()->is_in_reserved(from_obj), "must be in heap."); |
4841 assert(from_obj->is_objArray(), "must be obj array"); | 4841 assert(from_obj->is_objArray(), "must be obj array"); |
4842 objArrayOop from_obj_array = objArrayOop(from_obj); | 4842 objArrayOop from_obj_array = objArrayOop(from_obj); |
4843 // The from-space object contains the real length. | 4843 // We keep track of the next start index in the length field of the |
4844 int length = from_obj_array->length(); | 4844 // from-space object. |
4845 int next_index = from_obj_array->length(); | |
4845 | 4846 |
4846 assert(from_obj->is_forwarded(), "must be forwarded"); | 4847 assert(from_obj->is_forwarded(), "must be forwarded"); |
4847 oop to_obj = from_obj->forwardee(); | 4848 oop to_obj = from_obj->forwardee(); |
4848 assert(from_obj != to_obj, "should not be chunking self-forwarded objects"); | 4849 assert(from_obj != to_obj, "should not be chunking self-forwarded objects"); |
4849 objArrayOop to_obj_array = objArrayOop(to_obj); | 4850 objArrayOop to_obj_array = objArrayOop(to_obj); |
4850 // We keep track of the next start index in the length field of the | 4851 // The to-space object contains the real length. |
4851 // to-space object. | 4852 int length = to_obj_array->length(); |
4852 int next_index = to_obj_array->length(); | |
4853 assert(0 <= next_index && next_index < length, | 4853 assert(0 <= next_index && next_index < length, |
4854 err_msg("invariant, next index: %d, length: %d", next_index, length)); | 4854 err_msg("invariant, next index: %d, length: %d", next_index, length)); |
4855 | 4855 |
4856 int start = next_index; | 4856 int start = next_index; |
4857 int end = length; | 4857 int end = length; |
4858 int remainder = end - start; | 4858 int remainder = end - start; |
4859 // We'll try not to push a range that's smaller than ParGCArrayScanChunk. | 4859 // We'll try not to push a range that's smaller than ParGCArrayScanChunk. |
4860 if (remainder > 2 * ParGCArrayScanChunk) { | 4860 if (remainder > 2 * ParGCArrayScanChunk) { |
4861 end = start + ParGCArrayScanChunk; | 4861 end = start + ParGCArrayScanChunk; |
4862 to_obj_array->set_length(end); | 4862 from_obj_array->set_length(end); |
4863 // Push the remainder before we process the range in case another | 4863 // Push the remainder before we process the range in case another |
4864 // worker has run out of things to do and can steal it. | 4864 // worker has run out of things to do and can steal it. |
4865 oop* from_obj_p = set_partial_array_mask(from_obj); | 4865 oop* from_obj_p = set_partial_array_mask(from_obj); |
4866 _par_scan_state->push_on_queue(from_obj_p); | 4866 _par_scan_state->push_on_queue(from_obj_p); |
4867 } else { | 4867 } else { |
4868 assert(length == end, "sanity"); | 4868 assert(length == end, "sanity"); |
4869 // We'll process the final range for this object. Restore the length | 4869 // We'll process the final range for this object. Restore the length |
4870 // so that the heap remains parsable in case of evacuation failure. | 4870 // so that the heap remains parsable in case of evacuation failure. |
4871 to_obj_array->set_length(end); | 4871 from_obj_array->set_length(end); |
4872 } | 4872 } |
4873 _scanner.set_region(_g1->heap_region_containing_raw(to_obj)); | 4873 _scanner.set_region(_g1->heap_region_containing_raw(to_obj)); |
4874 // Process indexes [start,end). It will also process the header | 4874 // Process indexes [start,end). It will also process the header |
4875 // along with the first chunk (i.e., the chunk with start == 0). | 4875 // along with the first chunk (i.e., the chunk with start == 0). |
4876 // Note that at this point the length field of to_obj_array is not | 4876 // Note that at this point the length field of to_obj_array is not |