188
189 //=============================================================================
190 // Opto compiler runtime routines
191 //=============================================================================
192
193
194 //=============================allocation======================================
195 // We failed the fast-path allocation. Now we need to do a scavenge or GC
196 // and try allocation again.
197
198 void OptoRuntime::new_store_pre_barrier(JavaThread* thread) {
199 // After any safepoint, just before going back to compiled code,
200 // we inform the GC that we will be doing initializing writes to
201 // this object in the future without emitting card-marks, so
202 // GC may take any compensating steps.
203 // NOTE: Keep this code consistent with GraphKit::store_barrier.
204
205 oop new_obj = thread->vm_result();
206 if (new_obj == NULL) return;
207
208 assert(Universe::heap()->can_elide_tlab_store_barriers(),
209 "compiler must check this first");
210 // GC may decide to give back a safer copy of new_obj.
211 new_obj = Universe::heap()->new_store_pre_barrier(thread, new_obj);
212 thread->set_vm_result(new_obj);
213 }
214
215 // object allocation
216 JRT_BLOCK_ENTRY(void, OptoRuntime::new_instance_C(Klass* klass, JavaThread* thread))
217 JRT_BLOCK;
218 #ifndef PRODUCT
219 SharedRuntime::_new_instance_ctr++; // new instance requires GC
220 #endif
221 assert(check_compiled_frame(thread), "incorrect caller");
222
223 // These checks are cheap to make and support reflective allocation.
224 int lh = klass->layout_helper();
225 if (Klass::layout_helper_needs_slow_path(lh) || !InstanceKlass::cast(klass)->is_initialized()) {
226 Handle holder(THREAD, klass->klass_holder()); // keep the klass alive
227 klass->check_valid_for_instantiation(false, THREAD);
228 if (!HAS_PENDING_EXCEPTION) {
229 InstanceKlass::cast(klass)->initialize(THREAD);
230 }
231 }
|
188
189 //=============================================================================
190 // Opto compiler runtime routines
191 //=============================================================================
192
193
194 //=============================allocation======================================
195 // We failed the fast-path allocation. Now we need to do a scavenge or GC
196 // and try allocation again.
197
198 void OptoRuntime::new_store_pre_barrier(JavaThread* thread) {
199 // After any safepoint, just before going back to compiled code,
200 // we inform the GC that we will be doing initializing writes to
201 // this object in the future without emitting card-marks, so
202 // GC may take any compensating steps.
203 // NOTE: Keep this code consistent with GraphKit::store_barrier.
204
205 oop new_obj = thread->vm_result();
206 if (new_obj == NULL) return;
207
208 assert(GC::gc()->heap()->can_elide_tlab_store_barriers(),
209 "compiler must check this first");
210 // GC may decide to give back a safer copy of new_obj.
211 new_obj = GC::gc()->heap()->new_store_pre_barrier(thread, new_obj);
212 thread->set_vm_result(new_obj);
213 }
214
215 // object allocation
216 JRT_BLOCK_ENTRY(void, OptoRuntime::new_instance_C(Klass* klass, JavaThread* thread))
217 JRT_BLOCK;
218 #ifndef PRODUCT
219 SharedRuntime::_new_instance_ctr++; // new instance requires GC
220 #endif
221 assert(check_compiled_frame(thread), "incorrect caller");
222
223 // These checks are cheap to make and support reflective allocation.
224 int lh = klass->layout_helper();
225 if (Klass::layout_helper_needs_slow_path(lh) || !InstanceKlass::cast(klass)->is_initialized()) {
226 Handle holder(THREAD, klass->klass_holder()); // keep the klass alive
227 klass->check_valid_for_instantiation(false, THREAD);
228 if (!HAS_PENDING_EXCEPTION) {
229 InstanceKlass::cast(klass)->initialize(THREAD);
230 }
231 }
|