Skip to content

Commit

Permalink
[GR-19152] Fix SharedBytecodeParser NPE when intrinsified method was …
Browse files Browse the repository at this point in the history
…not parsed during analysis.

PullRequest: graal/4881
  • Loading branch information
cstancu committed Nov 16, 2019
2 parents 9b58bf5 + 1e2e576 commit a0f8df2
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4166,11 +4166,15 @@ private String unresolvedMethodAssertionMessage(JavaMethod result) {

private JavaMethod lookupMethod(int cpi, int opcode) {
maybeEagerlyResolve(cpi, opcode);
JavaMethod result = constantPool.lookupMethod(cpi, opcode);
JavaMethod result = lookupMethodInPool(cpi, opcode);
assert !graphBuilderConfig.unresolvedIsError() || result instanceof ResolvedJavaMethod : unresolvedMethodAssertionMessage(result);
return result;
}

protected JavaMethod lookupMethodInPool(int cpi, int opcode) {
return constantPool.lookupMethod(cpi, opcode);
}

protected JavaField lookupField(int cpi, int opcode) {
maybeEagerlyResolve(cpi, opcode);
JavaField result = constantPool.lookupField(cpi, method, opcode);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -306,7 +306,8 @@ public void addObserver(BigBang bb, TypeFlow<?> observer) {

private boolean addObserver(BigBang bb, TypeFlow<?> observer, boolean triggerUpdate, boolean registerObservees) {
if (doAddObserver(bb, observer, registerObservees)) {
if (triggerUpdate) {
/* Only trigger an observer update if this flow has a non-empty state. */
if (triggerUpdate && !this.state.isEmpty()) {
/*
* Notify the observer after registering. This flow might have already reached a
* fixed point and might never notify its observers otherwise.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -758,7 +758,18 @@ private void defaultParseFunction(DebugContext debug, HostedMethod method, Compi
ensureParsed(invokeImplementation, new VirtualCallReason(method, invokeImplementation, reason));
}
} else {
if (invokeTarget.wrapped.isImplementationInvoked()) {
/*
* Direct calls to instance methods (invokespecial bytecode or devirtualized
* calls) can go to methods that are unreachable if the receiver is always
* null. At this time, we do not know the receiver types, so we filter such
* invokes by looking at the reachability status from the point of view of
* the static analysis. Note that we cannot use "isImplementationInvoked"
* because (for historic reasons) it also returns true if a method has a
* graph builder plugin registered. All graph builder plugins are already
* applied during parsing before we reach this point, so we look at the
* "simple" implementation invoked status.
*/
if (invokeTarget.wrapped.isSimplyImplementationInvoked()) {
handleSpecialization(method, targetNode, invokeTarget, invokeTarget);
ensureParsed(invokeTarget, new DirectCallReason(method, reason));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import com.oracle.svm.core.option.SubstrateOptionsParser;
import com.oracle.svm.core.util.UserError;
import com.oracle.svm.core.util.UserError.UserException;
import com.oracle.svm.core.util.VMError;
import com.oracle.svm.hosted.ExceptionSynthesizer;
import com.oracle.svm.hosted.HostedConfiguration;
import com.oracle.svm.hosted.NativeImageOptions;
Expand Down Expand Up @@ -101,6 +102,15 @@ private boolean checkWordTypes() {
return getWordTypes() != null;
}

@Override
protected JavaMethod lookupMethodInPool(int cpi, int opcode) {
JavaMethod result = super.lookupMethodInPool(cpi, opcode);
if (result == null) {
throw VMError.shouldNotReachHere("Discovered an unresolved calee while parsing " + method.asStackTraceElement(bci()) + '.');
}
return result;
}

@Override
protected void maybeEagerlyResolve(int cpi, int bytecode) {
try {
Expand Down

0 comments on commit a0f8df2

Please sign in to comment.