Skip to content

Fix dotr -tasty #3436

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

Merged
merged 14 commits into from
Nov 16, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
5 changes: 4 additions & 1 deletion compiler/src/dotty/tools/dotc/core/SymbolLoaders.scala
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
Original file line number Diff line number Diff line change
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
31 changes: 31 additions & 0 deletions project/scripts/sbtBootstrappedTests
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,34 @@

# 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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any reason to use dist-bootstrapped/**/dotc instead of bin/dotc?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wanted to make sure I was testing that version of the script. We could also add some tests for bin/dotc in the future.

Copy link
Contributor

@OlivierBlanvillain OlivierBlanvillain Nov 15, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

bin/dotc just forwards to dist-bootstrapped/target/pack/bin/dotc and calls sbt dist-bootstrapped/pack if needed :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, I'll change it.

# FIXME #3477
#./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
# FIXME #3477
#./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
Original file line number Diff line number Diff line change
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