Skip to content

Commit

Permalink
Address PR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
Friendseeker committed Oct 5, 2024
1 parent 1f05eea commit 9a7ee51
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -24,11 +24,11 @@ public static AnalyzedClass create(long _compilationTimestamp, String _name, xsb
public static AnalyzedClass of(long _compilationTimestamp, String _name, xsbti.api.Lazy<Companions> _api, int _apiHash, NameHash[] _nameHashes, boolean _hasMacro, int _extraHash, String _provenance) {
return new AnalyzedClass(_compilationTimestamp, _name, _api, _apiHash, _nameHashes, _hasMacro, _extraHash, _provenance);
}
public static AnalyzedClass create(long _compilationTimestamp, String _name, xsbti.api.Lazy<Companions> _api, int _apiHash, NameHash[] _nameHashes, boolean _hasMacro, int _extraHash, String _provenance, int _bytecodeHash, int _extraBytecodeHash) {
return new AnalyzedClass(_compilationTimestamp, _name, _api, _apiHash, _nameHashes, _hasMacro, _extraHash, _provenance, _bytecodeHash, _extraBytecodeHash);
public static AnalyzedClass create(long _compilationTimestamp, String _name, xsbti.api.Lazy<Companions> _api, int _apiHash, NameHash[] _nameHashes, boolean _hasMacro, int _extraHash, String _provenance, long _bytecodeHash, long _transitiveBytecodeHash) {
return new AnalyzedClass(_compilationTimestamp, _name, _api, _apiHash, _nameHashes, _hasMacro, _extraHash, _provenance, _bytecodeHash, _transitiveBytecodeHash);
}
public static AnalyzedClass of(long _compilationTimestamp, String _name, xsbti.api.Lazy<Companions> _api, int _apiHash, NameHash[] _nameHashes, boolean _hasMacro, int _extraHash, String _provenance, int _bytecodeHash, int _extraBytecodeHash) {
return new AnalyzedClass(_compilationTimestamp, _name, _api, _apiHash, _nameHashes, _hasMacro, _extraHash, _provenance, _bytecodeHash, _extraBytecodeHash);
public static AnalyzedClass of(long _compilationTimestamp, String _name, xsbti.api.Lazy<Companions> _api, int _apiHash, NameHash[] _nameHashes, boolean _hasMacro, int _extraHash, String _provenance, long _bytecodeHash, long _transitiveBytecodeHash) {
return new AnalyzedClass(_compilationTimestamp, _name, _api, _apiHash, _nameHashes, _hasMacro, _extraHash, _provenance, _bytecodeHash, _transitiveBytecodeHash);
}
private long compilationTimestamp;
private String name;
Expand All @@ -38,8 +38,8 @@ public static AnalyzedClass of(long _compilationTimestamp, String _name, xsbti.a
private boolean hasMacro;
private int extraHash;
private String provenance;
private int bytecodeHash;
private int extraBytecodeHash;
private long bytecodeHash;
private long transitiveBytecodeHash;
protected AnalyzedClass(long _compilationTimestamp, String _name, xsbti.api.Lazy<Companions> _api, int _apiHash, NameHash[] _nameHashes, boolean _hasMacro) {
super();
compilationTimestamp = _compilationTimestamp;
Expand All @@ -51,7 +51,7 @@ protected AnalyzedClass(long _compilationTimestamp, String _name, xsbti.api.Lazy
extraHash = apiHash;
provenance = "";
bytecodeHash = 0;
extraBytecodeHash = 0;
transitiveBytecodeHash = 0;
}
protected AnalyzedClass(long _compilationTimestamp, String _name, xsbti.api.Lazy<Companions> _api, int _apiHash, NameHash[] _nameHashes, boolean _hasMacro, int _extraHash) {
super();
Expand All @@ -64,7 +64,7 @@ protected AnalyzedClass(long _compilationTimestamp, String _name, xsbti.api.Lazy
extraHash = _extraHash;
provenance = "";
bytecodeHash = 0;
extraBytecodeHash = 0;
transitiveBytecodeHash = 0;
}
protected AnalyzedClass(long _compilationTimestamp, String _name, xsbti.api.Lazy<Companions> _api, int _apiHash, NameHash[] _nameHashes, boolean _hasMacro, int _extraHash, String _provenance) {
super();
Expand All @@ -77,9 +77,9 @@ protected AnalyzedClass(long _compilationTimestamp, String _name, xsbti.api.Lazy
extraHash = _extraHash;
provenance = _provenance;
bytecodeHash = 0;
extraBytecodeHash = 0;
transitiveBytecodeHash = 0;
}
protected AnalyzedClass(long _compilationTimestamp, String _name, xsbti.api.Lazy<Companions> _api, int _apiHash, NameHash[] _nameHashes, boolean _hasMacro, int _extraHash, String _provenance, int _bytecodeHash, int _extraBytecodeHash) {
protected AnalyzedClass(long _compilationTimestamp, String _name, xsbti.api.Lazy<Companions> _api, int _apiHash, NameHash[] _nameHashes, boolean _hasMacro, int _extraHash, String _provenance, long _bytecodeHash, long _transitiveBytecodeHash) {
super();
compilationTimestamp = _compilationTimestamp;
name = _name;
Expand All @@ -90,7 +90,7 @@ protected AnalyzedClass(long _compilationTimestamp, String _name, xsbti.api.Lazy
extraHash = _extraHash;
provenance = _provenance;
bytecodeHash = _bytecodeHash;
extraBytecodeHash = _extraBytecodeHash;
transitiveBytecodeHash = _transitiveBytecodeHash;
}

public long compilationTimestamp() {
Expand Down Expand Up @@ -123,42 +123,42 @@ public String provenance() {
return this.provenance;
}
/** A hash of generated bytecode of source file hosting the class */
public int bytecodeHash() {
public long bytecodeHash() {
return this.bytecodeHash;
}
/** A hash of generated bytecode of all upstream dependencies */
public int extraBytecodeHash() {
return this.extraBytecodeHash;
public long transitiveBytecodeHash() {
return this.transitiveBytecodeHash;
}
public AnalyzedClass withCompilationTimestamp(long compilationTimestamp) {
return new AnalyzedClass(compilationTimestamp, name, api, apiHash, nameHashes, hasMacro, extraHash, provenance, bytecodeHash, extraBytecodeHash);
return new AnalyzedClass(compilationTimestamp, name, api, apiHash, nameHashes, hasMacro, extraHash, provenance, bytecodeHash, transitiveBytecodeHash);
}
public AnalyzedClass withName(String name) {
return new AnalyzedClass(compilationTimestamp, name, api, apiHash, nameHashes, hasMacro, extraHash, provenance, bytecodeHash, extraBytecodeHash);
return new AnalyzedClass(compilationTimestamp, name, api, apiHash, nameHashes, hasMacro, extraHash, provenance, bytecodeHash, transitiveBytecodeHash);
}
public AnalyzedClass withApi(xsbti.api.Lazy<Companions> api) {
return new AnalyzedClass(compilationTimestamp, name, api, apiHash, nameHashes, hasMacro, extraHash, provenance, bytecodeHash, extraBytecodeHash);
return new AnalyzedClass(compilationTimestamp, name, api, apiHash, nameHashes, hasMacro, extraHash, provenance, bytecodeHash, transitiveBytecodeHash);
}
public AnalyzedClass withApiHash(int apiHash) {
return new AnalyzedClass(compilationTimestamp, name, api, apiHash, nameHashes, hasMacro, extraHash, provenance, bytecodeHash, extraBytecodeHash);
return new AnalyzedClass(compilationTimestamp, name, api, apiHash, nameHashes, hasMacro, extraHash, provenance, bytecodeHash, transitiveBytecodeHash);
}
public AnalyzedClass withNameHashes(NameHash[] nameHashes) {
return new AnalyzedClass(compilationTimestamp, name, api, apiHash, nameHashes, hasMacro, extraHash, provenance, bytecodeHash, extraBytecodeHash);
return new AnalyzedClass(compilationTimestamp, name, api, apiHash, nameHashes, hasMacro, extraHash, provenance, bytecodeHash, transitiveBytecodeHash);
}
public AnalyzedClass withHasMacro(boolean hasMacro) {
return new AnalyzedClass(compilationTimestamp, name, api, apiHash, nameHashes, hasMacro, extraHash, provenance, bytecodeHash, extraBytecodeHash);
return new AnalyzedClass(compilationTimestamp, name, api, apiHash, nameHashes, hasMacro, extraHash, provenance, bytecodeHash, transitiveBytecodeHash);
}
public AnalyzedClass withExtraHash(int extraHash) {
return new AnalyzedClass(compilationTimestamp, name, api, apiHash, nameHashes, hasMacro, extraHash, provenance, bytecodeHash, extraBytecodeHash);
return new AnalyzedClass(compilationTimestamp, name, api, apiHash, nameHashes, hasMacro, extraHash, provenance, bytecodeHash, transitiveBytecodeHash);
}
public AnalyzedClass withProvenance(String provenance) {
return new AnalyzedClass(compilationTimestamp, name, api, apiHash, nameHashes, hasMacro, extraHash, provenance, bytecodeHash, extraBytecodeHash);
return new AnalyzedClass(compilationTimestamp, name, api, apiHash, nameHashes, hasMacro, extraHash, provenance, bytecodeHash, transitiveBytecodeHash);
}
public AnalyzedClass withBytecodeHash(int bytecodeHash) {
return new AnalyzedClass(compilationTimestamp, name, api, apiHash, nameHashes, hasMacro, extraHash, provenance, bytecodeHash, extraBytecodeHash);
public AnalyzedClass withBytecodeHash(long bytecodeHash) {
return new AnalyzedClass(compilationTimestamp, name, api, apiHash, nameHashes, hasMacro, extraHash, provenance, bytecodeHash, transitiveBytecodeHash);
}
public AnalyzedClass withExtraBytecodeHash(int extraBytecodeHash) {
return new AnalyzedClass(compilationTimestamp, name, api, apiHash, nameHashes, hasMacro, extraHash, provenance, bytecodeHash, extraBytecodeHash);
public AnalyzedClass withTransitiveBytecodeHash(long transitiveBytecodeHash) {
return new AnalyzedClass(compilationTimestamp, name, api, apiHash, nameHashes, hasMacro, extraHash, provenance, bytecodeHash, transitiveBytecodeHash);
}
public boolean equals(Object obj) {
return this == obj; // We have lazy members, so use object identity to avoid circularity.
Expand Down
6 changes: 3 additions & 3 deletions internal/compiler-interface/src/main/contraband/other.json
Original file line number Diff line number Diff line change
Expand Up @@ -31,16 +31,16 @@
},
{
"name": "bytecodeHash",
"type": "int",
"type": "long",
"default": "0",
"since": "2.0.0",
"doc": [
"A hash of generated bytecode of source file hosting the class"
]
},
{
"name": "extraBytecodeHash",
"type": "int",
"name": "transitiveBytecodeHash",
"type": "long",
"default": "0",
"since": "2.0.0",
"doc": [
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -946,7 +946,7 @@ private final class AnalysisCallback(

private def getAnalysis: Analysis = {
val analysis0 = addProductsAndDeps(Analysis.empty)
addUsedNames(addCompilation(addExtraBytecodeHash(analysis0)))
addUsedNames(addCompilation(addTransitiveBytecodeHash(analysis0)))
}

def getPostJavaAnalysis: Analysis = {
Expand All @@ -965,7 +965,7 @@ private final class AnalysisCallback(
)
}

private def addExtraBytecodeHash(base: Analysis): Analysis = {
private def addTransitiveBytecodeHash(base: Analysis): Analysis = {
import base.{ apis, relations }
val findUpstream = relations.memberRef.internal.forward _
val internalAPIs = apis.internal.map { case (className, analyzedClass) =>
Expand All @@ -976,7 +976,7 @@ private final class AnalysisCallback(
IncrementalCommon.transitiveDeps(Set(className), log, logging = false)(findUpstream)
val upstreamAnalyzedClasses = upstreamClasses.map(apis.internalAPI)
val upstreamHashes = upstreamAnalyzedClasses.map(_.bytecodeHash())
(className, analyzedClass.withExtraBytecodeHash(upstreamHashes.hashCode()))
(className, analyzedClass.withTransitiveBytecodeHash(upstreamHashes.hashCode()))
}
}
val APIs = new MAPIs(internalAPIs, apis.external)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -310,7 +310,7 @@ private[inc] abstract class IncrementalCommon(
(a.bytecodeHash() == b.bytecodeHash()) &&
(a.apiHash == b.apiHash) &&
(a.extraHash == b.extraHash) &&
(!hasMacro || a.extraBytecodeHash() == b.extraBytecodeHash())
(!hasMacro || a.transitiveBytecodeHash() == b.transitiveBytecodeHash())
}
// log.debug(s"[zinc] detectAPIChanges(recompiledClasses = $recompiledClasses)")
def classDiff(className: String, a: AnalyzedClass, b: AnalyzedClass): Option[APIChange] = {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -146,8 +146,8 @@ class ConsistentAnalysisFormat(val mappers: ReadWriteMappers, sort: Boolean) {
out.bool(ac.hasMacro)
out.string(ac.provenance())
out.int(ac.extraHash())
out.int(ac.bytecodeHash())
out.int(ac.extraBytecodeHash())
out.long(ac.bytecodeHash())
out.long(ac.transitiveBytecodeHash())
val nh0 = ac.nameHashes()
val nh = if (nh0.length > 1 && sort) {
val nh = nh0.clone()
Expand All @@ -173,8 +173,8 @@ class ConsistentAnalysisFormat(val mappers: ReadWriteMappers, sort: Boolean) {
val hm = in.bool()
val p = in.string()
val eh = in.int()
val bh = in.int()
val ebh = in.int()
val bh = in.long()
val ebh = in.long()
val nhNames = in.readStringArray()
val nhScopes = in.readArray[UseScope]() { UseScope.values()(in.byte().toInt) }
val nhHashes = in.readArray[Int]() { in.int() }
Expand Down

0 comments on commit 9a7ee51

Please sign in to comment.