18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_RUNTIME_SHAREDRUNTIME_HPP
26 #define SHARE_RUNTIME_SHAREDRUNTIME_HPP
27
28 #include "code/codeBlob.hpp"
29 #include "code/vmreg.hpp"
30 #include "interpreter/linkResolver.hpp"
31 #include "memory/allStatic.hpp"
32 #include "memory/resourceArea.hpp"
33 #include "utilities/macros.hpp"
34
35 class AdapterHandlerEntry;
36 class AdapterFingerPrint;
37 class vframeStream;
38
39 // Runtime is the base class for various runtime interfaces
40 // (InterpreterRuntime, CompilerRuntime, etc.). It provides
41 // shared functionality such as exception forwarding (C++ to
42 // Java exceptions), locking/unlocking mechanisms, statistical
43 // information, etc.
44
45 class SharedRuntime: AllStatic {
46 friend class VMStructs;
47
48 private:
49 // Shared stub locations
50
51 static RuntimeStub* _wrong_method_blob;
52 static RuntimeStub* _wrong_method_abstract_blob;
53 static RuntimeStub* _ic_miss_blob;
54 static RuntimeStub* _resolve_opt_virtual_call_blob;
55 static RuntimeStub* _resolve_virtual_call_blob;
56 static RuntimeStub* _resolve_static_call_blob;
57 static address _resolve_static_call_entry;
58
59 static DeoptimizationBlob* _deopt_blob;
60
61 static SafepointBlob* _polling_page_vectors_safepoint_handler_blob;
62 static SafepointBlob* _polling_page_safepoint_handler_blob;
63 static SafepointBlob* _polling_page_return_handler_blob;
64
65 #ifdef COMPILER2
66 static UncommonTrapBlob* _uncommon_trap_blob;
67 #endif // COMPILER2
68
69 static nmethod* _cont_doYield_stub;
70
71 #ifndef PRODUCT
72 // Counters
73 static int64_t _nof_megamorphic_calls; // total # of megamorphic calls (through vtable)
74 #endif // !PRODUCT
75
76 private:
77 enum { POLL_AT_RETURN, POLL_AT_LOOP, POLL_AT_VECTOR_LOOP };
181 // exception handling and implicit exceptions
182 static address compute_compiled_exc_handler(nmethod* nm, address ret_pc, Handle& exception,
183 bool force_unwind, bool top_frame_only, bool& recursive_exception_occurred);
184 enum ImplicitExceptionKind {
185 IMPLICIT_NULL,
186 IMPLICIT_DIVIDE_BY_ZERO,
187 STACK_OVERFLOW
188 };
189 static void throw_AbstractMethodError(JavaThread* current);
190 static void throw_IncompatibleClassChangeError(JavaThread* current);
191 static void throw_ArithmeticException(JavaThread* current);
192 static void throw_NullPointerException(JavaThread* current);
193 static void throw_NullPointerException_at_call(JavaThread* current);
194 static void throw_StackOverflowError(JavaThread* current);
195 static void throw_delayed_StackOverflowError(JavaThread* current);
196 static void throw_StackOverflowError_common(JavaThread* current, bool delayed);
197 static address continuation_for_implicit_exception(JavaThread* current,
198 address faulting_pc,
199 ImplicitExceptionKind exception_kind);
200
201 // Post-slow-path-allocation, pre-initializing-stores step for
202 // implementing e.g. ReduceInitialCardMarks
203 static void on_slowpath_allocation_exit(JavaThread* current);
204
205 static void enable_stack_reserved_zone(JavaThread* current);
206 static frame look_for_reserved_stack_annotated_method(JavaThread* current, frame fr);
207
208 // Shared stub locations
209 static address get_poll_stub(address pc);
210
211 static address get_ic_miss_stub() {
212 assert(_ic_miss_blob!= nullptr, "oops");
213 return _ic_miss_blob->entry_point();
214 }
215
216 static address get_handle_wrong_method_stub() {
217 assert(_wrong_method_blob!= nullptr, "oops");
218 return _wrong_method_blob->entry_point();
219 }
220
447 // created. It's entire job is to simply free this storage.
448 static void OSR_migration_end(intptr_t* buf);
449
450 // Convert a sig into a calling convention register layout
451 // and find interesting things about it.
452 static VMRegPair* find_callee_arguments(Symbol* sig, bool has_receiver, bool has_appendix, int *arg_size);
453 static VMReg name_for_receiver();
454
455 // "Top of Stack" slots that may be unused by the calling convention but must
456 // otherwise be preserved.
457 // On Intel these are not necessary and the value can be zero.
458 // On Sparc this describes the words reserved for storing a register window
459 // when an interrupt occurs.
460 static uint out_preserve_stack_slots();
461
462 // Stack slots that may be unused by the calling convention but must
463 // otherwise be preserved. On Intel this includes the return address.
464 // On PowerPC it includes the 4 words holding the old TOC & LR glue.
465 static uint in_preserve_stack_slots();
466
467 // Is vector's size (in bytes) bigger than a size saved by default?
468 // For example, on x86 16 bytes XMM registers are saved by default.
469 static bool is_wide_vector(int size);
470
471 // Save and restore a native result
472 static void save_native_result(MacroAssembler *_masm, BasicType ret_type, int frame_slots);
473 static void restore_native_result(MacroAssembler *_masm, BasicType ret_type, int frame_slots);
474
475 // Generate a native wrapper for a given method. The method takes arguments
476 // in the Java compiled code convention, marshals them to the native
477 // convention (handlizes oops, etc), transitions to native, makes the call,
478 // returns to java state (possibly blocking), unhandlizes any result and
479 // returns.
480 //
481 // The wrapper may contain special-case code if the given method
482 // is a compiled method handle adapter, such as _invokeBasic, _linkToVirtual, etc.
483 static nmethod* generate_native_wrapper(MacroAssembler* masm,
484 const methodHandle& method,
485 int compile_id,
486 BasicType* sig_bt,
487 VMRegPair* regs,
488 BasicType ret_type);
489
490 // A compiled caller has just called the interpreter, but compiled code
491 // exists. Patch the caller so he no longer calls into the interpreter.
492 static void fixup_callers_callsite(Method* moop, address ret_pc);
493 static bool should_fixup_call_destination(address destination, address entry_point, address caller_pc, Method* moop, CodeBlob* cb);
494
495 // Slow-path Locking and Unlocking
496 static void complete_monitor_locking_C(oopDesc* obj, BasicLock* lock, JavaThread* current);
497 static void complete_monitor_unlocking_C(oopDesc* obj, BasicLock* lock, JavaThread* current);
498
499 // Resolving of calls
500 static address get_resolved_entry (JavaThread* current, methodHandle callee_method);
501 static address resolve_static_call_C (JavaThread* current);
502 static address resolve_virtual_call_C (JavaThread* current);
503 static address resolve_opt_virtual_call_C(JavaThread* current);
504
505 // arraycopy, the non-leaf version. (See StubRoutines for all the leaf calls.)
506 static void slow_arraycopy_C(oopDesc* src, jint src_pos,
507 oopDesc* dest, jint dest_pos,
508 jint length, JavaThread* thread);
509
510 // handle ic miss with caller being compiled code
511 // wrong method handling (inline cache misses)
512 static address handle_wrong_method(JavaThread* current);
513 static address handle_wrong_method_abstract(JavaThread* current);
514 static address handle_wrong_method_ic_miss(JavaThread* current);
515
516 static address handle_unsafe_access(JavaThread* thread, address next_pc);
517
|
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #ifndef SHARE_RUNTIME_SHAREDRUNTIME_HPP
26 #define SHARE_RUNTIME_SHAREDRUNTIME_HPP
27
28 #include "code/codeBlob.hpp"
29 #include "code/vmreg.hpp"
30 #include "interpreter/linkResolver.hpp"
31 #include "memory/allStatic.hpp"
32 #include "memory/resourceArea.hpp"
33 #include "utilities/macros.hpp"
34
35 class AdapterHandlerEntry;
36 class AdapterFingerPrint;
37 class vframeStream;
38 class ObjectWaiter;
39
40 // Runtime is the base class for various runtime interfaces
41 // (InterpreterRuntime, CompilerRuntime, etc.). It provides
42 // shared functionality such as exception forwarding (C++ to
43 // Java exceptions), locking/unlocking mechanisms, statistical
44 // information, etc.
45
46 class SharedRuntime: AllStatic {
47 friend class VMStructs;
48
49 private:
50 // Shared stub locations
51
52 static RuntimeStub* _wrong_method_blob;
53 static RuntimeStub* _wrong_method_abstract_blob;
54 static RuntimeStub* _ic_miss_blob;
55 static RuntimeStub* _resolve_opt_virtual_call_blob;
56 static RuntimeStub* _resolve_virtual_call_blob;
57 static RuntimeStub* _resolve_static_call_blob;
58 static address _resolve_static_call_entry;
59 static address _native_frame_resume_entry;
60
61 static DeoptimizationBlob* _deopt_blob;
62
63 static SafepointBlob* _polling_page_vectors_safepoint_handler_blob;
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 static nmethod* _cont_doYield_stub;
72
73 #ifndef PRODUCT
74 // Counters
75 static int64_t _nof_megamorphic_calls; // total # of megamorphic calls (through vtable)
76 #endif // !PRODUCT
77
78 private:
79 enum { POLL_AT_RETURN, POLL_AT_LOOP, POLL_AT_VECTOR_LOOP };
183 // exception handling and implicit exceptions
184 static address compute_compiled_exc_handler(nmethod* nm, address ret_pc, Handle& exception,
185 bool force_unwind, bool top_frame_only, bool& recursive_exception_occurred);
186 enum ImplicitExceptionKind {
187 IMPLICIT_NULL,
188 IMPLICIT_DIVIDE_BY_ZERO,
189 STACK_OVERFLOW
190 };
191 static void throw_AbstractMethodError(JavaThread* current);
192 static void throw_IncompatibleClassChangeError(JavaThread* current);
193 static void throw_ArithmeticException(JavaThread* current);
194 static void throw_NullPointerException(JavaThread* current);
195 static void throw_NullPointerException_at_call(JavaThread* current);
196 static void throw_StackOverflowError(JavaThread* current);
197 static void throw_delayed_StackOverflowError(JavaThread* current);
198 static void throw_StackOverflowError_common(JavaThread* current, bool delayed);
199 static address continuation_for_implicit_exception(JavaThread* current,
200 address faulting_pc,
201 ImplicitExceptionKind exception_kind);
202
203 static address native_frame_resume_entry() { return _native_frame_resume_entry; }
204 static void set_native_frame_resume_entry(address val) {
205 assert(_native_frame_resume_entry == nullptr, "");
206 _native_frame_resume_entry = val;
207 }
208
209 // Post-slow-path-allocation, pre-initializing-stores step for
210 // implementing e.g. ReduceInitialCardMarks
211 static void on_slowpath_allocation_exit(JavaThread* current);
212
213 static void enable_stack_reserved_zone(JavaThread* current);
214 static frame look_for_reserved_stack_annotated_method(JavaThread* current, frame fr);
215
216 // Shared stub locations
217 static address get_poll_stub(address pc);
218
219 static address get_ic_miss_stub() {
220 assert(_ic_miss_blob!= nullptr, "oops");
221 return _ic_miss_blob->entry_point();
222 }
223
224 static address get_handle_wrong_method_stub() {
225 assert(_wrong_method_blob!= nullptr, "oops");
226 return _wrong_method_blob->entry_point();
227 }
228
455 // created. It's entire job is to simply free this storage.
456 static void OSR_migration_end(intptr_t* buf);
457
458 // Convert a sig into a calling convention register layout
459 // and find interesting things about it.
460 static VMRegPair* find_callee_arguments(Symbol* sig, bool has_receiver, bool has_appendix, int *arg_size);
461 static VMReg name_for_receiver();
462
463 // "Top of Stack" slots that may be unused by the calling convention but must
464 // otherwise be preserved.
465 // On Intel these are not necessary and the value can be zero.
466 // On Sparc this describes the words reserved for storing a register window
467 // when an interrupt occurs.
468 static uint out_preserve_stack_slots();
469
470 // Stack slots that may be unused by the calling convention but must
471 // otherwise be preserved. On Intel this includes the return address.
472 // On PowerPC it includes the 4 words holding the old TOC & LR glue.
473 static uint in_preserve_stack_slots();
474
475 static VMReg thread_register();
476
477 static void continuation_enter_cleanup(MacroAssembler* masm);
478
479 // Is vector's size (in bytes) bigger than a size saved by default?
480 // For example, on x86 16 bytes XMM registers are saved by default.
481 static bool is_wide_vector(int size);
482
483 // Save and restore a native result
484 static void save_native_result(MacroAssembler *_masm, BasicType ret_type, int frame_slots);
485 static void restore_native_result(MacroAssembler *_masm, BasicType ret_type, int frame_slots);
486
487 // Generate a native wrapper for a given method. The method takes arguments
488 // in the Java compiled code convention, marshals them to the native
489 // convention (handlizes oops, etc), transitions to native, makes the call,
490 // returns to java state (possibly blocking), unhandlizes any result and
491 // returns.
492 //
493 // The wrapper may contain special-case code if the given method
494 // is a compiled method handle adapter, such as _invokeBasic, _linkToVirtual, etc.
495 static nmethod* generate_native_wrapper(MacroAssembler* masm,
496 const methodHandle& method,
497 int compile_id,
498 BasicType* sig_bt,
499 VMRegPair* regs,
500 BasicType ret_type);
501
502 // A compiled caller has just called the interpreter, but compiled code
503 // exists. Patch the caller so he no longer calls into the interpreter.
504 static void fixup_callers_callsite(Method* moop, address ret_pc);
505 static bool should_fixup_call_destination(address destination, address entry_point, address caller_pc, Method* moop, CodeBlob* cb);
506
507 // Slow-path Locking and Unlocking
508 static void complete_monitor_locking_C(oopDesc* obj, BasicLock* lock, JavaThread* current);
509 static void complete_monitor_unlocking_C(oopDesc* obj, BasicLock* lock, JavaThread* current);
510 static void resume_monitor_operation(JavaThread* current, ObjectWaiter* node);
511
512 // Resolving of calls
513 static address get_resolved_entry (JavaThread* current, methodHandle callee_method);
514 static address resolve_static_call_C (JavaThread* current);
515 static address resolve_virtual_call_C (JavaThread* current);
516 static address resolve_opt_virtual_call_C(JavaThread* current);
517
518 // arraycopy, the non-leaf version. (See StubRoutines for all the leaf calls.)
519 static void slow_arraycopy_C(oopDesc* src, jint src_pos,
520 oopDesc* dest, jint dest_pos,
521 jint length, JavaThread* thread);
522
523 // handle ic miss with caller being compiled code
524 // wrong method handling (inline cache misses)
525 static address handle_wrong_method(JavaThread* current);
526 static address handle_wrong_method_abstract(JavaThread* current);
527 static address handle_wrong_method_ic_miss(JavaThread* current);
528
529 static address handle_unsafe_access(JavaThread* thread, address next_pc);
530
|