@@ -313,10 +313,21 @@ protected AnalysisMethod(AnalysisMethod original, MultiMethodKey multiMethodKey)
313
313
this .enableReachableInCurrentLayer = original .enableReachableInCurrentLayer ;
314
314
}
315
315
316
+ /**
317
+ * This method should not be used directly, except to set the {@link CompilationBehavior} from a
318
+ * previous layer. To set a new {@link CompilationBehavior}, please use the associated setter.
319
+ */
316
320
public void setCompilationBehavior (CompilationBehavior compilationBehavior ) {
321
+ assert getUniverse ().getBigbang ().getHostVM ().buildingImageLayer () : "The method compilation behavior can only be set in layered images" ;
317
322
this .compilationBehavior = compilationBehavior ;
318
323
}
319
324
325
+ private void setNewCompilationBehavior (CompilationBehavior compilationBehavior ) {
326
+ assert (!isInBaseLayer && this .compilationBehavior == CompilationBehavior .DEFAULT ) || this .compilationBehavior == compilationBehavior : "The method was already assigned " +
327
+ this .compilationBehavior + ", but trying to assign " + compilationBehavior ;
328
+ setCompilationBehavior (compilationBehavior );
329
+ }
330
+
320
331
public CompilationBehavior getCompilationBehavior () {
321
332
return compilationBehavior ;
322
333
}
@@ -327,11 +338,11 @@ public CompilationBehavior getCompilationBehavior() {
327
338
*/
328
339
public void setFullyDelayedToApplicationLayer () {
329
340
HostVM hostVM = getUniverse ().getBigbang ().getHostVM ();
330
- AnalysisError .guarantee (hostVM .buildingImageLayer (), "Methods can only be delayed in layered images" );
341
+ AnalysisError .guarantee (hostVM .buildingImageLayer (), "Methods can only be delayed in layered images: %s" , this );
331
342
AnalysisError .guarantee (parsedGraphCacheState .get () == GraphCacheEntry .UNPARSED , "The method %s was marked as delayed to the application layer but was already parsed" , this );
332
343
AnalysisError .guarantee (!hostVM .hasAlwaysInlineDirective (this ), "Method %s with an always inline directive cannot be delayed to the application layer as such methods cannot be inlined" , this );
333
344
AnalysisError .guarantee (isConcrete (), "Method %s is not concrete and cannot be delayed to the application layer" , this );
334
- this . compilationBehavior = CompilationBehavior .FULLY_DELAYED_TO_APPLICATION_LAYER ;
345
+ setNewCompilationBehavior ( CompilationBehavior .FULLY_DELAYED_TO_APPLICATION_LAYER ) ;
335
346
}
336
347
337
348
/**
@@ -342,6 +353,22 @@ public boolean isDelayed() {
342
353
return compilationBehavior == CompilationBehavior .FULLY_DELAYED_TO_APPLICATION_LAYER && buildingSharedLayer ;
343
354
}
344
355
356
+ public void setPinnedToInitialLayer () {
357
+ BigBang bigbang = getUniverse ().getBigbang ();
358
+ AnalysisError .guarantee (bigbang .getHostVM ().buildingInitialLayer (), "Methods can only be pinned to the initial layer: %s" , this );
359
+ boolean nonAbstractInstanceClass = !declaringClass .isArray () && declaringClass .isInstanceClass () && !declaringClass .isAbstract ();
360
+ AnalysisError .guarantee (nonAbstractInstanceClass , "Only methods from non abstract instance class can be delayed: %s" , this );
361
+ bigbang .forcedAddRootMethod (this , true , "Method is pinned to the initial layer" );
362
+ if (!isStatic ()) {
363
+ declaringClass .registerAsInstantiated (this + " is pinned to the initial layer" );
364
+ }
365
+ setNewCompilationBehavior (CompilationBehavior .PINNED_TO_INITIAL_LAYER );
366
+ }
367
+
368
+ public boolean isPinnedToInitialLayer () {
369
+ return compilationBehavior == CompilationBehavior .PINNED_TO_INITIAL_LAYER ;
370
+ }
371
+
345
372
private static String createName (ResolvedJavaMethod wrapped , MultiMethodKey multiMethodKey ) {
346
373
String aName = wrapped .getName ();
347
374
if (multiMethodKey != ORIGINAL_METHOD ) {
@@ -1429,9 +1456,9 @@ public enum CompilationBehavior {
1429
1456
DEFAULT ,
1430
1457
1431
1458
/**
1432
- * Method is pinned to a specific shared layer, meaning it has to be analyzed and compiled
1433
- * in this specific layer. A method can only be pinned to a shared layer.
1459
+ * Method is pinned to the initial layer, meaning it has to be analyzed and compiled in this
1460
+ * specific layer.
1434
1461
*/
1435
- PINNED_TO_SHARED_LAYER ,
1462
+ PINNED_TO_INITIAL_LAYER ,
1436
1463
}
1437
1464
}
0 commit comments