# HG changeset patch # User Bernhard Urban # Date 1413982209 -7200 # Node ID 9db0af368bb4426f5d260e6bf4444787e0dc0f56 # Parent 0e7455cb3004751d972030f4e912007136b77772 truffleCache: refactor in order to fix recursive inlining warning diff -r 0e7455cb3004 -r 9db0af368bb4 graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCacheImpl.java --- a/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCacheImpl.java Tue Oct 21 20:33:04 2014 +0200 +++ b/graal/com.oracle.graal.truffle/src/com/oracle/graal/truffle/TruffleCacheImpl.java Wed Oct 22 14:50:09 2014 +0200 @@ -104,11 +104,7 @@ return graph; } - public StructuredGraph lookup(ResolvedJavaMethod method, NodeInputList arguments, CanonicalizerPhase canonicalizer) { - if (method.getAnnotation(CompilerDirectives.TruffleBoundary.class) != null) { - return null; - } - + private static List computeCacheKey(ResolvedJavaMethod method, NodeInputList arguments) { List key = new ArrayList<>(arguments.size() + 1); key.add(method); for (ValueNode v : arguments) { @@ -116,12 +112,28 @@ key.add(v.stamp()); } } + return key; + } + + public StructuredGraph lookup(ResolvedJavaMethod method, NodeInputList arguments, CanonicalizerPhase canonicalizer) { + List key = computeCacheKey(method, arguments); StructuredGraph resultGraph = cache.get(key); if (resultGraph == markerGraph) { - // Avoid recursive inlining or a previous attempt bailed out (and we won't try again). + // compilation failed previously, don't try again + return null; + } + StructuredGraph graph = cacheLookup(method, arguments, canonicalizer); + assert graph != markerGraph : "markerGraph should not leak out"; + return graph; + } + + private StructuredGraph cacheLookup(ResolvedJavaMethod method, NodeInputList arguments, CanonicalizerPhase canonicalizer) { + if (method.getAnnotation(CompilerDirectives.TruffleBoundary.class) != null) { return null; } + List key = computeCacheKey(method, arguments); + StructuredGraph resultGraph = cache.get(key); if (resultGraph != null) { lastUsed.put(key, counter++); return resultGraph; @@ -280,7 +292,7 @@ private void expandInvoke(MethodCallTargetNode methodCallTargetNode, CanonicalizerPhase canonicalizer) { StructuredGraph inlineGraph = providers.getReplacements().getMethodSubstitution(methodCallTargetNode.targetMethod()); if (inlineGraph == null) { - inlineGraph = TruffleCacheImpl.this.lookup(methodCallTargetNode.targetMethod(), methodCallTargetNode.arguments(), canonicalizer); + inlineGraph = cacheLookup(methodCallTargetNode.targetMethod(), methodCallTargetNode.arguments(), canonicalizer); } if (inlineGraph == null) { return;