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)) |
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 |