Mercurial > hg > truffle
comparison src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp @ 17759:bc22cbb8b45a
8035330: Remove G1ParScanPartialArrayClosure and G1ParScanHeapEvacClosure
Summary: Mentioned closures are actually wrapped methods. This adds confusion to readers, and in this case also increases code size as G1ParScanHeapEvacClosure is part of the oop_oop_iterate() methods. Move them into G1ParScanThreadState as methods.
Reviewed-by: stefank
author | tschatzl |
---|---|
date | Mon, 24 Mar 2014 15:30:56 +0100 |
parents | a07bea31ef35 |
children | 8ee855b4e667 |
comparison
equal
deleted
inserted
replaced
17758:ae7336d6337e | 17759:bc22cbb8b45a |
---|---|
1791 | 1791 |
1792 size_t _alloc_buffer_waste; | 1792 size_t _alloc_buffer_waste; |
1793 size_t _undo_waste; | 1793 size_t _undo_waste; |
1794 | 1794 |
1795 OopsInHeapRegionClosure* _evac_failure_cl; | 1795 OopsInHeapRegionClosure* _evac_failure_cl; |
1796 G1ParScanHeapEvacClosure* _evac_cl; | |
1797 G1ParScanPartialArrayClosure* _partial_scan_cl; | |
1798 | 1796 |
1799 int _hash_seed; | 1797 int _hash_seed; |
1800 uint _queue_num; | 1798 uint _queue_num; |
1801 | 1799 |
1802 size_t _term_attempts; | 1800 size_t _term_attempts; |
1920 } | 1918 } |
1921 OopsInHeapRegionClosure* evac_failure_closure() { | 1919 OopsInHeapRegionClosure* evac_failure_closure() { |
1922 return _evac_failure_cl; | 1920 return _evac_failure_cl; |
1923 } | 1921 } |
1924 | 1922 |
1925 void set_evac_closure(G1ParScanHeapEvacClosure* evac_cl) { | |
1926 _evac_cl = evac_cl; | |
1927 } | |
1928 | |
1929 void set_partial_scan_closure(G1ParScanPartialArrayClosure* partial_scan_cl) { | |
1930 _partial_scan_cl = partial_scan_cl; | |
1931 } | |
1932 | |
1933 int* hash_seed() { return &_hash_seed; } | 1923 int* hash_seed() { return &_hash_seed; } |
1934 uint queue_num() { return _queue_num; } | 1924 uint queue_num() { return _queue_num; } |
1935 | 1925 |
1936 size_t term_attempts() const { return _term_attempts; } | 1926 size_t term_attempts() const { return _term_attempts; } |
1937 void note_term_attempt() { _term_attempts++; } | 1927 void note_term_attempt() { _term_attempts++; } |
1975 _alloc_buffers[ap]->flush_stats_and_retire(_g1h->stats_for_purpose((GCAllocPurpose)ap), | 1965 _alloc_buffers[ap]->flush_stats_and_retire(_g1h->stats_for_purpose((GCAllocPurpose)ap), |
1976 true /* end_of_gc */, | 1966 true /* end_of_gc */, |
1977 false /* retain */); | 1967 false /* retain */); |
1978 } | 1968 } |
1979 } | 1969 } |
1970 private: | |
1971 #define G1_PARTIAL_ARRAY_MASK 0x2 | |
1972 | |
1973 inline bool has_partial_array_mask(oop* ref) const { | |
1974 return ((uintptr_t)ref & G1_PARTIAL_ARRAY_MASK) == G1_PARTIAL_ARRAY_MASK; | |
1975 } | |
1976 | |
1977 // We never encode partial array oops as narrowOop*, so return false immediately. | |
1978 // This allows the compiler to create optimized code when popping references from | |
1979 // the work queue. | |
1980 inline bool has_partial_array_mask(narrowOop* ref) const { | |
1981 assert(((uintptr_t)ref & G1_PARTIAL_ARRAY_MASK) != G1_PARTIAL_ARRAY_MASK, "Partial array oop reference encoded as narrowOop*"); | |
1982 return false; | |
1983 } | |
1984 | |
1985 // Only implement set_partial_array_mask() for regular oops, not for narrowOops. | |
1986 // We always encode partial arrays as regular oop, to allow the | |
1987 // specialization for has_partial_array_mask() for narrowOops above. | |
1988 // This means that unintentional use of this method with narrowOops are caught | |
1989 // by the compiler. | |
1990 inline oop* set_partial_array_mask(oop obj) const { | |
1991 assert(((uintptr_t)(void *)obj & G1_PARTIAL_ARRAY_MASK) == 0, "Information loss!"); | |
1992 return (oop*) ((uintptr_t)(void *)obj | G1_PARTIAL_ARRAY_MASK); | |
1993 } | |
1994 | |
1995 inline oop clear_partial_array_mask(oop* ref) const { | |
1996 return cast_to_oop((intptr_t)ref & ~G1_PARTIAL_ARRAY_MASK); | |
1997 } | |
1998 | |
1999 void do_oop_partial_array(oop* p) { | |
2000 assert(has_partial_array_mask(p), "invariant"); | |
2001 oop from_obj = clear_partial_array_mask(p); | |
2002 | |
2003 assert(Universe::heap()->is_in_reserved(from_obj), "must be in heap."); | |
2004 assert(from_obj->is_objArray(), "must be obj array"); | |
2005 objArrayOop from_obj_array = objArrayOop(from_obj); | |
2006 // The from-space object contains the real length. | |
2007 int length = from_obj_array->length(); | |
2008 | |
2009 assert(from_obj->is_forwarded(), "must be forwarded"); | |
2010 oop to_obj = from_obj->forwardee(); | |
2011 assert(from_obj != to_obj, "should not be chunking self-forwarded objects"); | |
2012 objArrayOop to_obj_array = objArrayOop(to_obj); | |
2013 // We keep track of the next start index in the length field of the | |
2014 // to-space object. | |
2015 int next_index = to_obj_array->length(); | |
2016 assert(0 <= next_index && next_index < length, | |
2017 err_msg("invariant, next index: %d, length: %d", next_index, length)); | |
2018 | |
2019 int start = next_index; | |
2020 int end = length; | |
2021 int remainder = end - start; | |
2022 // We'll try not to push a range that's smaller than ParGCArrayScanChunk. | |
2023 if (remainder > 2 * ParGCArrayScanChunk) { | |
2024 end = start + ParGCArrayScanChunk; | |
2025 to_obj_array->set_length(end); | |
2026 // Push the remainder before we process the range in case another | |
2027 // worker has run out of things to do and can steal it. | |
2028 oop* from_obj_p = set_partial_array_mask(from_obj); | |
2029 push_on_queue(from_obj_p); | |
2030 } else { | |
2031 assert(length == end, "sanity"); | |
2032 // We'll process the final range for this object. Restore the length | |
2033 // so that the heap remains parsable in case of evacuation failure. | |
2034 to_obj_array->set_length(end); | |
2035 } | |
2036 _scanner.set_region(_g1h->heap_region_containing_raw(to_obj)); | |
2037 // Process indexes [start,end). It will also process the header | |
2038 // along with the first chunk (i.e., the chunk with start == 0). | |
2039 // Note that at this point the length field of to_obj_array is not | |
2040 // correct given that we are using it to keep track of the next | |
2041 // start index. oop_iterate_range() (thankfully!) ignores the length | |
2042 // field and only relies on the start / end parameters. It does | |
2043 // however return the size of the object which will be incorrect. So | |
2044 // we have to ignore it even if we wanted to use it. | |
2045 to_obj_array->oop_iterate_range(&_scanner, start, end); | |
2046 } | |
2047 | |
2048 // This method is applied to the fields of the objects that have just been copied. | |
2049 template <class T> void do_oop_evac(T* p, HeapRegion* from) { | |
2050 assert(!oopDesc::is_null(oopDesc::load_decode_heap_oop(p)), | |
2051 "Reference should not be NULL here as such are never pushed to the task queue."); | |
2052 oop obj = oopDesc::load_decode_heap_oop_not_null(p); | |
2053 | |
2054 // Although we never intentionally push references outside of the collection | |
2055 // set, due to (benign) races in the claim mechanism during RSet scanning more | |
2056 // than one thread might claim the same card. So the same card may be | |
2057 // processed multiple times. So redo this check. | |
2058 if (_g1h->in_cset_fast_test(obj)) { | |
2059 oop forwardee; | |
2060 if (obj->is_forwarded()) { | |
2061 forwardee = obj->forwardee(); | |
2062 } else { | |
2063 forwardee = copy_to_survivor_space(obj); | |
2064 } | |
2065 assert(forwardee != NULL, "forwardee should not be NULL"); | |
2066 oopDesc::encode_store_heap_oop(p, forwardee); | |
2067 } | |
2068 | |
2069 assert(obj != NULL, "Must be"); | |
2070 update_rs(from, p, queue_num()); | |
2071 } | |
2072 public: | |
1980 | 2073 |
1981 oop copy_to_survivor_space(oop const obj); | 2074 oop copy_to_survivor_space(oop const obj); |
1982 | 2075 |
1983 template <class T> void deal_with_reference(T* ref_to_scan) { | 2076 template <class T> void deal_with_reference(T* ref_to_scan) { |
1984 if (has_partial_array_mask(ref_to_scan)) { | 2077 if (!has_partial_array_mask(ref_to_scan)) { |
1985 _partial_scan_cl->do_oop_nv(ref_to_scan); | |
1986 } else { | |
1987 // Note: we can use "raw" versions of "region_containing" because | 2078 // Note: we can use "raw" versions of "region_containing" because |
1988 // "obj_to_scan" is definitely in the heap, and is not in a | 2079 // "obj_to_scan" is definitely in the heap, and is not in a |
1989 // humongous region. | 2080 // humongous region. |
1990 HeapRegion* r = _g1h->heap_region_containing_raw(ref_to_scan); | 2081 HeapRegion* r = _g1h->heap_region_containing_raw(ref_to_scan); |
1991 _evac_cl->set_region(r); | 2082 do_oop_evac(ref_to_scan, r); |
1992 _evac_cl->do_oop_nv(ref_to_scan); | 2083 } else { |
2084 do_oop_partial_array((oop*)ref_to_scan); | |
1993 } | 2085 } |
1994 } | 2086 } |
1995 | 2087 |
1996 void deal_with_reference(StarTask ref) { | 2088 void deal_with_reference(StarTask ref) { |
1997 assert(verify_task(ref), "sanity"); | 2089 assert(verify_task(ref), "sanity"); |