41 // Runtime is the base class for various runtime interfaces 42 // (InterpreterRuntime, CompilerRuntime, etc.). It provides 43 // shared functionality such as exception forwarding (C++ to 44 // Java exceptions), locking/unlocking mechanisms, statistical 45 // information, etc. 46 47 class SharedRuntime: AllStatic { 48 private: 49 static methodHandle resolve_sub_helper(JavaThread *thread, 50 bool is_virtual, 51 bool is_optimized, TRAPS); 52 53 // Shared stub locations 54 55 static RuntimeStub* _wrong_method_blob; 56 static RuntimeStub* _ic_miss_blob; 57 static RuntimeStub* _resolve_opt_virtual_call_blob; 58 static RuntimeStub* _resolve_virtual_call_blob; 59 static RuntimeStub* _resolve_static_call_blob; 60 61 static RicochetBlob* _ricochet_blob; 62 63 static SafepointBlob* _polling_page_safepoint_handler_blob; 64 static SafepointBlob* _polling_page_return_handler_blob; 65 #ifdef COMPILER2 66 static ExceptionBlob* _exception_blob; 67 static UncommonTrapBlob* _uncommon_trap_blob; 68 #endif // COMPILER2 69 70 #ifndef PRODUCT 71 72 // Counters 73 static int _nof_megamorphic_calls; // total # of megamorphic calls (through vtable) 74 75 #endif // !PRODUCT 76 public: 77 78 // max bytes for each dtrace string parameter 79 enum { max_dtrace_string_size = 256 }; 80 81 // The following arithmetic routines are used on platforms that do 82 // not have machine instructions to implement their functionality. 83 // Do not remove these. 84 85 // long arithmetics 86 static jlong lmul(jlong y, jlong x); 87 static jlong ldiv(jlong y, jlong x); 88 static jlong lrem(jlong y, jlong x); 89 90 // float and double remainder 91 static jfloat frem(jfloat x, jfloat y); 92 static jdouble drem(jdouble x, jdouble y); 93 94 #ifdef __SOFTFP__ 95 static jfloat fadd(jfloat x, jfloat y); 96 static jfloat fsub(jfloat x, jfloat y); 309 * @param name the name of the class of the object attempted to be cast 310 * @param klass the name of the target klass attempt 311 * @param gripe the specific kind of problem being reported 312 * @return the dynamically allocated exception message (must be freed 313 * by the caller using a resource mark) 314 * 315 * This version does not require access the frame, so it can be called 316 * from interpreted code 317 * The caller (or one of it's callers) must use a ResourceMark 318 * in order to correctly free the result. 319 */ 320 static char* generate_class_cast_message(const char* name, const char* klass, 321 const char* gripe = " cannot be cast to "); 322 323 // Resolves a call site- may patch in the destination of the call into the 324 // compiled code. 325 static methodHandle resolve_helper(JavaThread *thread, 326 bool is_virtual, 327 bool is_optimized, TRAPS); 328 329 static void generate_stubs(void); 330 331 private: 332 // deopt blob 333 static void generate_deopt_blob(void); 334 static DeoptimizationBlob* _deopt_blob; 335 336 public: 337 static DeoptimizationBlob* deopt_blob(void) { return _deopt_blob; } 338 339 // Resets a call-site in compiled code so it will get resolved again. 340 static methodHandle reresolve_call_site(JavaThread *thread, TRAPS); 341 342 // In the code prolog, if the klass comparison fails, the inline cache 343 // misses and the call site is patched to megamorphic 344 static methodHandle handle_ic_miss_helper(JavaThread* thread, TRAPS); 345 346 // Find the method that called us. 347 static methodHandle find_callee_method(JavaThread* thread, TRAPS); 348 349 350 private: 351 static Handle find_callee_info(JavaThread* thread, 352 Bytecodes::Code& bc, 353 CallInfo& callinfo, TRAPS); 354 static Handle find_callee_info_helper(JavaThread* thread, | 41 // Runtime is the base class for various runtime interfaces 42 // (InterpreterRuntime, CompilerRuntime, etc.). It provides 43 // shared functionality such as exception forwarding (C++ to 44 // Java exceptions), locking/unlocking mechanisms, statistical 45 // information, etc. 46 47 class SharedRuntime: AllStatic { 48 private: 49 static methodHandle resolve_sub_helper(JavaThread *thread, 50 bool is_virtual, 51 bool is_optimized, TRAPS); 52 53 // Shared stub locations 54 55 static RuntimeStub* _wrong_method_blob; 56 static RuntimeStub* _ic_miss_blob; 57 static RuntimeStub* _resolve_opt_virtual_call_blob; 58 static RuntimeStub* _resolve_virtual_call_blob; 59 static RuntimeStub* _resolve_static_call_blob; 60 61 static DeoptimizationBlob* _deopt_blob; 62 static RicochetBlob* _ricochet_blob; 63 64 static SafepointBlob* _polling_page_safepoint_handler_blob; 65 static SafepointBlob* _polling_page_return_handler_blob; 66 67 #ifdef COMPILER2 68 static UncommonTrapBlob* _uncommon_trap_blob; 69 #endif // COMPILER2 70 71 #ifndef PRODUCT 72 // Counters 73 static int _nof_megamorphic_calls; // total # of megamorphic calls (through vtable) 74 #endif // !PRODUCT 75 76 private: 77 static SafepointBlob* generate_handler_blob(address call_ptr, bool cause_return); 78 static RuntimeStub* generate_resolve_blob(address destination, const char* name); 79 80 public: 81 static void generate_stubs(void); 82 83 // max bytes for each dtrace string parameter 84 enum { max_dtrace_string_size = 256 }; 85 86 // The following arithmetic routines are used on platforms that do 87 // not have machine instructions to implement their functionality. 88 // Do not remove these. 89 90 // long arithmetics 91 static jlong lmul(jlong y, jlong x); 92 static jlong ldiv(jlong y, jlong x); 93 static jlong lrem(jlong y, jlong x); 94 95 // float and double remainder 96 static jfloat frem(jfloat x, jfloat y); 97 static jdouble drem(jdouble x, jdouble y); 98 99 #ifdef __SOFTFP__ 100 static jfloat fadd(jfloat x, jfloat y); 101 static jfloat fsub(jfloat x, jfloat y); 314 * @param name the name of the class of the object attempted to be cast 315 * @param klass the name of the target klass attempt 316 * @param gripe the specific kind of problem being reported 317 * @return the dynamically allocated exception message (must be freed 318 * by the caller using a resource mark) 319 * 320 * This version does not require access the frame, so it can be called 321 * from interpreted code 322 * The caller (or one of it's callers) must use a ResourceMark 323 * in order to correctly free the result. 324 */ 325 static char* generate_class_cast_message(const char* name, const char* klass, 326 const char* gripe = " cannot be cast to "); 327 328 // Resolves a call site- may patch in the destination of the call into the 329 // compiled code. 330 static methodHandle resolve_helper(JavaThread *thread, 331 bool is_virtual, 332 bool is_optimized, TRAPS); 333 334 private: 335 // deopt blob 336 static void generate_deopt_blob(void); 337 338 public: 339 static DeoptimizationBlob* deopt_blob(void) { return _deopt_blob; } 340 341 // Resets a call-site in compiled code so it will get resolved again. 342 static methodHandle reresolve_call_site(JavaThread *thread, TRAPS); 343 344 // In the code prolog, if the klass comparison fails, the inline cache 345 // misses and the call site is patched to megamorphic 346 static methodHandle handle_ic_miss_helper(JavaThread* thread, TRAPS); 347 348 // Find the method that called us. 349 static methodHandle find_callee_method(JavaThread* thread, TRAPS); 350 351 352 private: 353 static Handle find_callee_info(JavaThread* thread, 354 Bytecodes::Code& bc, 355 CallInfo& callinfo, TRAPS); 356 static Handle find_callee_info_helper(JavaThread* thread, |