34
34
import com .oracle .svm .core .genscavenge .HeapChunk ;
35
35
import com .oracle .svm .core .genscavenge .ObjectHeaderImpl ;
36
36
import com .oracle .svm .core .genscavenge .Space ;
37
- import com .oracle .svm .core .genscavenge .remset .AlignedChunkRememberedSet ;
38
37
import com .oracle .svm .core .genscavenge .remset .BrickTable ;
39
- import com .oracle .svm .core .genscavenge .remset .FirstObjectTable ;
40
38
import com .oracle .svm .core .hub .LayoutEncoding ;
41
39
42
40
import jdk .graal .compiler .word .Word ;
@@ -58,9 +56,6 @@ public PlanningVisitor() {
58
56
public void init (Space space ) {
59
57
allocChunk = space .getFirstAlignedHeapChunk ();
60
58
allocPointer = AlignedHeapChunk .getObjectsStart (allocChunk );
61
- if (!allocChunk .getShouldSweepInsteadOfCompact ()) {
62
- FirstObjectTable .initializeTable (AlignedChunkRememberedSet .getFirstObjectTableStart (allocChunk ), AlignedChunkRememberedSet .getFirstObjectTableSize ());
63
- }
64
59
}
65
60
66
61
@ Override
@@ -120,43 +115,12 @@ public boolean visitChunk(AlignedHeapChunk.AlignedHeader chunk) {
120
115
}
121
116
122
117
objSeqSize = objSeqSize .add (objSize );
123
- if (!sweeping ) {
124
- if (allocPointer .add (objSeqSize ).aboveThan (AlignedHeapChunk .getObjectsEnd (allocChunk ))) {
125
- /* Out of space, move to the start of the next chunk. */
126
- allocChunk = HeapChunk .getNext (allocChunk );
127
- assert allocChunk .isNonNull ();
128
- assert !allocChunk .getShouldSweepInsteadOfCompact ();
129
- allocPointer = AlignedHeapChunk .getObjectsStart (allocChunk );
130
-
131
- /*
132
- * TODO: we should reset the FOT entries we already wrote in the last chunk
133
- * (but they should not be accessed, not even by heap verification)
134
- */
135
-
136
- /* Visit previous objects in sequence again to write new FOT entries. */
137
- FirstObjectTable .initializeTable (AlignedChunkRememberedSet .getFirstObjectTableStart (allocChunk ), AlignedChunkRememberedSet .getFirstObjectTableSize ());
138
- Pointer q = objSeq ;
139
- while (q .notEqual (p )) {
140
- UnsignedWord offset = q .subtract (objSeq );
141
- UnsignedWord size = LayoutEncoding .getSizeFromObjectInlineInGC (q .toObject ());
142
- FirstObjectTable .setTableForObject (AlignedChunkRememberedSet .getFirstObjectTableStart (allocChunk ), offset , offset .add (size ));
143
- q = q .add (size );
144
- }
145
- }
146
-
147
- Pointer allocEndOffset = allocPointer .add (objSeqSize ).subtract (AlignedHeapChunk .getObjectsStart (allocChunk ));
148
- FirstObjectTable .setTableForObject (AlignedChunkRememberedSet .getFirstObjectTableStart (allocChunk ), allocEndOffset .subtract (objSize ), allocEndOffset );
149
- }
150
118
151
119
} else { // not marked, i.e. not alive and start of a gap of yet unknown size
152
120
if (objSeqSize .notEqual (0 )) { // end of an object sequence
121
+ Pointer newAddress = sweeping ? objSeq : allocate (objSeqSize );
122
+ ObjectMoveInfo .setNewAddress (objSeq , newAddress );
153
123
ObjectMoveInfo .setObjectSeqSize (objSeq , objSeqSize );
154
- if (sweeping ) {
155
- ObjectMoveInfo .setNewAddress (objSeq , objSeq );
156
- } else {
157
- ObjectMoveInfo .setNewAddress (objSeq , allocPointer );
158
- allocPointer = allocPointer .add (objSeqSize ); // ensured enough memory above
159
- }
160
124
161
125
objSeqSize = Word .zero ();
162
126
@@ -175,15 +139,10 @@ public boolean visitChunk(AlignedHeapChunk.AlignedHeader chunk) {
175
139
176
140
if (gapSize .notEqual (0 )) { // truncate gap at chunk end
177
141
chunk .setTopOffset (chunk .getTopOffset ().subtract (gapSize ));
178
-
179
142
} else if (objSeqSize .notEqual (0 )) {
143
+ Pointer newAddress = sweeping ? objSeq : allocate (objSeqSize );
144
+ ObjectMoveInfo .setNewAddress (objSeq , newAddress );
180
145
ObjectMoveInfo .setObjectSeqSize (objSeq , objSeqSize );
181
- if (sweeping ) {
182
- ObjectMoveInfo .setNewAddress (objSeq , objSeq );
183
- } else {
184
- ObjectMoveInfo .setNewAddress (objSeq , allocPointer );
185
- allocPointer = allocPointer .add (objSeqSize ); // ensured enough memory above
186
- }
187
146
}
188
147
189
148
if (sweeping ) {
@@ -209,4 +168,18 @@ public boolean visitChunk(AlignedHeapChunk.AlignedHeader chunk) {
209
168
210
169
return true ;
211
170
}
171
+
172
+ private Pointer allocate (UnsignedWord size ) {
173
+ Pointer p = allocPointer ;
174
+ allocPointer = allocPointer .add (size );
175
+ if (allocPointer .aboveThan (AlignedHeapChunk .getObjectsEnd (allocChunk ))) {
176
+ allocChunk = HeapChunk .getNext (allocChunk );
177
+ assert allocChunk .isNonNull ();
178
+ assert !allocChunk .getShouldSweepInsteadOfCompact ();
179
+
180
+ p = AlignedHeapChunk .getObjectsStart (allocChunk );
181
+ allocPointer = p .add (size );
182
+ }
183
+ return p ;
184
+ }
212
185
}
0 commit comments