241
242 // Scavenge and allocate an instance.
243 oop result;
244
245 if (array_type->is_valueArray_klass()) {
246 // TODO refactor all these checks, is_typeArray_klass should not be true for a value type array
247 // TODO use oopFactory::new_array
248 Klass* elem_type = ValueArrayKlass::cast(array_type)->element_klass();
249 result = oopFactory::new_valueArray(elem_type, len, THREAD);
250 } else if (array_type->is_typeArray_klass()) {
251 // The oopFactory likes to work with the element type.
252 // (We could bypass the oopFactory, since it doesn't add much value.)
253 BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type();
254 result = oopFactory::new_typeArray(elem_type, len, THREAD);
255 } else {
256 // Although the oopFactory likes to work with the elem_type,
257 // the compiler prefers the array_type, since it must already have
258 // that latter value in hand for the fast path.
259 Handle holder(THREAD, array_type->klass_holder()); // keep the array klass alive
260 Klass* elem_type = ObjArrayKlass::cast(array_type)->element_klass();
261 result = oopFactory::new_array(elem_type, len, THREAD);
262 }
263
264 // Pass oops back through thread local storage. Our apparent type to Java
265 // is that we return an oop, but we can block on exit from this routine and
266 // a GC can trash the oop in C's return register. The generated stub will
267 // fetch the oop from TLS after any possible GC.
268 deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION);
269 thread->set_vm_result(result);
270 JRT_BLOCK_END;
271
272 // inform GC that we won't do card marks for initializing writes.
273 SharedRuntime::on_slowpath_allocation_exit(thread);
274 JRT_END
275
276 // array allocation without zeroing
277 JRT_BLOCK_ENTRY(void, OptoRuntime::new_array_nozero_C(Klass* array_type, int len, JavaThread *thread))
278 JRT_BLOCK;
279 #ifndef PRODUCT
280 SharedRuntime::_new_array_ctr++; // new array requires GC
281 #endif
|
241
242 // Scavenge and allocate an instance.
243 oop result;
244
245 if (array_type->is_valueArray_klass()) {
246 // TODO refactor all these checks, is_typeArray_klass should not be true for a value type array
247 // TODO use oopFactory::new_array
248 Klass* elem_type = ValueArrayKlass::cast(array_type)->element_klass();
249 result = oopFactory::new_valueArray(elem_type, len, THREAD);
250 } else if (array_type->is_typeArray_klass()) {
251 // The oopFactory likes to work with the element type.
252 // (We could bypass the oopFactory, since it doesn't add much value.)
253 BasicType elem_type = TypeArrayKlass::cast(array_type)->element_type();
254 result = oopFactory::new_typeArray(elem_type, len, THREAD);
255 } else {
256 // Although the oopFactory likes to work with the elem_type,
257 // the compiler prefers the array_type, since it must already have
258 // that latter value in hand for the fast path.
259 Handle holder(THREAD, array_type->klass_holder()); // keep the array klass alive
260 Klass* elem_type = ObjArrayKlass::cast(array_type)->element_klass();
261 result = ObjArrayKlass::cast(array_type)->allocate(len, THREAD);
262 }
263
264 // Pass oops back through thread local storage. Our apparent type to Java
265 // is that we return an oop, but we can block on exit from this routine and
266 // a GC can trash the oop in C's return register. The generated stub will
267 // fetch the oop from TLS after any possible GC.
268 deoptimize_caller_frame(thread, HAS_PENDING_EXCEPTION);
269 thread->set_vm_result(result);
270 JRT_BLOCK_END;
271
272 // inform GC that we won't do card marks for initializing writes.
273 SharedRuntime::on_slowpath_allocation_exit(thread);
274 JRT_END
275
276 // array allocation without zeroing
277 JRT_BLOCK_ENTRY(void, OptoRuntime::new_array_nozero_C(Klass* array_type, int len, JavaThread *thread))
278 JRT_BLOCK;
279 #ifndef PRODUCT
280 SharedRuntime::_new_array_ctr++; // new array requires GC
281 #endif
|