20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/classLoader.hpp"
27 #include "classfile/javaClasses.hpp"
28 #include "classfile/systemDictionary.hpp"
29 #include "classfile/vmSymbols.hpp"
30 #include "code/codeCache.hpp"
31 #include "code/codeCacheExtensions.hpp"
32 #include "code/scopeDesc.hpp"
33 #include "compiler/compileBroker.hpp"
34 #include "gc/shared/gcLocker.inline.hpp"
35 #include "gc/shared/workgroup.hpp"
36 #include "interpreter/interpreter.hpp"
37 #include "interpreter/linkResolver.hpp"
38 #include "interpreter/oopMapCache.hpp"
39 #include "jvmtifiles/jvmtiEnv.hpp"
40 #include "memory/metaspaceShared.hpp"
41 #include "memory/oopFactory.hpp"
42 #include "memory/universe.inline.hpp"
43 #include "oops/instanceKlass.hpp"
44 #include "oops/objArrayOop.hpp"
45 #include "oops/oop.inline.hpp"
46 #include "oops/symbol.hpp"
47 #include "oops/verifyOopClosure.hpp"
48 #include "prims/jvm_misc.hpp"
49 #include "prims/jvmtiExport.hpp"
50 #include "prims/jvmtiThreadState.hpp"
51 #include "prims/privilegedStack.hpp"
52 #include "runtime/arguments.hpp"
53 #include "runtime/atomic.inline.hpp"
54 #include "runtime/biasedLocking.hpp"
55 #include "runtime/commandLineFlagConstraintList.hpp"
56 #include "runtime/commandLineFlagRangeList.hpp"
57 #include "runtime/deoptimization.hpp"
58 #include "runtime/fprofiler.hpp"
59 #include "runtime/frame.inline.hpp"
3289 }
3290
3291 jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
3292 extern void JDK_Version_init();
3293
3294 // Preinitialize version info.
3295 VM_Version::early_initialize();
3296
3297 // Check version
3298 if (!is_supported_jni_version(args->version)) return JNI_EVERSION;
3299
3300 // Initialize the output stream module
3301 ostream_init();
3302
3303 // Process java launcher properties.
3304 Arguments::process_sun_java_launcher_properties(args);
3305
3306 // Initialize the os module before using TLS
3307 os::init();
3308
3309 // Initialize system properties.
3310 Arguments::init_system_properties();
3311
3312 // So that JDK version can be used as a discriminator when parsing arguments
3313 JDK_Version_init();
3314
3315 // Update/Initialize System properties after JDK version number is known
3316 Arguments::init_version_specific_system_properties();
3317
3318 // Parse arguments
3319 jint parse_result = Arguments::parse(args);
3320 if (parse_result != JNI_OK) return parse_result;
3321
3322 os::init_before_ergo();
3323
3324 jint ergo_result = Arguments::apply_ergo();
3325 if (ergo_result != JNI_OK) return ergo_result;
3326
3327 // Final check of all ranges after ergonomics which may change values.
3328 if (!CommandLineFlagRangeList::check_ranges()) {
3329 return JNI_EINVAL;
3330 }
3331
3332 // Final check of all 'AfterErgo' constraints after ergonomics which may change values.
3333 bool constraint_result = CommandLineFlagConstraintList::check_constraints(CommandLineFlagConstraint::AfterErgo);
3334 if (!constraint_result) {
3335 return JNI_EINVAL;
3336 }
3337
3338 if (PauseAtStartup) {
3339 os::pause();
3340 }
3341
3342 HOTSPOT_VM_INIT_BEGIN();
3343
3344 // Record VM creation timing statistics
3345 TraceVmCreationTime create_vm_timer;
3346 create_vm_timer.start();
3347
3348 // Timing (must come after argument parsing)
3349 TraceTime timer("Create VM", TraceStartupTime);
3350
3351 // Initialize the os module after parsing the args
3352 jint os_init_2_result = os::init_2();
3353 if (os_init_2_result != JNI_OK) return os_init_2_result;
3354
3355 jint adjust_after_os_result = Arguments::adjust_after_os();
3356 if (adjust_after_os_result != JNI_OK) return adjust_after_os_result;
3357
3358 // initialize TLS
3359 ThreadLocalStorage::init();
3360
3361 // Initialize output stream logging
3362 ostream_init_log();
3363
3364 // Convert -Xrun to -agentlib: if there is no JVM_OnLoad
3365 // Must be before create_vm_init_agents()
3366 if (Arguments::init_libraries_at_startup()) {
3367 convert_vm_init_libraries_to_agents();
3475 JvmtiExport::post_vm_start();
3476
3477 initialize_java_lang_classes(main_thread, CHECK_JNI_ERR);
3478
3479 // We need this for ClassDataSharing - the initial vm.info property is set
3480 // with the default value of CDS "sharing" which may be reset through
3481 // command line options.
3482 reset_vm_info_property(CHECK_JNI_ERR);
3483
3484 quicken_jni_functions();
3485
3486 // Must be run after init_ft which initializes ft_enabled
3487 if (TRACE_INITIALIZE() != JNI_OK) {
3488 vm_exit_during_initialization("Failed to initialize tracing backend");
3489 }
3490
3491 // Set flag that basic initialization has completed. Used by exceptions and various
3492 // debug stuff, that does not work until all basic classes have been initialized.
3493 set_init_completed();
3494
3495 Metaspace::post_initialize();
3496
3497 HOTSPOT_VM_INIT_END();
3498
3499 // record VM initialization completion time
3500 #if INCLUDE_MANAGEMENT
3501 Management::record_vm_init_completed();
3502 #endif // INCLUDE_MANAGEMENT
3503
3504 // Compute system loader. Note that this has to occur after set_init_completed, since
3505 // valid exceptions may be thrown in the process.
3506 // Note that we do not use CHECK_0 here since we are inside an EXCEPTION_MARK and
3507 // set_init_completed has just been called, causing exceptions not to be shortcut
3508 // anymore. We call vm_exit_during_initialization directly instead.
3509 SystemDictionary::compute_java_system_loader(CHECK_JNI_ERR);
3510
3511 #if INCLUDE_ALL_GCS
3512 // Support for ConcurrentMarkSweep. This should be cleaned up
3513 // and better encapsulated. The ugly nested if test would go away
3514 // once things are properly refactored. XXX YSR
3948 // running Java code or in VM are stopped by the Safepoint. However,
3949 // daemon threads executing native code are still running. But they
3950 // will be stopped at native=>Java/VM barriers. Note that we can't
3951 // simply kill or suspend them, as it is inherently deadlock-prone.
3952
3953 #ifndef PRODUCT
3954 // disable function tracing at JNI/JVM barriers
3955 TraceJNICalls = false;
3956 TraceJVMCalls = false;
3957 TraceRuntimeCalls = false;
3958 #endif
3959
3960 VM_Exit::set_vm_exited();
3961
3962 notify_vm_shutdown();
3963
3964 delete thread;
3965
3966 // exit_globals() will delete tty
3967 exit_globals();
3968
3969 return true;
3970 }
3971
3972
3973 jboolean Threads::is_supported_jni_version_including_1_1(jint version) {
3974 if (version == JNI_VERSION_1_1) return JNI_TRUE;
3975 return is_supported_jni_version(version);
3976 }
3977
3978
3979 jboolean Threads::is_supported_jni_version(jint version) {
3980 if (version == JNI_VERSION_1_2) return JNI_TRUE;
3981 if (version == JNI_VERSION_1_4) return JNI_TRUE;
3982 if (version == JNI_VERSION_1_6) return JNI_TRUE;
3983 if (version == JNI_VERSION_1_8) return JNI_TRUE;
3984 return JNI_FALSE;
3985 }
3986
3987
|
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/classLoader.hpp"
27 #include "classfile/javaClasses.hpp"
28 #include "classfile/systemDictionary.hpp"
29 #include "classfile/vmSymbols.hpp"
30 #include "code/codeCache.hpp"
31 #include "code/codeCacheExtensions.hpp"
32 #include "code/scopeDesc.hpp"
33 #include "compiler/compileBroker.hpp"
34 #include "gc/shared/gcLocker.inline.hpp"
35 #include "gc/shared/workgroup.hpp"
36 #include "interpreter/interpreter.hpp"
37 #include "interpreter/linkResolver.hpp"
38 #include "interpreter/oopMapCache.hpp"
39 #include "jvmtifiles/jvmtiEnv.hpp"
40 #include "logging/logConfiguration.hpp"
41 #include "memory/metaspaceShared.hpp"
42 #include "memory/oopFactory.hpp"
43 #include "memory/universe.inline.hpp"
44 #include "oops/instanceKlass.hpp"
45 #include "oops/objArrayOop.hpp"
46 #include "oops/oop.inline.hpp"
47 #include "oops/symbol.hpp"
48 #include "oops/verifyOopClosure.hpp"
49 #include "prims/jvm_misc.hpp"
50 #include "prims/jvmtiExport.hpp"
51 #include "prims/jvmtiThreadState.hpp"
52 #include "prims/privilegedStack.hpp"
53 #include "runtime/arguments.hpp"
54 #include "runtime/atomic.inline.hpp"
55 #include "runtime/biasedLocking.hpp"
56 #include "runtime/commandLineFlagConstraintList.hpp"
57 #include "runtime/commandLineFlagRangeList.hpp"
58 #include "runtime/deoptimization.hpp"
59 #include "runtime/fprofiler.hpp"
60 #include "runtime/frame.inline.hpp"
3290 }
3291
3292 jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) {
3293 extern void JDK_Version_init();
3294
3295 // Preinitialize version info.
3296 VM_Version::early_initialize();
3297
3298 // Check version
3299 if (!is_supported_jni_version(args->version)) return JNI_EVERSION;
3300
3301 // Initialize the output stream module
3302 ostream_init();
3303
3304 // Process java launcher properties.
3305 Arguments::process_sun_java_launcher_properties(args);
3306
3307 // Initialize the os module before using TLS
3308 os::init();
3309
3310 // Record VM creation timing statistics
3311 TraceVmCreationTime create_vm_timer;
3312 create_vm_timer.start();
3313
3314 // Initialize system properties.
3315 Arguments::init_system_properties();
3316
3317 // So that JDK version can be used as a discriminator when parsing arguments
3318 JDK_Version_init();
3319
3320 // Update/Initialize System properties after JDK version number is known
3321 Arguments::init_version_specific_system_properties();
3322
3323 // Make sure to initialize log configuration *before* parsing arguments
3324 LogConfiguration::initialize(create_vm_timer.begin_time());
3325
3326 // Parse arguments
3327 jint parse_result = Arguments::parse(args);
3328 if (parse_result != JNI_OK) return parse_result;
3329
3330 os::init_before_ergo();
3331
3332 jint ergo_result = Arguments::apply_ergo();
3333 if (ergo_result != JNI_OK) return ergo_result;
3334
3335 // Final check of all ranges after ergonomics which may change values.
3336 if (!CommandLineFlagRangeList::check_ranges()) {
3337 return JNI_EINVAL;
3338 }
3339
3340 // Final check of all 'AfterErgo' constraints after ergonomics which may change values.
3341 bool constraint_result = CommandLineFlagConstraintList::check_constraints(CommandLineFlagConstraint::AfterErgo);
3342 if (!constraint_result) {
3343 return JNI_EINVAL;
3344 }
3345
3346 if (PauseAtStartup) {
3347 os::pause();
3348 }
3349
3350 HOTSPOT_VM_INIT_BEGIN();
3351
3352 // Timing (must come after argument parsing)
3353 TraceTime timer("Create VM", TraceStartupTime);
3354
3355 // Initialize the os module after parsing the args
3356 jint os_init_2_result = os::init_2();
3357 if (os_init_2_result != JNI_OK) return os_init_2_result;
3358
3359 jint adjust_after_os_result = Arguments::adjust_after_os();
3360 if (adjust_after_os_result != JNI_OK) return adjust_after_os_result;
3361
3362 // initialize TLS
3363 ThreadLocalStorage::init();
3364
3365 // Initialize output stream logging
3366 ostream_init_log();
3367
3368 // Convert -Xrun to -agentlib: if there is no JVM_OnLoad
3369 // Must be before create_vm_init_agents()
3370 if (Arguments::init_libraries_at_startup()) {
3371 convert_vm_init_libraries_to_agents();
3479 JvmtiExport::post_vm_start();
3480
3481 initialize_java_lang_classes(main_thread, CHECK_JNI_ERR);
3482
3483 // We need this for ClassDataSharing - the initial vm.info property is set
3484 // with the default value of CDS "sharing" which may be reset through
3485 // command line options.
3486 reset_vm_info_property(CHECK_JNI_ERR);
3487
3488 quicken_jni_functions();
3489
3490 // Must be run after init_ft which initializes ft_enabled
3491 if (TRACE_INITIALIZE() != JNI_OK) {
3492 vm_exit_during_initialization("Failed to initialize tracing backend");
3493 }
3494
3495 // Set flag that basic initialization has completed. Used by exceptions and various
3496 // debug stuff, that does not work until all basic classes have been initialized.
3497 set_init_completed();
3498
3499 LogConfiguration::post_initialize();
3500 Metaspace::post_initialize();
3501
3502 HOTSPOT_VM_INIT_END();
3503
3504 // record VM initialization completion time
3505 #if INCLUDE_MANAGEMENT
3506 Management::record_vm_init_completed();
3507 #endif // INCLUDE_MANAGEMENT
3508
3509 // Compute system loader. Note that this has to occur after set_init_completed, since
3510 // valid exceptions may be thrown in the process.
3511 // Note that we do not use CHECK_0 here since we are inside an EXCEPTION_MARK and
3512 // set_init_completed has just been called, causing exceptions not to be shortcut
3513 // anymore. We call vm_exit_during_initialization directly instead.
3514 SystemDictionary::compute_java_system_loader(CHECK_JNI_ERR);
3515
3516 #if INCLUDE_ALL_GCS
3517 // Support for ConcurrentMarkSweep. This should be cleaned up
3518 // and better encapsulated. The ugly nested if test would go away
3519 // once things are properly refactored. XXX YSR
3953 // running Java code or in VM are stopped by the Safepoint. However,
3954 // daemon threads executing native code are still running. But they
3955 // will be stopped at native=>Java/VM barriers. Note that we can't
3956 // simply kill or suspend them, as it is inherently deadlock-prone.
3957
3958 #ifndef PRODUCT
3959 // disable function tracing at JNI/JVM barriers
3960 TraceJNICalls = false;
3961 TraceJVMCalls = false;
3962 TraceRuntimeCalls = false;
3963 #endif
3964
3965 VM_Exit::set_vm_exited();
3966
3967 notify_vm_shutdown();
3968
3969 delete thread;
3970
3971 // exit_globals() will delete tty
3972 exit_globals();
3973
3974 LogConfiguration::finalize();
3975
3976 return true;
3977 }
3978
3979
3980 jboolean Threads::is_supported_jni_version_including_1_1(jint version) {
3981 if (version == JNI_VERSION_1_1) return JNI_TRUE;
3982 return is_supported_jni_version(version);
3983 }
3984
3985
3986 jboolean Threads::is_supported_jni_version(jint version) {
3987 if (version == JNI_VERSION_1_2) return JNI_TRUE;
3988 if (version == JNI_VERSION_1_4) return JNI_TRUE;
3989 if (version == JNI_VERSION_1_6) return JNI_TRUE;
3990 if (version == JNI_VERSION_1_8) return JNI_TRUE;
3991 return JNI_FALSE;
3992 }
3993
3994
|