< prev index next >

src/hotspot/share/runtime/safepoint.cpp

Print this page

  29 #include "classfile/symbolTable.hpp"
  30 #include "code/codeCache.hpp"
  31 #include "code/icBuffer.hpp"
  32 #include "code/nmethod.hpp"
  33 #include "code/pcDesc.hpp"
  34 #include "code/scopeDesc.hpp"
  35 #include "compiler/compilationPolicy.hpp"
  36 #include "gc/shared/collectedHeap.hpp"
  37 #include "gc/shared/gcLocker.hpp"
  38 #include "gc/shared/oopStorage.hpp"
  39 #include "gc/shared/strongRootsScope.hpp"
  40 #include "gc/shared/workgroup.hpp"
  41 #include "interpreter/interpreter.hpp"
  42 #include "jfr/jfrEvents.hpp"
  43 #include "logging/log.hpp"
  44 #include "logging/logStream.hpp"
  45 #include "memory/resourceArea.hpp"
  46 #include "memory/universe.hpp"
  47 #include "oops/oop.inline.hpp"
  48 #include "oops/symbol.hpp"

  49 #include "runtime/atomic.hpp"
  50 #include "runtime/deoptimization.hpp"
  51 #include "runtime/frame.inline.hpp"
  52 #include "runtime/handles.inline.hpp"
  53 #include "runtime/interfaceSupport.inline.hpp"
  54 #include "runtime/mutexLocker.hpp"
  55 #include "runtime/orderAccess.hpp"
  56 #include "runtime/osThread.hpp"
  57 #include "runtime/safepoint.hpp"
  58 #include "runtime/safepointMechanism.inline.hpp"
  59 #include "runtime/signature.hpp"
  60 #include "runtime/stackWatermarkSet.inline.hpp"
  61 #include "runtime/stubCodeGenerator.hpp"
  62 #include "runtime/stubRoutines.hpp"
  63 #include "runtime/sweeper.hpp"
  64 #include "runtime/synchronizer.hpp"
  65 #include "runtime/thread.inline.hpp"
  66 #include "runtime/threadSMR.hpp"
  67 #include "runtime/threadWXSetters.inline.hpp"
  68 #include "runtime/timerTrace.hpp"

 898   CodeBlob *cb = CodeCache::find_blob(real_return_addr);
 899   assert(cb != NULL && cb->is_compiled(), "return address should be in nmethod");
 900   CompiledMethod* nm = (CompiledMethod*)cb;
 901 
 902   // Find frame of caller
 903   frame stub_fr = self->last_frame();
 904   CodeBlob* stub_cb = stub_fr.cb();
 905   assert(stub_cb->is_safepoint_stub(), "must be a safepoint stub");
 906   RegisterMap map(self, true, false);
 907   frame caller_fr = stub_fr.sender(&map);
 908 
 909   // Should only be poll_return or poll
 910   assert( nm->is_at_poll_or_poll_return(real_return_addr), "should not be at call" );
 911 
 912   // This is a poll immediately before a return. The exception handling code
 913   // has already had the effect of causing the return to occur, so the execution
 914   // will continue immediately after the call. In addition, the oopmap at the
 915   // return point does not mark the return value as an oop (if it is), so
 916   // it needs a handle here to be updated.
 917   if( nm->is_at_poll_return(real_return_addr) ) {

 918     // See if return type is an oop.
 919     bool return_oop = nm->method()->is_returning_oop();

 920     HandleMark hm(self);
 921     Handle return_value;






















 922     if (return_oop) {
 923       // The oop result has been saved on the stack together with all
 924       // the other registers. In order to preserve it over GCs we need
 925       // to keep it in a handle.
 926       oop result = caller_fr.saved_oop_result(&map);
 927       assert(oopDesc::is_oop_or_null(result), "must be oop");
 928       return_value = Handle(self, result);
 929       assert(Universe::heap()->is_in_or_null(result), "must be heap pointer");
 930     }
 931 
 932     // We get here if compiled return polls found a reason to call into the VM.
 933     // One condition for that is that the top frame is not yet safe to use.
 934     // The following stack watermark barrier poll will catch such situations.
 935     StackWatermarkSet::after_unwind(self);
 936 
 937     // Process pending operation
 938     SafepointMechanism::process_if_requested_with_exit_check(self, true /* check asyncs */);
 939 
 940     // restore oop result, if any
 941     if (return_oop) {
 942       caller_fr.set_saved_oop_result(&map, return_value());



 943     }
 944   }
 945 
 946   // This is a safepoint poll. Verify the return address and block.
 947   else {
 948 
 949     // verify the blob built the "return address" correctly
 950     assert(real_return_addr == caller_fr.pc(), "must match");
 951 
 952     set_at_poll_safepoint(true);
 953     // Process pending operation
 954     // We never deliver an async exception at a polling point as the
 955     // compiler may not have an exception handler for it. The polling
 956     // code will notice the pending async exception, deoptimize and
 957     // the exception will be delivered. (Polling at a return point
 958     // is ok though). Sure is a lot of bother for a deprecated feature...
 959     SafepointMechanism::process_if_requested_with_exit_check(self, false /* check asyncs */);
 960     set_at_poll_safepoint(false);
 961 
 962     // If we have a pending async exception deoptimize the frame

  29 #include "classfile/symbolTable.hpp"
  30 #include "code/codeCache.hpp"
  31 #include "code/icBuffer.hpp"
  32 #include "code/nmethod.hpp"
  33 #include "code/pcDesc.hpp"
  34 #include "code/scopeDesc.hpp"
  35 #include "compiler/compilationPolicy.hpp"
  36 #include "gc/shared/collectedHeap.hpp"
  37 #include "gc/shared/gcLocker.hpp"
  38 #include "gc/shared/oopStorage.hpp"
  39 #include "gc/shared/strongRootsScope.hpp"
  40 #include "gc/shared/workgroup.hpp"
  41 #include "interpreter/interpreter.hpp"
  42 #include "jfr/jfrEvents.hpp"
  43 #include "logging/log.hpp"
  44 #include "logging/logStream.hpp"
  45 #include "memory/resourceArea.hpp"
  46 #include "memory/universe.hpp"
  47 #include "oops/oop.inline.hpp"
  48 #include "oops/symbol.hpp"
  49 #include "oops/inlineKlass.hpp"
  50 #include "runtime/atomic.hpp"
  51 #include "runtime/deoptimization.hpp"
  52 #include "runtime/frame.inline.hpp"
  53 #include "runtime/handles.inline.hpp"
  54 #include "runtime/interfaceSupport.inline.hpp"
  55 #include "runtime/mutexLocker.hpp"
  56 #include "runtime/orderAccess.hpp"
  57 #include "runtime/osThread.hpp"
  58 #include "runtime/safepoint.hpp"
  59 #include "runtime/safepointMechanism.inline.hpp"
  60 #include "runtime/signature.hpp"
  61 #include "runtime/stackWatermarkSet.inline.hpp"
  62 #include "runtime/stubCodeGenerator.hpp"
  63 #include "runtime/stubRoutines.hpp"
  64 #include "runtime/sweeper.hpp"
  65 #include "runtime/synchronizer.hpp"
  66 #include "runtime/thread.inline.hpp"
  67 #include "runtime/threadSMR.hpp"
  68 #include "runtime/threadWXSetters.inline.hpp"
  69 #include "runtime/timerTrace.hpp"

 899   CodeBlob *cb = CodeCache::find_blob(real_return_addr);
 900   assert(cb != NULL && cb->is_compiled(), "return address should be in nmethod");
 901   CompiledMethod* nm = (CompiledMethod*)cb;
 902 
 903   // Find frame of caller
 904   frame stub_fr = self->last_frame();
 905   CodeBlob* stub_cb = stub_fr.cb();
 906   assert(stub_cb->is_safepoint_stub(), "must be a safepoint stub");
 907   RegisterMap map(self, true, false);
 908   frame caller_fr = stub_fr.sender(&map);
 909 
 910   // Should only be poll_return or poll
 911   assert( nm->is_at_poll_or_poll_return(real_return_addr), "should not be at call" );
 912 
 913   // This is a poll immediately before a return. The exception handling code
 914   // has already had the effect of causing the return to occur, so the execution
 915   // will continue immediately after the call. In addition, the oopmap at the
 916   // return point does not mark the return value as an oop (if it is), so
 917   // it needs a handle here to be updated.
 918   if( nm->is_at_poll_return(real_return_addr) ) {
 919     ResourceMark rm;
 920     // See if return type is an oop.
 921     Method* method = nm->method();
 922     bool return_oop = method->is_returning_oop();
 923     HandleMark hm(self);
 924 
 925     GrowableArray<Handle> return_values;
 926     InlineKlass* vk = NULL;
 927 
 928     if (return_oop && InlineTypeReturnedAsFields) {
 929       SignatureStream ss(method->signature());
 930       while (!ss.at_return_type()) {
 931         ss.next();
 932       }
 933       if (ss.type() == T_INLINE_TYPE) {
 934         // Check if inline type is returned as fields
 935         vk = InlineKlass::returned_inline_klass(map);
 936         if (vk != NULL) {
 937           // We're at a safepoint at the return of a method that returns
 938           // multiple values. We must make sure we preserve the oop values
 939           // across the safepoint.
 940           assert(vk == method->returned_inline_type(thread()), "bad inline klass");
 941           vk->save_oop_fields(map, return_values);
 942           return_oop = false;
 943         }
 944       }
 945     }
 946 
 947     if (return_oop) {
 948       // The oop result has been saved on the stack together with all
 949       // the other registers. In order to preserve it over GCs we need
 950       // to keep it in a handle.
 951       oop result = caller_fr.saved_oop_result(&map);
 952       assert(oopDesc::is_oop_or_null(result), "must be oop");
 953       return_values.push(Handle(self, result));
 954       assert(Universe::heap()->is_in_or_null(result), "must be heap pointer");
 955     }
 956 
 957     // We get here if compiled return polls found a reason to call into the VM.
 958     // One condition for that is that the top frame is not yet safe to use.
 959     // The following stack watermark barrier poll will catch such situations.
 960     StackWatermarkSet::after_unwind(self);
 961 
 962     // Process pending operation
 963     SafepointMechanism::process_if_requested_with_exit_check(self, true /* check asyncs */);
 964 
 965     // restore oop result, if any
 966     if (return_oop) {
 967       assert(return_values.length() == 1, "only one return value");
 968       caller_fr.set_saved_oop_result(&map, return_values.pop()());
 969     } else if (vk != NULL) {
 970       vk->restore_oop_results(map, return_values);
 971     }
 972   }
 973 
 974   // This is a safepoint poll. Verify the return address and block.
 975   else {
 976 
 977     // verify the blob built the "return address" correctly
 978     assert(real_return_addr == caller_fr.pc(), "must match");
 979 
 980     set_at_poll_safepoint(true);
 981     // Process pending operation
 982     // We never deliver an async exception at a polling point as the
 983     // compiler may not have an exception handler for it. The polling
 984     // code will notice the pending async exception, deoptimize and
 985     // the exception will be delivered. (Polling at a return point
 986     // is ok though). Sure is a lot of bother for a deprecated feature...
 987     SafepointMechanism::process_if_requested_with_exit_check(self, false /* check asyncs */);
 988     set_at_poll_safepoint(false);
 989 
 990     // If we have a pending async exception deoptimize the frame
< prev index next >