Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc/dllinit.c
5985 views
1
2
/*******************************************************************************
3
* Copyright (c) 1991, 2020 IBM Corp. and others
4
*
5
* This program and the accompanying materials are made available under
6
* the terms of the Eclipse Public License 2.0 which accompanies this
7
* distribution and is available at https://www.eclipse.org/legal/epl-2.0/
8
* or the Apache License, Version 2.0 which accompanies this distribution and
9
* is available at https://www.apache.org/licenses/LICENSE-2.0.
10
*
11
* This Source Code may also be made available under the following
12
* Secondary Licenses when the conditions for such availability set
13
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
14
* General Public License, version 2 with the GNU Classpath
15
* Exception [1] and GNU General Public License, version 2 with the
16
* OpenJDK Assembly Exception [2].
17
*
18
* [1] https://www.gnu.org/software/classpath/license.html
19
* [2] http://openjdk.java.net/legal/assembly-exception.html
20
*
21
* 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-exception
22
*******************************************************************************/
23
24
/**
25
* @file
26
* @ingroup GC
27
*/
28
29
#include "j9.h"
30
#include "j9cfg.h"
31
#include "jni.h"
32
#include "jvminit.h"
33
#include "mminit.h"
34
#include "ModronAssertions.h"
35
#include "util_api.h"
36
37
jint JNICALL
38
JVM_OnLoad( JavaVM *jvm, char* commandLineOptions, void *reserved )
39
{
40
return JNI_OK;
41
}
42
43
/**
44
* Main entrypoint for GC DLL
45
*
46
* This function is called by the VM multiple times during startup and shutdown -
47
* once for each stage. The implementation traps stages GC is interested in and
48
* starts up/shuts down the memory manager as appropriate.
49
*
50
* @param stage Stage the VM has reached
51
* @return Success/failure
52
*/
53
IDATA
54
J9VMDllMain(J9JavaVM* vm, IDATA stage, void* reserved)
55
{
56
IDATA rc = J9VMDLLMAIN_OK;
57
J9VMDllLoadInfo *loadInfo = getGCDllLoadInfo(vm);
58
59
switch (stage) {
60
case PORT_LIBRARY_GUARANTEED:
61
case ALL_DEFAULT_LIBRARIES_LOADED:
62
break;
63
64
case ALL_LIBRARIES_LOADED:
65
/* Note: this must happen now, otherwise -verbose:sizes will not work, as verbose
66
* support is initialized during this stage.
67
*/
68
rc = gcInitializeDefaults(vm);
69
break;
70
71
case DLL_LOAD_TABLE_FINALIZED:
72
case VM_THREADING_INITIALIZED:
73
break;
74
75
case HEAP_STRUCTURES_INITIALIZED:
76
rc = gcInitializeHeapStructures(vm);
77
break;
78
79
case ALL_VM_ARGS_CONSUMED :
80
case BYTECODE_TABLE_SET :
81
case SYSTEM_CLASSLOADER_SET :
82
case DEBUG_SERVER_INITIALIZED :
83
break;
84
85
case JIT_INITIALIZED :
86
/* Register this module with trace */
87
UT_J9MM_MODULE_LOADED(J9_UTINTERFACE_FROM_VM(vm));
88
Trc_MM_VMInitStages_Event1(NULL);
89
90
rc = triggerGCInitialized(vm->mainThread);
91
92
break;
93
94
case ABOUT_TO_BOOTSTRAP :
95
/* Expand heap based on hints stored by previous runs into Shared Cache */
96
gcExpandHeapOnStartup(vm);
97
case JCL_INITIALIZED :
98
case LIBRARIES_ONUNLOAD :
99
break;
100
101
case HEAP_STRUCTURES_FREED :
102
if ( IS_STAGE_COMPLETED( loadInfo->completedBits, HEAP_STRUCTURES_INITIALIZED ) ) {
103
gcCleanupHeapStructures(vm);
104
}
105
break;
106
107
case GC_SHUTDOWN_COMPLETE :
108
if ( IS_STAGE_COMPLETED( loadInfo->completedBits, ALL_LIBRARIES_LOADED ) ) {
109
gcCleanupInitializeDefaults(vm->omrVM);
110
}
111
break;
112
}
113
return rc;
114
}
115
116
117