Skip to content

Commit

Permalink
Fix serialization of alias analysis graph (#8550)
Browse files Browse the repository at this point in the history
close #8431

Fixes the scenario:
- user sends `executionContext/executeExpression`
- program execution is scheduled
- during the compilation the already compiled `IR` is loaded from the cache (reading invalid alias analysis graph)
- during the codegen the local scope with that aliasing graph is propagated to the runtime
- `EvalNode` compiles the expression to execute with the local scope containing an invalid aliasing graph
- compilation fails in the `AliasAnalysis` pass because of the clashing IDs in the graph
  • Loading branch information
4e6 committed Dec 15, 2023
1 parent 4b65e44 commit 56cc956
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ protected void writeObject(
@org.openide.util.lookup.ServiceProvider(service = Persistance.class)
public static final class PersistAliasAnalysisGraph extends Persistance<Graph> {
public PersistAliasAnalysisGraph() {
super(Graph.class, false, 1119);
super(Graph.class, false, 1131);
}

@SuppressWarnings("unchecked")
Expand All @@ -160,6 +160,10 @@ protected Graph readObject(Input in) throws IOException {
var links =
(scala.collection.immutable.Set) in.readInline(scala.collection.immutable.Set.class);
g.links_$eq(links);

var nextIdCounter = in.readInt();
g.nextIdCounter_$eq(nextIdCounter);

return g;
}

Expand All @@ -168,6 +172,7 @@ protected Graph readObject(Input in) throws IOException {
protected void writeObject(Graph obj, Output out) throws IOException {
out.writeObject(obj.rootScope());
out.writeInline(scala.collection.immutable.Set.class, obj.links());
out.writeInt(obj.nextIdCounter());
}

private static void assignParents(AliasAnalysis$Graph$Scope scope) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ import scala.reflect.ClassTag
*
* - A [[org.enso.compiler.pass.PassConfiguration]] containing an instance of
* [[AliasAnalysis.Configuration]].
* - A [[LocalScope]], where relevant.
* - A [[org.enso.compiler.context.LocalScope]], where relevant.
*/
case object AliasAnalysis extends IRPass {

Expand Down Expand Up @@ -940,11 +940,10 @@ case object AliasAnalysis extends IRPass {
sealed class Graph extends Serializable {
var rootScope: Graph.Scope = new Graph.Scope()
var links: Set[Graph.Link] = Set()
var nextIdCounter = 0

private var globalSymbols: Map[Graph.Symbol, Occurrence.Global] = Map()

private var nextIdCounter = 0

/** @return a deep structural copy of `this` */
def deepCopy(
scope_mapping: mutable.Map[Scope, Scope] = mutable.Map()
Expand Down

0 comments on commit 56cc956

Please sign in to comment.