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 // Stub names indexed by sharedStubId
135 static const char *_stub_names[];
136
137 // define stubs
138 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);
139
140 //
141 // Implementation of runtime methods
142 // =================================
143
144 // Allocate storage for a Java instance.
145 static void new_instance_C(Klass* instance_klass, JavaThread* current);
146
147 // Allocate storage for a objArray or typeArray
148 static void new_array_C(Klass* array_klass, int len, JavaThread* current);
149 static void new_array_nozero_C(Klass* array_klass, int len, JavaThread* current);
150
151 // Allocate storage for a multi-dimensional arrays
152 // Note: needs to be fixed for arbitrary number of dimensions
153 static void multianewarray2_C(Klass* klass, int len1, int len2, JavaThread* current);
154 static void multianewarray3_C(Klass* klass, int len1, int len2, int len3, JavaThread* current);
155 static void multianewarray4_C(Klass* klass, int len1, int len2, int len3, int len4, JavaThread* current);
156 static void multianewarray5_C(Klass* klass, int len1, int len2, int len3, int len4, int len5, JavaThread* current);
157 static void multianewarrayN_C(Klass* klass, arrayOopDesc* dims, JavaThread* current);
158
159 // local methods passed as arguments to stub generator that forward
170 private:
171
172 // Implicit exception support
173 static void throw_null_exception_C(JavaThread* thread);
174
175 // Exception handling
176 static address handle_exception_C (JavaThread* current);
177 static address handle_exception_C_helper(JavaThread* current, nmethod*& nm);
178 static address rethrow_C (oopDesc* exception, JavaThread *thread, address return_pc );
179 static void deoptimize_caller_frame (JavaThread *thread);
180 static void deoptimize_caller_frame (JavaThread *thread, bool doit);
181 static bool is_deoptimized_caller_frame (JavaThread *thread);
182
183 // CodeBlob support
184 // ===================================================================
185
186 static void generate_uncommon_trap_blob(void);
187 static void generate_exception_blob();
188
189 static void register_finalizer_C(oopDesc* obj, JavaThread* current);
190
191 public:
192
193 static bool is_callee_saved_register(MachRegisterNumbers reg);
194
195 // One time only generate runtime code stubs. Returns true
196 // when runtime stubs have been generated successfully and
197 // false otherwise.
198 static bool generate(ciEnv* env);
199
200 // Returns the name of a stub
201 static const char* stub_name(address entry);
202
203 // Returns the name associated with a given stub id
204 static const char* stub_name(OptoStubId id) {
205 assert(id > OptoStubId::NO_STUBID && id < OptoStubId::NUM_STUBIDS, "stub id out of range");
206 return _stub_names[(int)id];
207 }
208
209 // access to runtime stubs entry points for java code
210 static address new_instance_Java() { return _new_instance_Java; }
211 static address new_array_Java() { return _new_array_Java; }
212 static address new_array_nozero_Java() { return _new_array_nozero_Java; }
213 static address multianewarray2_Java() { return _multianewarray2_Java; }
214 static address multianewarray3_Java() { return _multianewarray3_Java; }
215 static address multianewarray4_Java() { return _multianewarray4_Java; }
216 static address multianewarray5_Java() { return _multianewarray5_Java; }
217 static address multianewarrayN_Java() { return _multianewarrayN_Java; }
218 static address complete_monitor_locking_Java() { return _complete_monitor_locking_Java; }
219 static address monitor_notify_Java() { return _monitor_notify_Java; }
220 static address monitor_notifyAll_Java() { return _monitor_notifyAll_Java; }
221
222 static address slow_arraycopy_Java() { return _slow_arraycopy_Java; }
223 static address register_finalizer_Java() { return _register_finalizer_Java; }
224 #if INCLUDE_JVMTI
225 static address notify_jvmti_vthread_start() { return _notify_jvmti_vthread_start; }
226 static address notify_jvmti_vthread_end() { return _notify_jvmti_vthread_end; }
227 static address notify_jvmti_vthread_mount() { return _notify_jvmti_vthread_mount; }
228 static address notify_jvmti_vthread_unmount() { return _notify_jvmti_vthread_unmount; }
229 #endif
230
231 static UncommonTrapBlob* uncommon_trap_blob() { return _uncommon_trap_blob; }
232 static ExceptionBlob* exception_blob() { return _exception_blob; }
233
234 // Implicit exception support
235 static void throw_div0_exception_C (JavaThread* thread);
236 static void throw_stack_overflow_error_C(JavaThread* thread);
237
238 // Exception handling
239 static address rethrow_stub() { return _rethrow_Java; }
240
241
242 // Type functions
243 // ======================================================
306
307 static const TypeFunc* ghash_processBlocks_Type();
308 static const TypeFunc* chacha20Block_Type();
309 static const TypeFunc* base64_encodeBlock_Type();
310 static const TypeFunc* base64_decodeBlock_Type();
311 static const TypeFunc* string_IndexOf_Type();
312 static const TypeFunc* poly1305_processBlocks_Type();
313 static const TypeFunc* intpoly_montgomeryMult_P256_Type();
314 static const TypeFunc* intpoly_assign_Type();
315
316 static const TypeFunc* updateBytesCRC32_Type();
317 static const TypeFunc* updateBytesCRC32C_Type();
318
319 static const TypeFunc* updateBytesAdler32_Type();
320
321 // leaf on stack replacement interpreter accessor types
322 static const TypeFunc* osr_end_Type();
323
324 static const TypeFunc* register_finalizer_Type();
325
326 JFR_ONLY(static const TypeFunc* class_id_load_barrier_Type();)
327 #if INCLUDE_JVMTI
328 static const TypeFunc* notify_jvmti_vthread_Type();
329 #endif
330
331 // Dtrace support
332 static const TypeFunc* dtrace_method_entry_exit_Type();
333 static const TypeFunc* dtrace_object_alloc_Type();
334
335 private:
336 static NamedCounter * volatile _named_counters;
337
338 public:
339 // helper function which creates a named counter labeled with the
340 // if they are available
341 static NamedCounter* new_named_counter(JVMState* jvms, NamedCounter::CounterTag tag);
342
343 // dumps all the named counters
344 static void print_named_counters();
345
346 };
347
348 #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 // Stub names indexed by sharedStubId
135 static const char *_stub_names[];
136
137 // define stubs
138 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);
139
140 static address _vtable_must_compile_Java;
141
142 //
143 // Implementation of runtime methods
144 // =================================
145
146 // Allocate storage for a Java instance.
147 static void new_instance_C(Klass* instance_klass, JavaThread* current);
148
149 // Allocate storage for a objArray or typeArray
150 static void new_array_C(Klass* array_klass, int len, JavaThread* current);
151 static void new_array_nozero_C(Klass* array_klass, int len, JavaThread* current);
152
153 // Allocate storage for a multi-dimensional arrays
154 // Note: needs to be fixed for arbitrary number of dimensions
155 static void multianewarray2_C(Klass* klass, int len1, int len2, JavaThread* current);
156 static void multianewarray3_C(Klass* klass, int len1, int len2, int len3, JavaThread* current);
157 static void multianewarray4_C(Klass* klass, int len1, int len2, int len3, int len4, JavaThread* current);
158 static void multianewarray5_C(Klass* klass, int len1, int len2, int len3, int len4, int len5, JavaThread* current);
159 static void multianewarrayN_C(Klass* klass, arrayOopDesc* dims, JavaThread* current);
160
161 // local methods passed as arguments to stub generator that forward
172 private:
173
174 // Implicit exception support
175 static void throw_null_exception_C(JavaThread* thread);
176
177 // Exception handling
178 static address handle_exception_C (JavaThread* current);
179 static address handle_exception_C_helper(JavaThread* current, nmethod*& nm);
180 static address rethrow_C (oopDesc* exception, JavaThread *thread, address return_pc );
181 static void deoptimize_caller_frame (JavaThread *thread);
182 static void deoptimize_caller_frame (JavaThread *thread, bool doit);
183 static bool is_deoptimized_caller_frame (JavaThread *thread);
184
185 // CodeBlob support
186 // ===================================================================
187
188 static void generate_uncommon_trap_blob(void);
189 static void generate_exception_blob();
190
191 static void register_finalizer_C(oopDesc* obj, JavaThread* current);
192 static void class_init_barrier_C(Klass* k, JavaThread* current);
193 public:
194
195 static bool is_callee_saved_register(MachRegisterNumbers reg);
196
197 // One time only generate runtime code stubs. Returns true
198 // when runtime stubs have been generated successfully and
199 // false otherwise.
200 static bool generate(ciEnv* env);
201
202 // Returns the name of a stub
203 static const char* stub_name(address entry);
204
205 // Returns the name associated with a given stub id
206 static const char* stub_name(OptoStubId id) {
207 assert(id > OptoStubId::NO_STUBID && id < OptoStubId::NUM_STUBIDS, "stub id out of range");
208 return _stub_names[(int)id];
209 }
210
211 // access to runtime stubs entry points for java code
212 static address new_instance_Java() { return _new_instance_Java; }
213 static address new_array_Java() { return _new_array_Java; }
214 static address new_array_nozero_Java() { return _new_array_nozero_Java; }
215 static address multianewarray2_Java() { return _multianewarray2_Java; }
216 static address multianewarray3_Java() { return _multianewarray3_Java; }
217 static address multianewarray4_Java() { return _multianewarray4_Java; }
218 static address multianewarray5_Java() { return _multianewarray5_Java; }
219 static address multianewarrayN_Java() { return _multianewarrayN_Java; }
220 static address vtable_must_compile_stub() { return _vtable_must_compile_Java; }
221 static address complete_monitor_locking_Java() { return _complete_monitor_locking_Java; }
222 static address monitor_notify_Java() { return _monitor_notify_Java; }
223 static address monitor_notifyAll_Java() { return _monitor_notifyAll_Java; }
224
225 static address slow_arraycopy_Java() { return _slow_arraycopy_Java; }
226 static address register_finalizer_Java() { return _register_finalizer_Java; }
227 static address class_init_barrier_Java() { return _class_init_barrier_Java; }
228 #if INCLUDE_JVMTI
229 static address notify_jvmti_vthread_start() { return _notify_jvmti_vthread_start; }
230 static address notify_jvmti_vthread_end() { return _notify_jvmti_vthread_end; }
231 static address notify_jvmti_vthread_mount() { return _notify_jvmti_vthread_mount; }
232 static address notify_jvmti_vthread_unmount() { return _notify_jvmti_vthread_unmount; }
233 #endif
234
235 static UncommonTrapBlob* uncommon_trap_blob() { return _uncommon_trap_blob; }
236 static ExceptionBlob* exception_blob() { return _exception_blob; }
237
238 // Implicit exception support
239 static void throw_div0_exception_C (JavaThread* thread);
240 static void throw_stack_overflow_error_C(JavaThread* thread);
241
242 // Exception handling
243 static address rethrow_stub() { return _rethrow_Java; }
244
245
246 // Type functions
247 // ======================================================
310
311 static const TypeFunc* ghash_processBlocks_Type();
312 static const TypeFunc* chacha20Block_Type();
313 static const TypeFunc* base64_encodeBlock_Type();
314 static const TypeFunc* base64_decodeBlock_Type();
315 static const TypeFunc* string_IndexOf_Type();
316 static const TypeFunc* poly1305_processBlocks_Type();
317 static const TypeFunc* intpoly_montgomeryMult_P256_Type();
318 static const TypeFunc* intpoly_assign_Type();
319
320 static const TypeFunc* updateBytesCRC32_Type();
321 static const TypeFunc* updateBytesCRC32C_Type();
322
323 static const TypeFunc* updateBytesAdler32_Type();
324
325 // leaf on stack replacement interpreter accessor types
326 static const TypeFunc* osr_end_Type();
327
328 static const TypeFunc* register_finalizer_Type();
329
330 static const TypeFunc* class_init_barrier_Type();
331
332 JFR_ONLY(static const TypeFunc* class_id_load_barrier_Type();)
333 #if INCLUDE_JVMTI
334 static const TypeFunc* notify_jvmti_vthread_Type();
335 #endif
336
337 // runtime upcalls support
338 static const TypeFunc* runtime_up_call_Type();
339
340 // Dtrace support
341 static const TypeFunc* dtrace_method_entry_exit_Type();
342 static const TypeFunc* dtrace_object_alloc_Type();
343
344 private:
345 static NamedCounter * volatile _named_counters;
346
347 public:
348 // helper function which creates a named counter labeled with the
349 // if they are available
350 static NamedCounter* new_named_counter(JVMState* jvms, NamedCounter::CounterTag tag);
351
352 // dumps all the named counters
353 static void print_named_counters();
354
355 public:
356 static void init_counters();
357 static void print_counters_on(outputStream* st);
358 };
359
360 #endif // SHARE_OPTO_RUNTIME_HPP
|