mirror of
https://github.com/enso-org/enso.git
synced 2024-12-23 17:03:32 +03:00
Serialize UUID for non-library modules (#9057)
Missing ID's in IR meant that instrumentation wouldn't be applied for loaded modules. This is the reason why after a restart engine wouldn't send **any** expression updates. Closes #8689. # Important Notes After the change [Kazam_screencast_00038.webm](https://github.com/enso-org/enso/assets/292128/4249287b-6c41-4c9d-b138-e7af59512566) The video somehow doesn't show that all nodes are loaded after the restart, but once I moved the screen they are there. This appears to be a bug in the recording somehow.
This commit is contained in:
parent
6746bdc148
commit
d29c2cd66a
@ -23,7 +23,7 @@ import scala.annotation.unused
|
||||
*/
|
||||
|
||||
@SerialVersionUID(
|
||||
8160L // Use BindingsMap
|
||||
9057L // Use BindingsMap
|
||||
)
|
||||
case class BindingsMap(
|
||||
definedEntities: List[DefinedEntity],
|
||||
|
@ -30,7 +30,7 @@ import scala.collection.immutable.List;
|
||||
*/
|
||||
public interface IR extends Serializable {
|
||||
|
||||
long serialVersionUID = 8145L; // Scala to Java
|
||||
long serialVersionUID = 9057L; // Scala to Java
|
||||
|
||||
/**
|
||||
* Storage for metadata that the node has been tagged with as the result of various compiler
|
||||
|
@ -20,7 +20,7 @@ import java.util.UUID
|
||||
* @param diagnostics compiler diagnostics for this node
|
||||
*/
|
||||
@SerialVersionUID(
|
||||
8160L // Use BindingsMap
|
||||
9057L // Use BindingsMap
|
||||
) // prevents reading broken caches, see PR-3692 for details
|
||||
final case class Module(
|
||||
imports: List[Import],
|
||||
|
@ -1,5 +1,6 @@
|
||||
package org.enso.interpreter.caches;
|
||||
|
||||
import com.oracle.truffle.api.TruffleFile;
|
||||
import java.io.IOException;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.security.MessageDigest;
|
||||
@ -8,40 +9,38 @@ import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
|
||||
import org.enso.compiler.context.CompilerContext;
|
||||
import org.enso.compiler.core.ir.ProcessingPass;
|
||||
import org.enso.pkg.SourceFile;
|
||||
import org.enso.text.Hex;
|
||||
|
||||
import com.oracle.truffle.api.TruffleFile;
|
||||
|
||||
final class CacheUtils {
|
||||
private CacheUtils() {
|
||||
}
|
||||
private CacheUtils() {}
|
||||
|
||||
static Function<Object, Object> writeReplace(CompilerContext context) {
|
||||
return (obj) -> switch (obj) {
|
||||
case ProcessingPass.Metadata metadata -> metadata.prepareForSerialization(context);
|
||||
case UUID _ -> null;
|
||||
case null -> null;
|
||||
default -> obj;
|
||||
};
|
||||
static Function<Object, Object> writeReplace(CompilerContext context, boolean keepUUIDs) {
|
||||
return (obj) ->
|
||||
switch (obj) {
|
||||
case ProcessingPass.Metadata metadata -> metadata.prepareForSerialization(context);
|
||||
case UUID id -> keepUUIDs ? id : null;
|
||||
case null -> null;
|
||||
default -> obj;
|
||||
};
|
||||
}
|
||||
|
||||
static Function<Object, Object> readResolve(CompilerContext context) {
|
||||
return (obj) -> switch (obj) {
|
||||
case ProcessingPass.Metadata metadata -> {
|
||||
var option = metadata.restoreFromSerialization(context);
|
||||
if (option.nonEmpty()) {
|
||||
yield option.get();
|
||||
} else {
|
||||
throw raise(RuntimeException.class, new IOException("Cannot convert " + metadata));
|
||||
}
|
||||
}
|
||||
case null -> null;
|
||||
default -> obj;
|
||||
};
|
||||
return (obj) ->
|
||||
switch (obj) {
|
||||
case ProcessingPass.Metadata metadata -> {
|
||||
var option = metadata.restoreFromSerialization(context);
|
||||
if (option.nonEmpty()) {
|
||||
yield option.get();
|
||||
} else {
|
||||
throw raise(RuntimeException.class, new IOException("Cannot convert " + metadata));
|
||||
}
|
||||
}
|
||||
case null -> null;
|
||||
default -> obj;
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
@ -75,9 +74,7 @@ final class CacheUtils {
|
||||
* @param pkgSources the list of package sources
|
||||
* @return string representation of bytes' hash
|
||||
*/
|
||||
static final String computeDigestOfLibrarySources(
|
||||
List<SourceFile<TruffleFile>> pkgSources
|
||||
) {
|
||||
static final String computeDigestOfLibrarySources(List<SourceFile<TruffleFile>> pkgSources) {
|
||||
pkgSources.sort(Comparator.comparing(o -> o.qualifiedName().toString()));
|
||||
|
||||
try {
|
||||
@ -95,5 +92,4 @@ final class CacheUtils {
|
||||
static <T extends Exception> T raise(Class<T> cls, Exception e) throws T {
|
||||
throw (T) e;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -65,7 +65,7 @@ public final class ImportExportCache
|
||||
public byte[] serialize(EnsoContext context, CachedBindings entry) throws IOException {
|
||||
var arr =
|
||||
Persistance.write(
|
||||
entry.bindings(), CacheUtils.writeReplace(context.getCompiler().context()));
|
||||
entry.bindings(), CacheUtils.writeReplace(context.getCompiler().context(), false));
|
||||
return arr;
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ public final class ModuleCache
|
||||
public byte[] serialize(EnsoContext context, CachedModule entry) throws IOException {
|
||||
var arr =
|
||||
Persistance.write(
|
||||
entry.moduleIR(), CacheUtils.writeReplace(context.getCompiler().context()));
|
||||
entry.moduleIR(), CacheUtils.writeReplace(context.getCompiler().context(), true));
|
||||
return arr;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user