1
1
/* ******************************************************************************
2
- * Copyright (c) 2001, 2020 IBM Corp. and others
2
+ * Copyright (c) 2001, 2022 IBM Corp. and others
3
3
*
4
4
* This program and the accompanying materials are made available under
5
5
* the terms of the Eclipse Public License 2.0 which accompanies this
36
36
#include " Task.hpp"
37
37
#include " UnfinalizedObjectBuffer.hpp"
38
38
#include " UnfinalizedObjectList.hpp"
39
+ #include " ContinuationObjectBuffer.hpp"
40
+ #include " ContinuationObjectList.hpp"
39
41
40
42
41
43
#if defined(J9VM_GC_FINALIZATION)
@@ -97,7 +99,7 @@ MM_CompactSchemeFixupRoots::fixupUnfinalizedObjects(MM_EnvironmentBase *env)
97
99
GC_HeapRegionIteratorStandard regionIterator (extensions->getHeap ()->getHeapRegionManager ());
98
100
while (NULL != (region = regionIterator.nextRegion ())) {
99
101
MM_HeapRegionDescriptorStandardExtension *regionExtension = MM_ConfigurationDelegate::getHeapRegionDescriptorStandardExtension (env, region);
100
- for (UDATA i = 0 ; i < regionExtension->_maxListIndex ; i++) {
102
+ for (uintptr_t i = 0 ; i < regionExtension->_maxListIndex ; i++) {
101
103
MM_UnfinalizedObjectList *list = ®ionExtension->_unfinalizedObjectLists [i];
102
104
list->startUnfinalizedProcessing ();
103
105
}
@@ -108,7 +110,7 @@ MM_CompactSchemeFixupRoots::fixupUnfinalizedObjects(MM_EnvironmentBase *env)
108
110
GC_HeapRegionIteratorStandard regionIterator (extensions->getHeap ()->getHeapRegionManager ());
109
111
while (NULL != (region = regionIterator.nextRegion ())) {
110
112
MM_HeapRegionDescriptorStandardExtension *regionExtension = MM_ConfigurationDelegate::getHeapRegionDescriptorStandardExtension (env, region);
111
- for (UDATA i = 0 ; i < regionExtension->_maxListIndex ; i++) {
113
+ for (uintptr_t i = 0 ; i < regionExtension->_maxListIndex ; i++) {
112
114
MM_UnfinalizedObjectList *list = ®ionExtension->_unfinalizedObjectLists [i];
113
115
if (!list->wasEmpty ()) {
114
116
if (J9MODRON_HANDLE_NEXT_WORK_UNIT (env)) {
@@ -129,3 +131,45 @@ MM_CompactSchemeFixupRoots::fixupUnfinalizedObjects(MM_EnvironmentBase *env)
129
131
env->getGCEnvironment ()->_unfinalizedObjectBuffer ->flush (env);
130
132
}
131
133
#endif /* J9VM_GC_FINALIZATION */
134
+
135
+
136
+ void
137
+ MM_CompactSchemeFixupRoots::fixupContinuationObjects (MM_EnvironmentBase *env)
138
+ {
139
+ MM_GCExtensions* extensions = MM_GCExtensions::getExtensions (env);
140
+ if (env->_currentTask ->synchronizeGCThreadsAndReleaseMain (env, UNIQUE_ID)) {
141
+ MM_HeapRegionDescriptorStandard *region = NULL ;
142
+ GC_HeapRegionIteratorStandard regionIterator (extensions->getHeap ()->getHeapRegionManager ());
143
+ while (NULL != (region = regionIterator.nextRegion ())) {
144
+ MM_HeapRegionDescriptorStandardExtension *regionExtension = MM_ConfigurationDelegate::getHeapRegionDescriptorStandardExtension (env, region);
145
+ for (uintptr_t i = 0 ; i < regionExtension->_maxListIndex ; i++) {
146
+ MM_ContinuationObjectList *list = ®ionExtension->_continuationObjectLists [i];
147
+ list->startProcessing ();
148
+ }
149
+ }
150
+ env->_currentTask ->releaseSynchronizedGCThreads (env);
151
+ }
152
+ MM_HeapRegionDescriptorStandard *region = NULL ;
153
+ GC_HeapRegionIteratorStandard regionIterator (extensions->getHeap ()->getHeapRegionManager ());
154
+ while (NULL != (region = regionIterator.nextRegion ())) {
155
+ MM_HeapRegionDescriptorStandardExtension *regionExtension = MM_ConfigurationDelegate::getHeapRegionDescriptorStandardExtension (env, region);
156
+ for (uintptr_t i = 0 ; i < regionExtension->_maxListIndex ; i++) {
157
+ MM_ContinuationObjectList *list = ®ionExtension->_continuationObjectLists [i];
158
+ if (!list->wasEmpty ()) {
159
+ if (J9MODRON_HANDLE_NEXT_WORK_UNIT (env)) {
160
+ omrobjectptr_t object = list->getPriorList ();
161
+ while (NULL != object) {
162
+ omrobjectptr_t forwardedPtr = _compactScheme->getForwardingPtr (object);
163
+ /* read the next link out of the moved copy of the object before we add it to the buffer */
164
+ object = extensions->accessBarrier ->getContinuationLink (forwardedPtr);
165
+ /* store the object in this thread's buffer. It will be flushed to the appropriate list when necessary. */
166
+ env->getGCEnvironment ()->_continuationObjectBuffer ->add (env, forwardedPtr);
167
+ }
168
+ }
169
+ }
170
+ }
171
+ }
172
+
173
+ /* restore everything to a flushed state before exiting */
174
+ env->getGCEnvironment ()->_continuationObjectBuffer ->flush (env);
175
+ }
0 commit comments