3366 jint status = init_globals();
3367 if (status != JNI_OK) {
3368 delete main_thread;
3369 *canTryAgain = false; // don't let caller call JNI_CreateJavaVM again
3370 return status;
3371 }
3372
3373 // Should be done after the heap is fully created
3374 main_thread->cache_global_variables();
3375
3376 HandleMark hm;
3377
3378 { MutexLocker mu(Threads_lock);
3379 Threads::add(main_thread);
3380 }
3381
3382 // Any JVMTI raw monitors entered in onload will transition into
3383 // real raw monitor. VM is setup enough here for raw monitor enter.
3384 JvmtiExport::transition_pending_onload_raw_monitors();
3385
3386 if (VerifyBeforeGC &&
3387 Universe::heap()->total_collections() >= VerifyGCStartAt) {
3388 Universe::heap()->prepare_for_verify();
3389 Universe::verify(); // make sure we're starting with a clean slate
3390 }
3391
3392 // Fully start NMT
3393 MemTracker::start();
3394
3395 // Create the VMThread
3396 { TraceTime timer("Start VMThread", TraceStartupTime);
3397 VMThread::create();
3398 Thread* vmthread = VMThread::vm_thread();
3399
3400 if (!os::create_thread(vmthread, os::vm_thread))
3401 vm_exit_during_initialization("Cannot create VM thread. Out of system resources.");
3402
3403 // Wait for the VM thread to become ready, and VMThread::run to initialize
3404 // Monitors can have spurious returns, must always check another state flag
3405 {
3406 MutexLocker ml(Notify_lock);
3407 os::start_thread(vmthread);
3408 while (vmthread->active_handles() == NULL) {
3409 Notify_lock->wait();
3410 }
3411 }
3412 }
3413
3414 assert (Universe::is_fully_initialized(), "not initialized");
3415 EXCEPTION_MARK;
3416
3417 // At this point, the Universe is initialized, but we have not executed
3418 // any byte code. Now is a good time (the only time) to dump out the
3419 // internal state of the JVM for sharing.
3420
3421 if (DumpSharedSpaces) {
3422 Universe::heap()->preload_and_dump(CHECK_0);
3423 ShouldNotReachHere();
3424 }
3425
3426 // Always call even when there are not JVMTI environments yet, since environments
3427 // may be attached late and JVMTI must track phases of VM execution
3428 JvmtiExport::enter_start_phase();
3429
3430 // Notify JVMTI agents that VM has started (JNI is up) - nop if no agents.
3431 JvmtiExport::post_vm_start();
3432
3433 {
3434 TraceTime timer("Initialize java.lang classes", TraceStartupTime);
|
3366 jint status = init_globals();
3367 if (status != JNI_OK) {
3368 delete main_thread;
3369 *canTryAgain = false; // don't let caller call JNI_CreateJavaVM again
3370 return status;
3371 }
3372
3373 // Should be done after the heap is fully created
3374 main_thread->cache_global_variables();
3375
3376 HandleMark hm;
3377
3378 { MutexLocker mu(Threads_lock);
3379 Threads::add(main_thread);
3380 }
3381
3382 // Any JVMTI raw monitors entered in onload will transition into
3383 // real raw monitor. VM is setup enough here for raw monitor enter.
3384 JvmtiExport::transition_pending_onload_raw_monitors();
3385
3386 // Fully start NMT
3387 MemTracker::start();
3388
3389 // Create the VMThread
3390 { TraceTime timer("Start VMThread", TraceStartupTime);
3391 VMThread::create();
3392 Thread* vmthread = VMThread::vm_thread();
3393
3394 if (!os::create_thread(vmthread, os::vm_thread))
3395 vm_exit_during_initialization("Cannot create VM thread. Out of system resources.");
3396
3397 // Wait for the VM thread to become ready, and VMThread::run to initialize
3398 // Monitors can have spurious returns, must always check another state flag
3399 {
3400 MutexLocker ml(Notify_lock);
3401 os::start_thread(vmthread);
3402 while (vmthread->active_handles() == NULL) {
3403 Notify_lock->wait();
3404 }
3405 }
3406 }
3407
3408 assert (Universe::is_fully_initialized(), "not initialized");
3409 if (VerifyBeforeGC && VerifyGCStartAt == 0) {
3410 Universe::heap()->prepare_for_verify();
3411 Universe::verify(); // make sure we're starting with a clean slate
3412 }
3413
3414 EXCEPTION_MARK;
3415
3416 // At this point, the Universe is initialized, but we have not executed
3417 // any byte code. Now is a good time (the only time) to dump out the
3418 // internal state of the JVM for sharing.
3419
3420 if (DumpSharedSpaces) {
3421 Universe::heap()->preload_and_dump(CHECK_0);
3422 ShouldNotReachHere();
3423 }
3424
3425 // Always call even when there are not JVMTI environments yet, since environments
3426 // may be attached late and JVMTI must track phases of VM execution
3427 JvmtiExport::enter_start_phase();
3428
3429 // Notify JVMTI agents that VM has started (JNI is up) - nop if no agents.
3430 JvmtiExport::post_vm_start();
3431
3432 {
3433 TraceTime timer("Initialize java.lang classes", TraceStartupTime);
|