fix for forName selector: use the CHA in getRelevantParameters to resolve

the declared target of the call site.  This is needed to make sure
forName targets loaded with the Application loader get resolved to point
to the real metod reference for forName.

this issue actually manifested itself in the Kawa Chess program, and so
I have added an assertion to make sure this resolution is done properly.
This commit is contained in:
Julian Dolby 2018-10-18 22:25:21 -04:00
parent 533d392bda
commit 38c5de6160
2 changed files with 8 additions and 2 deletions

View File

@ -58,6 +58,9 @@ public class KawaCallGraphTest extends DynamicCallGraphTestBase {
Set<CGNode> append$v = getNodes(CG, "Lkawa/lang/Quote", "append$V", "([Ljava/lang/Object;)Ljava/lang/Object;");
assert ! append$v.isEmpty();
Set<CGNode> clinit = getNodes(CG, "Lkawa/lib/kawa/base", "<clinit>", "()V");
assert ! clinit.isEmpty();
}
@Test
@ -91,7 +94,9 @@ public class KawaCallGraphTest extends DynamicCallGraphTestBase {
MethodHandles.analyzeMethodHandles(options, builder);
return builder.makeCallGraph(options, null);
CallGraph cg = builder.makeCallGraph(options, null);
return cg;
}
}

View File

@ -131,7 +131,8 @@ class ClassFactoryContextSelector implements ContextSelector {
@Override
public IntSet getRelevantParameters(CGNode caller, CallSiteReference site) {
if (isClassFactory(site.getDeclaredTarget())) {
IMethod resolved = caller.getMethod().getClassHierarchy().resolveMethod(site.getDeclaredTarget());
if (isClassFactory(resolved != null? resolved.getReference(): site.getDeclaredTarget())) {
SSAAbstractInvokeInstruction[] invokeInstructions = caller.getIR().getCalls(site);
if (invokeInstructions.length >= 1) {
if (invokeInstructions[0].isStatic()) {