Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/openj9
Path: blob/master/runtime/gc_base/GCObjectEvents.cpp
5986 views
1
/*******************************************************************************
2
* Copyright (c) 1991, 2021 IBM Corp. and others
3
*
4
* This program and the accompanying materials are made available under
5
* the terms of the Eclipse Public License 2.0 which accompanies this
6
* 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 and
8
* is available at https://www.apache.org/licenses/LICENSE-2.0.
9
*
10
* This Source Code may also be made available under the following
11
* Secondary Licenses when the conditions for such availability set
12
* forth in the Eclipse Public License, v. 2.0 are satisfied: GNU
13
* General Public License, version 2 with the GNU Classpath
14
* Exception [1] and GNU General Public License, version 2 with the
15
* OpenJDK Assembly Exception [2].
16
*
17
* [1] https://www.gnu.org/software/classpath/license.html
18
* [2] http://openjdk.java.net/legal/assembly-exception.html
19
*
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-exception
21
*******************************************************************************/
22
23
#include "j9.h"
24
#include "j9cfg.h"
25
#include "j9consts.h"
26
#include "modronopt.h"
27
28
#if defined(J9VM_PROF_EVENT_REPORTING)
29
30
#include "mmhook_internal.h"
31
#include "mmomrhook_internal.h"
32
33
#include "EnvironmentBase.hpp"
34
#include "ForwardedHeader.hpp"
35
#include "Heap.hpp"
36
#include "HeapMap.hpp"
37
#include "MemorySpace.hpp"
38
#include "MemorySubSpace.hpp"
39
#include "MemorySubSpaceSemiSpace.hpp"
40
#include "MemorySubSpaceRegionIterator.hpp"
41
#include "ObjectHeapBufferedIterator.hpp"
42
#include "ObjectModel.hpp"
43
#include "HeapRegionDescriptor.hpp"
44
#include "HeapRegionIterator.hpp"
45
#include "GCExtensions.hpp"
46
#include "HeapRegionManager.hpp"
47
48
void
49
globalGCReportObjectEvents(MM_EnvironmentBase *env, MM_HeapMap *markMap)
50
{
51
MM_GCExtensions *extensions = MM_GCExtensions::getExtensions(env);
52
MM_HeapRegionManager *regionManager = extensions->heap->getHeapRegionManager();
53
GC_HeapRegionIterator regionIterator(regionManager);
54
MM_HeapRegionDescriptor *region = NULL;
55
OMR_VMThread *vmThread = env->getOmrVMThread();
56
while((region = regionIterator.nextRegion()) != NULL) {
57
/* Iterate over live objects only */
58
MM_MemorySubSpace *memorySubSpace = region->getSubSpace();
59
60
GC_ObjectHeapBufferedIterator objectHeapIterator(extensions, region);
61
62
J9Object *objectPtr = NULL;
63
while( NULL != (objectPtr = objectHeapIterator.nextObject()) ) {
64
/* Check the mark state of each object. If it isn't marked, build a dead object. */
65
if(!markMap->isBitSet(objectPtr)) {
66
67
UDATA deadObjectByteSize = extensions->objectModel.getConsumedSizeInBytesWithHeader(objectPtr);
68
memorySubSpace->abandonHeapChunk(objectPtr, ((U_8*)objectPtr) + deadObjectByteSize);
69
70
TRIGGER_J9HOOK_MM_OMR_OBJECT_DELETE(env->getExtensions()->omrHookInterface, vmThread, objectPtr, memorySubSpace);
71
}
72
}
73
}
74
}
75
76
void
77
localGCReportObjectEvents(MM_EnvironmentBase *env, MM_MemorySubSpaceSemiSpace *memorySubSpaceNew)
78
{
79
MM_GCExtensions *extensions = MM_GCExtensions::getExtensions(env);
80
OMR_VMThread *vmThread = env->getOmrVMThread();
81
82
/* Find the region associated with the evacuate allocate profile */
83
GC_MemorySubSpaceRegionIterator regionIterator(memorySubSpaceNew);
84
MM_HeapRegionDescriptor *evacuateRegion = NULL;
85
bool const compressed = extensions->compressObjectReferences();
86
while ((evacuateRegion = regionIterator.nextRegion()) != NULL) {
87
J9Object *objectPtr = (J9Object *)evacuateRegion->getLowAddress();
88
/* skip survivor regions */
89
if (memorySubSpaceNew->isObjectInEvacuateMemory(objectPtr)) {
90
MM_MemorySubSpace *evacuateMemorySubSpace = evacuateRegion->getSubSpace();
91
/* Use the object model helper to test for holes,
92
* otherwise use ForwardedHeader to test for forwarded objects.
93
*/
94
while(objectPtr < (J9Object *)evacuateRegion->getHighAddress()) {
95
if (extensions->objectModel.isDeadObject(objectPtr)) {
96
objectPtr = (J9Object *)((U_8 *)objectPtr + extensions->objectModel.getSizeInBytesDeadObject(objectPtr));
97
} else {
98
MM_ForwardedHeader forwardHeader(objectPtr, compressed);
99
if (forwardHeader.isForwardedPointer()) {
100
J9Object *forwardPtr = forwardHeader.getForwardedObject();
101
Assert_MM_true(NULL != forwardPtr);
102
TRIGGER_J9HOOK_MM_OMR_OBJECT_RENAME(env->getExtensions()->omrHookInterface, vmThread, objectPtr, forwardPtr);
103
objectPtr = (J9Object *)((U_8 *)objectPtr + extensions->objectModel.getConsumedSizeInBytesWithHeaderBeforeMove(forwardPtr));
104
} else {
105
TRIGGER_J9HOOK_MM_OMR_OBJECT_DELETE(env->getExtensions()->omrHookInterface, vmThread, objectPtr, evacuateMemorySubSpace);
106
objectPtr = (J9Object *)((U_8 *)objectPtr + extensions->objectModel.getConsumedSizeInBytesWithHeader(objectPtr));
107
}
108
}
109
}
110
}
111
}
112
}
113
114
#endif /* J9VM_PROF_EVENT_REPORTING */
115
116