Mercurial > hg > graal-jvmci-8
comparison src/share/vm/oops/objArrayKlass.cpp @ 845:df6caf649ff7
6700789: G1: Enable use of compressed oops with G1 heaps
Summary: Modifications to G1 so as to allow the use of compressed oops.
Reviewed-by: apetrusenko, coleenp, jmasa, kvn, never, phh, tonyp
author | ysr |
---|---|
date | Tue, 14 Jul 2009 15:40:39 -0700 |
parents | c89f86385056 |
children | 494244ae0171 |
comparison
equal
deleted
inserted
replaced
839:bb18957ad21e | 845:df6caf649ff7 |
---|---|
82 | 82 |
83 // Either oop or narrowOop depending on UseCompressedOops. | 83 // Either oop or narrowOop depending on UseCompressedOops. |
84 template <class T> void objArrayKlass::do_copy(arrayOop s, T* src, | 84 template <class T> void objArrayKlass::do_copy(arrayOop s, T* src, |
85 arrayOop d, T* dst, int length, TRAPS) { | 85 arrayOop d, T* dst, int length, TRAPS) { |
86 | 86 |
87 const size_t word_len = objArrayOopDesc::array_size(length); | |
88 | |
89 BarrierSet* bs = Universe::heap()->barrier_set(); | 87 BarrierSet* bs = Universe::heap()->barrier_set(); |
90 // For performance reasons, we assume we are that the write barrier we | 88 // For performance reasons, we assume we are that the write barrier we |
91 // are using has optimized modes for arrays of references. At least one | 89 // are using has optimized modes for arrays of references. At least one |
92 // of the asserts below will fail if this is not the case. | 90 // of the asserts below will fail if this is not the case. |
93 assert(bs->has_write_ref_array_opt(), "Barrier set must have ref array opt"); | 91 assert(bs->has_write_ref_array_opt(), "Barrier set must have ref array opt"); |
94 assert(bs->has_write_ref_array_pre_opt(), "For pre-barrier as well."); | 92 assert(bs->has_write_ref_array_pre_opt(), "For pre-barrier as well."); |
95 | 93 |
96 MemRegion dst_mr = MemRegion((HeapWord*)dst, word_len); | |
97 if (s == d) { | 94 if (s == d) { |
98 // since source and destination are equal we do not need conversion checks. | 95 // since source and destination are equal we do not need conversion checks. |
99 assert(length > 0, "sanity check"); | 96 assert(length > 0, "sanity check"); |
100 bs->write_ref_array_pre(dst_mr); | 97 bs->write_ref_array_pre(dst, length); |
101 Copy::conjoint_oops_atomic(src, dst, length); | 98 Copy::conjoint_oops_atomic(src, dst, length); |
102 } else { | 99 } else { |
103 // We have to make sure all elements conform to the destination array | 100 // We have to make sure all elements conform to the destination array |
104 klassOop bound = objArrayKlass::cast(d->klass())->element_klass(); | 101 klassOop bound = objArrayKlass::cast(d->klass())->element_klass(); |
105 klassOop stype = objArrayKlass::cast(s->klass())->element_klass(); | 102 klassOop stype = objArrayKlass::cast(s->klass())->element_klass(); |
106 if (stype == bound || Klass::cast(stype)->is_subtype_of(bound)) { | 103 if (stype == bound || Klass::cast(stype)->is_subtype_of(bound)) { |
107 // elements are guaranteed to be subtypes, so no check necessary | 104 // elements are guaranteed to be subtypes, so no check necessary |
108 bs->write_ref_array_pre(dst_mr); | 105 bs->write_ref_array_pre(dst, length); |
109 Copy::conjoint_oops_atomic(src, dst, length); | 106 Copy::conjoint_oops_atomic(src, dst, length); |
110 } else { | 107 } else { |
111 // slow case: need individual subtype checks | 108 // slow case: need individual subtype checks |
112 // note: don't use obj_at_put below because it includes a redundant store check | 109 // note: don't use obj_at_put below because it includes a redundant store check |
113 T* from = src; | 110 T* from = src; |
135 return; | 132 return; |
136 } | 133 } |
137 } | 134 } |
138 } | 135 } |
139 } | 136 } |
137 const size_t word_len = objArrayOopDesc::array_size(length); | |
140 bs->write_ref_array(MemRegion((HeapWord*)dst, word_len)); | 138 bs->write_ref_array(MemRegion((HeapWord*)dst, word_len)); |
141 } | 139 } |
142 | 140 |
143 void objArrayKlass::copy_array(arrayOop s, int src_pos, arrayOop d, | 141 void objArrayKlass::copy_array(arrayOop s, int src_pos, arrayOop d, |
144 int dst_pos, int length, TRAPS) { | 142 int dst_pos, int length, TRAPS) { |