@@ -229,12 +229,16 @@ private void injectPriorLayerInfo(HostedType type, HostedDispatchTable dispatchT
229
229
if (priorInfo != null ) {
230
230
compareTypeInfo (dispatchTable , priorInfo );
231
231
dispatchTable .status = priorInfo .installed ? HubStatus .INSTALLED_PRIOR_LAYER : HubStatus .COMPUTED_PRIOR_LAYER ;
232
- for (int i = 0 ; i < dispatchTable .slots .length ; i ++) {
233
- HostedDispatchSlot slot = dispatchTable .slots [i ];
234
- PriorDispatchSlot priorSlot = priorInfo .slots [i ];
235
- if (priorSlot .status .isCompiled ()) {
236
- slot .status = SlotResolutionStatus .PRIOR_LAYER ;
237
- slot .symbol = priorSlot .slotSymbolName ;
232
+ if (priorInfo .installed ) {
233
+ // record symbol info for installed hubs
234
+ for (int i = 0 ; i < dispatchTable .slots .length ; i ++) {
235
+ HostedDispatchSlot slot = dispatchTable .slots [i ];
236
+ PriorDispatchSlot priorSlot = priorInfo .slots [i ];
237
+ if (priorSlot .status .isCompiled ()) {
238
+ slot .status = SlotResolutionStatus .PRIOR_LAYER ;
239
+ assert !priorSlot .slotSymbolName .equals (PriorDispatchSlot .INVALID_SYMBOL_NAME );
240
+ slot .symbol = priorSlot .slotSymbolName ;
241
+ }
238
242
}
239
243
}
240
244
}
@@ -415,7 +419,7 @@ public void defineDispatchTableSlotSymbols(ObjectFile objectFile, ObjectFile.Sec
415
419
* Next determine if any vtable symbols defined in prior layers now have a resolved target.
416
420
*/
417
421
for (HostedDispatchTable typeInfo : typeToDispatchTable .values ()) {
418
- if (typeInfo .status == HubStatus .INSTALLED_PRIOR_LAYER || typeInfo . status == HubStatus . COMPUTED_PRIOR_LAYER ) {
422
+ if (typeInfo .status == HubStatus .INSTALLED_PRIOR_LAYER ) {
419
423
for (HostedDispatchSlot slotInfo : typeInfo .slots ) {
420
424
if (slotInfo .status == SlotResolutionStatus .COMPUTED && slotInfo .resolvedMethod .isCompiled ()) {
421
425
/*
@@ -449,9 +453,6 @@ public void defineDispatchTableSlotSymbols(ObjectFile objectFile, ObjectFile.Sec
449
453
*/
450
454
if (ImageLayerBuildingSupport .buildingApplicationLayer ()) {
451
455
priorUnresolvedSymbols .forEach (symbol -> {
452
- if (symbol .isEmpty ()) {
453
- return ;
454
- }
455
456
if (!resolvedPriorVTableMap .containsKey (symbol )) {
456
457
CompilationResult result = codeCache .compilationResultFor (invalidMethod );
457
458
@@ -520,9 +521,9 @@ public PersistFlags preparePersist(ImageSingletonWriter writer) {
520
521
* Write out dispatch tables for persisted types.
521
522
*/
522
523
List <Integer > dispatchTableInts = new ArrayList <>();
524
+ List <Boolean > dispatchTableBooleans = new ArrayList <>();
523
525
List <Integer > dispatchSlotInts = new ArrayList <>();
524
526
List <String > dispatchSlotStrings = new ArrayList <>();
525
- List <Boolean > dispatchTableBooleans = new ArrayList <>();
526
527
int nextSlotIdx = 0 ;
527
528
for (HostedDispatchTable info : typeToDispatchTable .values ()) {
528
529
if (!layerWriter .isTypePersisted (info .type .getWrapped ())) {
@@ -538,9 +539,11 @@ public PersistFlags preparePersist(ImageSingletonWriter writer) {
538
539
localTargets .add (methodToOffsetMapper .apply (hMethod ));
539
540
}
540
541
542
+ boolean hubInstalled = info .status == HubStatus .INSTALLED_CURRENT_LAYER ;
541
543
if (info .slots != null ) {
542
544
for (var slotInfo : info .slots ) {
543
- dispatchSlotStrings .add (slotInfo .symbol );
545
+ var symbolName = hubInstalled ? slotInfo .symbol : PriorDispatchSlot .INVALID_SYMBOL_NAME ;
546
+ dispatchSlotStrings .add (symbolName );
544
547
dispatchSlotInts .add (slotInfo .slotNum );
545
548
dispatchSlotInts .add (slotInfo .status .ordinal ());
546
549
dispatchSlotInts .add (methodToOffsetMapper .apply (slotInfo .declaredMethod ));
@@ -559,29 +562,29 @@ public PersistFlags preparePersist(ImageSingletonWriter writer) {
559
562
dispatchTableInts .add (slotOffsets .size ());
560
563
dispatchTableInts .addAll (localTargets );
561
564
dispatchTableInts .addAll (slotOffsets );
562
- dispatchTableBooleans .add (info . type . getWrapped (). isReachable () );
565
+ dispatchTableBooleans .add (hubInstalled );
563
566
}
564
567
565
568
writer .writeIntList ("dispatchTableInts" , dispatchTableInts );
569
+ writer .writeBoolList ("dispatchTableBooleans" , dispatchTableBooleans );
566
570
writer .writeIntList ("dispatchSlotInts" , dispatchSlotInts );
567
571
writer .writeStringList ("dispatchSlotStrings" , dispatchSlotStrings );
568
572
writer .writeBoolList ("methodBooleans" , methodBooleans );
569
573
writer .writeIntList ("methodInts" , methodInts );
570
574
writer .writeStringList ("methodStrings" , methodStrings );
571
- writer .writeBoolList ("dispatchTableBooleans" , dispatchTableBooleans );
572
575
573
576
return PersistFlags .CREATE ;
574
577
}
575
578
576
579
@ SuppressWarnings ("unused" )
577
580
public static Object createFromLoader (ImageSingletonLoader loader ) {
578
581
List <Integer > dispatchTableInts = loader .readIntList ("dispatchTableInts" );
582
+ List <Boolean > dispatchTableBooleans = loader .readBoolList ("dispatchTableBooleans" );
579
583
List <Integer > dispatchSlotInts = loader .readIntList ("dispatchSlotInts" );
580
584
List <String > dispatchSlotStrings = loader .readStringList ("dispatchSlotStrings" );
581
585
List <Boolean > methodBooleans = loader .readBoolList ("methodBooleans" );
582
586
List <Integer > methodInts = loader .readIntList ("methodInts" );
583
587
List <String > methodStrings = loader .readStringList ("methodStrings" );
584
- List <Boolean > dispatchTableBooleans = loader .readBoolList ("dispatchTableBooleans" );
585
588
586
589
Set <String > unresolvedSymbols = new HashSet <>();
587
590
Map <Integer , PriorDispatchTable > priorTypes = new HashMap <>();
@@ -616,10 +619,6 @@ public static Object createFromLoader(ImageSingletonLoader loader) {
616
619
resolvedMethod = priorMethods .get (index );
617
620
}
618
621
619
- if (status == SlotResolutionStatus .UNRESOLVED || status == SlotResolutionStatus .NOT_COMPILED ) {
620
- unresolvedSymbols .add (slotSymbolName );
621
- }
622
-
623
622
var slotInfo = new PriorDispatchSlot (declaredMethod , resolvedMethod , slotNum , status , slotSymbolName );
624
623
priorDispatchSlots .add (slotInfo );
625
624
}
@@ -628,7 +627,7 @@ public static Object createFromLoader(ImageSingletonLoader loader) {
628
627
boolIterator = dispatchTableBooleans .iterator ();
629
628
while (intIterator .hasNext ()) {
630
629
int typeId = intIterator .next ();
631
- boolean installed = boolIterator .next ();
630
+ boolean hubInstalled = boolIterator .next ();
632
631
int locallyDeclaredMethodsSize = intIterator .next ();
633
632
int allSlotsSize = intIterator .next ();
634
633
PriorDispatchMethod [] locallyDeclaredSlots = new PriorDispatchMethod [locallyDeclaredMethodsSize ];
@@ -638,9 +637,17 @@ public static Object createFromLoader(ImageSingletonLoader loader) {
638
637
}
639
638
for (int i = 0 ; i < allSlotsSize ; i ++) {
640
639
dispatchTableSlots [i ] = priorDispatchSlots .get (intIterator .next ());
640
+ if (hubInstalled ) {
641
+ var status = dispatchTableSlots [i ].status ;
642
+ if (status == SlotResolutionStatus .UNRESOLVED || status == SlotResolutionStatus .NOT_COMPILED ) {
643
+ assert !dispatchTableSlots [i ].slotSymbolName .equals (PriorDispatchSlot .INVALID_SYMBOL_NAME );
644
+ unresolvedSymbols .add (dispatchTableSlots [i ].slotSymbolName );
645
+ }
646
+
647
+ }
641
648
}
642
649
643
- var priorDispatchTable = new PriorDispatchTable (typeId , installed , locallyDeclaredSlots , dispatchTableSlots );
650
+ var priorDispatchTable = new PriorDispatchTable (typeId , hubInstalled , locallyDeclaredSlots , dispatchTableSlots );
644
651
Object prev = priorTypes .put (typeId , priorDispatchTable );
645
652
assert prev == null : prev ;
646
653
@@ -715,6 +722,7 @@ record PriorDispatchSlot(
715
722
PriorDispatchMethod declaredMethod , PriorDispatchMethod resolvedMethod ,
716
723
int slotNum , SlotResolutionStatus status , String slotSymbolName ) {
717
724
static final int UNKNOWN_METHOD = -1 ;
725
+ static final String INVALID_SYMBOL_NAME = "invalid" ;
718
726
}
719
727
720
728
/**
0 commit comments