98 RegisterMap reg_map(thread, false);
99 frame runtime_frame = thread->last_frame();
100 frame caller_frame = runtime_frame.sender(®_map);
101 Deoptimization::deoptimize_frame(thread, caller_frame.id(), Deoptimization::Reason_constraint);
102 assert(caller_is_deopted(), "Must be deoptimized");
103 }
104 }
105
106 JRT_BLOCK_ENTRY(void, JVMCIRuntime::new_instance(JavaThread* thread, Klass* klass))
107 JRT_BLOCK;
108 assert(klass->is_klass(), "not a class");
109 Handle holder(THREAD, klass->klass_holder()); // keep the klass alive
110 InstanceKlass* ik = InstanceKlass::cast(klass);
111 ik->check_valid_for_instantiation(true, CHECK);
112 // make sure klass is initialized
113 ik->initialize(CHECK);
114 // allocate instance and return via TLS
115 oop obj = ik->allocate_instance(CHECK);
116 thread->set_vm_result(obj);
117 JRT_BLOCK_END;
118
119 if (ReduceInitialCardMarks) {
120 new_store_pre_barrier(thread);
121 }
122 JRT_END
123
124 JRT_BLOCK_ENTRY(void, JVMCIRuntime::new_array(JavaThread* thread, Klass* array_klass, jint length))
125 JRT_BLOCK;
126 // Note: no handle for klass needed since they are not used
127 // anymore after new_objArray() and no GC can happen before.
128 // (This may have to change if this code changes!)
129 assert(array_klass->is_klass(), "not a class");
130 oop obj;
131 if (array_klass->is_typeArray_klass()) {
132 BasicType elt_type = TypeArrayKlass::cast(array_klass)->element_type();
133 obj = oopFactory::new_typeArray(elt_type, length, CHECK);
134 } else {
135 Handle holder(THREAD, array_klass->klass_holder()); // keep the klass alive
136 Klass* elem_klass = ObjArrayKlass::cast(array_klass)->element_klass();
137 obj = oopFactory::new_objArray(elem_klass, length, CHECK);
138 }
139 thread->set_vm_result(obj);
140 // This is pretty rare but this runtime patch is stressful to deoptimization
141 // if we deoptimize here so force a deopt to stress the path.
142 if (DeoptimizeALot) {
143 static int deopts = 0;
144 // Alternate between deoptimizing and raising an error (which will also cause a deopt)
145 if (deopts++ % 2 == 0) {
146 ResourceMark rm(THREAD);
147 THROW(vmSymbols::java_lang_OutOfMemoryError());
148 } else {
149 deopt_caller();
150 }
151 }
152 JRT_BLOCK_END;
153
154 if (ReduceInitialCardMarks) {
155 new_store_pre_barrier(thread);
156 }
157 JRT_END
158
159 void JVMCIRuntime::new_store_pre_barrier(JavaThread* thread) {
160 // After any safepoint, just before going back to compiled code,
161 // we inform the GC that we will be doing initializing writes to
162 // this object in the future without emitting card-marks, so
163 // GC may take any compensating steps.
164 // NOTE: Keep this code consistent with GraphKit::store_barrier.
165
166 oop new_obj = thread->vm_result();
167 if (new_obj == NULL) return;
168
169 assert(Universe::heap()->can_elide_tlab_store_barriers(),
170 "compiler must check this first");
171 // GC may decide to give back a safer copy of new_obj.
172 new_obj = Universe::heap()->new_store_pre_barrier(thread, new_obj);
173 thread->set_vm_result(new_obj);
174 }
175
176 JRT_ENTRY(void, JVMCIRuntime::new_multi_array(JavaThread* thread, Klass* klass, int rank, jint* dims))
177 assert(klass->is_klass(), "not a class");
178 assert(rank >= 1, "rank must be nonzero");
179 Handle holder(THREAD, klass->klass_holder()); // keep the klass alive
180 oop obj = ArrayKlass::cast(klass)->multi_allocate(rank, dims, CHECK);
181 thread->set_vm_result(obj);
182 JRT_END
183
184 JRT_ENTRY(void, JVMCIRuntime::dynamic_new_array(JavaThread* thread, oopDesc* element_mirror, jint length))
185 oop obj = Reflection::reflect_new_array(element_mirror, length, CHECK);
186 thread->set_vm_result(obj);
187 JRT_END
188
189 JRT_ENTRY(void, JVMCIRuntime::dynamic_new_instance(JavaThread* thread, oopDesc* type_mirror))
190 InstanceKlass* klass = InstanceKlass::cast(java_lang_Class::as_Klass(type_mirror));
191
192 if (klass == NULL) {
193 ResourceMark rm(THREAD);
|
98 RegisterMap reg_map(thread, false);
99 frame runtime_frame = thread->last_frame();
100 frame caller_frame = runtime_frame.sender(®_map);
101 Deoptimization::deoptimize_frame(thread, caller_frame.id(), Deoptimization::Reason_constraint);
102 assert(caller_is_deopted(), "Must be deoptimized");
103 }
104 }
105
106 JRT_BLOCK_ENTRY(void, JVMCIRuntime::new_instance(JavaThread* thread, Klass* klass))
107 JRT_BLOCK;
108 assert(klass->is_klass(), "not a class");
109 Handle holder(THREAD, klass->klass_holder()); // keep the klass alive
110 InstanceKlass* ik = InstanceKlass::cast(klass);
111 ik->check_valid_for_instantiation(true, CHECK);
112 // make sure klass is initialized
113 ik->initialize(CHECK);
114 // allocate instance and return via TLS
115 oop obj = ik->allocate_instance(CHECK);
116 thread->set_vm_result(obj);
117 JRT_BLOCK_END;
118 SharedRuntime::on_slowpath_allocation_exit(thread);
119 JRT_END
120
121 JRT_BLOCK_ENTRY(void, JVMCIRuntime::new_array(JavaThread* thread, Klass* array_klass, jint length))
122 JRT_BLOCK;
123 // Note: no handle for klass needed since they are not used
124 // anymore after new_objArray() and no GC can happen before.
125 // (This may have to change if this code changes!)
126 assert(array_klass->is_klass(), "not a class");
127 oop obj;
128 if (array_klass->is_typeArray_klass()) {
129 BasicType elt_type = TypeArrayKlass::cast(array_klass)->element_type();
130 obj = oopFactory::new_typeArray(elt_type, length, CHECK);
131 } else {
132 Handle holder(THREAD, array_klass->klass_holder()); // keep the klass alive
133 Klass* elem_klass = ObjArrayKlass::cast(array_klass)->element_klass();
134 obj = oopFactory::new_objArray(elem_klass, length, CHECK);
135 }
136 thread->set_vm_result(obj);
137 // This is pretty rare but this runtime patch is stressful to deoptimization
138 // if we deoptimize here so force a deopt to stress the path.
139 if (DeoptimizeALot) {
140 static int deopts = 0;
141 // Alternate between deoptimizing and raising an error (which will also cause a deopt)
142 if (deopts++ % 2 == 0) {
143 ResourceMark rm(THREAD);
144 THROW(vmSymbols::java_lang_OutOfMemoryError());
145 } else {
146 deopt_caller();
147 }
148 }
149 JRT_BLOCK_END;
150 SharedRuntime::on_slowpath_allocation_exit(thread);
151 JRT_END
152
153 JRT_ENTRY(void, JVMCIRuntime::new_multi_array(JavaThread* thread, Klass* klass, int rank, jint* dims))
154 assert(klass->is_klass(), "not a class");
155 assert(rank >= 1, "rank must be nonzero");
156 Handle holder(THREAD, klass->klass_holder()); // keep the klass alive
157 oop obj = ArrayKlass::cast(klass)->multi_allocate(rank, dims, CHECK);
158 thread->set_vm_result(obj);
159 JRT_END
160
161 JRT_ENTRY(void, JVMCIRuntime::dynamic_new_array(JavaThread* thread, oopDesc* element_mirror, jint length))
162 oop obj = Reflection::reflect_new_array(element_mirror, length, CHECK);
163 thread->set_vm_result(obj);
164 JRT_END
165
166 JRT_ENTRY(void, JVMCIRuntime::dynamic_new_instance(JavaThread* thread, oopDesc* type_mirror))
167 InstanceKlass* klass = InstanceKlass::cast(java_lang_Class::as_Klass(type_mirror));
168
169 if (klass == NULL) {
170 ResourceMark rm(THREAD);
|