158 }
159 }
160 #endif
161 thread->set_vm_result(result);
162 if (!is_fast_aldc) {
163 // Tell the interpreter how to unbox the primitive.
164 guarantee(java_lang_boxing_object::is_instance(result, type), "");
165 int offset = java_lang_boxing_object::value_offset_in_bytes(type);
166 intptr_t flags = ((as_TosState(type) << ConstantPoolCacheEntry::tos_state_shift)
167 | (offset & ConstantPoolCacheEntry::field_index_mask));
168 thread->set_vm_result_2((Metadata*)flags);
169 }
170 }
171 IRT_END
172
173
174 //------------------------------------------------------------------------------------------------------------------------
175 // Allocation
176
177 IRT_ENTRY(void, InterpreterRuntime::_new(JavaThread* thread, ConstantPool* pool, int index))
178 Klass* k = pool->klass_at(index, CHECK);
179 InstanceKlass* klass = InstanceKlass::cast(k);
180
181 // Make sure we are not instantiating an abstract klass
182 klass->check_valid_for_instantiation(true, CHECK);
183
184 // Make sure klass is initialized
185 klass->initialize(CHECK);
186
187 // At this point the class may not be fully initialized
188 // because of recursive initialization. If it is fully
189 // initialized & has_finalized is not set, we rewrite
190 // it into its fast version (Note: no locking is needed
191 // here since this is an atomic byte write and can be
192 // done more than once).
193 //
194 // Note: In case of classes with has_finalized we don't
195 // rewrite since that saves us an extra check in
196 // the fast version which then would call the
197 // slow version anyway (and do a call back into
198 // Java).
199 // If we have a breakpoint, then we don't rewrite
200 // because the _breakpoint bytecode would be lost.
201 oop obj = klass->allocate_instance(CHECK);
202 thread->set_vm_result(obj);
203 IRT_END
204
205
206 IRT_ENTRY(void, InterpreterRuntime::newarray(JavaThread* thread, BasicType type, jint size))
207 oop obj = oopFactory::new_typeArray(type, size, CHECK);
208 thread->set_vm_result(obj);
209 IRT_END
210
211
212 IRT_ENTRY(void, InterpreterRuntime::anewarray(JavaThread* thread, ConstantPool* pool, int index, jint size))
213 Klass* klass = pool->klass_at(index, CHECK);
214 objArrayOop obj = oopFactory::new_objArray(klass, size, CHECK);
215 thread->set_vm_result(obj);
216 IRT_END
217
218
219 IRT_ENTRY(void, InterpreterRuntime::multianewarray(JavaThread* thread, jint* first_size_address))
220 // We may want to pass in more arguments - could make this slightly faster
221 LastFrameAccessor last_frame(thread);
222 ConstantPool* constants = last_frame.method()->constants();
223 int i = last_frame.get_index_u2(Bytecodes::_multianewarray);
224 Klass* klass = constants->klass_at(i, CHECK);
225 int nof_dims = last_frame.number_of_dimensions();
226 assert(klass->is_klass(), "not a class");
227 assert(nof_dims >= 1, "multianewarray rank must be nonzero");
228
229 // We must create an array of jints to pass to multi_allocate.
230 ResourceMark rm(thread);
231 const int small_dims = 10;
232 jint dim_array[small_dims];
233 jint *dims = &dim_array[0];
234 if (nof_dims > small_dims) {
235 dims = (jint*) NEW_RESOURCE_ARRAY(jint, nof_dims);
236 }
237 for (int index = 0; index < nof_dims; index++) {
238 // offset from first_size_address is addressed as local[index]
239 int n = Interpreter::local_offset_in_bytes(index)/jintSize;
|
158 }
159 }
160 #endif
161 thread->set_vm_result(result);
162 if (!is_fast_aldc) {
163 // Tell the interpreter how to unbox the primitive.
164 guarantee(java_lang_boxing_object::is_instance(result, type), "");
165 int offset = java_lang_boxing_object::value_offset_in_bytes(type);
166 intptr_t flags = ((as_TosState(type) << ConstantPoolCacheEntry::tos_state_shift)
167 | (offset & ConstantPoolCacheEntry::field_index_mask));
168 thread->set_vm_result_2((Metadata*)flags);
169 }
170 }
171 IRT_END
172
173
174 //------------------------------------------------------------------------------------------------------------------------
175 // Allocation
176
177 IRT_ENTRY(void, InterpreterRuntime::_new(JavaThread* thread, ConstantPool* pool, int index))
178 JvmtiSampledObjectAllocEventCollector collector;
179 Klass* k = pool->klass_at(index, CHECK);
180 InstanceKlass* klass = InstanceKlass::cast(k);
181
182 // Make sure we are not instantiating an abstract klass
183 klass->check_valid_for_instantiation(true, CHECK);
184
185 // Make sure klass is initialized
186 klass->initialize(CHECK);
187
188 // At this point the class may not be fully initialized
189 // because of recursive initialization. If it is fully
190 // initialized & has_finalized is not set, we rewrite
191 // it into its fast version (Note: no locking is needed
192 // here since this is an atomic byte write and can be
193 // done more than once).
194 //
195 // Note: In case of classes with has_finalized we don't
196 // rewrite since that saves us an extra check in
197 // the fast version which then would call the
198 // slow version anyway (and do a call back into
199 // Java).
200 // If we have a breakpoint, then we don't rewrite
201 // because the _breakpoint bytecode would be lost.
202 oop obj = klass->allocate_instance(CHECK);
203 thread->set_vm_result(obj);
204 IRT_END
205
206
207 IRT_ENTRY(void, InterpreterRuntime::newarray(JavaThread* thread, BasicType type, jint size))
208 JvmtiSampledObjectAllocEventCollector collector;
209 oop obj = oopFactory::new_typeArray(type, size, CHECK);
210 thread->set_vm_result(obj);
211 IRT_END
212
213
214 IRT_ENTRY(void, InterpreterRuntime::anewarray(JavaThread* thread, ConstantPool* pool, int index, jint size))
215 JvmtiSampledObjectAllocEventCollector collector;
216 Klass* klass = pool->klass_at(index, CHECK);
217 objArrayOop obj = oopFactory::new_objArray(klass, size, CHECK);
218 thread->set_vm_result(obj);
219 IRT_END
220
221
222 IRT_ENTRY(void, InterpreterRuntime::multianewarray(JavaThread* thread, jint* first_size_address))
223 JvmtiSampledObjectAllocEventCollector collector;
224 // We may want to pass in more arguments - could make this slightly faster
225 LastFrameAccessor last_frame(thread);
226 ConstantPool* constants = last_frame.method()->constants();
227 int i = last_frame.get_index_u2(Bytecodes::_multianewarray);
228 Klass* klass = constants->klass_at(i, CHECK);
229 int nof_dims = last_frame.number_of_dimensions();
230 assert(klass->is_klass(), "not a class");
231 assert(nof_dims >= 1, "multianewarray rank must be nonzero");
232
233 // We must create an array of jints to pass to multi_allocate.
234 ResourceMark rm(thread);
235 const int small_dims = 10;
236 jint dim_array[small_dims];
237 jint *dims = &dim_array[0];
238 if (nof_dims > small_dims) {
239 dims = (jint*) NEW_RESOURCE_ARRAY(jint, nof_dims);
240 }
241 for (int index = 0; index < nof_dims; index++) {
242 // offset from first_size_address is addressed as local[index]
243 int n = Interpreter::local_offset_in_bytes(index)/jintSize;
|