src/share/vm/runtime/init.cpp

Thu, 12 Oct 2017 21:27:07 +0800

author
aoqi
date
Thu, 12 Oct 2017 21:27:07 +0800
changeset 7535
7ae4e26cb1e0
parent 7074
833b0f92429a
parent 6876
710a3c8b516e
permissions
-rw-r--r--

merge

aoqi@0 1 /*
zgu@7074 2 * Copyright (c) 1997, 2014, 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"
zgu@7074 37 #include "services/memTracker.hpp"
aoqi@0 38 #include "utilities/macros.hpp"
aoqi@0 39
zgu@7074 40
aoqi@0 41 // Initialization done by VM thread in vm_init_globals()
aoqi@0 42 void check_ThreadShadow();
aoqi@0 43 void eventlog_init();
aoqi@0 44 void mutex_init();
aoqi@0 45 void chunkpool_init();
aoqi@0 46 void perfMemory_init();
aoqi@0 47
aoqi@0 48 // Initialization done by Java thread in init_globals()
aoqi@0 49 void management_init();
aoqi@0 50 void bytecodes_init();
aoqi@0 51 void classLoader_init();
aoqi@0 52 void codeCache_init();
aoqi@0 53 void VM_Version_init();
aoqi@0 54 void os_init_globals(); // depends on VM_Version_init, before universe_init
aoqi@0 55 void stubRoutines_init1();
aoqi@0 56 jint universe_init(); // depends on codeCache_init and stubRoutines_init
aoqi@0 57 void interpreter_init(); // before any methods loaded
aoqi@0 58 void invocationCounter_init(); // before any methods loaded
aoqi@0 59 void marksweep_init();
aoqi@0 60 void accessFlags_init();
aoqi@0 61 void templateTable_init();
aoqi@0 62 void InterfaceSupport_init();
aoqi@0 63 void universe2_init(); // dependent on codeCache_init and stubRoutines_init, loads primordial classes
aoqi@0 64 void referenceProcessor_init();
aoqi@0 65 void jni_handles_init();
aoqi@0 66 void vmStructs_init();
aoqi@0 67
aoqi@0 68 void vtableStubs_init();
aoqi@0 69 void InlineCacheBuffer_init();
aoqi@0 70 void compilerOracle_init();
aoqi@0 71 void compilationPolicy_init();
aoqi@0 72 void compileBroker_init();
aoqi@0 73
aoqi@0 74 // Initialization after compiler initialization
aoqi@0 75 bool universe_post_init(); // must happen after compiler_init
aoqi@0 76 void javaClasses_init(); // must happen after vtable initialization
aoqi@0 77 void stubRoutines_init2(); // note: StubRoutines need 2-phase init
aoqi@0 78
aoqi@0 79 // Do not disable thread-local-storage, as it is important for some
aoqi@0 80 // JNI/JVM/JVMTI functions and signal handlers to work properly
aoqi@0 81 // during VM shutdown
aoqi@0 82 void perfMemory_exit();
aoqi@0 83 void ostream_exit();
aoqi@0 84
aoqi@0 85 void vm_init_globals() {
aoqi@0 86 check_ThreadShadow();
aoqi@0 87 basic_types_init();
aoqi@0 88 eventlog_init();
aoqi@0 89 mutex_init();
aoqi@0 90 chunkpool_init();
aoqi@0 91 perfMemory_init();
aoqi@0 92 }
aoqi@0 93
aoqi@0 94
aoqi@0 95 jint init_globals() {
aoqi@0 96 HandleMark hm;
aoqi@0 97 management_init();
aoqi@0 98 bytecodes_init();
aoqi@0 99 classLoader_init();
aoqi@0 100 codeCache_init();
aoqi@0 101 VM_Version_init();
aoqi@0 102 os_init_globals();
aoqi@0 103 stubRoutines_init1();
aoqi@0 104 jint status = universe_init(); // dependent on codeCache_init and
aoqi@0 105 // stubRoutines_init1 and metaspace_init.
aoqi@0 106 if (status != JNI_OK)
aoqi@0 107 return status;
aoqi@0 108
aoqi@0 109 interpreter_init(); // before any methods loaded
aoqi@0 110 invocationCounter_init(); // before any methods loaded
aoqi@0 111 marksweep_init();
aoqi@0 112 accessFlags_init();
aoqi@0 113 templateTable_init();
aoqi@0 114 InterfaceSupport_init();
aoqi@0 115 SharedRuntime::generate_stubs();
aoqi@0 116 universe2_init(); // dependent on codeCache_init and stubRoutines_init1
aoqi@0 117 referenceProcessor_init();
aoqi@0 118 jni_handles_init();
aoqi@0 119 #if INCLUDE_VM_STRUCTS
aoqi@0 120 vmStructs_init();
aoqi@0 121 #endif // INCLUDE_VM_STRUCTS
aoqi@0 122
aoqi@0 123 vtableStubs_init();
aoqi@0 124 InlineCacheBuffer_init();
aoqi@0 125 compilerOracle_init();
aoqi@0 126 compilationPolicy_init();
aoqi@0 127 compileBroker_init();
aoqi@0 128 VMRegImpl::set_regName();
aoqi@0 129
aoqi@0 130 if (!universe_post_init()) {
aoqi@0 131 return JNI_ERR;
aoqi@0 132 }
aoqi@0 133 javaClasses_init(); // must happen after vtable initialization
aoqi@0 134 stubRoutines_init2(); // note: StubRoutines need 2-phase init
aoqi@0 135
zgu@7074 136 #if INCLUDE_NMT
zgu@7074 137 // Solaris stack is walkable only after stubRoutines are set up.
zgu@7074 138 // On Other platforms, the stack is always walkable.
zgu@7074 139 NMT_stack_walkable = true;
zgu@7074 140 #endif // INCLUDE_NMT
zgu@7074 141
aoqi@0 142 // All the flags that get adjusted by VM_Version_init and os::init_2
aoqi@0 143 // have been set so dump the flags now.
aoqi@0 144 if (PrintFlagsFinal) {
aoqi@0 145 CommandLineFlags::printFlags(tty, false);
aoqi@0 146 }
aoqi@0 147
aoqi@0 148 return JNI_OK;
aoqi@0 149 }
aoqi@0 150
aoqi@0 151
aoqi@0 152 void exit_globals() {
aoqi@0 153 static bool destructorsCalled = false;
aoqi@0 154 if (!destructorsCalled) {
aoqi@0 155 destructorsCalled = true;
aoqi@0 156 perfMemory_exit();
aoqi@0 157 if (PrintSafepointStatistics) {
aoqi@0 158 // Print the collected safepoint statistics.
aoqi@0 159 SafepointSynchronize::print_stat_on_exit();
aoqi@0 160 }
aoqi@0 161 if (PrintStringTableStatistics) {
aoqi@0 162 SymbolTable::dump(tty);
aoqi@0 163 StringTable::dump(tty);
aoqi@0 164 }
aoqi@0 165 ostream_exit();
aoqi@0 166 }
aoqi@0 167 }
aoqi@0 168
aoqi@0 169
aoqi@0 170 static bool _init_completed = false;
aoqi@0 171
aoqi@0 172 bool is_init_completed() {
aoqi@0 173 return _init_completed;
aoqi@0 174 }
aoqi@0 175
aoqi@0 176
aoqi@0 177 void set_init_completed() {
aoqi@0 178 assert(Universe::is_fully_initialized(), "Should have completed initialization");
aoqi@0 179 _init_completed = true;
aoqi@0 180 }

mercurial