diff --git a/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/heap/ImageLayerLoader.java b/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/heap/ImageLayerLoader.java index 47ee090ab228..d89d6b431fed 100644 --- a/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/heap/ImageLayerLoader.java +++ b/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/heap/ImageLayerLoader.java @@ -578,10 +578,7 @@ public void addBaseLayerMethod(AnalysisMethod analysisMethod) { } public void initializeBaseLayerMethod(AnalysisMethod analysisMethod) { - initializeBaseLayerMethod(analysisMethod, getMethodData(analysisMethod)); - } - - protected void initializeBaseLayerMethod(AnalysisMethod analysisMethod, PersistedAnalysisMethod.Reader md) { + PersistedAnalysisMethod.Reader md = getMethodData(analysisMethod); registerFlag(md.getIsVirtualRootMethod(), true, () -> analysisMethod.registerAsVirtualRootMethod(PERSISTED)); registerFlag(md.getIsDirectRootMethod(), true, () -> analysisMethod.registerAsDirectRootMethod(PERSISTED)); registerFlag(md.getIsInvoked(), true, () -> analysisMethod.registerAsInvoked(PERSISTED)); @@ -600,16 +597,28 @@ public boolean hasAnalysisParsedGraph(AnalysisMethod analysisMethod) { public AnalysisParsedGraph getAnalysisParsedGraph(AnalysisMethod analysisMethod) { PersistedAnalysisMethod.Reader methodData = getMethodData(analysisMethod); - byte[] encodedAnalyzedGraph = readEncodedGraph(methodData.getAnalysisGraphLocation().toString()); boolean intrinsic = methodData.getAnalysisGraphIsIntrinsic(); - EncodedGraph analyzedGraph = (EncodedGraph) ObjectCopier.decode(imageLayerSnapshotUtil.getGraphDecoder(this, analysisMethod, universe.getSnippetReflection()), encodedAnalyzedGraph); + EncodedGraph analyzedGraph = getEncodedGraph(analysisMethod, methodData.getAnalysisGraphLocation()); if (hasStrengthenedGraph(analysisMethod)) { throw AnalysisError.shouldNotReachHere("Strengthened graphs are not supported until late loading is implemented."); } - afterGraphDecodeHook(analyzedGraph); return new AnalysisParsedGraph(analyzedGraph, intrinsic); } + public boolean hasStrengthenedGraph(AnalysisMethod analysisMethod) { + return getMethodData(analysisMethod).hasStrengthenedGraphLocation(); + } + + public EncodedGraph getStrengthenedGraph(AnalysisMethod analysisMethod) { + PersistedAnalysisMethod.Reader methodData = getMethodData(analysisMethod); + return getEncodedGraph(analysisMethod, methodData.getStrengthenedGraphLocation()); + } + + protected EncodedGraph getEncodedGraph(AnalysisMethod analysisMethod, Text.Reader location) { + byte[] encodedAnalyzedGraph = readEncodedGraph(location.toString()); + return (EncodedGraph) ObjectCopier.decode(imageLayerSnapshotUtil.getGraphDecoder(this, analysisMethod, universe.getSnippetReflection()), encodedAnalyzedGraph); + } + private byte[] readEncodedGraph(String location) { int closingBracketAt = location.length() - 1; AnalysisError.guarantee(location.charAt(0) == '@' && location.charAt(closingBracketAt) == ']', "Location must start with '@' and end with ']': %s", location); @@ -632,23 +641,6 @@ private byte[] readEncodedGraph(String location) { return bb.array(); } - public boolean hasStrengthenedGraph(AnalysisMethod analysisMethod) { - return getMethodData(analysisMethod).hasStrengthenedGraphLocation(); - } - - public void setStrengthenedGraph(AnalysisMethod analysisMethod) { - PersistedAnalysisMethod.Reader methodData = getMethodData(analysisMethod); - byte[] encodedAnalyzedGraph = readEncodedGraph(methodData.getStrengthenedGraphLocation().toString()); - EncodedGraph analyzedGraph = (EncodedGraph) ObjectCopier.decode(imageLayerSnapshotUtil.getGraphDecoder(this, analysisMethod, universe.getSnippetReflection()), encodedAnalyzedGraph); - afterGraphDecodeHook(analyzedGraph); - analysisMethod.setAnalyzedGraph(analyzedGraph); - } - - @SuppressWarnings("unused") - protected void afterGraphDecodeHook(EncodedGraph encodedGraph) { - - } - protected static int getId(String line) { return Integer.parseInt(line.split(" = ")[1]); } diff --git a/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/results/StrengthenGraphs.java b/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/results/StrengthenGraphs.java index b5834093e2a9..0e5d143918a2 100644 --- a/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/results/StrengthenGraphs.java +++ b/substratevm/src/com.oracle.graal.pointsto/src/com/oracle/graal/pointsto/results/StrengthenGraphs.java @@ -240,7 +240,10 @@ public final void applyResults(AnalysisMethod method) { } if (method.analyzedInPriorLayer()) { - useSharedLayerGraph(method); + /* + * The method was already strengthened in a prior layer, so there is no need to + * strengthen it in this layer. + */ return; } @@ -273,8 +276,6 @@ public final void applyResults(AnalysisMethod method) { protected abstract void postStrengthenGraphs(StructuredGraph graph, AnalysisMethod method); - protected abstract void useSharedLayerGraph(AnalysisMethod method); - protected abstract void persistStrengthenGraph(AnalysisMethod method); /* diff --git a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SVMHost.java b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SVMHost.java index 6d9c11ff30c9..6371b13d7b79 100644 --- a/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SVMHost.java +++ b/substratevm/src/com.oracle.svm.hosted/src/com/oracle/svm/hosted/SVMHost.java @@ -258,11 +258,14 @@ public boolean useBaseLayer() { /** * If we are skipping the analysis of a prior layer method, we must ensure analysis was - * performed in the prior layer and the analysis results have been serialized. Currently this + * performed in the prior layer and the analysis results have been serialized. Currently, this * approximates to either: *