212 }
213 }
214 #endif
215 thread->set_vm_result(result);
216 if (!is_fast_aldc) {
217 // Tell the interpreter how to unbox the primitive.
218 guarantee(java_lang_boxing_object::is_instance(result, type), "");
219 int offset = java_lang_boxing_object::value_offset_in_bytes(type);
220 intptr_t flags = ((as_TosState(type) << ConstantPoolCacheEntry::tos_state_shift)
221 | (offset & ConstantPoolCacheEntry::field_index_mask));
222 thread->set_vm_result_2((Metadata*)flags);
223 }
224 }
225 IRT_END
226
227
228 //------------------------------------------------------------------------------------------------------------------------
229 // Allocation
230
231 IRT_ENTRY(void, InterpreterRuntime::_new(JavaThread* thread, ConstantPool* pool, int index))
232 Klass* k = pool->klass_at(index, CHECK);
233 InstanceKlass* klass = InstanceKlass::cast(k);
234
235 // Make sure we are not instantiating an abstract klass
236 klass->check_valid_for_instantiation(true, CHECK);
237
238 // Make sure klass is initialized
239 klass->initialize(CHECK);
240
241 // At this point the class may not be fully initialized
242 // because of recursive initialization. If it is fully
243 // initialized & has_finalized is not set, we rewrite
244 // it into its fast version (Note: no locking is needed
245 // here since this is an atomic byte write and can be
246 // done more than once).
247 //
248 // Note: In case of classes with has_finalized we don't
249 // rewrite since that saves us an extra check in
250 // the fast version which then would call the
251 // slow version anyway (and do a call back into
252 // Java).
253 // If we have a breakpoint, then we don't rewrite
254 // because the _breakpoint bytecode would be lost.
255 oop obj = klass->allocate_instance(CHECK);
256 thread->set_vm_result(obj);
257 IRT_END
258
259
260 IRT_ENTRY(void, InterpreterRuntime::newarray(JavaThread* thread, BasicType type, jint size))
261 oop obj = oopFactory::new_typeArray(type, size, CHECK);
262 thread->set_vm_result(obj);
263 IRT_END
264
265
266 IRT_ENTRY(void, InterpreterRuntime::anewarray(JavaThread* thread, ConstantPool* pool, int index, jint size))
267 Klass* klass = pool->klass_at(index, CHECK);
268 objArrayOop obj = oopFactory::new_objArray(klass, size, CHECK);
269 thread->set_vm_result(obj);
270 IRT_END
271
272
273 IRT_ENTRY(void, InterpreterRuntime::multianewarray(JavaThread* thread, jint* first_size_address))
274 // We may want to pass in more arguments - could make this slightly faster
275 LastFrameAccessor last_frame(thread);
276 ConstantPool* constants = last_frame.method()->constants();
277 int i = last_frame.get_index_u2(Bytecodes::_multianewarray);
278 Klass* klass = constants->klass_at(i, CHECK);
279 int nof_dims = last_frame.number_of_dimensions();
280 assert(klass->is_klass(), "not a class");
281 assert(nof_dims >= 1, "multianewarray rank must be nonzero");
282
283 // We must create an array of jints to pass to multi_allocate.
284 ResourceMark rm(thread);
285 const int small_dims = 10;
286 jint dim_array[small_dims];
287 jint *dims = &dim_array[0];
288 if (nof_dims > small_dims) {
289 dims = (jint*) NEW_RESOURCE_ARRAY(jint, nof_dims);
290 }
291 for (int index = 0; index < nof_dims; index++) {
292 // offset from first_size_address is addressed as local[index]
293 int n = Interpreter::local_offset_in_bytes(index)/jintSize;
|
212 }
213 }
214 #endif
215 thread->set_vm_result(result);
216 if (!is_fast_aldc) {
217 // Tell the interpreter how to unbox the primitive.
218 guarantee(java_lang_boxing_object::is_instance(result, type), "");
219 int offset = java_lang_boxing_object::value_offset_in_bytes(type);
220 intptr_t flags = ((as_TosState(type) << ConstantPoolCacheEntry::tos_state_shift)
221 | (offset & ConstantPoolCacheEntry::field_index_mask));
222 thread->set_vm_result_2((Metadata*)flags);
223 }
224 }
225 IRT_END
226
227
228 //------------------------------------------------------------------------------------------------------------------------
229 // Allocation
230
231 IRT_ENTRY(void, InterpreterRuntime::_new(JavaThread* thread, ConstantPool* pool, int index))
232 JvmtiSampledObjectAllocEventCollector collector;
233 Klass* k = pool->klass_at(index, CHECK);
234 InstanceKlass* klass = InstanceKlass::cast(k);
235
236 // Make sure we are not instantiating an abstract klass
237 klass->check_valid_for_instantiation(true, CHECK);
238
239 // Make sure klass is initialized
240 klass->initialize(CHECK);
241
242 // At this point the class may not be fully initialized
243 // because of recursive initialization. If it is fully
244 // initialized & has_finalized is not set, we rewrite
245 // it into its fast version (Note: no locking is needed
246 // here since this is an atomic byte write and can be
247 // done more than once).
248 //
249 // Note: In case of classes with has_finalized we don't
250 // rewrite since that saves us an extra check in
251 // the fast version which then would call the
252 // slow version anyway (and do a call back into
253 // Java).
254 // If we have a breakpoint, then we don't rewrite
255 // because the _breakpoint bytecode would be lost.
256 oop obj = klass->allocate_instance(CHECK);
257 thread->set_vm_result(obj);
258 IRT_END
259
260
261 IRT_ENTRY(void, InterpreterRuntime::newarray(JavaThread* thread, BasicType type, jint size))
262 JvmtiSampledObjectAllocEventCollector collector;
263 oop obj = oopFactory::new_typeArray(type, size, CHECK);
264 thread->set_vm_result(obj);
265 IRT_END
266
267
268 IRT_ENTRY(void, InterpreterRuntime::anewarray(JavaThread* thread, ConstantPool* pool, int index, jint size))
269 JvmtiSampledObjectAllocEventCollector collector;
270 Klass* klass = pool->klass_at(index, CHECK);
271 objArrayOop obj = oopFactory::new_objArray(klass, size, CHECK);
272 thread->set_vm_result(obj);
273 IRT_END
274
275
276 IRT_ENTRY(void, InterpreterRuntime::multianewarray(JavaThread* thread, jint* first_size_address))
277 JvmtiSampledObjectAllocEventCollector collector;
278 // We may want to pass in more arguments - could make this slightly faster
279 LastFrameAccessor last_frame(thread);
280 ConstantPool* constants = last_frame.method()->constants();
281 int i = last_frame.get_index_u2(Bytecodes::_multianewarray);
282 Klass* klass = constants->klass_at(i, CHECK);
283 int nof_dims = last_frame.number_of_dimensions();
284 assert(klass->is_klass(), "not a class");
285 assert(nof_dims >= 1, "multianewarray rank must be nonzero");
286
287 // We must create an array of jints to pass to multi_allocate.
288 ResourceMark rm(thread);
289 const int small_dims = 10;
290 jint dim_array[small_dims];
291 jint *dims = &dim_array[0];
292 if (nof_dims > small_dims) {
293 dims = (jint*) NEW_RESOURCE_ARRAY(jint, nof_dims);
294 }
295 for (int index = 0; index < nof_dims; index++) {
296 // offset from first_size_address is addressed as local[index]
297 int n = Interpreter::local_offset_in_bytes(index)/jintSize;
|