Mercurial > hg > graal-jvmci-8
comparison src/share/vm/opto/runtime.cpp @ 1027:39b01ab7035a
6888898: CMS: ReduceInitialCardMarks unsafe in the presence of cms precleaning
6889757: G1: enable card mark elision for initializing writes from compiled code (ReduceInitialCardMarks)
Summary: Defer the (compiler-elided) card-mark upon a slow-path allocation until after the store and before the next subsequent safepoint; G1 now answers yes to can_elide_tlab_write_barriers().
Reviewed-by: jcoomes, kvn, never
author | ysr |
---|---|
date | Fri, 16 Oct 2009 02:05:46 -0700 |
parents | 98cb887364d3 |
children | e66fd840cb6b |
comparison
equal
deleted
inserted
replaced
1025:1ee412f7fec9 | 1027:39b01ab7035a |
---|---|
141 | 141 |
142 //=============================allocation====================================== | 142 //=============================allocation====================================== |
143 // We failed the fast-path allocation. Now we need to do a scavenge or GC | 143 // We failed the fast-path allocation. Now we need to do a scavenge or GC |
144 // and try allocation again. | 144 // and try allocation again. |
145 | 145 |
146 void OptoRuntime::do_eager_card_mark(JavaThread* thread) { | 146 void OptoRuntime::maybe_defer_card_mark(JavaThread* thread) { |
147 // After any safepoint, just before going back to compiled code, | 147 // After any safepoint, just before going back to compiled code, |
148 // we perform a card mark. This lets the compiled code omit | 148 // we inform the GC that we will be doing initializing writes to |
149 // card marks for initialization of new objects. | 149 // this object in the future without emitting card-marks, so |
150 // Keep this code consistent with GraphKit::store_barrier. | 150 // GC may take any compensating steps. |
151 // NOTE: Keep this code consistent with GraphKit::store_barrier. | |
151 | 152 |
152 oop new_obj = thread->vm_result(); | 153 oop new_obj = thread->vm_result(); |
153 if (new_obj == NULL) return; | 154 if (new_obj == NULL) return; |
154 | 155 |
155 assert(Universe::heap()->can_elide_tlab_store_barriers(), | 156 assert(Universe::heap()->can_elide_tlab_store_barriers(), |
156 "compiler must check this first"); | 157 "compiler must check this first"); |
157 new_obj = Universe::heap()->new_store_barrier(new_obj); | 158 // GC may decide to give back a safer copy of new_obj. |
159 new_obj = Universe::heap()->defer_store_barrier(thread, new_obj); | |
158 thread->set_vm_result(new_obj); | 160 thread->set_vm_result(new_obj); |
159 } | 161 } |
160 | 162 |
161 // object allocation | 163 // object allocation |
162 JRT_BLOCK_ENTRY(void, OptoRuntime::new_instance_C(klassOopDesc* klass, JavaThread* thread)) | 164 JRT_BLOCK_ENTRY(void, OptoRuntime::new_instance_C(klassOopDesc* klass, JavaThread* thread)) |
195 | 197 |
196 deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION); | 198 deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION); |
197 JRT_BLOCK_END; | 199 JRT_BLOCK_END; |
198 | 200 |
199 if (GraphKit::use_ReduceInitialCardMarks()) { | 201 if (GraphKit::use_ReduceInitialCardMarks()) { |
200 // do them now so we don't have to do them on the fast path | 202 // inform GC that we won't do card marks for initializing writes. |
201 do_eager_card_mark(thread); | 203 maybe_defer_card_mark(thread); |
202 } | 204 } |
203 JRT_END | 205 JRT_END |
204 | 206 |
205 | 207 |
206 // array allocation | 208 // array allocation |
234 deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION); | 236 deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION); |
235 thread->set_vm_result(result); | 237 thread->set_vm_result(result); |
236 JRT_BLOCK_END; | 238 JRT_BLOCK_END; |
237 | 239 |
238 if (GraphKit::use_ReduceInitialCardMarks()) { | 240 if (GraphKit::use_ReduceInitialCardMarks()) { |
239 // do them now so we don't have to do them on the fast path | 241 // inform GC that we won't do card marks for initializing writes. |
240 do_eager_card_mark(thread); | 242 maybe_defer_card_mark(thread); |
241 } | 243 } |
242 JRT_END | 244 JRT_END |
243 | 245 |
244 // Note: multianewarray for one dimension is handled inline by GraphKit::new_array. | 246 // Note: multianewarray for one dimension is handled inline by GraphKit::new_array. |
245 | 247 |