< prev index next >

src/hotspot/share/runtime/init.cpp

Print this page

 24 
 25 #include "precompiled.hpp"
 26 #include "classfile/stringTable.hpp"
 27 #include "classfile/symbolTable.hpp"
 28 #include "code/icBuffer.hpp"
 29 #include "compiler/compiler_globals.hpp"
 30 #include "gc/shared/collectedHeap.hpp"
 31 #if INCLUDE_JVMCI
 32 #include "jvmci/jvmci.hpp"
 33 #endif
 34 #include "interpreter/bytecodes.hpp"
 35 #include "logging/log.hpp"
 36 #include "logging/logAsyncWriter.hpp"
 37 #include "logging/logTag.hpp"
 38 #include "memory/universe.hpp"
 39 #include "prims/jvmtiExport.hpp"
 40 #include "prims/methodHandles.hpp"
 41 #include "prims/universalNativeInvoker.hpp"
 42 #include "runtime/globals.hpp"
 43 #include "runtime/atomic.hpp"

 44 #include "runtime/flags/jvmFlag.hpp"
 45 #include "runtime/handles.inline.hpp"
 46 #include "runtime/icache.hpp"
 47 #include "runtime/init.hpp"
 48 #include "runtime/safepoint.hpp"
 49 #include "runtime/sharedRuntime.hpp"
 50 #include "services/memTracker.hpp"
 51 #include "utilities/macros.hpp"
 52 
 53 
 54 // Initialization done by VM thread in vm_init_globals()
 55 void check_ThreadShadow();
 56 void eventlog_init();
 57 void mutex_init();
 58 void universe_oopstorage_init();
 59 void perfMemory_init();
 60 void SuspendibleThreadSet_init();
 61 
 62 // Initialization done by Java thread in init_globals()
 63 void management_init();
 64 void bytecodes_init();
 65 void classLoader_init1();
 66 void compilationPolicy_init();
 67 void codeCache_init();
 68 void VM_Version_init();
 69 void stubRoutines_init1();

 70 jint universe_init();          // depends on codeCache_init and stubRoutines_init
 71 // depends on universe_init, must be before interpreter_init (currently only on SPARC)
 72 void gc_barrier_stubs_init();
 73 void interpreter_init_stub();  // before any methods loaded
 74 void interpreter_init_code();  // after methods loaded, but before they are linked
 75 void accessFlags_init();
 76 void InterfaceSupport_init();
 77 void universe2_init();  // dependent on codeCache_init and stubRoutines_init, loads primordial classes
 78 void referenceProcessor_init();
 79 void jni_handles_init();
 80 void vmStructs_init() NOT_DEBUG_RETURN;
 81 
 82 void vtableStubs_init();
 83 void InlineCacheBuffer_init();
 84 void compilerOracle_init();
 85 bool compileBroker_init();
 86 void dependencyContext_init();
 87 void dependencies_init();
 88 
 89 // Initialization after compiler initialization
 90 bool universe_post_init();  // must happen after compiler_init
 91 void javaClasses_init();  // must happen after vtable initialization
 92 void stubRoutines_init2(); // note: StubRoutines need 2-phase init
 93 


 94 // Do not disable thread-local-storage, as it is important for some
 95 // JNI/JVM/JVMTI functions and signal handlers to work properly
 96 // during VM shutdown
 97 void perfMemory_exit();
 98 void ostream_exit();
 99 
100 void vm_init_globals() {
101   check_ThreadShadow();
102   basic_types_init();
103   eventlog_init();
104   mutex_init();
105   universe_oopstorage_init();
106   perfMemory_init();
107   SuspendibleThreadSet_init();
108 }
109 
110 
111 jint init_globals() {
112   management_init();
113   JvmtiExport::initialize_oop_storage();
114   bytecodes_init();
115   classLoader_init1();
116   compilationPolicy_init();
117   codeCache_init();
118   VM_Version_init();              // depends on codeCache_init for emitting code
119   stubRoutines_init1();
120   jint status = universe_init();  // dependent on codeCache_init and
121                                   // stubRoutines_init1 and metaspace_init.
122   if (status != JNI_OK)
123     return status;
124 
125   AsyncLogWriter::initialize();
126   gc_barrier_stubs_init();  // depends on universe_init, must be before interpreter_init

127   interpreter_init_stub();  // before methods get loaded
128   accessFlags_init();
129   InterfaceSupport_init();
130   VMRegImpl::set_regName(); // need this before generate_stubs (for printing oop maps).
131   SharedRuntime::generate_stubs();
132   universe2_init();  // dependent on codeCache_init and stubRoutines_init1
133   javaClasses_init();// must happen after vtable initialization, before referenceProcessor_init
134   interpreter_init_code();  // after javaClasses_init and before any method gets linked
135   referenceProcessor_init();
136   jni_handles_init();
137 #if INCLUDE_VM_STRUCTS
138   vmStructs_init();
139 #endif // INCLUDE_VM_STRUCTS
140 
141   vtableStubs_init();
142   InlineCacheBuffer_init();
143   compilerOracle_init();
144   dependencyContext_init();
145   dependencies_init();
146 
147   if (!compileBroker_init()) {
148     return JNI_EINVAL;
149   }
150 #if INCLUDE_JVMCI
151   if (EnableJVMCI) {
152     JVMCI::initialize_globals();
153   }
154 #endif
155 
156   if (!universe_post_init()) {
157     return JNI_ERR;
158   }
159   stubRoutines_init2(); // note: StubRoutines need 2-phase init
160   MethodHandles::generate_adapters();
161 


162   // All the flags that get adjusted by VM_Version_init and os::init_2
163   // have been set so dump the flags now.
164   if (PrintFlagsFinal || PrintFlagsRanges) {
165     JVMFlag::printFlags(tty, false, PrintFlagsRanges);
166   }
167 

168   return JNI_OK;
169 }
170 
171 
172 void exit_globals() {
173   static bool destructorsCalled = false;
174   if (!destructorsCalled) {
175     destructorsCalled = true;
176     perfMemory_exit();
177     SafepointTracing::statistics_exit_log();
178     if (PrintStringTableStatistics) {
179       SymbolTable::dump(tty);
180       StringTable::dump(tty);
181     }
182     ostream_exit();
183   }
184 }
185 
186 static volatile bool _init_completed = false;
187 

 24 
 25 #include "precompiled.hpp"
 26 #include "classfile/stringTable.hpp"
 27 #include "classfile/symbolTable.hpp"
 28 #include "code/icBuffer.hpp"
 29 #include "compiler/compiler_globals.hpp"
 30 #include "gc/shared/collectedHeap.hpp"
 31 #if INCLUDE_JVMCI
 32 #include "jvmci/jvmci.hpp"
 33 #endif
 34 #include "interpreter/bytecodes.hpp"
 35 #include "logging/log.hpp"
 36 #include "logging/logAsyncWriter.hpp"
 37 #include "logging/logTag.hpp"
 38 #include "memory/universe.hpp"
 39 #include "prims/jvmtiExport.hpp"
 40 #include "prims/methodHandles.hpp"
 41 #include "prims/universalNativeInvoker.hpp"
 42 #include "runtime/globals.hpp"
 43 #include "runtime/atomic.hpp"
 44 #include "runtime/continuation.hpp"
 45 #include "runtime/flags/jvmFlag.hpp"
 46 #include "runtime/handles.inline.hpp"
 47 #include "runtime/icache.hpp"
 48 #include "runtime/init.hpp"
 49 #include "runtime/safepoint.hpp"
 50 #include "runtime/sharedRuntime.hpp"
 51 #include "services/memTracker.hpp"
 52 #include "utilities/macros.hpp"
 53 
 54 
 55 // Initialization done by VM thread in vm_init_globals()
 56 void check_ThreadShadow();
 57 void eventlog_init();
 58 void mutex_init();
 59 void universe_oopstorage_init();
 60 void perfMemory_init();
 61 void SuspendibleThreadSet_init();
 62 
 63 // Initialization done by Java thread in init_globals()
 64 void management_init();
 65 void bytecodes_init();
 66 void classLoader_init1();
 67 void compilationPolicy_init();
 68 void codeCache_init();
 69 void VM_Version_init();
 70 void stubRoutines_init1();
 71 void stubRoutines_initContinuationStubs();
 72 jint universe_init();          // depends on codeCache_init and stubRoutines_init
 73 // depends on universe_init, must be before interpreter_init (currently only on SPARC)
 74 void gc_barrier_stubs_init();
 75 void interpreter_init_stub();  // before any methods loaded
 76 void interpreter_init_code();  // after methods loaded, but before they are linked
 77 void accessFlags_init();
 78 void InterfaceSupport_init();
 79 void universe2_init();  // dependent on codeCache_init and stubRoutines_init, loads primordial classes
 80 void referenceProcessor_init();
 81 void jni_handles_init();
 82 void vmStructs_init() NOT_DEBUG_RETURN;
 83 
 84 void vtableStubs_init();
 85 void InlineCacheBuffer_init();
 86 void compilerOracle_init();
 87 bool compileBroker_init();
 88 void dependencyContext_init();
 89 void dependencies_init();
 90 
 91 // Initialization after compiler initialization
 92 bool universe_post_init();  // must happen after compiler_init
 93 void javaClasses_init();  // must happen after vtable initialization
 94 void stubRoutines_init2(); // note: StubRoutines need 2-phase init
 95 
 96 void continuations_init(); // depends on flags (UseCompressedOops, LoomGenCode) and barrier sets
 97 
 98 // Do not disable thread-local-storage, as it is important for some
 99 // JNI/JVM/JVMTI functions and signal handlers to work properly
100 // during VM shutdown
101 void perfMemory_exit();
102 void ostream_exit();
103 
104 void vm_init_globals() {
105   check_ThreadShadow();
106   basic_types_init();
107   eventlog_init();
108   mutex_init();
109   universe_oopstorage_init();
110   perfMemory_init();
111   SuspendibleThreadSet_init();
112 }
113 
114 
115 jint init_globals() {
116   management_init();
117   JvmtiExport::initialize_oop_storage();
118   bytecodes_init();
119   classLoader_init1();
120   compilationPolicy_init();
121   codeCache_init();
122   VM_Version_init();              // depends on codeCache_init for emitting code
123   stubRoutines_init1();
124   jint status = universe_init();  // dependent on codeCache_init and
125                                   // stubRoutines_init1 and metaspace_init.
126   if (status != JNI_OK)
127     return status;
128 
129   AsyncLogWriter::initialize();
130   gc_barrier_stubs_init();  // depends on universe_init, must be before interpreter_init
131   stubRoutines_initContinuationStubs();
132   interpreter_init_stub();  // before methods get loaded
133   accessFlags_init();
134   InterfaceSupport_init();
135   VMRegImpl::set_regName(); // need this before generate_stubs (for printing oop maps).
136   SharedRuntime::generate_stubs();
137   universe2_init();  // dependent on codeCache_init and stubRoutines_init1
138   javaClasses_init();// must happen after vtable initialization, before referenceProcessor_init
139   interpreter_init_code();  // after javaClasses_init and before any method gets linked
140   referenceProcessor_init();
141   jni_handles_init();
142 #if INCLUDE_VM_STRUCTS
143   vmStructs_init();
144 #endif // INCLUDE_VM_STRUCTS
145 
146   vtableStubs_init();
147   InlineCacheBuffer_init();
148   compilerOracle_init();
149   dependencyContext_init();
150   dependencies_init();
151 
152   if (!compileBroker_init()) {
153     return JNI_EINVAL;
154   }
155 #if INCLUDE_JVMCI
156   if (EnableJVMCI) {
157     JVMCI::initialize_globals();
158   }
159 #endif
160 
161   if (!universe_post_init()) {
162     return JNI_ERR;
163   }
164   stubRoutines_init2(); // note: StubRoutines need 2-phase init
165   MethodHandles::generate_adapters();
166 
167   continuations_init();
168 
169   // All the flags that get adjusted by VM_Version_init and os::init_2
170   // have been set so dump the flags now.
171   if (PrintFlagsFinal || PrintFlagsRanges) {
172     JVMFlag::printFlags(tty, false, PrintFlagsRanges);
173   }
174 
175 
176   return JNI_OK;
177 }
178 
179 
180 void exit_globals() {
181   static bool destructorsCalled = false;
182   if (!destructorsCalled) {
183     destructorsCalled = true;
184     perfMemory_exit();
185     SafepointTracing::statistics_exit_log();
186     if (PrintStringTableStatistics) {
187       SymbolTable::dump(tty);
188       StringTable::dump(tty);
189     }
190     ostream_exit();
191   }
192 }
193 
194 static volatile bool _init_completed = false;
195 
< prev index next >