Skip to content

Commit ef391dd

Browse files
committed
Fix rebase on master.
1 parent 49b2fb0 commit ef391dd

File tree

3 files changed

+13
-42
lines changed

3 files changed

+13
-42
lines changed

compilation/src/main/dotc/scala/tools/benchmark/BenchmarkDriver.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import dotty.tools.dotc.core.Contexts.ContextBase
66

77
trait BenchmarkDriver extends BaseBenchmarkDriver {
88
def compileImpl(): Unit = {
9-
implicit val ctx = (new ContextBase).initialCtx.fresh
9+
implicit val ctx = new ContextBase().initialCtx.fresh
1010
ctx.setSetting(ctx.settings.usejavacp, true)
1111
if (depsClasspath != null) {
1212
ctx.setSetting(ctx.settings.classpath,
@@ -15,8 +15,8 @@ trait BenchmarkDriver extends BaseBenchmarkDriver {
1515
ctx.setSetting(ctx.settings.d, tempDir.getAbsolutePath)
1616
ctx.setSetting(ctx.settings.language, List("Scala2"))
1717
val compiler = new dotty.tools.dotc.Compiler
18-
val reporter =
19-
dotty.tools.dotc.Bench.doCompile(compiler, compilerArgs.toList)
18+
val args = compilerArgs ++ sourceFiles
19+
val reporter = dotty.tools.dotc.Bench.doCompile(compiler, args)
2020
assert(!reporter.hasErrors)
2121
}
2222
}

compilation/src/main/scala/scala/tools/nsc/ScalacBenchmark.scala

Lines changed: 4 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ trait BaseBenchmarkDriver {
2121
def depsClasspath: String
2222
def tempDir: File
2323
def corpusSourcePath: Path
24-
def compilerArgs: Array[String]
24+
def compilerArgs: List[String]
25+
def sourceFiles: List[String]
2526
}
2627

2728
@State(Scope.Benchmark)
@@ -39,39 +40,7 @@ class ScalacBenchmark extends BenchmarkDriver {
3940

4041
var depsClasspath: String = _
4142

42-
def compileImpl(): Unit = {
43-
44-
// MainClass is copy-pasted from compiler for source compatibility with 2.10.x - 2.13.x
45-
class MainClass extends Driver with EvalLoop {
46-
def resident(compiler: Global): Unit = loop { line =>
47-
val command = new CompilerCommand(line split "\\s+" toList, new Settings(scalacError))
48-
compiler.reporter.reset()
49-
new compiler.Run() compile command.files
50-
}
51-
52-
override def newCompiler(): Global = Global(settings, reporter)
53-
54-
override protected def processSettingsHook(): Boolean = {
55-
if (source == "scala")
56-
settings.sourcepath.value = Paths.get(s"../corpus/$source/$corpusVersion/library").toAbsolutePath.normalize.toString
57-
else
58-
settings.usejavacp.value = true
59-
settings.outdir.value = tempDir.getAbsolutePath
60-
settings.nowarn.value = true
61-
if (depsClasspath != null)
62-
settings.processArgumentString(s"-cp $depsClasspath")
63-
true
64-
}
65-
}
66-
val driver = new MainClass
67-
68-
val extras = if (extraArgs != null && extraArgs != "") extraArgs.split('|').toList else Nil
69-
val allArgs = compilerArgs ++ extras ++ sourceFiles
70-
driver.process(allArgs.toArray)
71-
assert(!driver.reporter.hasErrors)
72-
}
73-
74-
def compilerArgs: List[String] = if (source.startsWith("@")) List(source) else Nil
43+
def compilerArgs: List[String] = if (source.startsWith("@")) source :: Nil else Nil
7544

7645
def sourceFiles: List[String] =
7746
if (source.startsWith("@")) Nil
@@ -81,7 +50,7 @@ class ScalacBenchmark extends BenchmarkDriver {
8150
val files = allFiles.filter(f => {
8251
val name = f.getFileName.toString
8352
name.endsWith(".scala") || name.endsWith(".java")
84-
}).map(_.toAbsolutePath.normalize.toString).toList
53+
}).map(_.toAbsolutePath.normalize.toString)
8554
files
8655
}
8756

compilation/src/main/scalac/scala/tools/benchmark/BenchmarkDriver.scala

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,15 @@ trait BenchmarkDriver extends BaseBenchmarkDriver {
2424
settings.nowarn.value = true
2525
if (depsClasspath != null)
2626
settings.processArgumentString(s"-cp $depsClasspath")
27-
if (extraArgs != null && extraArgs != "")
28-
settings.processArgumentString(extraArgs)
2927
true
3028
}
3129
}
3230
val driver = new MainClass
33-
driver.process(compilerArgs)
31+
32+
val extras = if (extraArgs != null && extraArgs != "") extraArgs.split('|').toList else Nil
33+
val allArgs = compilerArgs ++ extras ++ sourceFiles
34+
driver.process(allArgs.toArray)
3435
assert(!driver.reporter.hasErrors)
3536
}
36-
}
37+
38+
}

0 commit comments

Comments
 (0)