Introduce hash seed to invaldiate caches (#9082)

This commit is contained in:
Hubert Plociniczak 2024-02-17 00:43:30 +01:00 committed by GitHub
parent 642d5a691e
commit fe0f9046db
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 8 additions and 12 deletions

View File

@ -171,6 +171,10 @@ Every `Persistance` class has a unique identifier. In order to keep definitions
consistent one should not attempt to use smaller `id`s than previously assigned.
One should also not delete any `Persistance` classes.
Additionally, `PerMap.serialVersionUID` version provides a seed to the version
stamp calculated from all `Persistance` classes. Increasing the
`serialVersionUID` will invalidate all caches.
## Loading the IR
Loading the IR is a multi-stage process that involves performing integrity

View File

@ -21,10 +21,6 @@ import scala.annotation.unused
* @param definedEntities the list of entities defined in the current module
* @param currentModule the module holding these bindings
*/
@SerialVersionUID(
9057L // Use BindingsMap
)
case class BindingsMap(
definedEntities: List[DefinedEntity],
currentModule: ModuleReference

View File

@ -1,6 +1,5 @@
package org.enso.compiler.core;
import java.io.Serializable;
import java.util.UUID;
import java.util.function.Function;
import org.enso.compiler.core.ir.DiagnosticStorage;
@ -28,9 +27,7 @@ import scala.collection.immutable.List;
*
* <p>See also: Note [IR Equality and hashing]
*/
public interface IR extends Serializable {
long serialVersionUID = 9057L; // Scala to Java
public interface IR {
/**
* Storage for metadata that the node has been tagged with as the result of various compiler

View File

@ -19,9 +19,6 @@ import java.util.UUID
* @param passData the pass metadata associated with this node
* @param diagnostics compiler diagnostics for this node
*/
@SerialVersionUID(
9057L // Use BindingsMap
) // prevents reading broken caches, see PR-3692 for details
final case class Module(
imports: List[Import],
exports: List[Export],

View File

@ -7,6 +7,8 @@ import java.util.Map;
import org.openide.util.lookup.Lookups;
final class PerMap {
private static final int serialVersionUID = 8689; // Use PR number
private static final Collection<? extends Persistance> ALL;
static {
@ -20,7 +22,7 @@ final class PerMap {
final int versionStamp;
private PerMap() {
int hash = 0;
int hash = serialVersionUID;
for (var orig : ALL) {
var p = orig.newClone();
var prevId = ids.put(p.id, p);