23 */ |
23 */ |
24 |
24 |
25 #include "precompiled.hpp" |
25 #include "precompiled.hpp" |
26 #include "code/compiledIC.hpp" |
26 #include "code/compiledIC.hpp" |
27 #include "code/compiledMethod.inline.hpp" |
27 #include "code/compiledMethod.inline.hpp" |
|
28 #include "code/exceptionHandlerTable.hpp" |
28 #include "code/scopeDesc.hpp" |
29 #include "code/scopeDesc.hpp" |
29 #include "code/codeCache.hpp" |
30 #include "code/codeCache.hpp" |
30 #include "code/icBuffer.hpp" |
31 #include "code/icBuffer.hpp" |
31 #include "gc/shared/barrierSet.hpp" |
32 #include "gc/shared/barrierSet.hpp" |
32 #include "gc/shared/gcBehaviours.hpp" |
33 #include "gc/shared/gcBehaviours.hpp" |
35 #include "logging/logTag.hpp" |
36 #include "logging/logTag.hpp" |
36 #include "memory/resourceArea.hpp" |
37 #include "memory/resourceArea.hpp" |
37 #include "oops/methodData.hpp" |
38 #include "oops/methodData.hpp" |
38 #include "oops/method.inline.hpp" |
39 #include "oops/method.inline.hpp" |
39 #include "prims/methodHandles.hpp" |
40 #include "prims/methodHandles.hpp" |
|
41 #include "runtime/deoptimization.hpp" |
40 #include "runtime/handles.inline.hpp" |
42 #include "runtime/handles.inline.hpp" |
41 #include "runtime/mutexLocker.hpp" |
43 #include "runtime/mutexLocker.hpp" |
|
44 #include "runtime/sharedRuntime.hpp" |
42 |
45 |
43 CompiledMethod::CompiledMethod(Method* method, const char* name, CompilerType type, const CodeBlobLayout& layout, |
46 CompiledMethod::CompiledMethod(Method* method, const char* name, CompilerType type, const CodeBlobLayout& layout, |
44 int frame_complete_offset, int frame_size, ImmutableOopMapSet* oop_maps, |
47 int frame_complete_offset, int frame_size, ImmutableOopMapSet* oop_maps, |
45 bool caller_must_gc_arguments) |
48 bool caller_must_gc_arguments) |
46 : CodeBlob(name, type, layout, frame_complete_offset, frame_size, oop_maps, caller_must_gc_arguments), |
49 : CodeBlob(name, type, layout, frame_complete_offset, frame_size, oop_maps, caller_must_gc_arguments), |
99 return NULL; |
102 return NULL; |
100 } |
103 } |
101 } |
104 } |
102 |
105 |
103 //----------------------------------------------------------------------------- |
106 //----------------------------------------------------------------------------- |
|
107 void CompiledMethod::mark_for_deoptimization(bool inc_recompile_counts) { |
|
108 MutexLocker ml(CompiledMethod_lock->owned_by_self() ? NULL : CompiledMethod_lock, |
|
109 Mutex::_no_safepoint_check_flag); |
|
110 _mark_for_deoptimization_status = (inc_recompile_counts ? deoptimize : deoptimize_noupdate); |
|
111 } |
|
112 |
|
113 //----------------------------------------------------------------------------- |
104 |
114 |
105 ExceptionCache* CompiledMethod::exception_cache_acquire() const { |
115 ExceptionCache* CompiledMethod::exception_cache_acquire() const { |
106 return OrderAccess::load_acquire(&_exception_cache); |
116 return OrderAccess::load_acquire(&_exception_cache); |
107 } |
117 } |
108 |
118 |
636 os::is_readable_pointer(method) && |
646 os::is_readable_pointer(method) && |
637 os::is_readable_pointer(method->constants()) && |
647 os::is_readable_pointer(method->constants()) && |
638 os::is_readable_pointer(method->signature()); |
648 os::is_readable_pointer(method->signature()); |
639 } |
649 } |
640 |
650 |
|
651 address CompiledMethod::continuation_for_implicit_exception(address pc, bool for_div0_check) { |
|
652 // Exception happened outside inline-cache check code => we are inside |
|
653 // an active nmethod => use cpc to determine a return address |
|
654 int exception_offset = pc - code_begin(); |
|
655 int cont_offset = ImplicitExceptionTable(this).continuation_offset( exception_offset ); |
|
656 #ifdef ASSERT |
|
657 if (cont_offset == 0) { |
|
658 Thread* thread = Thread::current(); |
|
659 ResetNoHandleMark rnm; // Might be called from LEAF/QUICK ENTRY |
|
660 HandleMark hm(thread); |
|
661 ResourceMark rm(thread); |
|
662 CodeBlob* cb = CodeCache::find_blob(pc); |
|
663 assert(cb != NULL && cb == this, ""); |
|
664 ttyLocker ttyl; |
|
665 tty->print_cr("implicit exception happened at " INTPTR_FORMAT, p2i(pc)); |
|
666 print(); |
|
667 method()->print_codes(); |
|
668 print_code(); |
|
669 print_pcs(); |
|
670 } |
|
671 #endif |
|
672 if (cont_offset == 0) { |
|
673 // Let the normal error handling report the exception |
|
674 return NULL; |
|
675 } |
|
676 if (cont_offset == exception_offset) { |
|
677 #if INCLUDE_JVMCI |
|
678 Deoptimization::DeoptReason deopt_reason = for_div0_check ? Deoptimization::Reason_div0_check : Deoptimization::Reason_null_check; |
|
679 JavaThread *thread = JavaThread::current(); |
|
680 thread->set_jvmci_implicit_exception_pc(pc); |
|
681 thread->set_pending_deoptimization(Deoptimization::make_trap_request(deopt_reason, |
|
682 Deoptimization::Action_reinterpret)); |
|
683 return (SharedRuntime::deopt_blob()->implicit_exception_uncommon_trap()); |
|
684 #else |
|
685 ShouldNotReachHere(); |
|
686 #endif |
|
687 } |
|
688 return code_begin() + cont_offset; |
|
689 } |
|
690 |
641 class HasEvolDependency : public MetadataClosure { |
691 class HasEvolDependency : public MetadataClosure { |
642 bool _has_evol_dependency; |
692 bool _has_evol_dependency; |
643 public: |
693 public: |
644 HasEvolDependency() : _has_evol_dependency(false) {} |
694 HasEvolDependency() : _has_evol_dependency(false) {} |
645 void do_metadata(Metadata* md) { |
695 void do_metadata(Metadata* md) { |