src/share/vm/prims/jni.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File hotspot Sdiff src/share/vm/prims

src/share/vm/prims/jni.cpp

Print this page




  64 #include "runtime/java.hpp"
  65 #include "runtime/javaCalls.hpp"
  66 #include "runtime/jfieldIDWorkaround.hpp"
  67 #include "runtime/orderAccess.inline.hpp"
  68 #include "runtime/reflection.hpp"
  69 #include "runtime/sharedRuntime.hpp"
  70 #include "runtime/signature.hpp"
  71 #include "runtime/thread.inline.hpp"
  72 #include "runtime/vm_operations.hpp"
  73 #include "services/memTracker.hpp"
  74 #include "services/runtimeService.hpp"
  75 #include "trace/tracing.hpp"
  76 #include "utilities/defaultStream.hpp"
  77 #include "utilities/dtrace.hpp"
  78 #include "utilities/events.hpp"
  79 #include "utilities/histogram.hpp"
  80 #include "utilities/macros.hpp"
  81 #if INCLUDE_ALL_GCS
  82 #include "gc/g1/g1SATBCardTableModRefBS.hpp"
  83 #endif // INCLUDE_ALL_GCS




  84 
  85 static jint CurrentVersion = JNI_VERSION_1_8;
  86 
  87 #ifdef _WIN32
  88 extern LONG WINAPI topLevelExceptionFilter(_EXCEPTION_POINTERS* );
  89 #endif
  90 
  91 // The DT_RETURN_MARK macros create a scoped object to fire the dtrace
  92 // '-return' probe regardless of the return path is taken out of the function.
  93 // Methods that have multiple return paths use this to avoid having to
  94 // instrument each return path.  Methods that use CHECK or THROW must use this
  95 // since those macros can cause an immedate uninstrumented return.
  96 //
  97 // In order to get the return value, a reference to the variable containing
  98 // the return value must be passed to the contructor of the object, and
  99 // the return value must be set before return (since the mark object has
 100 // a reference to it).
 101 //
 102 // Example:
 103 // DT_RETURN_MARK_DECL(SomeFunc, int);


3967   /**
3968    * Certain errors during initialization are recoverable and do not
3969    * prevent this method from being called again at a later time
3970    * (perhaps with different arguments).  However, at a certain
3971    * point during initialization if an error occurs we cannot allow
3972    * this function to be called again (or it will crash).  In those
3973    * situations, the 'canTryAgain' flag is set to false, which atomically
3974    * sets safe_to_recreate_vm to 1, such that any new call to
3975    * JNI_CreateJavaVM will immediately fail using the above logic.
3976    */
3977   bool can_try_again = true;
3978 
3979   result = Threads::create_vm((JavaVMInitArgs*) args, &can_try_again);
3980   if (result == JNI_OK) {
3981     JavaThread *thread = JavaThread::current();
3982     assert(!thread->has_pending_exception(), "should have returned not OK");
3983     /* thread is thread_in_vm here */
3984     *vm = (JavaVM *)(&main_vm);
3985     *(JNIEnv**)penv = thread->jni_environment();
3986 













3987     // Tracks the time application was running before GC
3988     RuntimeService::record_application_start();
3989 
3990     // Notify JVMTI
3991     if (JvmtiExport::should_post_thread_life()) {
3992        JvmtiExport::post_thread_start(thread);
3993     }
3994 
3995     EventThreadStart event;
3996     if (event.should_commit()) {
3997       event.set_javalangthread(java_lang_Thread::thread_id(thread->threadObj()));
3998       event.commit();
3999     }
4000 
4001 #ifndef PRODUCT
4002     // Check if we should compile all classes on bootclasspath
4003     if (CompileTheWorld) ClassLoader::compile_the_world();
4004     if (ReplayCompiles) ciReplay::replay(thread);
4005 
4006     // Some platforms (like Win*) need a wrapper around these test




  64 #include "runtime/java.hpp"
  65 #include "runtime/javaCalls.hpp"
  66 #include "runtime/jfieldIDWorkaround.hpp"
  67 #include "runtime/orderAccess.inline.hpp"
  68 #include "runtime/reflection.hpp"
  69 #include "runtime/sharedRuntime.hpp"
  70 #include "runtime/signature.hpp"
  71 #include "runtime/thread.inline.hpp"
  72 #include "runtime/vm_operations.hpp"
  73 #include "services/memTracker.hpp"
  74 #include "services/runtimeService.hpp"
  75 #include "trace/tracing.hpp"
  76 #include "utilities/defaultStream.hpp"
  77 #include "utilities/dtrace.hpp"
  78 #include "utilities/events.hpp"
  79 #include "utilities/histogram.hpp"
  80 #include "utilities/macros.hpp"
  81 #if INCLUDE_ALL_GCS
  82 #include "gc/g1/g1SATBCardTableModRefBS.hpp"
  83 #endif // INCLUDE_ALL_GCS
  84 #if INCLUDE_JVMCI
  85 #include "jvmci/jvmciCompiler.hpp"
  86 #include "jvmci/jvmciRuntime.hpp"
  87 #endif
  88 
  89 static jint CurrentVersion = JNI_VERSION_1_8;
  90 
  91 #ifdef _WIN32
  92 extern LONG WINAPI topLevelExceptionFilter(_EXCEPTION_POINTERS* );
  93 #endif
  94 
  95 // The DT_RETURN_MARK macros create a scoped object to fire the dtrace
  96 // '-return' probe regardless of the return path is taken out of the function.
  97 // Methods that have multiple return paths use this to avoid having to
  98 // instrument each return path.  Methods that use CHECK or THROW must use this
  99 // since those macros can cause an immedate uninstrumented return.
 100 //
 101 // In order to get the return value, a reference to the variable containing
 102 // the return value must be passed to the contructor of the object, and
 103 // the return value must be set before return (since the mark object has
 104 // a reference to it).
 105 //
 106 // Example:
 107 // DT_RETURN_MARK_DECL(SomeFunc, int);


3971   /**
3972    * Certain errors during initialization are recoverable and do not
3973    * prevent this method from being called again at a later time
3974    * (perhaps with different arguments).  However, at a certain
3975    * point during initialization if an error occurs we cannot allow
3976    * this function to be called again (or it will crash).  In those
3977    * situations, the 'canTryAgain' flag is set to false, which atomically
3978    * sets safe_to_recreate_vm to 1, such that any new call to
3979    * JNI_CreateJavaVM will immediately fail using the above logic.
3980    */
3981   bool can_try_again = true;
3982 
3983   result = Threads::create_vm((JavaVMInitArgs*) args, &can_try_again);
3984   if (result == JNI_OK) {
3985     JavaThread *thread = JavaThread::current();
3986     assert(!thread->has_pending_exception(), "should have returned not OK");
3987     /* thread is thread_in_vm here */
3988     *vm = (JavaVM *)(&main_vm);
3989     *(JNIEnv**)penv = thread->jni_environment();
3990 
3991 #if INCLUDE_JVMCI
3992     if (EnableJVMCI) {
3993       if (UseJVMCICompiler) {
3994         // JVMCI is initialized on a CompilerThread
3995         if (BootstrapJVMCI) {
3996           JavaThread* THREAD = thread;
3997           JVMCICompiler* compiler = JVMCICompiler::instance(CATCH);
3998           compiler->bootstrap();
3999         }
4000       }
4001     }
4002 #endif
4003 
4004     // Tracks the time application was running before GC
4005     RuntimeService::record_application_start();
4006 
4007     // Notify JVMTI
4008     if (JvmtiExport::should_post_thread_life()) {
4009        JvmtiExport::post_thread_start(thread);
4010     }
4011 
4012     EventThreadStart event;
4013     if (event.should_commit()) {
4014       event.set_javalangthread(java_lang_Thread::thread_id(thread->threadObj()));
4015       event.commit();
4016     }
4017 
4018 #ifndef PRODUCT
4019     // Check if we should compile all classes on bootclasspath
4020     if (CompileTheWorld) ClassLoader::compile_the_world();
4021     if (ReplayCompiles) ciReplay::replay(thread);
4022 
4023     // Some platforms (like Win*) need a wrapper around these test


src/share/vm/prims/jni.cpp
Index Unified diffs Context diffs Sdiffs Wdiffs Patch New Old Previous File Next File