@@ -739,24 +739,29 @@ private void initializeBaseLayerTypeBeforePublishing(AnalysisType type, Persiste
739739 public void initializeBaseLayerType (AnalysisType type ) {
740740 VMError .guarantee (type .isInBaseLayer ());
741741 PersistedAnalysisType .Reader td = findType (getBaseLayerTypeId (type ));
742- registerFlag (td .getIsInstantiated (), _ -> type .registerAsInstantiated (PERSISTED ));
743- registerFlag (td .getIsUnsafeAllocated (), _ -> type .registerAsUnsafeAllocated (PERSISTED ));
744- registerFlag (td .getIsReachable (), _ -> type .registerAsReachable (PERSISTED ));
742+ postTask (td .getIsInstantiated (), _ -> type .registerAsInstantiated (PERSISTED ));
743+ postTask (td .getIsUnsafeAllocated (), _ -> type .registerAsUnsafeAllocated (PERSISTED ));
744+ postTask (td .getIsReachable (), _ -> type .registerAsReachable (PERSISTED ));
745745
746- if (!td .getIsInstantiated () && td .getIsAnySubtypeInstantiated ()) {
746+ if (td .getIsAnySubtypeInstantiated ()) {
747+ /*
748+ * Once a base layer type is loaded, loading all its instantiated subtypes ensures that
749+ * the application layer typestate is coherent with the base layer typestate. Otherwise,
750+ * unwanted optimizations could occur as the typestate would not contain some missed
751+ * types from the base layer.
752+ */
747753 var subTypesReader = td .getSubTypes ();
748754 for (int i = 0 ; i < subTypesReader .size (); ++i ) {
749755 int tid = subTypesReader .get (i );
750756 var subTypeReader = findType (tid );
751- if (subTypeReader .getIsInstantiated ()) {
752- registerFlag (true , _ -> getAnalysisTypeForBaseLayerId (subTypeReader .getId ()));
753- }
757+ /* Only load instantiated subtypes. */
758+ postTask (subTypeReader .getIsInstantiated (), _ -> getAnalysisTypeForBaseLayerId (subTypeReader .getId ()));
754759 }
755760 }
756761 }
757762
758- private void registerFlag (boolean flag , DebugContextRunnable task ) {
759- if (flag ) {
763+ private void postTask (boolean condition , DebugContextRunnable task ) {
764+ if (condition ) {
760765 if (universe .getBigbang () != null ) {
761766 universe .getBigbang ().postTask (task );
762767 } else {
@@ -1022,11 +1027,11 @@ public void addBaseLayerMethod(AnalysisMethod analysisMethod) {
10221027 methods .putIfAbsent (analysisMethod .getId (), analysisMethod );
10231028
10241029 PersistedAnalysisMethod .Reader md = getMethodData (analysisMethod );
1025- registerFlag (md .getIsVirtualRootMethod (), _ -> analysisMethod .registerAsVirtualRootMethod (PERSISTED ));
1026- registerFlag (md .getIsDirectRootMethod (), _ -> analysisMethod .registerAsDirectRootMethod (PERSISTED ));
1027- registerFlag (md .getIsInvoked (), _ -> analysisMethod .registerAsInvoked (PERSISTED ));
1028- registerFlag (md .getIsImplementationInvoked (), _ -> analysisMethod .registerAsImplementationInvoked (PERSISTED ));
1029- registerFlag (md .getIsIntrinsicMethod (), _ -> analysisMethod .registerAsIntrinsicMethod (PERSISTED ));
1030+ postTask (md .getIsVirtualRootMethod (), _ -> analysisMethod .registerAsVirtualRootMethod (PERSISTED ));
1031+ postTask (md .getIsDirectRootMethod (), _ -> analysisMethod .registerAsDirectRootMethod (PERSISTED ));
1032+ postTask (md .getIsInvoked (), _ -> analysisMethod .registerAsInvoked (PERSISTED ));
1033+ postTask (md .getIsImplementationInvoked (), _ -> analysisMethod .registerAsImplementationInvoked (PERSISTED ));
1034+ postTask (md .getIsIntrinsicMethod (), _ -> analysisMethod .registerAsIntrinsicMethod (PERSISTED ));
10301035
10311036 AnalysisMethod .CompilationBehavior compilationBehavior = AnalysisMethod .CompilationBehavior .values ()[md .getCompilationBehaviorOrdinal ()];
10321037 analysisMethod .setCompilationBehavior (compilationBehavior );
@@ -1309,17 +1314,17 @@ public void initializeBaseLayerField(AnalysisField analysisField) {
13091314 if (!analysisField .isStatic () && (isAccessed || isRead )) {
13101315 analysisField .getDeclaringClass ().getInstanceFields (true );
13111316 }
1312- registerFlag (isAccessed , _ -> {
1317+ postTask (isAccessed , _ -> {
13131318 analysisField .injectDeclaredType ();
13141319 analysisField .registerAsAccessed (PERSISTED );
13151320 });
1316- registerFlag (isRead , _ -> analysisField .registerAsRead (PERSISTED ));
1317- registerFlag (fieldData .getIsWritten (), _ -> {
1321+ postTask (isRead , _ -> analysisField .registerAsRead (PERSISTED ));
1322+ postTask (fieldData .getIsWritten (), _ -> {
13181323 analysisField .injectDeclaredType ();
13191324 analysisField .registerAsWritten (PERSISTED );
13201325 });
1321- registerFlag (fieldData .getIsFolded (), _ -> analysisField .registerAsFolded (PERSISTED ));
1322- registerFlag (fieldData .getIsUnsafeAccessed (), _ -> analysisField .registerAsUnsafeAccessed (PERSISTED ));
1326+ postTask (fieldData .getIsFolded (), _ -> analysisField .registerAsFolded (PERSISTED ));
1327+ postTask (fieldData .getIsUnsafeAccessed (), _ -> analysisField .registerAsUnsafeAccessed (PERSISTED ));
13231328
13241329 /*
13251330 * Inject the base layer position. If the position computed for this layer, either before
0 commit comments