Skip to content

Commit

Permalink
Do not insert -Yretain-trees when compiling with -tasty
Browse files Browse the repository at this point in the history
  • Loading branch information
nicolasstucki committed Nov 15, 2017
1 parent fdbab48 commit a809cfd
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 13 deletions.
5 changes: 4 additions & 1 deletion compiler/src/dotty/tools/dotc/core/SymbolLoaders.scala
Expand Up @@ -326,7 +326,7 @@ class ClassfileLoader(val classfile: AbstractFile) extends SymbolLoader {
val (classRoot, moduleRoot) = rootDenots(root.asClass)
val classfileParser = new ClassfileParser(classfile, classRoot, moduleRoot)(ctx)
val result = classfileParser.run()
if (ctx.settings.YretainTrees.value || ctx.settings.XlinkOptimise.value) {
if (mayLoadTreesFromTasty) {
result match {
case Some(unpickler: tasty.DottyUnpickler) =>
classRoot.symbol.asClass.unpickler = unpickler
Expand All @@ -335,6 +335,9 @@ class ClassfileLoader(val classfile: AbstractFile) extends SymbolLoader {
}
}
}

private def mayLoadTreesFromTasty(implicit ctx: Context): Boolean =
ctx.settings.YretainTrees.value || ctx.settings.XlinkOptimise.value || ctx.settings.tasty.value
}

class SourcefileLoader(val srcfile: AbstractFile) extends SymbolLoader {
Expand Down
Expand Up @@ -20,7 +20,6 @@ class ReadTastyTreesFromClasses extends FrontEnd {

def readTASTY(unit: CompilationUnit)(implicit ctx: Context): Option[CompilationUnit] = unit match {
case unit: TASTYCompilationUnit =>
assert(ctx.settings.YretainTrees.value)
val className = unit.className.toTypeName
def compilationUnit(className: TypeName): Option[CompilationUnit] = {
tree(className).flatMap {
Expand Down
2 changes: 1 addition & 1 deletion compiler/test/dotty/tools/vulpix/ParallelTesting.scala
Expand Up @@ -1099,7 +1099,7 @@ trait ParallelTesting extends RunnerOrchestration { self =>
val target = JointCompilationSource(
testGroup.name,
Array(sourceFile),
flags.withClasspath(tastySource.getPath) and "-Yretain-trees",
flags.withClasspath(tastySource.getPath) and "-tasty",
tastySource,
fromTasty = true
)
Expand Down
1 change: 0 additions & 1 deletion dist/bin/dotc
Expand Up @@ -81,7 +81,6 @@ case "$1" in
# Optimize for short-running applications, see https://github.com/lampepfl/dotty/issues/222
-Oshort) addJava "-XX:+TieredCompilation -XX:TieredStopAtLevel=1" && shift ;;
-repl) PROG_NAME="$ReplMain" && shift ;;
-tasty) addScala "-Yretain-trees" && PROG_NAME="$CompilerMain" && shift ;;
-compile) PROG_NAME="$CompilerMain" && shift ;;
-run) PROG_NAME="$ReplMain" && shift ;;
-bootcp) bootcp=true && shift ;;
Expand Down
8 changes: 1 addition & 7 deletions project/Build.scala
Expand Up @@ -623,17 +623,11 @@ object Build {
val args0: List[String] = spaceDelimited("<arg>").parsed.toList
val args = args0.filter(arg => arg != "-repl")

val tasty = args0.contains("-tasty")

val main =
if (repl) "dotty.tools.repl.Main"
else "dotty.tools.dotc.Main"

val extraArgs =
if (tasty && !args.contains("-Yretain-trees")) List("-Yretain-trees")
else Nil

val fullArgs = main :: extraArgs ::: insertClasspathInArgs(args, dottyLib)
val fullArgs = main :: insertClasspathInArgs(args, dottyLib)

(runMain in Compile).toTask(fullArgs.mkString(" ", " ", ""))
}
Expand Down
29 changes: 29 additions & 0 deletions project/scripts/sbtBootstrappedTests
Expand Up @@ -2,3 +2,32 @@

# check that benchmarks can run
./project/scripts/sbt "dotty-bench-bootstrapped/jmh:run 1 1 tests/pos/alias.scala"


# setup for `dotc`/`dotr` script tests
./project/scripts/sbt dist-bootstrapped/pack

# check that `dotc` compiles and `dotr` runs it
echo "testing sbt dotc and dotr"
mkdir out/scriptedtest0
./dist-bootstrapped/target/pack/bin/dotc tests/pos/sbtDotrTest.scala -d out/scriptedtest0
./dist-bootstrapped/target/pack/bin/dotr -classpath out/scriptedtest0 dotrtest.Test" > sbtdotr1.out
if grep -e "dotr test ok" sbtdotr1.out; then
echo "output ok"
else
exit -1
fi
# check that `dotc` compiles and `dotr` runs it
echo "testing sbt dotc -tasty and dotr -classpath"
mkdir out/scriptedtest1
mkdir out/scriptedtest2
./dist-bootstrapped/target/pack/bin/dotc tests/pos/sbtDotrTest.scala -d out/scriptedtest1/
./dist-bootstrapped/target/pack/bin/dotc -tasty -classpath out/scriptedtest1/ -d out/scriptedtest2/ dotrtest.Test
./dist-bootstrapped/target/pack/bin/dotr -classpath out/scriptedtest2/ dotrtest.Test" > sbtdotr2.out
if grep -e "dotr test ok" sbtdotr2.out; then
echo "output ok"
else
exit -1
fi
4 changes: 2 additions & 2 deletions project/scripts/sbtTests
Expand Up @@ -3,7 +3,7 @@
# check that benchmarks can run
./project/scripts/sbt "dotty-bench/jmh:run 1 1 tests/pos/alias.scala"

# check that `dotc` compiles and `dotr` runs it
# check that `sbt dotc` compiles and `sbt dotr` runs it
echo "testing sbt dotc and dotr"
mkdir out/scriptedtest0
./project/scripts/sbt ";dotc tests/pos/sbtDotrTest.scala -d out/scriptedtest0 ;dotr -classpath out/scriptedtest0 dotrtest.Test" > sbtdotr1.out
Expand All @@ -13,7 +13,7 @@ else
exit -1
fi

# check that `dotc` compiles and `dotr` runs it
# check that `sbt dotc` compiles and `sbt dotr` runs it
echo "testing sbt dotc -tasty and dotr -classpath"
mkdir out/scriptedtest1
mkdir out/scriptedtest2
Expand Down

0 comments on commit a809cfd

Please sign in to comment.