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

Revert "Avoid copying IR nodes when no change is performed in passes" #11018

Closed
wants to merge 1 commit into from
Closed
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 @@ -98,8 +98,8 @@ case object AmbiguousImportsAnalysis extends IRPass {
_,
Some(onlyNames),
_,
_,
false,
_,
_
) =>
getImportTargets(moduleImport, bindingMap) match {
Expand Down Expand Up @@ -149,8 +149,8 @@ case object AmbiguousImportsAnalysis extends IRPass {
true,
_,
hiddenNames,
_,
false,
_,
_
) =>
getImportTargets(moduleImport, bindingMap) match {
Expand Down Expand Up @@ -207,8 +207,8 @@ case object AmbiguousImportsAnalysis extends IRPass {
_,
_,
_,
_,
false,
_,
_
) =>
val symbolPath = importPath.name
Expand All @@ -230,8 +230,8 @@ case object AmbiguousImportsAnalysis extends IRPass {
_,
_,
_,
_,
false,
_,
_
) =>
tryAddEncounteredSymbol(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ case object ImportSymbolAnalysis extends IRPass {
isAll,
_,
_,
_,
isSynthetic,
_,
_
) if isAll && !isSynthetic =>
bindingMap.resolvedImports.find(_.importDef == imp) match {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ case object ModuleNameConflicts extends IRPass {
_,
_,
None,
None,
true,
None,
_
) =>
Some(mod)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -185,8 +185,8 @@ final class ImportResolver(compiler: Compiler) extends ImportResolverForIR {
expName,
rename,
onlyNames,
_,
isSynthetic,
_,
_
) if !isSynthetic =>
val exportsItself = curModName.equals(expName.name)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,11 +155,10 @@ class MetadataStorageTest extends CompilerTest {

meta1 shouldEqual meta2

val meta = TestPass1.Metadata1()
meta1.update(TestPass1, meta)
meta2.update(TestPass1, meta)
meta1.update(TestPass1, TestPass1.Metadata1())
meta2.update(TestPass1, TestPass1.Metadata1())

meta1 shouldNot equal(meta2)
meta1 shouldEqual meta2
}

def newMetadataStorage(init: Seq[MetadataPair[_]]): MetadataStorage = {
Expand All @@ -186,7 +185,7 @@ class MetadataStorageTest extends CompilerTest {
meta.map((p, m) => (p, m.metadataName)).asScala shouldEqual expected
}

"allow copying to create a new instance with the same data but are not equal" in {
"allow copying to create a new instance with the same data" in {
val meta = newMetadataStorage(
Seq(
new MetadataPair(TestPass1, TestPass1.Metadata1()),
Expand All @@ -201,8 +200,8 @@ class MetadataStorageTest extends CompilerTest {
)
)

meta.duplicate shouldNot equal(meta)
meta.duplicate shouldNot equal(expected)
meta.duplicate shouldEqual meta
meta.duplicate shouldEqual expected
}

"enforce safe construction" in {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1804,7 +1804,7 @@ Import translateImport(Tree.Import imp) {
return new Import.Module(
qualifiedName, rename, isAll || onlyNames.isDefined() || hidingNames.isDefined(),
onlyNames,
hidingNames, getIdentifiedLocation(imp), false,
hidingNames, false, getIdentifiedLocation(imp),
meta()
);
} catch (SyntaxException err) {
Expand Down Expand Up @@ -1868,7 +1868,7 @@ Export translateExport(Tree.Export exp) {
}
return new Export.Module(
qualifiedName, rename, onlyNames,
getIdentifiedLocation(exp), false,
false, getIdentifiedLocation(exp),
meta()
);
} catch (SyntaxException err) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ public boolean equals(Object obj) {
return true;
}
if (obj instanceof MetadataStorage other) {
return this.metadata == other.metadata;
return Objects.equals(this.metadata, other.metadata);
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,19 +68,15 @@ object CallArgument {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Specified = {
if (
name != this.name
|| value != this.value
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Specified(name, value, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Specified(
name,
value,
location,
passData
)
res.diagnostics = diagnostics
res.id = id
res
}

/** @inheritdoc */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -118,28 +118,17 @@ object DefinitionArgument {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Specified = {
if (
name != this.name
|| ascribedType != this.ascribedType
|| defaultValue != this.defaultValue
|| suspended != this.suspended
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Specified(
name,
ascribedType,
defaultValue,
suspended,
location,
passData
)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Specified(
name,
ascribedType,
defaultValue,
suspended,
location,
passData
)
res.diagnostics = diagnostics
res.id = id
res
}

override def withName(ir: Name): DefinitionArgument = copy(name = ir)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,10 @@ sealed case class Empty(
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Empty = {
if (
location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Empty(location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Empty(location, passData)
res.diagnostics = diagnostics
res.id = id
res
}

/** @inheritdoc */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,26 +85,16 @@ object Expression {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Block = {
if (
expressions != this.expressions
|| returnValue != this.returnValue
|| suspended != this.suspended
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Block(
expressions,
returnValue,
location,
suspended,
passData
)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Block(
expressions,
returnValue,
location,
suspended,
passData
)
res.diagnostics = diagnostics
res.id = id
res
}

/** @inheritdoc */
Expand Down Expand Up @@ -227,19 +217,10 @@ object Expression {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Binding = {
if (
name != this.name
|| expression != this.expression
|| location != this.location
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res = Binding(name, expression, location, passData)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res = Binding(name, expression, location, passData)
res.diagnostics = diagnostics
res.id = id
res
}

/** @inheritdoc */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -113,27 +113,17 @@ object Function {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Lambda = {
if (
arguments != this.arguments
|| body != this.body
|| location != this.location
|| canBeTCO != this.canBeTCO
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res =
Lambda(
arguments,
Persistance.Reference.of(body, false),
location,
canBeTCO,
passData
)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res =
Lambda(
arguments,
Persistance.Reference.of(body, false),
location,
canBeTCO,
passData
)
res.diagnostics = diagnostics
res.id = id
res
}

/** @inheritdoc */
Expand Down Expand Up @@ -277,31 +267,19 @@ object Function {
diagnostics: DiagnosticStorage = diagnostics,
id: UUID @Identifier = id
): Binding = {
if (
name != this.name
|| arguments != this.arguments
|| body != this.body
|| isPrivate != this.isPrivate
|| location != this.location
|| canBeTCO != this.canBeTCO
|| passData != this.passData
|| diagnostics != this.diagnostics
|| id != this.id
) {
val res =
Binding(
name,
arguments,
body,
isPrivate,
location,
canBeTCO,
passData
)
res.diagnostics = diagnostics
res.id = id
res
} else this
val res =
Binding(
name,
arguments,
body,
isPrivate,
location,
canBeTCO,
passData
)
res.diagnostics = diagnostics
res.id = id
res
}

/** @inheritdoc */
Expand Down
Loading
Loading