Skip to content

Commit 01eb5a2

Browse files
authored
Merge pull request scala#12197 from philwalk/refactored-scalac-startup-latency
avoid duplicate call to dist/bin/common via refactored scalac
2 parents 3d8b6a1 + 48262d0 commit 01eb5a2

File tree

6 files changed

+221
-144
lines changed

6 files changed

+221
-144
lines changed
Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,2 @@
1-
scala> val d: java.sql.Date = new java.sql.Date(100L)
2-
val d: java.sql.Date = 1970-01-01
3-
1+
scala> val d: Long = (new java.sql.Date(100L)).getTime
2+
val d: Long = 100

compiler/test/dotty/tools/scripting/ClasspathTests.scala

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ class ClasspathTests:
1818
val packBinDir = "dist/target/pack/bin"
1919
val scalaCopy = makeTestableScriptCopy("scala")
2020
val scalacCopy = makeTestableScriptCopy("scalac")
21+
val commonCopy = makeTestableScriptCopy("common")
2122

2223
// only interested in classpath test scripts
2324
def testFiles = scripts("/scripting").filter { _.getName.matches("classpath.*[.]sc") }
@@ -38,7 +39,8 @@ class ClasspathTests:
3839
if Files.exists(scriptPath) then
3940
val lines = Files.readAllLines(scriptPath).asScala.map {
4041
_.replaceAll("/scalac", "/scalac-copy").
41-
replaceFirst("^eval(.*JAVACMD.*)", "echo $1")
42+
replaceAll("/common", "/common-copy").
43+
replaceFirst("^ *eval(.*JAVACMD.*)", "echo $1")
4244
}
4345
val bytes = (lines.mkString("\n")+"\n").getBytes
4446
Files.write(scriptCopy, bytes)

dist/bin/common

Lines changed: 65 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -54,15 +54,15 @@ case "`uname`" in
5454
esac
5555

5656
unset CYGPATHCMD
57-
if [[ $cygwin || $mingw || $msys ]]; then
57+
if [[ ${cygwin-} || ${mingw-} || ${msys-} ]]; then
5858
# ConEmu terminal is incompatible with jna-5.*.jar
59-
[[ ($CONEMUANSI || $ConEmuANSI) ]] && conemu=true
59+
[[ (${CONEMUANSI-} || ${ConEmuANSI-}) ]] && conemu=true
6060
# cygpath is used by various windows shells: cygwin, git-sdk, gitbash, msys, etc.
6161
CYGPATHCMD=`which cygpath 2>/dev/null`
6262
case "$TERM" in
6363
rxvt* | xterm* | cygwin*)
6464
stty -icanon min 1 -echo
65-
SCALA_OPTS="$SCALA_OPTS -Djline.terminal=unix"
65+
JAVA_OPTS="$JAVA_OPTS -Djline.terminal=unix"
6666
;;
6767
esac
6868
fi
@@ -111,14 +111,14 @@ CLASSPATH_SUFFIX=""
111111
PSEP=":"
112112

113113
# translate paths to Windows-mixed format before running java
114-
if [ -n "$CYGPATHCMD" ]; then
115-
[ -n "$PROG_HOME" ] &&
114+
if [ -n "${CYGPATHCMD-}" ]; then
115+
[ -n "${PROG_HOME-}" ] &&
116116
PROG_HOME=`"$CYGPATHCMD" -am "$PROG_HOME"`
117117
[ -n "$JAVA_HOME" ] &&
118118
JAVA_HOME=`"$CYGPATHCMD" -am "$JAVA_HOME"`
119119
CLASSPATH_SUFFIX=";"
120120
PSEP=";"
121-
elif [[ $mingw || $msys ]]; then
121+
elif [[ ${mingw-} || ${msys-} ]]; then
122122
# For Mingw / Msys, convert paths from UNIX format before anything is touched
123123
[ -n "$PROG_HOME" ] &&
124124
PROG_HOME="`(cd "$PROG_HOME"; pwd -W | sed 's|/|\\\\|g')`"
@@ -155,8 +155,66 @@ SBT_INTF=$(find_lib "*compiler-interface*")
155155
JLINE_READER=$(find_lib "*jline-reader-3*")
156156
JLINE_TERMINAL=$(find_lib "*jline-terminal-3*")
157157
JLINE_TERMINAL_JNA=$(find_lib "*jline-terminal-jna-3*")
158-
[[ $conemu ]] || JNA=$(find_lib "*jna-5*")
158+
[[ ${conemu-} ]] || JNA=$(find_lib "*jna-5*")
159159

160160
# debug
161161

162162
DEBUG_STR=-agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=5005
163+
164+
classpathArgs () {
165+
# echo "dotty-compiler: $DOTTY_COMP"
166+
# echo "dotty-interface: $DOTTY_INTF"
167+
# echo "dotty-library: $DOTTY_LIB"
168+
# echo "tasty-core: $TASTY_CORE"
169+
# echo "scala-asm: $SCALA_ASM"
170+
# echo "scala-lib: $SCALA_LIB"
171+
# echo "sbt-intface: $SBT_INTF"
172+
173+
toolchain=""
174+
toolchain+="$SCALA_LIB$PSEP"
175+
toolchain+="$DOTTY_LIB$PSEP"
176+
toolchain+="$SCALA_ASM$PSEP"
177+
toolchain+="$SBT_INTF$PSEP"
178+
toolchain+="$DOTTY_INTF$PSEP"
179+
toolchain+="$DOTTY_COMP$PSEP"
180+
toolchain+="$TASTY_CORE$PSEP"
181+
toolchain+="$DOTTY_STAGING$PSEP"
182+
toolchain+="$DOTTY_TASTY_INSPECTOR$PSEP"
183+
184+
# jine
185+
toolchain+="$JLINE_READER$PSEP"
186+
toolchain+="$JLINE_TERMINAL$PSEP"
187+
toolchain+="$JLINE_TERMINAL_JNA$PSEP"
188+
[ -n "${JNA-}" ] && toolchain+="$JNA$PSEP"
189+
190+
if [ -n "${jvm_cp_args-}" ]; then
191+
jvm_cp_args="$toolchain$jvm_cp_args"
192+
else
193+
jvm_cp_args="$toolchain$PSEP"
194+
fi
195+
}
196+
197+
default_java_opts="-Xmx768m -Xms768m"
198+
199+
CompilerMain=dotty.tools.dotc.Main
200+
DecompilerMain=dotty.tools.dotc.decompiler.Main
201+
ReplMain=dotty.tools.repl.Main
202+
ScriptingMain=dotty.tools.scripting.Main
203+
204+
declare -a java_args
205+
declare -a scala_args
206+
declare -a residual_args
207+
declare -a script_args
208+
209+
addJava () {
210+
java_args+=("'$1'")
211+
}
212+
addScala () {
213+
scala_args+=("'$1'")
214+
}
215+
addResidual () {
216+
residual_args+=("'$1'")
217+
}
218+
addScript () {
219+
script_args+=("'$1'")
220+
}

0 commit comments

Comments
 (0)