< prev index next >

src/share/vm/runtime/javaCalls.cpp

Print this page




  32 #include "memory/universe.inline.hpp"
  33 #include "oops/oop.inline.hpp"
  34 #include "prims/jniCheck.hpp"
  35 #include "runtime/compilationPolicy.hpp"
  36 #include "runtime/handles.inline.hpp"
  37 #include "runtime/interfaceSupport.hpp"
  38 #include "runtime/javaCalls.hpp"
  39 #include "runtime/mutexLocker.hpp"
  40 #include "runtime/os.inline.hpp"
  41 #include "runtime/signature.hpp"
  42 #include "runtime/stubRoutines.hpp"
  43 #include "runtime/thread.inline.hpp"
  44 #if INCLUDE_JVMCI
  45 #include "jvmci/jvmciJavaClasses.hpp"
  46 #include "jvmci/jvmciRuntime.hpp"
  47 #endif
  48 
  49 // -----------------------------------------------------
  50 // Implementation of JavaCallWrapper
  51 
  52 JavaCallWrapper::JavaCallWrapper(methodHandle callee_method, Handle receiver, JavaValue* result, TRAPS) {
  53   JavaThread* thread = (JavaThread *)THREAD;
  54   bool clear_pending_exception = true;
  55 
  56   guarantee(thread->is_Java_thread(), "crucial check - the VM thread cannot and must not escape to Java code");
  57   assert(!thread->owns_locks(), "must release all locks when leaving VM");
  58   guarantee(thread->can_call_java(), "cannot make java calls from the native compiler");
  59   _result   = result;
  60 
  61   // Allocate handle block for Java code. This must be done before we change thread_state to _thread_in_Java_or_stub,
  62   // since it can potentially block.
  63   JNIHandleBlock* new_handles = JNIHandleBlock::allocate_block(thread);
  64 
  65   // After this, we are official in JavaCode. This needs to be done before we change any of the thread local
  66   // info, since we cannot find oops before the new information is set up completely.
  67   ThreadStateTransition::transition(thread, _thread_in_vm, _thread_in_Java);
  68 
  69   // Make sure that we handle asynchronous stops and suspends _before_ we clear all thread state
  70   // in JavaCallWrapper::JavaCallWrapper(). This way, we can decide if we need to do any pd actions
  71   // to prepare for stop/suspend (flush register windows on sparcs, cache sp, or other state).
  72   if (thread->has_special_runtime_exit_condition()) {




  32 #include "memory/universe.inline.hpp"
  33 #include "oops/oop.inline.hpp"
  34 #include "prims/jniCheck.hpp"
  35 #include "runtime/compilationPolicy.hpp"
  36 #include "runtime/handles.inline.hpp"
  37 #include "runtime/interfaceSupport.hpp"
  38 #include "runtime/javaCalls.hpp"
  39 #include "runtime/mutexLocker.hpp"
  40 #include "runtime/os.inline.hpp"
  41 #include "runtime/signature.hpp"
  42 #include "runtime/stubRoutines.hpp"
  43 #include "runtime/thread.inline.hpp"
  44 #if INCLUDE_JVMCI
  45 #include "jvmci/jvmciJavaClasses.hpp"
  46 #include "jvmci/jvmciRuntime.hpp"
  47 #endif
  48 
  49 // -----------------------------------------------------
  50 // Implementation of JavaCallWrapper
  51 
  52 JavaCallWrapper::JavaCallWrapper(const methodHandle& callee_method, Handle receiver, JavaValue* result, TRAPS) {
  53   JavaThread* thread = (JavaThread *)THREAD;
  54   bool clear_pending_exception = true;
  55 
  56   guarantee(thread->is_Java_thread(), "crucial check - the VM thread cannot and must not escape to Java code");
  57   assert(!thread->owns_locks(), "must release all locks when leaving VM");
  58   guarantee(thread->can_call_java(), "cannot make java calls from the native compiler");
  59   _result   = result;
  60 
  61   // Allocate handle block for Java code. This must be done before we change thread_state to _thread_in_Java_or_stub,
  62   // since it can potentially block.
  63   JNIHandleBlock* new_handles = JNIHandleBlock::allocate_block(thread);
  64 
  65   // After this, we are official in JavaCode. This needs to be done before we change any of the thread local
  66   // info, since we cannot find oops before the new information is set up completely.
  67   ThreadStateTransition::transition(thread, _thread_in_vm, _thread_in_Java);
  68 
  69   // Make sure that we handle asynchronous stops and suspends _before_ we clear all thread state
  70   // in JavaCallWrapper::JavaCallWrapper(). This way, we can decide if we need to do any pd actions
  71   // to prepare for stop/suspend (flush register windows on sparcs, cache sp, or other state).
  72   if (thread->has_special_runtime_exit_condition()) {


< prev index next >