duke@435: /* duke@435: * Copyright 1997-2007 Sun Microsystems, Inc. All Rights Reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * duke@435: * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, duke@435: * CA 95054 USA or visit www.sun.com if you need additional information or duke@435: * have any questions. duke@435: * duke@435: */ duke@435: duke@435: # include "incls/_precompiled.incl" duke@435: # include "incls/_init.cpp.incl" duke@435: duke@435: // Initialization done by VM thread in vm_init_globals() duke@435: void check_ThreadShadow(); duke@435: void check_basic_types(); duke@435: void eventlog_init(); duke@435: void mutex_init(); duke@435: void chunkpool_init(); duke@435: void perfMemory_init(); duke@435: duke@435: // Initialization done by Java thread in init_globals() duke@435: void management_init(); duke@435: void vtune_init(); duke@435: void bytecodes_init(); duke@435: void classLoader_init(); duke@435: void codeCache_init(); duke@435: void VM_Version_init(); duke@435: void JDK_Version_init(); duke@435: void stubRoutines_init1(); duke@435: jint universe_init(); // dependent on codeCache_init and stubRoutines_init duke@435: void interpreter_init(); // before any methods loaded duke@435: void invocationCounter_init(); // before any methods loaded duke@435: void marksweep_init(); duke@435: void accessFlags_init(); duke@435: void templateTable_init(); duke@435: void InterfaceSupport_init(); duke@435: void universe2_init(); // dependent on codeCache_init and stubRoutines_init duke@435: void referenceProcessor_init(); duke@435: void jni_handles_init(); duke@435: void vmStructs_init(); duke@435: duke@435: void vtableStubs_init(); duke@435: void InlineCacheBuffer_init(); duke@435: void compilerOracle_init(); duke@435: void compilationPolicy_init(); duke@435: duke@435: duke@435: // Initialization after compiler initialization duke@435: bool universe_post_init(); // must happen after compiler_init duke@435: void javaClasses_init(); // must happen after vtable initialization duke@435: void stubRoutines_init2(); // note: StubRoutines need 2-phase init duke@435: duke@435: // Do not disable thread-local-storage, as it is important for some duke@435: // JNI/JVM/JVMTI functions and signal handlers to work properly duke@435: // during VM shutdown duke@435: void perfMemory_exit(); duke@435: void ostream_exit(); duke@435: duke@435: void vm_init_globals() { duke@435: check_ThreadShadow(); duke@435: check_basic_types(); duke@435: eventlog_init(); duke@435: mutex_init(); duke@435: chunkpool_init(); duke@435: perfMemory_init(); duke@435: } duke@435: duke@435: duke@435: jint init_globals() { duke@435: HandleMark hm; duke@435: management_init(); duke@435: vtune_init(); duke@435: bytecodes_init(); duke@435: classLoader_init(); duke@435: codeCache_init(); duke@435: VM_Version_init(); duke@435: JDK_Version_init(); duke@435: stubRoutines_init1(); duke@435: jint status = universe_init(); // dependent on codeCache_init and stubRoutines_init duke@435: if (status != JNI_OK) duke@435: return status; duke@435: duke@435: interpreter_init(); // before any methods loaded duke@435: invocationCounter_init(); // before any methods loaded duke@435: marksweep_init(); duke@435: accessFlags_init(); duke@435: templateTable_init(); duke@435: InterfaceSupport_init(); duke@435: SharedRuntime::generate_stubs(); duke@435: universe2_init(); // dependent on codeCache_init and stubRoutines_init duke@435: referenceProcessor_init(); duke@435: jni_handles_init(); duke@435: #ifndef VM_STRUCTS_KERNEL duke@435: vmStructs_init(); duke@435: #endif // VM_STRUCTS_KERNEL duke@435: duke@435: vtableStubs_init(); duke@435: InlineCacheBuffer_init(); duke@435: compilerOracle_init(); duke@435: compilationPolicy_init(); duke@435: VMRegImpl::set_regName(); duke@435: duke@435: if (!universe_post_init()) { duke@435: return JNI_ERR; duke@435: } duke@435: javaClasses_init(); // must happen after vtable initialization duke@435: stubRoutines_init2(); // note: StubRoutines need 2-phase init duke@435: duke@435: // Although we'd like to, we can't easily do a heap verify duke@435: // here because the main thread isn't yet a JavaThread, so duke@435: // its TLAB may not be made parseable from the usual interfaces. duke@435: if (VerifyBeforeGC && !UseTLAB && duke@435: Universe::heap()->total_collections() >= VerifyGCStartAt) { duke@435: Universe::heap()->prepare_for_verify(); duke@435: Universe::verify(); // make sure we're starting with a clean slate duke@435: } duke@435: duke@435: return JNI_OK; duke@435: } duke@435: duke@435: duke@435: void exit_globals() { duke@435: static bool destructorsCalled = false; duke@435: if (!destructorsCalled) { duke@435: destructorsCalled = true; duke@435: perfMemory_exit(); duke@435: if (PrintSafepointStatistics) { duke@435: // Print the collected safepoint statistics. duke@435: SafepointSynchronize::print_stat_on_exit(); duke@435: } duke@435: ostream_exit(); duke@435: } duke@435: } duke@435: duke@435: duke@435: static bool _init_completed = false; duke@435: duke@435: bool is_init_completed() { duke@435: return _init_completed; duke@435: } duke@435: duke@435: duke@435: void set_init_completed() { duke@435: _init_completed = true; duke@435: }