38
38
import java .util .function .BiConsumer ;
39
39
import java .util .function .Consumer ;
40
40
41
- import com .oracle .graal .pointsto .util .AtomicUtils ;
42
41
import org .graalvm .nativeimage .hosted .Feature .DuringAnalysisAccess ;
43
42
44
43
import com .oracle .graal .pointsto .BigBang ;
47
46
import com .oracle .graal .pointsto .reports .ReportUtils ;
48
47
import com .oracle .graal .pointsto .util .AnalysisError ;
49
48
import com .oracle .graal .pointsto .util .AnalysisFuture ;
49
+ import com .oracle .graal .pointsto .util .AtomicUtils ;
50
50
import com .oracle .graal .pointsto .util .ConcurrentLightHashSet ;
51
51
52
52
import jdk .graal .compiler .debug .GraalError ;
@@ -309,8 +309,7 @@ private void build() {
309
309
while (!reasonStack .isEmpty ()) {
310
310
boolean expanded ;
311
311
Object top = reasonStack .peekLast ();
312
- if (top instanceof CompoundReason ) {
313
- CompoundReason compoundReason = (CompoundReason ) top ;
312
+ if (top instanceof CompoundReason compoundReason ) {
314
313
if (compoundReason .isFirst ()) {
315
314
compoundReason .storeCurrentIndent (indent );
316
315
}
@@ -378,23 +377,20 @@ private boolean processReason(Object current, String prefix) {
378
377
if (current instanceof String ) {
379
378
reasonStr = "str: " + current ;
380
379
381
- } else if (current instanceof AnalysisMethod ) {
382
- AnalysisMethod method = (AnalysisMethod ) current ;
383
- reasonStr = "at " + method .format ("%f method %H.%n(%p)" ) + ", " + methodReasonStr (method );
384
- expanded = methodReason ((AnalysisMethod ) current );
380
+ } else if (current instanceof AnalysisMethod method ) {
381
+ reasonStr = "at " + method .format ("%f method %H.%n(%p)" ) + " " + methodReasonStr (method );
382
+ expanded = methodReason (method );
385
383
386
- } else if (current instanceof AnalysisField ) {
387
- AnalysisField field = (AnalysisField ) current ;
384
+ } else if (current instanceof AnalysisField field ) {
388
385
reasonStr = "field " + field .format ("%H.%n" ) + " " + fieldReasonStr (field );
389
386
expanded = fieldReason (field );
390
387
391
- } else if (current instanceof AnalysisType ) {
392
- AnalysisType type = (AnalysisType ) current ;
393
- reasonStr = "type " + (type ).toJavaName () + " " + typeReasonStr (type );
388
+ } else if (current instanceof AnalysisType type ) {
389
+ reasonStr = "type " + type .toJavaName () + " " + typeReasonStr (type );
394
390
expanded = typeReason (type );
395
391
396
- } else if (current instanceof ResolvedJavaMethod ) {
397
- reasonStr = (( ResolvedJavaMethod ) current ) .format ("%f method %H.%n" );
392
+ } else if (current instanceof ResolvedJavaMethod method ) {
393
+ reasonStr = method .format ("%f method %H.%n" );
398
394
399
395
} else if (current instanceof ResolvedJavaField field ) {
400
396
/*
@@ -408,26 +404,23 @@ private boolean processReason(Object current, String prefix) {
408
404
if (analysisField != null ) {
409
405
return processReason (analysisField , prefix );
410
406
} else {
411
- reasonStr = "field " + (( ResolvedJavaField ) current ) .format ("%H.%n" );
407
+ reasonStr = "field " + field .format ("%H.%n" );
412
408
}
413
409
414
410
} else if (current instanceof ResolvedJavaType ) {
415
411
reasonStr = "type " + ((ResolvedJavaType ) current ).getName ();
416
412
417
- } else if (current instanceof BytecodePosition ) {
418
- BytecodePosition position = (BytecodePosition ) current ;
413
+ } else if (current instanceof BytecodePosition position ) {
419
414
ResolvedJavaMethod method = position .getMethod ();
420
415
reasonStr = "at " + method .format ("%f" ) + " method " + method .asStackTraceElement (position .getBCI ()) + ", " + methodReasonStr (method );
421
416
expanded = methodReason (position .getMethod ());
422
417
423
- } else if (current instanceof MethodParsing ) {
424
- MethodParsing methodParsing = (MethodParsing ) current ;
418
+ } else if (current instanceof MethodParsing methodParsing ) {
425
419
AnalysisMethod method = methodParsing .getMethod ();
426
420
reasonStr = "at " + method .format ("%f method %H.%n(%p)" ) + ", " + methodReasonStr (method );
427
421
expanded = methodReason (methodParsing .getMethod ());
428
422
429
- } else if (current instanceof ObjectScanner .ScanReason ) {
430
- ObjectScanner .ScanReason scanReason = (ObjectScanner .ScanReason ) current ;
423
+ } else if (current instanceof ObjectScanner .ScanReason scanReason ) {
431
424
reasonStr = scanReason .toString (bb );
432
425
expanded = maybeExpandReasonStack (scanReason .getPrevious ());
433
426
@@ -447,6 +440,8 @@ private void print(String prefix, String reasonStr) {
447
440
private boolean typeReason (AnalysisType type ) {
448
441
if (type .isInstantiated ()) {
449
442
return maybeExpandReasonStack (type .getInstantiatedReason ());
443
+ } else if (type .isAnySubtypeInstantiated ()) {
444
+ return maybeExpandReasonStack (type .getAnyInstantiatedSubtype ());
450
445
} else {
451
446
return maybeExpandReasonStack (type .getReachableReason ());
452
447
}
@@ -455,6 +450,8 @@ private boolean typeReason(AnalysisType type) {
455
450
private static String typeReasonStr (AnalysisType type ) {
456
451
if (type .isInstantiated ()) {
457
452
return "is marked as instantiated" ;
453
+ } else if (type .isAnySubtypeInstantiated ()) {
454
+ return "has a subtype marked as instantiated" ;
458
455
}
459
456
return "is reachable" ;
460
457
}
@@ -489,8 +486,7 @@ private static String fieldReasonStr(AnalysisField field) {
489
486
}
490
487
491
488
private boolean methodReason (ResolvedJavaMethod method ) {
492
- if (method instanceof AnalysisMethod ) {
493
- AnalysisMethod aMethod = (AnalysisMethod ) method ;
489
+ if (method instanceof AnalysisMethod aMethod ) {
494
490
if (aMethod .isSimplyImplementationInvoked ()) {
495
491
if (aMethod .isStatic ()) {
496
492
return maybeExpandReasonStack (aMethod .getImplementationInvokedReason ());
@@ -522,29 +518,28 @@ private boolean maybeExpandReasonStack(Object reason) {
522
518
}
523
519
524
520
private static String methodReasonStr (ResolvedJavaMethod method ) {
525
- if (method instanceof AnalysisMethod ) {
526
- AnalysisMethod aMethod = (AnalysisMethod ) method ;
521
+ if (method instanceof AnalysisMethod aMethod ) {
527
522
if (aMethod .isSimplyImplementationInvoked ()) {
528
523
if (aMethod .isStatic ()) {
529
- return "implementation invoked" ;
524
+ return "is implementation invoked" ;
530
525
} else {
531
526
/* For virtual methods we follow back type reachability. */
532
527
AnalysisType declaringClass = aMethod .getDeclaringClass ();
533
528
assert declaringClass .isInstantiated () || declaringClass .isAbstract () ||
534
529
(declaringClass .isInterface () && aMethod .isDefault ()) || declaringClass .isReachable () : declaringClass + " is not reachable" ;
535
- return "implementation invoked" ;
530
+ return "is implementation invoked" ;
536
531
}
537
532
} else if (aMethod .isInlined ()) {
538
533
if (aMethod .isStatic ()) {
539
- return "inlined" ;
534
+ return "is inlined" ;
540
535
} else {
541
536
AnalysisType declaringClass = aMethod .getDeclaringClass ();
542
537
assert declaringClass .isInstantiated () || declaringClass .isAbstract () ||
543
538
(declaringClass .isInterface () && aMethod .isDefault ()) || declaringClass .isReachable () : declaringClass + " is not reachable" ;
544
- return "inlined" ;
539
+ return "is inlined" ;
545
540
}
546
541
} else if (aMethod .isIntrinsicMethod ()) {
547
- return "intrinsified" ;
542
+ return "is intrinsified" ;
548
543
}
549
544
}
550
545
return "<no available reason>" ;
0 commit comments