aboutsummaryrefslogtreecommitdiff
path: root/compiler
diff options
context:
space:
mode:
authorGuillaume Martres <smarter@ubuntu.com>2017-02-16 18:58:58 +0100
committerGuillaume Martres <smarter@ubuntu.com>2017-04-13 19:41:44 +0200
commit476778612e71379cf648693f7d02039301fb5607 (patch)
treea6d27763253f9de38ba03e155450039c9b6cead5 /compiler
parent0fe56ea73e6775a315f54772dc6bfb40815c7c98 (diff)
downloaddotty-476778612e71379cf648693f7d02039301fb5607.tar.gz
dotty-476778612e71379cf648693f7d02039301fb5607.tar.bz2
dotty-476778612e71379cf648693f7d02039301fb5607.zip
Fix #2184: Hyper Bootstrap! Integrate the backend as a git submodule
The backend lives in the scalac fork at https://github.com/lampepfl/scala/tree/sharing-backend. Before this commit, the scala-compiler built from this fork was a dependency of Scala just to get this backend. This made it much more cumbersome to test changes to the backend and also forced us to depend on Scala 2.11.5 since that is the version of scalac that the forked backend is based on. This commit changes this by adding a git submodule in the `scala-backend` directory that points to the scalac fork. We do not compile the whole submodule, instead we add the subset of files we need to the dotty-compiler project in the sbt build. See backend.md for more information (online at http://dotty.epfl.ch/docs/contributing/backend.html) once this commit is merged. The most important thing to note is that whenever you clone dotty you should do `git clone --recursive` to also clone the submodule. If you already have a cloned dotty you'll need to do: git submodule update --init You will need to repeat this command anytime you update dotty and the backend has been updated, otherwise the content of `scala-backend` will be stale.
Diffstat (limited to 'compiler')
-rw-r--r--compiler/src/dotty/tools/backend/jvm/GenBCode.scala6
-rw-r--r--compiler/src/dotty/tools/backend/jvm/scalaPrimitives.scala2
-rw-r--r--compiler/src/scala/tools/nsc/io/package.scala27
-rw-r--r--compiler/test/dotc/tests.scala3
-rw-r--r--compiler/test/dotty/tools/TypeStealer.scala21
-rw-r--r--compiler/test/dotty/tools/backend/jvm/DottyBytecodeTest.scala2
-rw-r--r--compiler/test/dotty/tools/dotc/CompilationTests.scala42
7 files changed, 71 insertions, 32 deletions
diff --git a/compiler/src/dotty/tools/backend/jvm/GenBCode.scala b/compiler/src/dotty/tools/backend/jvm/GenBCode.scala
index 8fd6d1bc0..25a8061ac 100644
--- a/compiler/src/dotty/tools/backend/jvm/GenBCode.scala
+++ b/compiler/src/dotty/tools/backend/jvm/GenBCode.scala
@@ -8,7 +8,6 @@ import dotty.tools.dotc.core.Names.TypeName
import scala.collection.mutable
import scala.tools.asm.{ClassVisitor, CustomAttr, FieldVisitor, MethodVisitor}
-import scala.tools.nsc.Settings
import scala.tools.nsc.backend.jvm._
import dotty.tools.dotc
import dotty.tools.dotc.backend.jvm.DottyPrimitives
@@ -35,7 +34,6 @@ import tpd._
import StdNames._
import scala.reflect.io.{AbstractFile, Directory, PlainDirectory}
-import scala.tools.nsc.backend.jvm.opt.LocalOpt
class GenBCode extends Phase {
def phaseName: String = "genBCode"
@@ -246,10 +244,10 @@ class GenBCodePipeline(val entryPoints: List[Symbol], val int: DottyBackendInter
* - converting the plain ClassNode to byte array and placing it on queue-3
*/
class Worker2 {
- lazy val localOpt = new LocalOpt(new Settings())
+ // lazy val localOpt = new LocalOpt(new Settings())
def localOptimizations(classNode: ClassNode): Unit = {
- /*BackendStats.timed(BackendStats.methodOptTimer)*/(localOpt.methodOptimizations(classNode))
+ // BackendStats.timed(BackendStats.methodOptTimer)(localOpt.methodOptimizations(classNode))
}
def run(): Unit = {
diff --git a/compiler/src/dotty/tools/backend/jvm/scalaPrimitives.scala b/compiler/src/dotty/tools/backend/jvm/scalaPrimitives.scala
index 7beae90c4..851cacaa2 100644
--- a/compiler/src/dotty/tools/backend/jvm/scalaPrimitives.scala
+++ b/compiler/src/dotty/tools/backend/jvm/scalaPrimitives.scala
@@ -37,7 +37,7 @@ import core.Symbols.{Symbol, NoSymbol}
* Inspired from the `scalac` compiler.
*/
class DottyPrimitives(ctx: Context) {
- import scala.tools.nsc.backend.ScalaPrimitives._
+ import scala.tools.nsc.backend.ScalaPrimitivesOps._
private lazy val primitives: immutable.Map[Symbol, Int] = init
diff --git a/compiler/src/scala/tools/nsc/io/package.scala b/compiler/src/scala/tools/nsc/io/package.scala
new file mode 100644
index 000000000..6b30e5441
--- /dev/null
+++ b/compiler/src/scala/tools/nsc/io/package.scala
@@ -0,0 +1,27 @@
+package scala.tools.nsc
+
+/**
+ * Compatibility layer needed for the backend.
+ *
+ * Our backend is based on the Scala 2.11 GenBCode backend and modified so that
+ * it compiles both with dotty and scalac, since the backend uses
+ * scala.tools.nsc.io.*, we need to also provide it.
+ *
+ * See http://dotty.epfl.ch/docs/contributing/backend.html for more information.
+ */
+package object io {
+ type AbstractFile = scala.reflect.io.AbstractFile
+ val AbstractFile = scala.reflect.io.AbstractFile
+
+ type Directory = scala.reflect.io.Directory
+ val Directory = scala.reflect.io.Directory
+
+ type Path = scala.reflect.io.Path
+ val Path = scala.reflect.io.Path
+
+ type File = scala.reflect.io.File
+ val File = scala.reflect.io.File
+
+ type Jar = dotty.tools.io.Jar
+ val Jar = dotty.tools.io.Jar
+}
diff --git a/compiler/test/dotc/tests.scala b/compiler/test/dotc/tests.scala
index efecc1df3..0f1732e2a 100644
--- a/compiler/test/dotc/tests.scala
+++ b/compiler/test/dotc/tests.scala
@@ -358,7 +358,8 @@ class tests extends CompilerTest {
@Test def tasty_dotc_util = compileDir(dotcDir, "util", testPickling)
@Test def tasty_tools_io = compileDir(toolsDir, "io", testPickling)
- @Test def tasty_bootstrap = {
+ // Disabled, not worth porting since we're getting rid of the old JUnit tests soon.
+ /*@Test*/ def tasty_bootstrap = {
val logging = if (false) List("-Ylog-classpath", "-verbose") else Nil
val opt = List("-priorityclasspath", defaultOutputDir) ++ logging
// first compile dotty
diff --git a/compiler/test/dotty/tools/TypeStealer.scala b/compiler/test/dotty/tools/TypeStealer.scala
deleted file mode 100644
index ccaf2d41e..000000000
--- a/compiler/test/dotty/tools/TypeStealer.scala
+++ /dev/null
@@ -1,21 +0,0 @@
-package dotty.tools
-
-import scala.tools.nsc.interpreter._
-import scala.tools.nsc.Settings
-
-object TypeStealer {
- def main(args: Array[String]): Unit = {
- def repl = new ILoop {}
-
- val settings = new Settings
- settings.Yreplsync.value = true
-
- //use when launching normally outside SBT
- settings.usejavacp.value = true
-
- //an alternative to 'usejavacp' setting, when launching from within SBT
- //settings.embeddedDefaults[Repl.type]
-
- repl.process(settings)
- }
-}
diff --git a/compiler/test/dotty/tools/backend/jvm/DottyBytecodeTest.scala b/compiler/test/dotty/tools/backend/jvm/DottyBytecodeTest.scala
index fc9853691..c423089d0 100644
--- a/compiler/test/dotty/tools/backend/jvm/DottyBytecodeTest.scala
+++ b/compiler/test/dotty/tools/backend/jvm/DottyBytecodeTest.scala
@@ -11,7 +11,7 @@ import asm._
import asm.tree._
import scala.collection.JavaConverters._
-import scala.tools.nsc.util.JavaClassPath
+import io.JavaClassPath
import scala.collection.JavaConverters._
import scala.tools.asm.{ClassWriter, ClassReader}
import scala.tools.asm.tree._
diff --git a/compiler/test/dotty/tools/dotc/CompilationTests.scala b/compiler/test/dotty/tools/dotc/CompilationTests.scala
index cf9b200d4..504bdd2e0 100644
--- a/compiler/test/dotty/tools/dotc/CompilationTests.scala
+++ b/compiler/test/dotty/tools/dotc/CompilationTests.scala
@@ -4,11 +4,15 @@ package dotc
import org.junit.{ Test, BeforeClass, AfterClass }
+import java.nio.file._
+import java.util.stream.{ Stream => JStream }
+import scala.collection.JavaConverters._
import scala.util.matching.Regex
import scala.concurrent.duration._
import vulpix.{ ParallelTesting, SummaryReport, SummaryReporting, TestConfiguration }
+
class CompilationTests extends ParallelTesting {
import TestConfiguration._
import CompilationTests._
@@ -219,7 +223,7 @@ class CompilationTests extends ParallelTesting {
// compile with bootstrapped library on cp:
defaultOutputDir + "lib/src/:" +
// as well as bootstrapped compiler:
- defaultOutputDir + "dotty1/dotty/:" +
+ defaultOutputDir + "dotty1/dotty1/:" +
Jars.dottyInterfaces
)
@@ -227,8 +231,36 @@ class CompilationTests extends ParallelTesting {
compileDir("../library/src",
allowDeepSubtypes.and("-Ycheck-reentrant", "-strict", "-priorityclasspath", defaultOutputDir))
- def dotty1 =
- compileDir("../compiler/src/dotty", opt)
+ def sources(paths: JStream[Path], excludedFiles: List[String] = Nil): List[String] =
+ paths.iterator().asScala
+ .filter(path =>
+ (path.toString.endsWith(".scala") || path.toString.endsWith(".java"))
+ && !excludedFiles.contains(path.getFileName.toString))
+ .map(_.toString).toList
+
+ val compilerDir = Paths.get("../compiler/src")
+ val compilerSources = sources(Files.walk(compilerDir))
+
+ val backendDir = Paths.get("../scala-backend/src/compiler/scala/tools/nsc/backend")
+ val backendJvmDir = Paths.get("../scala-backend/src/compiler/scala/tools/nsc/backend/jvm")
+
+ // NOTE: Keep these exclusions synchronized with the ones in the sbt build (Build.scala)
+ val backendExcluded =
+ List("JavaPlatform.scala", "Platform.scala", "ScalaPrimitives.scala")
+ val backendJvmExcluded =
+ List("BCodeICodeCommon.scala", "GenASM.scala", "GenBCode.scala", "ScalacBackendInterface.scala")
+
+ val backendSources =
+ sources(Files.list(backendDir), excludedFiles = backendExcluded)
+ val backendJvmSources =
+ sources(Files.list(backendJvmDir), excludedFiles = backendJvmExcluded)
+
+ def dotty1 = {
+ compileList(
+ "dotty1",
+ compilerSources ++ backendSources ++ backendJvmSources,
+ opt)
+ }
def dotty2 =
compileShallowFilesInDir("../compiler/src/dotty", opt)
@@ -247,7 +279,9 @@ class CompilationTests extends ParallelTesting {
compileShallowFilesInDir("../compiler/src/dotty/tools/dotc/rewrite", opt) +
compileShallowFilesInDir("../compiler/src/dotty/tools/dotc/transform", opt) +
compileShallowFilesInDir("../compiler/src/dotty/tools/dotc/typer", opt) +
- compileShallowFilesInDir("../compiler/src/dotty/tools/dotc/util", opt)
+ compileShallowFilesInDir("../compiler/src/dotty/tools/dotc/util", opt) +
+ compileList("shallow-backend", backendSources, opt) +
+ compileList("shallow-backend-jvm", backendJvmSources, opt)
} :: Nil
}.map(_.checkCompile()).foreach(_.delete())
}