< prev index next >

src/hotspot/share/opto/runtime.hpp

Print this page

 96 };
 97 
 98 typedef const TypeFunc*(*TypeFunc_generator)();
 99 
100 // define OptoStubId enum tags: uncommon_trap_id etc
101 
102 #define C2_BLOB_ID_ENUM_DECLARE(name, type) STUB_ID_NAME(name),
103 #define C2_STUB_ID_ENUM_DECLARE(name, f, t, r) STUB_ID_NAME(name),
104 #define C2_JVMTI_STUB_ID_ENUM_DECLARE(name) STUB_ID_NAME(name),
105 enum class OptoStubId :int {
106   NO_STUBID = -1,
107   C2_STUBS_DO(C2_BLOB_ID_ENUM_DECLARE, C2_STUB_ID_ENUM_DECLARE, C2_JVMTI_STUB_ID_ENUM_DECLARE)
108   NUM_STUBIDS
109 };
110 #undef C2_BLOB_ID_ENUM_DECLARE
111 #undef C2_STUB_ID_ENUM_DECLARE
112 #undef C2_JVMTI_STUB_ID_ENUM_DECLARE
113 
114 class OptoRuntime : public AllStatic {
115   friend class Matcher;  // allow access to stub names
116 
117  private:
118   // declare opto stub address/blob holder static fields
119 #define C2_BLOB_FIELD_DECLARE(name, type) \
120   static type        BLOB_FIELD_NAME(name);
121 #define C2_STUB_FIELD_NAME(name) _ ## name ## _Java
122 #define C2_STUB_FIELD_DECLARE(name, f, t, r) \
123   static address     C2_STUB_FIELD_NAME(name) ;
124 #define C2_JVMTI_STUB_FIELD_DECLARE(name) \
125   static address     STUB_FIELD_NAME(name);
126 
127   C2_STUBS_DO(C2_BLOB_FIELD_DECLARE, C2_STUB_FIELD_DECLARE, C2_JVMTI_STUB_FIELD_DECLARE)
128 
129 #undef C2_BLOB_FIELD_DECLARE
130 #undef C2_STUB_FIELD_NAME
131 #undef C2_STUB_FIELD_DECLARE
132 #undef C2_JVMTI_STUB_FIELD_DECLARE
133 
134   // static TypeFunc* data members
135   static const TypeFunc* _new_instance_Type;
136   static const TypeFunc* _new_array_Type;

188   static const TypeFunc* _updateBytesCRC32_Type;
189   static const TypeFunc* _updateBytesCRC32C_Type;
190   static const TypeFunc* _updateBytesAdler32_Type;
191   static const TypeFunc* _osr_end_Type;
192   static const TypeFunc* _register_finalizer_Type;
193 #if INCLUDE_JFR
194   static const TypeFunc* _class_id_load_barrier_Type;
195 #endif // INCLUDE_JFR
196 #if INCLUDE_JVMTI
197   static const TypeFunc* _notify_jvmti_vthread_Type;
198 #endif // INCLUDE_JVMTI
199   static const TypeFunc* _dtrace_method_entry_exit_Type;
200   static const TypeFunc* _dtrace_object_alloc_Type;
201 
202   // Stub names indexed by sharedStubId
203   static const char *_stub_names[];
204 
205   // define stubs
206   static address generate_stub(ciEnv* ci_env, TypeFunc_generator gen, address C_function, const char* name, int is_fancy_jump, bool pass_tls, bool return_pc);
207 


208   //
209   // Implementation of runtime methods
210   // =================================
211 
212   // Allocate storage for a Java instance.
213   static void new_instance_C(Klass* instance_klass, JavaThread* current);
214 
215   // Allocate storage for a objArray or typeArray
216   static void new_array_C(Klass* array_klass, int len, JavaThread* current);
217   static void new_array_nozero_C(Klass* array_klass, int len, JavaThread* current);
218 
219   // Allocate storage for a multi-dimensional arrays
220   // Note: needs to be fixed for arbitrary number of dimensions
221   static void multianewarray2_C(Klass* klass, int len1, int len2, JavaThread* current);
222   static void multianewarray3_C(Klass* klass, int len1, int len2, int len3, JavaThread* current);
223   static void multianewarray4_C(Klass* klass, int len1, int len2, int len3, int len4, JavaThread* current);
224   static void multianewarray5_C(Klass* klass, int len1, int len2, int len3, int len4, int len5, JavaThread* current);
225   static void multianewarrayN_C(Klass* klass, arrayOopDesc* dims, JavaThread* current);
226 
227   // local methods passed as arguments to stub generator that forward

238 private:
239 
240   // Implicit exception support
241   static void throw_null_exception_C(JavaThread* thread);
242 
243   // Exception handling
244   static address handle_exception_C       (JavaThread* current);
245   static address handle_exception_C_helper(JavaThread* current, nmethod*& nm);
246   static address rethrow_C                (oopDesc* exception, JavaThread *thread, address return_pc );
247   static void deoptimize_caller_frame     (JavaThread *thread);
248   static void deoptimize_caller_frame     (JavaThread *thread, bool doit);
249   static bool is_deoptimized_caller_frame (JavaThread *thread);
250 
251   // CodeBlob support
252   // ===================================================================
253 
254   static void generate_uncommon_trap_blob(void);
255   static void generate_exception_blob();
256 
257   static void register_finalizer_C(oopDesc* obj, JavaThread* current);
258 
259  public:
260 
261   static bool is_callee_saved_register(MachRegisterNumbers reg);
262 
263   // One time only generate runtime code stubs. Returns true
264   // when runtime stubs have been generated successfully and
265   // false otherwise.
266   static bool generate(ciEnv* env);
267 
268   // Returns the name of a stub
269   static const char* stub_name(address entry);
270 
271   // Returns the name associated with a given stub id
272   static const char* stub_name(OptoStubId id) {
273     assert(id > OptoStubId::NO_STUBID && id < OptoStubId::NUM_STUBIDS, "stub id out of range");
274     return _stub_names[(int)id];
275   }
276 
277   // access to runtime stubs entry points for java code
278   static address new_instance_Java()                     { return _new_instance_Java; }
279   static address new_array_Java()                        { return _new_array_Java; }
280   static address new_array_nozero_Java()                 { return _new_array_nozero_Java; }
281   static address multianewarray2_Java()                  { return _multianewarray2_Java; }
282   static address multianewarray3_Java()                  { return _multianewarray3_Java; }
283   static address multianewarray4_Java()                  { return _multianewarray4_Java; }
284   static address multianewarray5_Java()                  { return _multianewarray5_Java; }
285   static address multianewarrayN_Java()                  { return _multianewarrayN_Java; }

286   static address complete_monitor_locking_Java()         { return _complete_monitor_locking_Java; }
287   static address monitor_notify_Java()                   { return _monitor_notify_Java; }
288   static address monitor_notifyAll_Java()                { return _monitor_notifyAll_Java; }
289 
290   static address slow_arraycopy_Java()                   { return _slow_arraycopy_Java; }
291   static address register_finalizer_Java()               { return _register_finalizer_Java; }

292 #if INCLUDE_JVMTI
293   static address notify_jvmti_vthread_start()            { return _notify_jvmti_vthread_start; }
294   static address notify_jvmti_vthread_end()              { return _notify_jvmti_vthread_end; }
295   static address notify_jvmti_vthread_mount()            { return _notify_jvmti_vthread_mount; }
296   static address notify_jvmti_vthread_unmount()          { return _notify_jvmti_vthread_unmount; }
297 #endif
298 
299   static UncommonTrapBlob* uncommon_trap_blob()                  { return _uncommon_trap_blob; }
300   static ExceptionBlob*    exception_blob()                      { return _exception_blob; }
301 
302   // Implicit exception support
303   static void throw_div0_exception_C      (JavaThread* thread);
304   static void throw_stack_overflow_error_C(JavaThread* thread);
305 
306   // Exception handling
307   static address rethrow_stub()             { return _rethrow_Java; }
308 
309 
310   // Type functions
311   // ======================================================

635 
636 
637   // leaf on stack replacement interpreter accessor types
638   static inline const TypeFunc* osr_end_Type() {
639     assert(_osr_end_Type != nullptr, "should be initialized");
640     return _osr_end_Type;
641   }
642 
643   static inline const TypeFunc* register_finalizer_Type() {
644     assert(_register_finalizer_Type != nullptr, "should be initialized");
645     return _register_finalizer_Type;
646   }
647 
648 #if INCLUDE_JFR
649   static inline const TypeFunc* class_id_load_barrier_Type() {
650     assert(_class_id_load_barrier_Type != nullptr, "should be initialized");
651     return _class_id_load_barrier_Type;
652   }
653 #endif // INCLUDE_JFR
654 


655 #if INCLUDE_JVMTI
656   static inline const TypeFunc* notify_jvmti_vthread_Type() {
657     assert(_notify_jvmti_vthread_Type != nullptr, "should be initialized");
658     return _notify_jvmti_vthread_Type;
659   }
660 #endif
661 



662   // Dtrace support. entry and exit probes have the same signature
663   static inline const TypeFunc* dtrace_method_entry_exit_Type() {
664     assert(_dtrace_method_entry_exit_Type != nullptr, "should be initialized");
665     return _dtrace_method_entry_exit_Type;
666   }
667 
668   static inline const TypeFunc* dtrace_object_alloc_Type() {
669     assert(_dtrace_object_alloc_Type != nullptr, "should be initialized");
670     return _dtrace_object_alloc_Type;
671   }
672 
673  private:
674  static NamedCounter * volatile _named_counters;
675 
676  public:
677  // helper function which creates a named counter labeled with the
678  // if they are available
679  static NamedCounter* new_named_counter(JVMState* jvms, NamedCounter::CounterTag tag);
680 
681  // dumps all the named counters
682  static void          print_named_counters();
683 



684  static void          initialize_types();
685 };
686 
687 #endif // SHARE_OPTO_RUNTIME_HPP

 96 };
 97 
 98 typedef const TypeFunc*(*TypeFunc_generator)();
 99 
100 // define OptoStubId enum tags: uncommon_trap_id etc
101 
102 #define C2_BLOB_ID_ENUM_DECLARE(name, type) STUB_ID_NAME(name),
103 #define C2_STUB_ID_ENUM_DECLARE(name, f, t, r) STUB_ID_NAME(name),
104 #define C2_JVMTI_STUB_ID_ENUM_DECLARE(name) STUB_ID_NAME(name),
105 enum class OptoStubId :int {
106   NO_STUBID = -1,
107   C2_STUBS_DO(C2_BLOB_ID_ENUM_DECLARE, C2_STUB_ID_ENUM_DECLARE, C2_JVMTI_STUB_ID_ENUM_DECLARE)
108   NUM_STUBIDS
109 };
110 #undef C2_BLOB_ID_ENUM_DECLARE
111 #undef C2_STUB_ID_ENUM_DECLARE
112 #undef C2_JVMTI_STUB_ID_ENUM_DECLARE
113 
114 class OptoRuntime : public AllStatic {
115   friend class Matcher;  // allow access to stub names
116   friend class SCAddressTable;
117  private:
118   // declare opto stub address/blob holder static fields
119 #define C2_BLOB_FIELD_DECLARE(name, type) \
120   static type        BLOB_FIELD_NAME(name);
121 #define C2_STUB_FIELD_NAME(name) _ ## name ## _Java
122 #define C2_STUB_FIELD_DECLARE(name, f, t, r) \
123   static address     C2_STUB_FIELD_NAME(name) ;
124 #define C2_JVMTI_STUB_FIELD_DECLARE(name) \
125   static address     STUB_FIELD_NAME(name);
126 
127   C2_STUBS_DO(C2_BLOB_FIELD_DECLARE, C2_STUB_FIELD_DECLARE, C2_JVMTI_STUB_FIELD_DECLARE)
128 
129 #undef C2_BLOB_FIELD_DECLARE
130 #undef C2_STUB_FIELD_NAME
131 #undef C2_STUB_FIELD_DECLARE
132 #undef C2_JVMTI_STUB_FIELD_DECLARE
133 
134   // static TypeFunc* data members
135   static const TypeFunc* _new_instance_Type;
136   static const TypeFunc* _new_array_Type;

188   static const TypeFunc* _updateBytesCRC32_Type;
189   static const TypeFunc* _updateBytesCRC32C_Type;
190   static const TypeFunc* _updateBytesAdler32_Type;
191   static const TypeFunc* _osr_end_Type;
192   static const TypeFunc* _register_finalizer_Type;
193 #if INCLUDE_JFR
194   static const TypeFunc* _class_id_load_barrier_Type;
195 #endif // INCLUDE_JFR
196 #if INCLUDE_JVMTI
197   static const TypeFunc* _notify_jvmti_vthread_Type;
198 #endif // INCLUDE_JVMTI
199   static const TypeFunc* _dtrace_method_entry_exit_Type;
200   static const TypeFunc* _dtrace_object_alloc_Type;
201 
202   // Stub names indexed by sharedStubId
203   static const char *_stub_names[];
204 
205   // define stubs
206   static address generate_stub(ciEnv* ci_env, TypeFunc_generator gen, address C_function, const char* name, int is_fancy_jump, bool pass_tls, bool return_pc);
207 
208   static address _vtable_must_compile_Java;
209 
210   //
211   // Implementation of runtime methods
212   // =================================
213 
214   // Allocate storage for a Java instance.
215   static void new_instance_C(Klass* instance_klass, JavaThread* current);
216 
217   // Allocate storage for a objArray or typeArray
218   static void new_array_C(Klass* array_klass, int len, JavaThread* current);
219   static void new_array_nozero_C(Klass* array_klass, int len, JavaThread* current);
220 
221   // Allocate storage for a multi-dimensional arrays
222   // Note: needs to be fixed for arbitrary number of dimensions
223   static void multianewarray2_C(Klass* klass, int len1, int len2, JavaThread* current);
224   static void multianewarray3_C(Klass* klass, int len1, int len2, int len3, JavaThread* current);
225   static void multianewarray4_C(Klass* klass, int len1, int len2, int len3, int len4, JavaThread* current);
226   static void multianewarray5_C(Klass* klass, int len1, int len2, int len3, int len4, int len5, JavaThread* current);
227   static void multianewarrayN_C(Klass* klass, arrayOopDesc* dims, JavaThread* current);
228 
229   // local methods passed as arguments to stub generator that forward

240 private:
241 
242   // Implicit exception support
243   static void throw_null_exception_C(JavaThread* thread);
244 
245   // Exception handling
246   static address handle_exception_C       (JavaThread* current);
247   static address handle_exception_C_helper(JavaThread* current, nmethod*& nm);
248   static address rethrow_C                (oopDesc* exception, JavaThread *thread, address return_pc );
249   static void deoptimize_caller_frame     (JavaThread *thread);
250   static void deoptimize_caller_frame     (JavaThread *thread, bool doit);
251   static bool is_deoptimized_caller_frame (JavaThread *thread);
252 
253   // CodeBlob support
254   // ===================================================================
255 
256   static void generate_uncommon_trap_blob(void);
257   static void generate_exception_blob();
258 
259   static void register_finalizer_C(oopDesc* obj, JavaThread* current);
260   static void class_init_barrier_C(Klass* k, JavaThread* current);
261  public:
262 
263   static bool is_callee_saved_register(MachRegisterNumbers reg);
264 
265   // One time only generate runtime code stubs. Returns true
266   // when runtime stubs have been generated successfully and
267   // false otherwise.
268   static bool generate(ciEnv* env);
269 
270   // Returns the name of a stub
271   static const char* stub_name(address entry);
272 
273   // Returns the name associated with a given stub id
274   static const char* stub_name(OptoStubId id) {
275     assert(id > OptoStubId::NO_STUBID && id < OptoStubId::NUM_STUBIDS, "stub id out of range");
276     return _stub_names[(int)id];
277   }
278 
279   // access to runtime stubs entry points for java code
280   static address new_instance_Java()                     { return _new_instance_Java; }
281   static address new_array_Java()                        { return _new_array_Java; }
282   static address new_array_nozero_Java()                 { return _new_array_nozero_Java; }
283   static address multianewarray2_Java()                  { return _multianewarray2_Java; }
284   static address multianewarray3_Java()                  { return _multianewarray3_Java; }
285   static address multianewarray4_Java()                  { return _multianewarray4_Java; }
286   static address multianewarray5_Java()                  { return _multianewarray5_Java; }
287   static address multianewarrayN_Java()                  { return _multianewarrayN_Java; }
288   static address vtable_must_compile_stub()              { return _vtable_must_compile_Java; }
289   static address complete_monitor_locking_Java()         { return _complete_monitor_locking_Java; }
290   static address monitor_notify_Java()                   { return _monitor_notify_Java; }
291   static address monitor_notifyAll_Java()                { return _monitor_notifyAll_Java; }
292 
293   static address slow_arraycopy_Java()                   { return _slow_arraycopy_Java; }
294   static address register_finalizer_Java()               { return _register_finalizer_Java; }
295   static address class_init_barrier_Java()               { return _class_init_barrier_Java; }
296 #if INCLUDE_JVMTI
297   static address notify_jvmti_vthread_start()            { return _notify_jvmti_vthread_start; }
298   static address notify_jvmti_vthread_end()              { return _notify_jvmti_vthread_end; }
299   static address notify_jvmti_vthread_mount()            { return _notify_jvmti_vthread_mount; }
300   static address notify_jvmti_vthread_unmount()          { return _notify_jvmti_vthread_unmount; }
301 #endif
302 
303   static UncommonTrapBlob* uncommon_trap_blob()                  { return _uncommon_trap_blob; }
304   static ExceptionBlob*    exception_blob()                      { return _exception_blob; }
305 
306   // Implicit exception support
307   static void throw_div0_exception_C      (JavaThread* thread);
308   static void throw_stack_overflow_error_C(JavaThread* thread);
309 
310   // Exception handling
311   static address rethrow_stub()             { return _rethrow_Java; }
312 
313 
314   // Type functions
315   // ======================================================

639 
640 
641   // leaf on stack replacement interpreter accessor types
642   static inline const TypeFunc* osr_end_Type() {
643     assert(_osr_end_Type != nullptr, "should be initialized");
644     return _osr_end_Type;
645   }
646 
647   static inline const TypeFunc* register_finalizer_Type() {
648     assert(_register_finalizer_Type != nullptr, "should be initialized");
649     return _register_finalizer_Type;
650   }
651 
652 #if INCLUDE_JFR
653   static inline const TypeFunc* class_id_load_barrier_Type() {
654     assert(_class_id_load_barrier_Type != nullptr, "should be initialized");
655     return _class_id_load_barrier_Type;
656   }
657 #endif // INCLUDE_JFR
658 
659   static const TypeFunc* class_init_barrier_Type();
660 
661 #if INCLUDE_JVMTI
662   static inline const TypeFunc* notify_jvmti_vthread_Type() {
663     assert(_notify_jvmti_vthread_Type != nullptr, "should be initialized");
664     return _notify_jvmti_vthread_Type;
665   }
666 #endif
667 
668   // runtime upcalls support
669   static const TypeFunc* runtime_up_call_Type();
670 
671   // Dtrace support. entry and exit probes have the same signature
672   static inline const TypeFunc* dtrace_method_entry_exit_Type() {
673     assert(_dtrace_method_entry_exit_Type != nullptr, "should be initialized");
674     return _dtrace_method_entry_exit_Type;
675   }
676 
677   static inline const TypeFunc* dtrace_object_alloc_Type() {
678     assert(_dtrace_object_alloc_Type != nullptr, "should be initialized");
679     return _dtrace_object_alloc_Type;
680   }
681 
682  private:
683  static NamedCounter * volatile _named_counters;
684 
685  public:
686  // helper function which creates a named counter labeled with the
687  // if they are available
688  static NamedCounter* new_named_counter(JVMState* jvms, NamedCounter::CounterTag tag);
689 
690  // dumps all the named counters
691  static void          print_named_counters();
692 
693  public:
694   static void init_counters();
695   static void print_counters_on(outputStream* st);
696  static void          initialize_types();
697 };
698 
699 #endif // SHARE_OPTO_RUNTIME_HPP
< prev index next >