118 private:
119 // declare opto stub address/blob holder static fields
120 #define C2_BLOB_FIELD_DECLARE(name, type) \
121 static type BLOB_FIELD_NAME(name);
122 #define C2_STUB_FIELD_NAME(name) _ ## name ## _Java
123 #define C2_STUB_FIELD_DECLARE(name, f, t, r) \
124 static address C2_STUB_FIELD_NAME(name) ;
125 #define C2_JVMTI_STUB_FIELD_DECLARE(name) \
126 static address STUB_FIELD_NAME(name);
127
128 C2_STUBS_DO(C2_BLOB_FIELD_DECLARE, C2_STUB_FIELD_DECLARE, C2_JVMTI_STUB_FIELD_DECLARE)
129
130 #undef C2_BLOB_FIELD_DECLARE
131 #undef C2_STUB_FIELD_NAME
132 #undef C2_STUB_FIELD_DECLARE
133 #undef C2_JVMTI_STUB_FIELD_DECLARE
134
135 // static TypeFunc* data members
136 static const TypeFunc* _new_instance_Type;
137 static const TypeFunc* _new_array_Type;
138 static const TypeFunc* _multianewarray2_Type;
139 static const TypeFunc* _multianewarray3_Type;
140 static const TypeFunc* _multianewarray4_Type;
141 static const TypeFunc* _multianewarray5_Type;
142 static const TypeFunc* _multianewarrayN_Type;
143 static const TypeFunc* _complete_monitor_enter_Type;
144 static const TypeFunc* _complete_monitor_exit_Type;
145 static const TypeFunc* _monitor_notify_Type;
146 static const TypeFunc* _uncommon_trap_Type;
147 static const TypeFunc* _athrow_Type;
148 static const TypeFunc* _rethrow_Type;
149 static const TypeFunc* _Math_D_D_Type;
150 static const TypeFunc* _Math_DD_D_Type;
151 static const TypeFunc* _modf_Type;
152 static const TypeFunc* _l2f_Type;
153 static const TypeFunc* _void_long_Type;
154 static const TypeFunc* _void_void_Type;
155 static const TypeFunc* _jfr_write_checkpoint_Type;
156 static const TypeFunc* _flush_windows_Type;
157 static const TypeFunc* _fast_arraycopy_Type;
207 #if INCLUDE_JFR
208 static const TypeFunc* _class_id_load_barrier_Type;
209 #endif // INCLUDE_JFR
210 #if INCLUDE_JVMTI
211 static const TypeFunc* _notify_jvmti_vthread_Type;
212 #endif // INCLUDE_JVMTI
213 static const TypeFunc* _dtrace_method_entry_exit_Type;
214 static const TypeFunc* _dtrace_object_alloc_Type;
215
216 // Stub names indexed by sharedStubId
217 static const char *_stub_names[];
218
219 // define stubs
220 static address generate_stub(ciEnv* ci_env, TypeFunc_generator gen, address C_function, const char* name, int stub_id, int is_fancy_jump, bool pass_tls, bool return_pc);
221
222 //
223 // Implementation of runtime methods
224 // =================================
225
226 // Allocate storage for a Java instance.
227 static void new_instance_C(Klass* instance_klass, JavaThread* current);
228
229 // Allocate storage for a objArray or typeArray
230 static void new_array_C(Klass* array_klass, int len, JavaThread* current);
231 static void new_array_nozero_C(Klass* array_klass, int len, JavaThread* current);
232
233 // Allocate storage for a multi-dimensional arrays
234 // Note: needs to be fixed for arbitrary number of dimensions
235 static void multianewarray2_C(Klass* klass, int len1, int len2, JavaThread* current);
236 static void multianewarray3_C(Klass* klass, int len1, int len2, int len3, JavaThread* current);
237 static void multianewarray4_C(Klass* klass, int len1, int len2, int len3, int len4, JavaThread* current);
238 static void multianewarray5_C(Klass* klass, int len1, int len2, int len3, int len4, int len5, JavaThread* current);
239 static void multianewarrayN_C(Klass* klass, arrayOopDesc* dims, JavaThread* current);
240
241 // local methods passed as arguments to stub generator that forward
242 // control to corresponding JRT methods of SharedRuntime
243 static void slow_arraycopy_C(oopDesc* src, jint src_pos,
244 oopDesc* dest, jint dest_pos,
245 jint length, JavaThread* thread);
246 static void complete_monitor_locking_C(oopDesc* obj, BasicLock* lock, JavaThread* current);
247
248 public:
249 static void monitor_notify_C(oopDesc* obj, JavaThread* current);
250 static void monitor_notifyAll_C(oopDesc* obj, JavaThread* current);
254 // Implicit exception support
255 static void throw_null_exception_C(JavaThread* thread);
256
257 // Exception handling
258 static address handle_exception_C (JavaThread* current);
259 static address handle_exception_C_helper(JavaThread* current, nmethod*& nm);
260 static address rethrow_C (oopDesc* exception, JavaThread *thread, address return_pc );
261 static void deoptimize_caller_frame (JavaThread *thread);
262 static void deoptimize_caller_frame (JavaThread *thread, bool doit);
263 static bool is_deoptimized_caller_frame (JavaThread *thread);
264
265 // CodeBlob support
266 // ===================================================================
267
268 static UncommonTrapBlob* generate_uncommon_trap_blob(void);
269 static ExceptionBlob* generate_exception_blob();
270
271 static void register_finalizer_C(oopDesc* obj, JavaThread* current);
272
273 public:
274
275 static bool is_callee_saved_register(MachRegisterNumbers reg);
276
277 // One time only generate runtime code stubs. Returns true
278 // when runtime stubs have been generated successfully and
279 // false otherwise.
280 static bool generate(ciEnv* env);
281
282 // Returns the name of a stub
283 static const char* stub_name(address entry);
284
285 // Returns the name associated with a given stub id
286 static const char* stub_name(OptoStubId id) {
287 assert(id > OptoStubId::NO_STUBID && id < OptoStubId::NUM_STUBIDS, "stub id out of range");
288 return _stub_names[(int)id];
289 }
290
291 // access to runtime stubs entry points for java code
292 static address new_instance_Java() { return _new_instance_Java; }
293 static address new_array_Java() { return _new_array_Java; }
294 static address new_array_nozero_Java() { return _new_array_nozero_Java; }
295 static address multianewarray2_Java() { return _multianewarray2_Java; }
296 static address multianewarray3_Java() { return _multianewarray3_Java; }
297 static address multianewarray4_Java() { return _multianewarray4_Java; }
298 static address multianewarray5_Java() { return _multianewarray5_Java; }
299 static address multianewarrayN_Java() { return _multianewarrayN_Java; }
300 static address complete_monitor_locking_Java() { return _complete_monitor_locking_Java; }
301 static address monitor_notify_Java() { return _monitor_notify_Java; }
302 static address monitor_notifyAll_Java() { return _monitor_notifyAll_Java; }
303
304 static address slow_arraycopy_Java() { return _slow_arraycopy_Java; }
305 static address register_finalizer_Java() { return _register_finalizer_Java; }
306 #if INCLUDE_JVMTI
307 static address notify_jvmti_vthread_start() { return _notify_jvmti_vthread_start; }
308 static address notify_jvmti_vthread_end() { return _notify_jvmti_vthread_end; }
309 static address notify_jvmti_vthread_mount() { return _notify_jvmti_vthread_mount; }
310 static address notify_jvmti_vthread_unmount() { return _notify_jvmti_vthread_unmount; }
311 #endif
312
313 static UncommonTrapBlob* uncommon_trap_blob() { return _uncommon_trap_blob; }
314 static ExceptionBlob* exception_blob() { return _exception_blob; }
315
316 // Implicit exception support
317 static void throw_div0_exception_C (JavaThread* thread);
318 static void throw_stack_overflow_error_C(JavaThread* thread);
319
320 // Exception handling
321 static address rethrow_stub() { return _rethrow_Java; }
322
323
324 // Type functions
325 // ======================================================
326
327 static inline const TypeFunc* new_instance_Type() {
328 assert(_new_instance_Type != nullptr, "should be initialized");
329 return _new_instance_Type;
330 }
331
332 static inline const TypeFunc* new_array_Type() {
333 assert(_new_array_Type != nullptr, "should be initialized");
334 return _new_array_Type;
335 }
336
337 static inline const TypeFunc* new_array_nozero_Type() {
338 return new_array_Type();
339 }
340
341 static const TypeFunc* multianewarray_Type(int ndim); // multianewarray
342
343 static inline const TypeFunc* multianewarray2_Type() {
344 assert(_multianewarray2_Type != nullptr, "should be initialized");
345 return _multianewarray2_Type;
346 }
347
348 static inline const TypeFunc* multianewarray3_Type() {
349 assert(_multianewarray3_Type != nullptr, "should be initialized");
350 return _multianewarray3_Type;
351 }
352
353 static inline const TypeFunc* multianewarray4_Type() {
354 assert(_multianewarray4_Type != nullptr, "should be initialized");
355 return _multianewarray4_Type;
356 }
357
358 static inline const TypeFunc* multianewarray5_Type() {
718
719
720 // leaf on stack replacement interpreter accessor types
721 static inline const TypeFunc* osr_end_Type() {
722 assert(_osr_end_Type != nullptr, "should be initialized");
723 return _osr_end_Type;
724 }
725
726 static inline const TypeFunc* register_finalizer_Type() {
727 assert(_register_finalizer_Type != nullptr, "should be initialized");
728 return _register_finalizer_Type;
729 }
730
731 #if INCLUDE_JFR
732 static inline const TypeFunc* class_id_load_barrier_Type() {
733 assert(_class_id_load_barrier_Type != nullptr, "should be initialized");
734 return _class_id_load_barrier_Type;
735 }
736 #endif // INCLUDE_JFR
737
738 #if INCLUDE_JVMTI
739 static inline const TypeFunc* notify_jvmti_vthread_Type() {
740 assert(_notify_jvmti_vthread_Type != nullptr, "should be initialized");
741 return _notify_jvmti_vthread_Type;
742 }
743 #endif
744
745 // Dtrace support. entry and exit probes have the same signature
746 static inline const TypeFunc* dtrace_method_entry_exit_Type() {
747 assert(_dtrace_method_entry_exit_Type != nullptr, "should be initialized");
748 return _dtrace_method_entry_exit_Type;
749 }
750
751 static inline const TypeFunc* dtrace_object_alloc_Type() {
752 assert(_dtrace_object_alloc_Type != nullptr, "should be initialized");
753 return _dtrace_object_alloc_Type;
754 }
755
756 private:
757 static NamedCounter * volatile _named_counters;
|
118 private:
119 // declare opto stub address/blob holder static fields
120 #define C2_BLOB_FIELD_DECLARE(name, type) \
121 static type BLOB_FIELD_NAME(name);
122 #define C2_STUB_FIELD_NAME(name) _ ## name ## _Java
123 #define C2_STUB_FIELD_DECLARE(name, f, t, r) \
124 static address C2_STUB_FIELD_NAME(name) ;
125 #define C2_JVMTI_STUB_FIELD_DECLARE(name) \
126 static address STUB_FIELD_NAME(name);
127
128 C2_STUBS_DO(C2_BLOB_FIELD_DECLARE, C2_STUB_FIELD_DECLARE, C2_JVMTI_STUB_FIELD_DECLARE)
129
130 #undef C2_BLOB_FIELD_DECLARE
131 #undef C2_STUB_FIELD_NAME
132 #undef C2_STUB_FIELD_DECLARE
133 #undef C2_JVMTI_STUB_FIELD_DECLARE
134
135 // static TypeFunc* data members
136 static const TypeFunc* _new_instance_Type;
137 static const TypeFunc* _new_array_Type;
138 static const TypeFunc* _new_array_nozero_Type;
139 static const TypeFunc* _multianewarray2_Type;
140 static const TypeFunc* _multianewarray3_Type;
141 static const TypeFunc* _multianewarray4_Type;
142 static const TypeFunc* _multianewarray5_Type;
143 static const TypeFunc* _multianewarrayN_Type;
144 static const TypeFunc* _complete_monitor_enter_Type;
145 static const TypeFunc* _complete_monitor_exit_Type;
146 static const TypeFunc* _monitor_notify_Type;
147 static const TypeFunc* _uncommon_trap_Type;
148 static const TypeFunc* _athrow_Type;
149 static const TypeFunc* _rethrow_Type;
150 static const TypeFunc* _Math_D_D_Type;
151 static const TypeFunc* _Math_DD_D_Type;
152 static const TypeFunc* _modf_Type;
153 static const TypeFunc* _l2f_Type;
154 static const TypeFunc* _void_long_Type;
155 static const TypeFunc* _void_void_Type;
156 static const TypeFunc* _jfr_write_checkpoint_Type;
157 static const TypeFunc* _flush_windows_Type;
158 static const TypeFunc* _fast_arraycopy_Type;
208 #if INCLUDE_JFR
209 static const TypeFunc* _class_id_load_barrier_Type;
210 #endif // INCLUDE_JFR
211 #if INCLUDE_JVMTI
212 static const TypeFunc* _notify_jvmti_vthread_Type;
213 #endif // INCLUDE_JVMTI
214 static const TypeFunc* _dtrace_method_entry_exit_Type;
215 static const TypeFunc* _dtrace_object_alloc_Type;
216
217 // Stub names indexed by sharedStubId
218 static const char *_stub_names[];
219
220 // define stubs
221 static address generate_stub(ciEnv* ci_env, TypeFunc_generator gen, address C_function, const char* name, int stub_id, int is_fancy_jump, bool pass_tls, bool return_pc);
222
223 //
224 // Implementation of runtime methods
225 // =================================
226
227 // Allocate storage for a Java instance.
228 static void new_instance_C(Klass* instance_klass, bool is_larval, JavaThread* current);
229
230 // Allocate storage for a objArray or typeArray
231 static void new_array_C(Klass* array_klass, int len, oopDesc* init_val, JavaThread* current);
232 static void new_array_nozero_C(Klass* array_klass, int len, JavaThread* current);
233
234 // Allocate storage for a multi-dimensional arrays
235 // Note: needs to be fixed for arbitrary number of dimensions
236 static void multianewarray2_C(Klass* klass, int len1, int len2, JavaThread* current);
237 static void multianewarray3_C(Klass* klass, int len1, int len2, int len3, JavaThread* current);
238 static void multianewarray4_C(Klass* klass, int len1, int len2, int len3, int len4, JavaThread* current);
239 static void multianewarray5_C(Klass* klass, int len1, int len2, int len3, int len4, int len5, JavaThread* current);
240 static void multianewarrayN_C(Klass* klass, arrayOopDesc* dims, JavaThread* current);
241
242 // local methods passed as arguments to stub generator that forward
243 // control to corresponding JRT methods of SharedRuntime
244 static void slow_arraycopy_C(oopDesc* src, jint src_pos,
245 oopDesc* dest, jint dest_pos,
246 jint length, JavaThread* thread);
247 static void complete_monitor_locking_C(oopDesc* obj, BasicLock* lock, JavaThread* current);
248
249 public:
250 static void monitor_notify_C(oopDesc* obj, JavaThread* current);
251 static void monitor_notifyAll_C(oopDesc* obj, JavaThread* current);
255 // Implicit exception support
256 static void throw_null_exception_C(JavaThread* thread);
257
258 // Exception handling
259 static address handle_exception_C (JavaThread* current);
260 static address handle_exception_C_helper(JavaThread* current, nmethod*& nm);
261 static address rethrow_C (oopDesc* exception, JavaThread *thread, address return_pc );
262 static void deoptimize_caller_frame (JavaThread *thread);
263 static void deoptimize_caller_frame (JavaThread *thread, bool doit);
264 static bool is_deoptimized_caller_frame (JavaThread *thread);
265
266 // CodeBlob support
267 // ===================================================================
268
269 static UncommonTrapBlob* generate_uncommon_trap_blob(void);
270 static ExceptionBlob* generate_exception_blob();
271
272 static void register_finalizer_C(oopDesc* obj, JavaThread* current);
273
274 public:
275 static void load_unknown_inline_C(flatArrayOopDesc* array, int index, JavaThread* current);
276 static void store_unknown_inline_C(instanceOopDesc* buffer, flatArrayOopDesc* array, int index, JavaThread* current);
277
278 static bool is_callee_saved_register(MachRegisterNumbers reg);
279
280 // One time only generate runtime code stubs. Returns true
281 // when runtime stubs have been generated successfully and
282 // false otherwise.
283 static bool generate(ciEnv* env);
284
285 // Returns the name of a stub
286 static const char* stub_name(address entry);
287
288 // Returns the name associated with a given stub id
289 static const char* stub_name(OptoStubId id) {
290 assert(id > OptoStubId::NO_STUBID && id < OptoStubId::NUM_STUBIDS, "stub id out of range");
291 return _stub_names[(int)id];
292 }
293
294 // access to runtime stubs entry points for java code
295 static address new_instance_Java() { return _new_instance_Java; }
296 static address new_array_Java() { return _new_array_Java; }
297 static address new_array_nozero_Java() { return _new_array_nozero_Java; }
298 static address multianewarray2_Java() { return _multianewarray2_Java; }
299 static address multianewarray3_Java() { return _multianewarray3_Java; }
300 static address multianewarray4_Java() { return _multianewarray4_Java; }
301 static address multianewarray5_Java() { return _multianewarray5_Java; }
302 static address multianewarrayN_Java() { return _multianewarrayN_Java; }
303 static address complete_monitor_locking_Java() { return _complete_monitor_locking_Java; }
304 static address monitor_notify_Java() { return _monitor_notify_Java; }
305 static address monitor_notifyAll_Java() { return _monitor_notifyAll_Java; }
306
307 static address slow_arraycopy_Java() { return _slow_arraycopy_Java; }
308 static address register_finalizer_Java() { return _register_finalizer_Java; }
309 static address load_unknown_inline_Java() { return _load_unknown_inline_Java; }
310 static address store_unknown_inline_Java() { return _store_unknown_inline_Java; }
311 #if INCLUDE_JVMTI
312 static address notify_jvmti_vthread_start() { return _notify_jvmti_vthread_start; }
313 static address notify_jvmti_vthread_end() { return _notify_jvmti_vthread_end; }
314 static address notify_jvmti_vthread_mount() { return _notify_jvmti_vthread_mount; }
315 static address notify_jvmti_vthread_unmount() { return _notify_jvmti_vthread_unmount; }
316 #endif
317
318 static UncommonTrapBlob* uncommon_trap_blob() { return _uncommon_trap_blob; }
319 static ExceptionBlob* exception_blob() { return _exception_blob; }
320
321 // Implicit exception support
322 static void throw_div0_exception_C (JavaThread* thread);
323 static void throw_stack_overflow_error_C(JavaThread* thread);
324
325 // Exception handling
326 static address rethrow_stub() { return _rethrow_Java; }
327
328
329 // Type functions
330 // ======================================================
331
332 static inline const TypeFunc* new_instance_Type() {
333 assert(_new_instance_Type != nullptr, "should be initialized");
334 return _new_instance_Type;
335 }
336
337 static inline const TypeFunc* new_array_Type() {
338 assert(_new_array_Type != nullptr, "should be initialized");
339 return _new_array_Type;
340 }
341
342 static inline const TypeFunc* new_array_nozero_Type() {
343 assert(_new_array_nozero_Type != nullptr, "should be initialized");
344 return _new_array_nozero_Type;
345 }
346
347 static const TypeFunc* multianewarray_Type(int ndim); // multianewarray
348
349 static inline const TypeFunc* multianewarray2_Type() {
350 assert(_multianewarray2_Type != nullptr, "should be initialized");
351 return _multianewarray2_Type;
352 }
353
354 static inline const TypeFunc* multianewarray3_Type() {
355 assert(_multianewarray3_Type != nullptr, "should be initialized");
356 return _multianewarray3_Type;
357 }
358
359 static inline const TypeFunc* multianewarray4_Type() {
360 assert(_multianewarray4_Type != nullptr, "should be initialized");
361 return _multianewarray4_Type;
362 }
363
364 static inline const TypeFunc* multianewarray5_Type() {
724
725
726 // leaf on stack replacement interpreter accessor types
727 static inline const TypeFunc* osr_end_Type() {
728 assert(_osr_end_Type != nullptr, "should be initialized");
729 return _osr_end_Type;
730 }
731
732 static inline const TypeFunc* register_finalizer_Type() {
733 assert(_register_finalizer_Type != nullptr, "should be initialized");
734 return _register_finalizer_Type;
735 }
736
737 #if INCLUDE_JFR
738 static inline const TypeFunc* class_id_load_barrier_Type() {
739 assert(_class_id_load_barrier_Type != nullptr, "should be initialized");
740 return _class_id_load_barrier_Type;
741 }
742 #endif // INCLUDE_JFR
743
744 static const TypeFunc* load_unknown_inline_Type();
745 static const TypeFunc* store_unknown_inline_Type();
746
747 static const TypeFunc* store_inline_type_fields_Type();
748 static const TypeFunc* pack_inline_type_Type();
749
750 #if INCLUDE_JVMTI
751 static inline const TypeFunc* notify_jvmti_vthread_Type() {
752 assert(_notify_jvmti_vthread_Type != nullptr, "should be initialized");
753 return _notify_jvmti_vthread_Type;
754 }
755 #endif
756
757 // Dtrace support. entry and exit probes have the same signature
758 static inline const TypeFunc* dtrace_method_entry_exit_Type() {
759 assert(_dtrace_method_entry_exit_Type != nullptr, "should be initialized");
760 return _dtrace_method_entry_exit_Type;
761 }
762
763 static inline const TypeFunc* dtrace_object_alloc_Type() {
764 assert(_dtrace_object_alloc_Type != nullptr, "should be initialized");
765 return _dtrace_object_alloc_Type;
766 }
767
768 private:
769 static NamedCounter * volatile _named_counters;
|