Skip to content

Commit dbc1457

Browse files
committed
Remove the -Yemit-tasty-in-class option, along with handling of .hasTasty.
The default was flipped in a645566 in July 2018. Since then, it has not been really tested. Completely removing it will allow the tooling not to worry about `.hasTasty` and the need to read TASTy from class files. We keep the support of `.hasTasty` files in sbt-dotty for now, so that it still supports older versions of dotty.
1 parent f70ee5f commit dbc1457

File tree

10 files changed

+41
-52
lines changed

10 files changed

+41
-52
lines changed

.gitignore

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
*.DS_Store
22
*.class
33
*.tasty
4-
*.hasTasty
54
*.log
65
*.swp
76
*~

.vscode-template/settings.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
"search.exclude": {
99
"**/*.class": true,
10-
"**/*.hasTasty": true,
10+
"**/*.tasty": true,
1111
"**/target/": true,
1212
"community-build/community-projects": true
1313
}

compiler/src/dotty/tools/backend/jvm/GenBCode.scala

Lines changed: 21 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -234,33 +234,27 @@ class GenBCodePipeline(val int: DottyBackendInterface, val primitives: DottyPrim
234234
for (binary <- ctx.compilationUnit.pickled.get(claszSymbol.asClass)) {
235235
val store = if (mirrorC ne null) mirrorC else plainC
236236
val tasty =
237-
if (!ctx.settings.YemitTastyInClass.value) {
238-
val outTastyFile = getFileForClassfile(outF, store.name, ".tasty")
239-
val outstream = new DataOutputStream(outTastyFile.bufferedOutput)
240-
try outstream.write(binary())
241-
catch case ex: ClosedByInterruptException =>
242-
try
243-
outTastyFile.delete() // don't leave an empty or half-written tastyfile around after an interrupt
244-
catch case _: Throwable =>
245-
throw ex
246-
finally outstream.close()
247-
248-
val uuid = new TastyHeaderUnpickler(binary()).readHeader()
249-
val lo = uuid.getMostSignificantBits
250-
val hi = uuid.getLeastSignificantBits
251-
252-
// TASTY attribute is created but only the UUID bytes are stored in it.
253-
// A TASTY attribute has length 16 if and only if the .tasty file exists.
254-
val buffer = new TastyBuffer(16)
255-
buffer.writeUncompressedLong(lo)
256-
buffer.writeUncompressedLong(hi)
257-
buffer.bytes
258-
} else {
259-
// Create an empty file to signal that a tasty section exist in the corresponding .class
260-
// This is much cheaper and simpler to check than doing classfile parsing
261-
getFileForClassfile(outF, store.name, ".hasTasty")
262-
binary()
263-
}
237+
val outTastyFile = getFileForClassfile(outF, store.name, ".tasty")
238+
val outstream = new DataOutputStream(outTastyFile.bufferedOutput)
239+
try outstream.write(binary())
240+
catch case ex: ClosedByInterruptException =>
241+
try
242+
outTastyFile.delete() // don't leave an empty or half-written tastyfile around after an interrupt
243+
catch case _: Throwable =>
244+
throw ex
245+
finally outstream.close()
246+
247+
val uuid = new TastyHeaderUnpickler(binary()).readHeader()
248+
val lo = uuid.getMostSignificantBits
249+
val hi = uuid.getLeastSignificantBits
250+
251+
// TASTY attribute is created but only the UUID bytes are stored in it.
252+
// A TASTY attribute has length 16 if and only if the .tasty file exists.
253+
val buffer = new TastyBuffer(16)
254+
buffer.writeUncompressedLong(lo)
255+
buffer.writeUncompressedLong(hi)
256+
buffer.bytes
257+
264258
val dataAttr = createJAttribute(nme.TASTYATTR.mangledString, tasty, 0, tasty.length)
265259
store.visitAttribute(dataAttr)
266260
}

compiler/src/dotty/tools/dotc/config/ScalaSettings.scala

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,6 @@ class ScalaSettings extends Settings.SettingGroup with CommonScalaSettings {
154154
val YdebugError: Setting[Boolean] = BooleanSetting("-Ydebug-error", "Print the stack trace when any error is caught.", false)
155155
val YtermConflict: Setting[String] = ChoiceSetting("-Yresolve-term-conflict", "strategy", "Resolve term conflicts", List("package", "object", "error"), "error")
156156
val Ylog: Setting[List[String]] = PhasesSetting("-Ylog", "Log operations during")
157-
val YemitTastyInClass: Setting[Boolean] = BooleanSetting("-Yemit-tasty-in-class", "Generate tasty in the .class file and add an empty *.hasTasty file.")
158157
val YlogClasspath: Setting[Boolean] = BooleanSetting("-Ylog-classpath", "Output information about what classpath is being applied.")
159158
val YdisableFlatCpCaching: Setting[Boolean] = BooleanSetting("-YdisableFlatCpCaching", "Do not cache flat classpath representation of classpath elements from jars across compiler instances.")
160159

compiler/src/dotty/tools/dotc/fromtasty/Debug.scala

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,10 +36,9 @@ object Debug {
3636

3737
val fromTastyOut = Files.createDirectory(tmpOut.resolve("from-tasty"))
3838

39-
val extensions = List("tasty", "hasTasty").map(_.toLowerCase)
4039
val tastyFiles =
4140
Directory(fromSourcesOut).walk
42-
.filter(x => x.isFile && extensions.exists(_ == x.extension.toLowerCase))
41+
.filter(x => x.isFile && "tasty".equalsIgnoreCase(x.extension))
4342
.map(_.toString)
4443
.toList
4544

compiler/src/dotty/tools/dotc/interactive/InteractiveDriver.scala

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ class InteractiveDriver(val settings: List[String]) extends Driver {
5757

5858
// Presence of a file with one of these suffixes indicates that the
5959
// corresponding class has been pickled with TASTY.
60-
private val tastySuffixes = List(".hasTasty", ".tasty")
60+
private val tastySuffix = ".tasty"
6161

6262
// FIXME: All the code doing classpath handling is very fragile and ugly,
6363
// improving this requires changing the dotty classpath APIs to handle our usecases.
@@ -220,11 +220,8 @@ class InteractiveDriver(val settings: List[String]) extends Driver {
220220
while (entries.hasMoreElements) {
221221
val entry = entries.nextElement()
222222
val name = entry.getName
223-
tastySuffixes.find(name.endsWith) match {
224-
case Some(tastySuffix) =>
225-
buffer += name.replace("/", ".").stripSuffix(tastySuffix).toTypeName
226-
case _ =>
227-
}
223+
if name.endsWith(tastySuffix) then
224+
buffer += name.replace("/", ".").stripSuffix(tastySuffix).toTypeName
228225
}
229226
}
230227
finally zipFile.close()
@@ -237,13 +234,8 @@ class InteractiveDriver(val settings: List[String]) extends Driver {
237234
override def visitFile(path: Path, attrs: BasicFileAttributes) = {
238235
if (!attrs.isDirectory) {
239236
val name = path.getFileName.toString
240-
for {
241-
tastySuffix <- tastySuffixes
242-
if name.endsWith(tastySuffix)
243-
}
244-
{
237+
if name.endsWith(tastySuffix) then
245238
buffer += dir.relativize(path).toString.replace("/", ".").stripSuffix(tastySuffix).toTypeName
246-
}
247239
}
248240
FileVisitResult.CONTINUE
249241
}

compiler/test/dotty/tools/dotc/CompilationTests.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -232,7 +232,7 @@ class CompilationTests {
232232
Properties.compilerInterface, Properties.scalaLibrary, Properties.scalaAsm,
233233
Properties.dottyInterfaces, Properties.jlineTerminal, Properties.jlineReader,
234234
).mkString(File.pathSeparator),
235-
Array("-Ycheck-reentrant", "-Yemit-tasty-in-class", "-language:postfixOps", "-Ysemanticdb")
235+
Array("-Ycheck-reentrant", "-language:postfixOps", "-Ysemanticdb")
236236
)
237237

238238
val libraryDirs = List(Paths.get("library/src"), Paths.get("library/src-bootstrapped"))

compiler/test/dotty/tools/vulpix/ParallelTesting.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1369,5 +1369,5 @@ object ParallelTesting {
13691369
}
13701370

13711371
def isTastyFile(f: JFile): Boolean =
1372-
f.getName.endsWith(".hasTasty") || f.getName.endsWith(".tasty")
1372+
f.getName.endsWith(".tasty")
13731373
}

sbt-dotty/src/dotty/tools/sbtplugin/DottyPlugin.scala

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -136,15 +136,18 @@ object DottyPlugin extends AutoPlugin {
136136
override def requires: Plugins = plugins.JvmPlugin
137137
override def trigger = allRequirements
138138

139-
/** Patches the IncOptions so that .tasty and .hasTasty files are pruned as needed.
139+
/** Patches the IncOptions so that .tasty files are pruned as needed.
140140
*
141141
* This code is adapted from `scalaJSPatchIncOptions` in Scala.js, which needs
142-
* to do the exact same thing but for classfiles.
142+
* to do the exact same thing but for .sjsir files.
143143
*
144144
* This complicated logic patches the ClassfileManager factory of the given
145-
* IncOptions with one that is aware of .tasty and .hasTasty files emitted by the Dotty
145+
* IncOptions with one that is aware of .tasty files emitted by the Dotty
146146
* compiler. This makes sure that, when a .class file must be deleted, the
147-
* corresponding .tasty or .hasTasty file is also deleted.
147+
* corresponding .tasty file is also deleted.
148+
*
149+
* To support older versions of dotty, this also takes care of .hasTasty
150+
* files, although they are not used anymore.
148151
*/
149152
def dottyPatchIncOptions(incOptions: IncOptions): IncOptions = {
150153
val tastyFileManager = new TastyFileManager

sbt-dotty/src/dotty/tools/sbtplugin/TastyFileManager.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,18 @@ import xsbti.compile.ClassFileManager
99
import scala.collection.mutable
1010

1111

12-
/** A class file manger that prunes .tasty and .hasTasty as needed.
12+
/** A class file manger that prunes .tasty as needed.
1313
*
1414
* This makes sure that, when a .class file must be deleted, the
15-
* corresponding .tasty or .hasTasty file is also deleted.
15+
* corresponding .tasty file is also deleted.
1616
*
1717
* This code is adapted from Zinc `TransactionalClassFileManager`.
1818
* We need to duplicate the logic since forwarding to the default class
1919
* file manager doesn't work: we need to backup tasty files in a different
2020
* temporary directory as class files.
21+
*
22+
* To support older versions of dotty, this also takes care of .hasTasty
23+
* files, although they are not used anymore.
2124
*/
2225
final class TastyFileManager extends ClassFileManager {
2326
private[this] var _tempDir: File = null

0 commit comments

Comments
 (0)