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:
parent
533d392bda
commit
38c5de6160
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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()) {
|
||||
|
|
Loading…
Reference in New Issue