@@ -108,7 +108,7 @@ public final class HeapImpl extends Heap {
108
108
private final ObjectHeaderImpl objectHeaderImpl = new ObjectHeaderImpl ();
109
109
private final GCImpl gcImpl ;
110
110
private final RuntimeCodeInfoGCSupportImpl runtimeCodeInfoGcSupport ;
111
- private final ImageHeapInfo imageHeapInfo = new ImageHeapInfo ();
111
+ private final ImageHeapInfo firstImageHeapInfo = new ImageHeapInfo ();
112
112
private final HeapAccounting accounting = new HeapAccounting ();
113
113
114
114
/** Head of the linked list of currently pending (ready to be enqueued) {@link Reference}s. */
@@ -143,8 +143,8 @@ public static HeapImpl getHeapImpl() {
143
143
}
144
144
145
145
@ Fold
146
- public static ImageHeapInfo getImageHeapInfo () {
147
- return getHeapImpl ().imageHeapInfo ;
146
+ public static ImageHeapInfo getFirstImageHeapInfo () {
147
+ return getHeapImpl ().firstImageHeapInfo ;
148
148
}
149
149
150
150
@ Fold
@@ -179,7 +179,12 @@ public boolean isInPrimaryImageHeap(Object obj) {
179
179
@ Override
180
180
@ Uninterruptible (reason = "Called from uninterruptible code." , mayBeInlined = true )
181
181
public boolean isInPrimaryImageHeap (Pointer objPointer ) {
182
- return imageHeapInfo .isInImageHeap (objPointer );
182
+ for (ImageHeapInfo info = firstImageHeapInfo ; info != null ; info = info .next ) {
183
+ if (info .isInImageHeap (objPointer )) {
184
+ return true ;
185
+ }
186
+ }
187
+ return false ;
183
188
}
184
189
185
190
@ Override
@@ -283,7 +288,9 @@ void logChunks(Log log) {
283
288
284
289
void logImageHeapPartitionBoundaries (Log log ) {
285
290
log .string ("Native image heap boundaries:" ).indent (true );
286
- imageHeapInfo .print (log );
291
+ for (ImageHeapInfo info = firstImageHeapInfo ; info != null ; info = info .next ) {
292
+ info .print (log );
293
+ }
287
294
log .indent (false );
288
295
289
296
if (AuxiliaryImageHeap .isPresent ()) {
@@ -326,22 +333,28 @@ static void logZapValues(Log log) {
326
333
@ Override
327
334
@ Uninterruptible (reason = "Called from uninterruptible code." , mayBeInlined = true )
328
335
public int getClassCount () {
329
- return imageHeapInfo .dynamicHubCount ;
336
+ int count = firstImageHeapInfo .dynamicHubCount ;
337
+ for (ImageHeapInfo info = firstImageHeapInfo .next ; info != null ; info = info .next ) {
338
+ count += info .dynamicHubCount ;
339
+ }
340
+ return count ;
330
341
}
331
342
332
343
@ Override
333
344
protected List <Class <?>> getAllClasses () {
334
345
/* Two threads might race to set classList, but they compute the same result. */
335
346
if (classList == null ) {
336
347
ArrayList <Class <?>> list = new ArrayList <>(1024 );
337
- ImageHeapWalker .walkRegions (imageHeapInfo , new ClassListBuilderVisitor (list ));
348
+ for (ImageHeapInfo info = firstImageHeapInfo ; info != null ; info = info .next ) {
349
+ ImageHeapWalker .walkRegions (info , new ClassListBuilderVisitor (list ));
350
+ }
338
351
list .trimToSize ();
339
352
340
353
/* Ensure that other threads see consistent values once the list is published. */
341
354
MembarNode .memoryBarrier (MembarNode .FenceKind .STORE_STORE );
342
355
classList = list ;
343
356
}
344
- assert classList .size () == imageHeapInfo . dynamicHubCount ;
357
+ assert classList .size () == getClassCount () ;
345
358
return classList ;
346
359
}
347
360
@@ -429,11 +442,15 @@ public int getImageHeapOffsetInAddressSpace() {
429
442
@ Override
430
443
public boolean walkImageHeapObjects (ObjectVisitor visitor ) {
431
444
VMOperation .guaranteeInProgressAtSafepoint ("Must only be called at a safepoint" );
432
- if (visitor != null ) {
433
- return ImageHeapWalker .walkImageHeapObjects (imageHeapInfo , visitor ) &&
434
- (!AuxiliaryImageHeap .isPresent () || AuxiliaryImageHeap .singleton ().walkObjects (visitor ));
445
+ if (visitor == null ) {
446
+ return true ;
435
447
}
436
- return true ;
448
+ for (ImageHeapInfo info = firstImageHeapInfo ; info != null ; info = info .next ) {
449
+ if (!ImageHeapWalker .walkImageHeapObjects (info , visitor )) {
450
+ return false ;
451
+ }
452
+ }
453
+ return !AuxiliaryImageHeap .isPresent () || AuxiliaryImageHeap .singleton ().walkObjects (visitor );
437
454
}
438
455
439
456
@ Override
@@ -694,28 +711,32 @@ static Pointer getImageHeapStart() {
694
711
}
695
712
696
713
private boolean printLocationInfo (Log log , Pointer ptr , boolean allowJavaHeapAccess , boolean allowUnsafeOperations ) {
697
- if (imageHeapInfo .isInReadOnlyPrimitivePartition (ptr )) {
698
- log .string ("points into the image heap (read-only primitives)" );
699
- return true ;
700
- } else if (imageHeapInfo .isInReadOnlyReferencePartition (ptr )) {
701
- log .string ("points into the image heap (read-only references)" );
702
- return true ;
703
- } else if (imageHeapInfo .isInReadOnlyRelocatablePartition (ptr )) {
704
- log .string ("points into the image heap (read-only relocatables)" );
705
- return true ;
706
- } else if (imageHeapInfo .isInWritablePrimitivePartition (ptr )) {
707
- log .string ("points into the image heap (writable primitives)" );
708
- return true ;
709
- } else if (imageHeapInfo .isInWritableReferencePartition (ptr )) {
710
- log .string ("points into the image heap (writable references)" );
711
- return true ;
712
- } else if (imageHeapInfo .isInWritableHugePartition (ptr )) {
713
- log .string ("points into the image heap (writable huge)" );
714
- return true ;
715
- } else if (imageHeapInfo .isInReadOnlyHugePartition (ptr )) {
716
- log .string ("points into the image heap (read-only huge)" );
717
- return true ;
718
- } else if (AuxiliaryImageHeap .isPresent () && AuxiliaryImageHeap .singleton ().containsObject (ptr )) {
714
+ for (ImageHeapInfo info = firstImageHeapInfo ; info != null ; info = info .next ) {
715
+ if (info .isInReadOnlyPrimitivePartition (ptr )) {
716
+ log .string ("points into the image heap (read-only primitives)" );
717
+ return true ;
718
+ } else if (info .isInReadOnlyReferencePartition (ptr )) {
719
+ log .string ("points into the image heap (read-only references)" );
720
+ return true ;
721
+ } else if (info .isInReadOnlyRelocatablePartition (ptr )) {
722
+ log .string ("points into the image heap (read-only relocatables)" );
723
+ return true ;
724
+ } else if (info .isInWritablePrimitivePartition (ptr )) {
725
+ log .string ("points into the image heap (writable primitives)" );
726
+ return true ;
727
+ } else if (info .isInWritableReferencePartition (ptr )) {
728
+ log .string ("points into the image heap (writable references)" );
729
+ return true ;
730
+ } else if (info .isInWritableHugePartition (ptr )) {
731
+ log .string ("points into the image heap (writable huge)" );
732
+ return true ;
733
+ } else if (info .isInReadOnlyHugePartition (ptr )) {
734
+ log .string ("points into the image heap (read-only huge)" );
735
+ return true ;
736
+ }
737
+ }
738
+
739
+ if (AuxiliaryImageHeap .isPresent () && AuxiliaryImageHeap .singleton ().containsObject (ptr )) {
719
740
log .string ("points into the auxiliary image heap" );
720
741
return true ;
721
742
} else if (printTlabInfo (log , ptr , CurrentIsolate .getCurrentThread ())) {
0 commit comments