1/*******************************************************************************2* Copyright (c) 1991, 2020 IBM Corp. and others3*4* This program and the accompanying materials are made available under5* the terms of the Eclipse Public License 2.0 which accompanies this6* distribution and is available at https://www.eclipse.org/legal/epl-2.0/7* or the Apache License, Version 2.0 which accompanies this distribution and8* is available at https://www.apache.org/licenses/LICENSE-2.0.9*10* This Source Code may also be made available under the following11* Secondary Licenses when the conditions for such availability set12* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU13* General Public License, version 2 with the GNU Classpath14* Exception [1] and GNU General Public License, version 2 with the15* OpenJDK Assembly Exception [2].16*17* [1] https://www.gnu.org/software/classpath/license.html18* [2] http://openjdk.java.net/legal/assembly-exception.html19*20* SPDX-License-Identifier: EPL-2.0 OR Apache-2.0 OR GPL-2.0 WITH Classpath-exception-2.0 OR LicenseRef-GPL-2.0 WITH Assembly-exception21*******************************************************************************/2223/**24* @file25* @ingroup GC26*/2728#include "j9.h"29#include "j9cfg.h"30#include "jni.h"31#include "jvminit.h"32#include "mminit.h"33#include "ModronAssertions.h"34#include "util_api.h"3536jint JNICALL37JVM_OnLoad( JavaVM *jvm, char* commandLineOptions, void *reserved )38{39return JNI_OK;40}4142/**43* Main entrypoint for GC DLL44*45* This function is called by the VM multiple times during startup and shutdown -46* once for each stage. The implementation traps stages GC is interested in and47* starts up/shuts down the memory manager as appropriate.48*49* @param stage Stage the VM has reached50* @return Success/failure51*/52IDATA53J9VMDllMain(J9JavaVM* vm, IDATA stage, void* reserved)54{55IDATA rc = J9VMDLLMAIN_OK;56J9VMDllLoadInfo *loadInfo = getGCDllLoadInfo(vm);5758switch (stage) {59case PORT_LIBRARY_GUARANTEED:60case ALL_DEFAULT_LIBRARIES_LOADED:61break;6263case ALL_LIBRARIES_LOADED:64/* Note: this must happen now, otherwise -verbose:sizes will not work, as verbose65* support is initialized during this stage.66*/67rc = gcInitializeDefaults(vm);68break;6970case DLL_LOAD_TABLE_FINALIZED:71case VM_THREADING_INITIALIZED:72break;7374case HEAP_STRUCTURES_INITIALIZED:75rc = gcInitializeHeapStructures(vm);76break;7778case ALL_VM_ARGS_CONSUMED :79case BYTECODE_TABLE_SET :80case SYSTEM_CLASSLOADER_SET :81case DEBUG_SERVER_INITIALIZED :82break;8384case JIT_INITIALIZED :85/* Register this module with trace */86UT_J9MM_MODULE_LOADED(J9_UTINTERFACE_FROM_VM(vm));87Trc_MM_VMInitStages_Event1(NULL);8889rc = triggerGCInitialized(vm->mainThread);9091break;9293case ABOUT_TO_BOOTSTRAP :94/* Expand heap based on hints stored by previous runs into Shared Cache */95gcExpandHeapOnStartup(vm);96case JCL_INITIALIZED :97case LIBRARIES_ONUNLOAD :98break;99100case HEAP_STRUCTURES_FREED :101if ( IS_STAGE_COMPLETED( loadInfo->completedBits, HEAP_STRUCTURES_INITIALIZED ) ) {102gcCleanupHeapStructures(vm);103}104break;105106case GC_SHUTDOWN_COMPLETE :107if ( IS_STAGE_COMPLETED( loadInfo->completedBits, ALL_LIBRARIES_LOADED ) ) {108gcCleanupInitializeDefaults(vm->omrVM);109}110break;111}112return rc;113}114115116117