182 static void g1_wb_post(void* card_addr, JavaThread* thread);
183 #endif // INCLUDE_ALL_GCS
184
185 // exception handling and implicit exceptions
186 static address compute_compiled_exc_handler(nmethod* nm, address ret_pc, Handle& exception,
187 bool force_unwind, bool top_frame_only);
188 enum ImplicitExceptionKind {
189 IMPLICIT_NULL,
190 IMPLICIT_DIVIDE_BY_ZERO,
191 STACK_OVERFLOW
192 };
193 static void throw_AbstractMethodError(JavaThread* thread);
194 static void throw_IncompatibleClassChangeError(JavaThread* thread);
195 static void throw_ArithmeticException(JavaThread* thread);
196 static void throw_NullPointerException(JavaThread* thread);
197 static void throw_NullPointerException_at_call(JavaThread* thread);
198 static void throw_StackOverflowError(JavaThread* thread);
199 static address continuation_for_implicit_exception(JavaThread* thread,
200 address faulting_pc,
201 ImplicitExceptionKind exception_kind);
202
203 // Shared stub locations
204 static address get_poll_stub(address pc);
205
206 static address get_ic_miss_stub() {
207 assert(_ic_miss_blob!= NULL, "oops");
208 return _ic_miss_blob->entry_point();
209 }
210
211 static address get_handle_wrong_method_stub() {
212 assert(_wrong_method_blob!= NULL, "oops");
213 return _wrong_method_blob->entry_point();
214 }
215
216 static address get_handle_wrong_method_abstract_stub() {
217 assert(_wrong_method_abstract_blob!= NULL, "oops");
218 return _wrong_method_abstract_blob->entry_point();
219 }
220
221 #ifdef COMPILER2
400 // Although a c2i blob will always run interpreted even if compiled code is
401 // present if we see that compiled code is present the compiled call site
402 // will be patched/re-resolved so that later calls will run compiled.
403
404 // Additionally a c2i blob need to have a unverified entry because it can be reached
405 // in situations where the call site is an inlined cache site and may go megamorphic.
406
407 // A i2c adapter is simpler than the c2i adapter. This is because it is assumed
408 // that the interpreter before it does any call dispatch will record the current
409 // stack pointer in the interpreter frame. On return it will restore the stack
410 // pointer as needed. This means the i2c adapter code doesn't need any special
411 // handshaking path with compiled code to keep the stack walking correct.
412
413 static AdapterHandlerEntry* generate_i2c2i_adapters(MacroAssembler *_masm,
414 int total_args_passed,
415 int max_arg,
416 const BasicType *sig_bt,
417 const VMRegPair *regs,
418 AdapterFingerPrint* fingerprint);
419
420 // OSR support
421
422 // OSR_migration_begin will extract the jvm state from an interpreter
423 // frame (locals, monitors) and store the data in a piece of C heap
424 // storage. This then allows the interpreter frame to be removed from the
425 // stack and the OSR nmethod to be called. That method is called with a
426 // pointer to the C heap storage. This pointer is the return value from
427 // OSR_migration_begin.
428
429 static intptr_t* OSR_migration_begin(JavaThread *thread);
430
431 // OSR_migration_end is a trivial routine. It is called after the compiled
432 // method has extracted the jvm state from the C heap that OSR_migration_begin
433 // created. It's entire job is to simply free this storage.
434 static void OSR_migration_end(intptr_t* buf);
435
436 // Convert a sig into a calling convention register layout
437 // and find interesting things about it.
438 static VMRegPair* find_callee_arguments(Symbol* sig, bool has_receiver, bool has_appendix, int *arg_size);
439 static VMReg name_for_receiver();
458 // convention (handlizes oops, etc), transitions to native, makes the call,
459 // returns to java state (possibly blocking), unhandlizes any result and
460 // returns.
461 //
462 // The wrapper may contain special-case code if the given method
463 // is a JNI critical method, or a compiled method handle adapter,
464 // such as _invokeBasic, _linkToVirtual, etc.
465 static nmethod* generate_native_wrapper(MacroAssembler* masm,
466 methodHandle method,
467 int compile_id,
468 BasicType* sig_bt,
469 VMRegPair* regs,
470 BasicType ret_type);
471
472 // Block before entering a JNI critical method
473 static void block_for_jni_critical(JavaThread* thread);
474
475 // A compiled caller has just called the interpreter, but compiled code
476 // exists. Patch the caller so he no longer calls into the interpreter.
477 static void fixup_callers_callsite(Method* moop, address ret_pc);
478
479 // Slow-path Locking and Unlocking
480 static void complete_monitor_locking_C(oopDesc* obj, BasicLock* lock, JavaThread* thread);
481 static void complete_monitor_unlocking_C(oopDesc* obj, BasicLock* lock, JavaThread* thread);
482
483 // Resolving of calls
484 static address resolve_static_call_C (JavaThread *thread);
485 static address resolve_virtual_call_C (JavaThread *thread);
486 static address resolve_opt_virtual_call_C(JavaThread *thread);
487
488 // arraycopy, the non-leaf version. (See StubRoutines for all the leaf calls.)
489 static void slow_arraycopy_C(oopDesc* src, jint src_pos,
490 oopDesc* dest, jint dest_pos,
491 jint length, JavaThread* thread);
492
493 // handle ic miss with caller being compiled code
494 // wrong method handling (inline cache misses, zombie methods)
495 static address handle_wrong_method(JavaThread* thread);
496 static address handle_wrong_method_abstract(JavaThread* thread);
497 static address handle_wrong_method_ic_miss(JavaThread* thread);
656
657 //virtual void print_on(outputStream* st) const; DO NOT USE
658 void print_adapter_on(outputStream* st) const;
659 };
660
661 class AdapterHandlerLibrary: public AllStatic {
662 private:
663 static BufferBlob* _buffer; // the temporary code buffer in CodeCache
664 static AdapterHandlerTable* _adapters;
665 static AdapterHandlerEntry* _abstract_method_handler;
666 static BufferBlob* buffer_blob();
667 static void initialize();
668
669 public:
670
671 static AdapterHandlerEntry* new_entry(AdapterFingerPrint* fingerprint,
672 address i2c_entry, address c2i_entry, address c2i_unverified_entry);
673 static void create_native_wrapper(methodHandle method);
674 static AdapterHandlerEntry* get_adapter(methodHandle method);
675
676 static void print_handler(CodeBlob* b) { print_handler_on(tty, b); }
677 static void print_handler_on(outputStream* st, CodeBlob* b);
678 static bool contains(CodeBlob* b);
679 #ifndef PRODUCT
680 static void print_statistics();
681 #endif // PRODUCT
682
683 };
684
685 #endif // SHARE_VM_RUNTIME_SHAREDRUNTIME_HPP
|
182 static void g1_wb_post(void* card_addr, JavaThread* thread);
183 #endif // INCLUDE_ALL_GCS
184
185 // exception handling and implicit exceptions
186 static address compute_compiled_exc_handler(nmethod* nm, address ret_pc, Handle& exception,
187 bool force_unwind, bool top_frame_only);
188 enum ImplicitExceptionKind {
189 IMPLICIT_NULL,
190 IMPLICIT_DIVIDE_BY_ZERO,
191 STACK_OVERFLOW
192 };
193 static void throw_AbstractMethodError(JavaThread* thread);
194 static void throw_IncompatibleClassChangeError(JavaThread* thread);
195 static void throw_ArithmeticException(JavaThread* thread);
196 static void throw_NullPointerException(JavaThread* thread);
197 static void throw_NullPointerException_at_call(JavaThread* thread);
198 static void throw_StackOverflowError(JavaThread* thread);
199 static address continuation_for_implicit_exception(JavaThread* thread,
200 address faulting_pc,
201 ImplicitExceptionKind exception_kind);
202 #if INCLUDE_JVMCI
203 static address deoptimize_for_implicit_exception(JavaThread* thread, address pc, nmethod* nm, int deopt_reason);
204 #endif
205
206 // Shared stub locations
207 static address get_poll_stub(address pc);
208
209 static address get_ic_miss_stub() {
210 assert(_ic_miss_blob!= NULL, "oops");
211 return _ic_miss_blob->entry_point();
212 }
213
214 static address get_handle_wrong_method_stub() {
215 assert(_wrong_method_blob!= NULL, "oops");
216 return _wrong_method_blob->entry_point();
217 }
218
219 static address get_handle_wrong_method_abstract_stub() {
220 assert(_wrong_method_abstract_blob!= NULL, "oops");
221 return _wrong_method_abstract_blob->entry_point();
222 }
223
224 #ifdef COMPILER2
403 // Although a c2i blob will always run interpreted even if compiled code is
404 // present if we see that compiled code is present the compiled call site
405 // will be patched/re-resolved so that later calls will run compiled.
406
407 // Additionally a c2i blob need to have a unverified entry because it can be reached
408 // in situations where the call site is an inlined cache site and may go megamorphic.
409
410 // A i2c adapter is simpler than the c2i adapter. This is because it is assumed
411 // that the interpreter before it does any call dispatch will record the current
412 // stack pointer in the interpreter frame. On return it will restore the stack
413 // pointer as needed. This means the i2c adapter code doesn't need any special
414 // handshaking path with compiled code to keep the stack walking correct.
415
416 static AdapterHandlerEntry* generate_i2c2i_adapters(MacroAssembler *_masm,
417 int total_args_passed,
418 int max_arg,
419 const BasicType *sig_bt,
420 const VMRegPair *regs,
421 AdapterFingerPrint* fingerprint);
422
423 static void gen_i2c_adapter(MacroAssembler *_masm,
424 int total_args_passed,
425 int comp_args_on_stack,
426 const BasicType *sig_bt,
427 const VMRegPair *regs);
428
429 // OSR support
430
431 // OSR_migration_begin will extract the jvm state from an interpreter
432 // frame (locals, monitors) and store the data in a piece of C heap
433 // storage. This then allows the interpreter frame to be removed from the
434 // stack and the OSR nmethod to be called. That method is called with a
435 // pointer to the C heap storage. This pointer is the return value from
436 // OSR_migration_begin.
437
438 static intptr_t* OSR_migration_begin(JavaThread *thread);
439
440 // OSR_migration_end is a trivial routine. It is called after the compiled
441 // method has extracted the jvm state from the C heap that OSR_migration_begin
442 // created. It's entire job is to simply free this storage.
443 static void OSR_migration_end(intptr_t* buf);
444
445 // Convert a sig into a calling convention register layout
446 // and find interesting things about it.
447 static VMRegPair* find_callee_arguments(Symbol* sig, bool has_receiver, bool has_appendix, int *arg_size);
448 static VMReg name_for_receiver();
467 // convention (handlizes oops, etc), transitions to native, makes the call,
468 // returns to java state (possibly blocking), unhandlizes any result and
469 // returns.
470 //
471 // The wrapper may contain special-case code if the given method
472 // is a JNI critical method, or a compiled method handle adapter,
473 // such as _invokeBasic, _linkToVirtual, etc.
474 static nmethod* generate_native_wrapper(MacroAssembler* masm,
475 methodHandle method,
476 int compile_id,
477 BasicType* sig_bt,
478 VMRegPair* regs,
479 BasicType ret_type);
480
481 // Block before entering a JNI critical method
482 static void block_for_jni_critical(JavaThread* thread);
483
484 // A compiled caller has just called the interpreter, but compiled code
485 // exists. Patch the caller so he no longer calls into the interpreter.
486 static void fixup_callers_callsite(Method* moop, address ret_pc);
487 static bool should_fixup_call_destination(address destination, address entry_point, address caller_pc, Method* moop, CodeBlob* cb);
488
489 // Slow-path Locking and Unlocking
490 static void complete_monitor_locking_C(oopDesc* obj, BasicLock* lock, JavaThread* thread);
491 static void complete_monitor_unlocking_C(oopDesc* obj, BasicLock* lock, JavaThread* thread);
492
493 // Resolving of calls
494 static address resolve_static_call_C (JavaThread *thread);
495 static address resolve_virtual_call_C (JavaThread *thread);
496 static address resolve_opt_virtual_call_C(JavaThread *thread);
497
498 // arraycopy, the non-leaf version. (See StubRoutines for all the leaf calls.)
499 static void slow_arraycopy_C(oopDesc* src, jint src_pos,
500 oopDesc* dest, jint dest_pos,
501 jint length, JavaThread* thread);
502
503 // handle ic miss with caller being compiled code
504 // wrong method handling (inline cache misses, zombie methods)
505 static address handle_wrong_method(JavaThread* thread);
506 static address handle_wrong_method_abstract(JavaThread* thread);
507 static address handle_wrong_method_ic_miss(JavaThread* thread);
666
667 //virtual void print_on(outputStream* st) const; DO NOT USE
668 void print_adapter_on(outputStream* st) const;
669 };
670
671 class AdapterHandlerLibrary: public AllStatic {
672 private:
673 static BufferBlob* _buffer; // the temporary code buffer in CodeCache
674 static AdapterHandlerTable* _adapters;
675 static AdapterHandlerEntry* _abstract_method_handler;
676 static BufferBlob* buffer_blob();
677 static void initialize();
678
679 public:
680
681 static AdapterHandlerEntry* new_entry(AdapterFingerPrint* fingerprint,
682 address i2c_entry, address c2i_entry, address c2i_unverified_entry);
683 static void create_native_wrapper(methodHandle method);
684 static AdapterHandlerEntry* get_adapter(methodHandle method);
685
686 static void print_handler(const CodeBlob* b) { print_handler_on(tty, b); }
687 static void print_handler_on(outputStream* st, const CodeBlob* b);
688 static bool contains(const CodeBlob* b);
689 #ifndef PRODUCT
690 static void print_statistics();
691 #endif // PRODUCT
692
693 };
694
695 #endif // SHARE_VM_RUNTIME_SHAREDRUNTIME_HPP
|