Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix serialization of alias analysis graph #8550

Merged
merged 3 commits into from
Dec 15, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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());
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You have to change the id of the persisted object to signal that old caches can no longer be read.

}

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
Loading