Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/runtime/init.cpp
32285 views
/*1* Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "classfile/symbolTable.hpp"26#include "code/icBuffer.hpp"27#include "gc_interface/collectedHeap.hpp"28#include "interpreter/bytecodes.hpp"29#include "memory/universe.hpp"30#include "prims/methodHandles.hpp"31#include "runtime/handles.inline.hpp"32#include "runtime/icache.hpp"33#include "runtime/init.hpp"34#include "runtime/safepoint.hpp"35#include "runtime/sharedRuntime.hpp"36#include "services/memTracker.hpp"37#include "utilities/macros.hpp"383940// Initialization done by VM thread in vm_init_globals()41void check_ThreadShadow();42void eventlog_init();43void mutex_init();44void chunkpool_init();45void perfMemory_init();4647// Initialization done by Java thread in init_globals()48void management_init();49void bytecodes_init();50void classLoader_init();51void codeCache_init();52void VM_Version_init();53void os_init_globals(); // depends on VM_Version_init, before universe_init54void stubRoutines_init1();55jint universe_init(); // depends on codeCache_init and stubRoutines_init56void interpreter_init(); // before any methods loaded57void invocationCounter_init(); // before any methods loaded58void marksweep_init();59void accessFlags_init();60void templateTable_init();61void InterfaceSupport_init();62void universe2_init(); // dependent on codeCache_init and stubRoutines_init, loads primordial classes63void referenceProcessor_init();64void jni_handles_init();65void vmStructs_init();6667void vtableStubs_init();68void InlineCacheBuffer_init();69void compilerOracle_init();70void compilationPolicy_init();71void compileBroker_init();7273// Initialization after compiler initialization74bool universe_post_init(); // must happen after compiler_init75void javaClasses_init(); // must happen after vtable initialization76void stubRoutines_init2(); // note: StubRoutines need 2-phase init7778// Do not disable thread-local-storage, as it is important for some79// JNI/JVM/JVMTI functions and signal handlers to work properly80// during VM shutdown81void perfMemory_exit();82void ostream_exit();8384void vm_init_globals() {85check_ThreadShadow();86basic_types_init();87eventlog_init();88mutex_init();89chunkpool_init();90perfMemory_init();91}929394jint init_globals() {95HandleMark hm;96management_init();97bytecodes_init();98classLoader_init();99codeCache_init();100VM_Version_init();101os_init_globals();102stubRoutines_init1();103jint status = universe_init(); // dependent on codeCache_init and104// stubRoutines_init1 and metaspace_init.105if (status != JNI_OK)106return status;107108interpreter_init(); // before any methods loaded109invocationCounter_init(); // before any methods loaded110marksweep_init();111accessFlags_init();112templateTable_init();113InterfaceSupport_init();114SharedRuntime::generate_stubs();115universe2_init(); // dependent on codeCache_init and stubRoutines_init1116referenceProcessor_init();117jni_handles_init();118#if INCLUDE_VM_STRUCTS119vmStructs_init();120#endif // INCLUDE_VM_STRUCTS121122vtableStubs_init();123InlineCacheBuffer_init();124compilerOracle_init();125compilationPolicy_init();126compileBroker_init();127VMRegImpl::set_regName();128129if (!universe_post_init()) {130return JNI_ERR;131}132javaClasses_init(); // must happen after vtable initialization133stubRoutines_init2(); // note: StubRoutines need 2-phase init134135#if INCLUDE_NMT136// Solaris stack is walkable only after stubRoutines are set up.137// On Other platforms, the stack is always walkable.138NMT_stack_walkable = true;139#endif // INCLUDE_NMT140141// All the flags that get adjusted by VM_Version_init and os::init_2142// have been set so dump the flags now.143if (PrintFlagsFinal) {144CommandLineFlags::printFlags(tty, false);145}146147return JNI_OK;148}149150151void exit_globals() {152static bool destructorsCalled = false;153if (!destructorsCalled) {154destructorsCalled = true;155perfMemory_exit();156if (PrintSafepointStatistics) {157// Print the collected safepoint statistics.158SafepointSynchronize::print_stat_on_exit();159}160if (PrintStringTableStatistics) {161SymbolTable::dump(tty);162StringTable::dump(tty);163}164ostream_exit();165}166}167168169static bool _init_completed = false;170171bool is_init_completed() {172return _init_completed;173}174175176void set_init_completed() {177assert(Universe::is_fully_initialized(), "Should have completed initialization");178_init_completed = true;179}180181182