src/share/vm/runtime/init.cpp

Tue, 08 Aug 2017 15:57:29 +0800

author
aoqi
date
Tue, 08 Aug 2017 15:57:29 +0800
changeset 6876
710a3c8b516e
parent 5528
740e263c80c6
parent 0
f90c822e73f8
child 7535
7ae4e26cb1e0
permissions
-rw-r--r--

merge

aoqi@0 1 /*
aoqi@0 2 * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 4 *
aoqi@0 5 * This code is free software; you can redistribute it and/or modify it
aoqi@0 6 * under the terms of the GNU General Public License version 2 only, as
aoqi@0 7 * published by the Free Software Foundation.
aoqi@0 8 *
aoqi@0 9 * This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 12 * version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 13 * accompanied this code).
aoqi@0 14 *
aoqi@0 15 * You should have received a copy of the GNU General Public License version
aoqi@0 16 * 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 18 *
aoqi@0 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 20 * or visit www.oracle.com if you need additional information or have any
aoqi@0 21 * questions.
aoqi@0 22 *
aoqi@0 23 */
aoqi@0 24
aoqi@0 25 #include "precompiled.hpp"
aoqi@0 26 #include "classfile/symbolTable.hpp"
aoqi@0 27 #include "code/icBuffer.hpp"
aoqi@0 28 #include "gc_interface/collectedHeap.hpp"
aoqi@0 29 #include "interpreter/bytecodes.hpp"
aoqi@0 30 #include "memory/universe.hpp"
aoqi@0 31 #include "prims/methodHandles.hpp"
aoqi@0 32 #include "runtime/handles.inline.hpp"
aoqi@0 33 #include "runtime/icache.hpp"
aoqi@0 34 #include "runtime/init.hpp"
aoqi@0 35 #include "runtime/safepoint.hpp"
aoqi@0 36 #include "runtime/sharedRuntime.hpp"
aoqi@0 37 #include "utilities/macros.hpp"
aoqi@0 38
aoqi@0 39 // Initialization done by VM thread in vm_init_globals()
aoqi@0 40 void check_ThreadShadow();
aoqi@0 41 void eventlog_init();
aoqi@0 42 void mutex_init();
aoqi@0 43 void chunkpool_init();
aoqi@0 44 void perfMemory_init();
aoqi@0 45
aoqi@0 46 // Initialization done by Java thread in init_globals()
aoqi@0 47 void management_init();
aoqi@0 48 void bytecodes_init();
aoqi@0 49 void classLoader_init();
aoqi@0 50 void codeCache_init();
aoqi@0 51 void VM_Version_init();
aoqi@0 52 void os_init_globals(); // depends on VM_Version_init, before universe_init
aoqi@0 53 void stubRoutines_init1();
aoqi@0 54 jint universe_init(); // depends on codeCache_init and stubRoutines_init
aoqi@0 55 void interpreter_init(); // before any methods loaded
aoqi@0 56 void invocationCounter_init(); // before any methods loaded
aoqi@0 57 void marksweep_init();
aoqi@0 58 void accessFlags_init();
aoqi@0 59 void templateTable_init();
aoqi@0 60 void InterfaceSupport_init();
aoqi@0 61 void universe2_init(); // dependent on codeCache_init and stubRoutines_init, loads primordial classes
aoqi@0 62 void referenceProcessor_init();
aoqi@0 63 void jni_handles_init();
aoqi@0 64 void vmStructs_init();
aoqi@0 65
aoqi@0 66 void vtableStubs_init();
aoqi@0 67 void InlineCacheBuffer_init();
aoqi@0 68 void compilerOracle_init();
aoqi@0 69 void compilationPolicy_init();
aoqi@0 70 void compileBroker_init();
aoqi@0 71
aoqi@0 72 // Initialization after compiler initialization
aoqi@0 73 bool universe_post_init(); // must happen after compiler_init
aoqi@0 74 void javaClasses_init(); // must happen after vtable initialization
aoqi@0 75 void stubRoutines_init2(); // note: StubRoutines need 2-phase init
aoqi@0 76
aoqi@0 77 // Do not disable thread-local-storage, as it is important for some
aoqi@0 78 // JNI/JVM/JVMTI functions and signal handlers to work properly
aoqi@0 79 // during VM shutdown
aoqi@0 80 void perfMemory_exit();
aoqi@0 81 void ostream_exit();
aoqi@0 82
aoqi@0 83 void vm_init_globals() {
aoqi@0 84 check_ThreadShadow();
aoqi@0 85 basic_types_init();
aoqi@0 86 eventlog_init();
aoqi@0 87 mutex_init();
aoqi@0 88 chunkpool_init();
aoqi@0 89 perfMemory_init();
aoqi@0 90 }
aoqi@0 91
aoqi@0 92
aoqi@0 93 jint init_globals() {
aoqi@0 94 HandleMark hm;
aoqi@0 95 management_init();
aoqi@0 96 bytecodes_init();
aoqi@0 97 classLoader_init();
aoqi@0 98 codeCache_init();
aoqi@0 99 VM_Version_init();
aoqi@0 100 os_init_globals();
aoqi@0 101 stubRoutines_init1();
aoqi@0 102 jint status = universe_init(); // dependent on codeCache_init and
aoqi@0 103 // stubRoutines_init1 and metaspace_init.
aoqi@0 104 if (status != JNI_OK)
aoqi@0 105 return status;
aoqi@0 106
aoqi@0 107 interpreter_init(); // before any methods loaded
aoqi@0 108 invocationCounter_init(); // before any methods loaded
aoqi@0 109 marksweep_init();
aoqi@0 110 accessFlags_init();
aoqi@0 111 templateTable_init();
aoqi@0 112 InterfaceSupport_init();
aoqi@0 113 SharedRuntime::generate_stubs();
aoqi@0 114 universe2_init(); // dependent on codeCache_init and stubRoutines_init1
aoqi@0 115 referenceProcessor_init();
aoqi@0 116 jni_handles_init();
aoqi@0 117 #if INCLUDE_VM_STRUCTS
aoqi@0 118 vmStructs_init();
aoqi@0 119 #endif // INCLUDE_VM_STRUCTS
aoqi@0 120
aoqi@0 121 vtableStubs_init();
aoqi@0 122 InlineCacheBuffer_init();
aoqi@0 123 compilerOracle_init();
aoqi@0 124 compilationPolicy_init();
aoqi@0 125 compileBroker_init();
aoqi@0 126 VMRegImpl::set_regName();
aoqi@0 127
aoqi@0 128 if (!universe_post_init()) {
aoqi@0 129 return JNI_ERR;
aoqi@0 130 }
aoqi@0 131 javaClasses_init(); // must happen after vtable initialization
aoqi@0 132 stubRoutines_init2(); // note: StubRoutines need 2-phase init
aoqi@0 133
aoqi@0 134 // All the flags that get adjusted by VM_Version_init and os::init_2
aoqi@0 135 // have been set so dump the flags now.
aoqi@0 136 if (PrintFlagsFinal) {
aoqi@0 137 CommandLineFlags::printFlags(tty, false);
aoqi@0 138 }
aoqi@0 139
aoqi@0 140 return JNI_OK;
aoqi@0 141 }
aoqi@0 142
aoqi@0 143
aoqi@0 144 void exit_globals() {
aoqi@0 145 static bool destructorsCalled = false;
aoqi@0 146 if (!destructorsCalled) {
aoqi@0 147 destructorsCalled = true;
aoqi@0 148 perfMemory_exit();
aoqi@0 149 if (PrintSafepointStatistics) {
aoqi@0 150 // Print the collected safepoint statistics.
aoqi@0 151 SafepointSynchronize::print_stat_on_exit();
aoqi@0 152 }
aoqi@0 153 if (PrintStringTableStatistics) {
aoqi@0 154 SymbolTable::dump(tty);
aoqi@0 155 StringTable::dump(tty);
aoqi@0 156 }
aoqi@0 157 ostream_exit();
aoqi@0 158 }
aoqi@0 159 }
aoqi@0 160
aoqi@0 161
aoqi@0 162 static bool _init_completed = false;
aoqi@0 163
aoqi@0 164 bool is_init_completed() {
aoqi@0 165 return _init_completed;
aoqi@0 166 }
aoqi@0 167
aoqi@0 168
aoqi@0 169 void set_init_completed() {
aoqi@0 170 assert(Universe::is_fully_initialized(), "Should have completed initialization");
aoqi@0 171 _init_completed = true;
aoqi@0 172 }

mercurial