Skip to content

Commit

Permalink
Remove ROOT_COMPILATION and ROOT_COMPILATION_ENCODING
Browse files Browse the repository at this point in the history
  • Loading branch information
tkrodriguez committed Feb 14, 2022
1 parent e4b3ad5 commit 3e0acfa
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 71 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -567,24 +567,21 @@ static class InliningScope implements AutoCloseable {

@Override
public void close() {
processPlaceholderFrameStates(false);
processPlaceholderFrameStates();
}

/**
* Fixes up the {@linkplain BytecodeFrame#isPlaceholderBci(int) placeholder} frame states
* added to the graph while parsing/inlining the intrinsic for which this object exists.
*/
protected void processPlaceholderFrameStates(boolean isCompilationRoot) {
protected void processPlaceholderFrameStates() {
StructuredGraph graph = parser.getGraph();
graph.getDebug().dump(DebugContext.DETAILED_LEVEL, graph, "Before processPlaceholderFrameStates in %s", parser.method);
for (FrameState frameState : graph.getNewNodes(mark).filter(FrameState.class)) {
if (BytecodeFrame.isPlaceholderBci(frameState.bci)) {
if (frameState.bci == BytecodeFrame.AFTER_BCI) {
if (parser.getInvokeReturnType() == null) {
// A frame state in a root compiled intrinsic.
assert isCompilationRoot;
FrameState newFrameState = graph.add(new FrameState(BytecodeFrame.INVALID_FRAMESTATE_BCI));
frameState.replaceAndDelete(newFrameState);
throw GraalError.shouldNotReachHere("unhandled intrinsic path");
} else {
JavaKind returnKind = parser.getInvokeReturnType().getJavaKind();
FrameStateBuilder frameStateBuilder = parser.frameState;
Expand Down Expand Up @@ -684,16 +681,10 @@ static class IntrinsicScope extends InliningScope {
@Override
public void close() {
IntrinsicContext intrinsic = parser.intrinsicContext;
boolean isRootCompilation;
if (intrinsic != null) {
if (intrinsic.isPostParseInlined()) {
return;
}
isRootCompilation = intrinsic.isCompilationRoot();
} else {
isRootCompilation = false;
if (intrinsic != null && intrinsic.isPostParseInlined()) {
return;
}
processPlaceholderFrameStates(isRootCompilation);
processPlaceholderFrameStates();
if (invalidStateUsers != null) {
JavaKind returnKind = parser.getInvokeReturnType().getJavaKind();
ValueNode returnValue = parser.frameState.pop(returnKind);
Expand Down Expand Up @@ -754,7 +745,7 @@ public void close() {
*
* See ByteCodeParser::inline and search for compilationRoot
*/
assert intrinsic == null || intrinsic.isIntrinsicEncoding() || verifyIntrinsicRootCompileEffects();
assert intrinsic == null || verifyIntrinsicRootCompileEffects();
}
}

Expand Down Expand Up @@ -2393,44 +2384,31 @@ private boolean inline(ResolvedJavaMethod targetMethod, ResolvedJavaMethod inlin
boolean logInliningDecision = logInliningInvokable != null;

if (intrinsic != null && intrinsic.isCallToOriginal(targetMethod)) {
if (intrinsic.isCompilationRoot()) {
// A root compiled intrinsic needs to deoptimize
// if the slow path is taken. During frame state
// assignment, the deopt node will get its stateBefore
// from the start node of the intrinsic
append(new DeoptimizeNode(InvalidateRecompile, RuntimeConstraint));
printInlining(targetMethod, inlinedMethod, true, "compilation root (bytecode parsing)");
if (intrinsic.getOriginalMethod().isNative()) {
printInlining(targetMethod, inlinedMethod, false, "native method (bytecode parsing)");
if (logInliningDecision) {
graph.getInliningLog().addDecision(logInliningInvokable, false, "GraphBuilderPhase", null, null, "native method");
}
return false;
}
if (canInlinePartialIntrinsicExit()) {
// Otherwise inline the original method. Any frame state created
// during the inlining will exclude frame(s) in the
// intrinsic method (see FrameStateBuilder.create(int bci)).
notifyBeforeInline(inlinedMethod);
printInlining(targetMethod, inlinedMethod, true, "partial intrinsic exit (bytecode parsing)");
if (logInliningDecision) {
graph.getInliningLog().addDecision(logInliningInvokable, true, "GraphBuilderPhase", null, null, "compilation root");
graph.getInliningLog().addDecision(logInliningInvokable, true, "GraphBuilderPhase", null, null, "partial intrinsic exit");
}
parseAndInlineCallee(intrinsic.getOriginalMethod(), args, null);
notifyAfterInline(inlinedMethod);
return true;
} else {
if (intrinsic.getOriginalMethod().isNative()) {
printInlining(targetMethod, inlinedMethod, false, "native method (bytecode parsing)");
if (logInliningDecision) {
graph.getInliningLog().addDecision(logInliningInvokable, false, "GraphBuilderPhase", null, null, "native method");
}
return false;
}
if (canInlinePartialIntrinsicExit()) {
// Otherwise inline the original method. Any frame state created
// during the inlining will exclude frame(s) in the
// intrinsic method (see FrameStateBuilder.create(int bci)).
notifyBeforeInline(inlinedMethod);
printInlining(targetMethod, inlinedMethod, true, "partial intrinsic exit (bytecode parsing)");
if (logInliningDecision) {
graph.getInliningLog().addDecision(logInliningInvokable, true, "GraphBuilderPhase", null, null, "partial intrinsic exit");
}
parseAndInlineCallee(intrinsic.getOriginalMethod(), args, null);
notifyAfterInline(inlinedMethod);
return true;
} else {
printInlining(targetMethod, inlinedMethod, false, "partial intrinsic exit (bytecode parsing)");
if (logInliningDecision) {
graph.getInliningLog().addDecision(logInliningInvokable, false, "GraphBuilderPhase", null, null, "partial intrinsic exit");
}
return false;
printInlining(targetMethod, inlinedMethod, false, "partial intrinsic exit (bytecode parsing)");
if (logInliningDecision) {
graph.getInliningLog().addDecision(logInliningInvokable, false, "GraphBuilderPhase", null, null, "partial intrinsic exit");
}
return false;
}
} else {
boolean isIntrinsic = intrinsicBytecodeProvider != null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,6 @@
import static jdk.vm.ci.code.BytecodeFrame.BEFORE_BCI;
import static jdk.vm.ci.code.BytecodeFrame.INVALID_FRAMESTATE_BCI;
import static org.graalvm.compiler.nodes.graphbuilderconf.IntrinsicContext.CompilationContext.INLINE_AFTER_PARSING;
import static org.graalvm.compiler.nodes.graphbuilderconf.IntrinsicContext.CompilationContext.ROOT_COMPILATION;
import static org.graalvm.compiler.nodes.graphbuilderconf.IntrinsicContext.CompilationContext.ROOT_COMPILATION_ENCODING;

import org.graalvm.compiler.bytecode.BytecodeProvider;
import org.graalvm.compiler.graph.NodeSourcePosition;
Expand Down Expand Up @@ -86,7 +84,6 @@ public IntrinsicContext(ResolvedJavaMethod method, ResolvedJavaMethod intrinsic,
assert bytecodeProvider != null;
this.compilationContext = compilationContext;
this.allowPartialIntrinsicArgumentMismatch = allowPartialIntrinsicArgumentMismatch;
assert !isCompilationRoot() || method.hasBytecodes() : "Cannot root compile intrinsic for native or abstract method " + method.format("%H.%n(%p)");
}

/**
Expand Down Expand Up @@ -134,14 +131,6 @@ public boolean isPostParseInlined() {
return compilationContext.equals(INLINE_AFTER_PARSING);
}

public boolean isCompilationRoot() {
return compilationContext.equals(ROOT_COMPILATION) || compilationContext.equals(ROOT_COMPILATION_ENCODING);
}

public boolean isIntrinsicEncoding() {
return compilationContext.equals(ROOT_COMPILATION_ENCODING);
}

public NodeSourcePosition getNodeSourcePosition() {
return nodeSourcePosition;
}
Expand All @@ -164,17 +153,7 @@ public enum CompilationContext {
/**
* An intrinsic is being processed when inlining an {@link Invoke} in an existing graph.
*/
INLINE_AFTER_PARSING,

/**
* An intrinsic is the root of compilation.
*/
ROOT_COMPILATION,

/**
* An intrinsic is the root of a compilation done for graph encoding.
*/
ROOT_COMPILATION_ENCODING
INLINE_AFTER_PARSING
}

/**
Expand Down

0 comments on commit 3e0acfa

Please sign in to comment.