summaryrefslogtreecommitdiff
path: root/src/compiler/scala/tools/ant/templates/tool-unix.tmpl
diff options
context:
space:
mode:
authorPaul Phillips <paulp@improving.org>2010-12-07 02:59:01 +0000
committerPaul Phillips <paulp@improving.org>2010-12-07 02:59:01 +0000
commitfbe897d165bfbb8cda05e4b25f0f773288653f54 (patch)
tree4377600c688b4644721a6289c388100e24546fae /src/compiler/scala/tools/ant/templates/tool-unix.tmpl
parenta8db7a2da783b0752aad1a738b0e5600c303e97e (diff)
downloadscala-fbe897d165bfbb8cda05e4b25f0f773288653f54.tar.gz
scala-fbe897d165bfbb8cda05e4b25f0f773288653f54.tar.bz2
scala-fbe897d165bfbb8cda05e4b25f0f773288653f54.zip
Tackling long standing issues with startup.
anyone can offer any reason why it's not (long past) time to do this I can back the truck up. (But I will have a list of bourne shell scripts for you to write.) With this commit: 1) -J options are now passed to the underlying JVM, along with -D options which already were. scala -Dfoo=bar and scala -J-Dfoo=bar are identical (but -J can pass arbitrary arguments to the jvm: -J-verbose, -J-Xmx4G, etc.) 2) Eliminated DefinesSetting. It was ill-conceived because setting system properties must be done at JVM start to guarantee they will be seen where appropriate: by the time scala is involved it's too late. The starter script takes care of routing -D to the jvm, and no longer sends them along to scala as well. Since we have a new system package you can read any property in system.props, like this: % scala -Dp1="hi" -Dp2="bye" -e 'println(system.props filterKeys (_.length == 2))' Map(p2 -> bye, p1 -> hi) 3) After measuring that startup is a full second faster by putting the scala jars on the bootclasspath, I gave us a standard way to take advantage of this. It's not done by default, although we should seriously consider it (I'm familiar with the issues that have arisen in the past.) Reclaim your life, one startup second at a time. The flag is --usebootcp, as below: // Here's a way (in bash 4) to compare repl startup times each way while true ; do time pscala -i <(echo "system exit 0") ; done |& grep real while true ; do time pscala --usebootcp -i <(echo "system exit 0") ; done |& grep real Once again I find myself unable to nominate any plausible reviewer (if there were anyone interested in this stuff, they'd be doing it instead of me) so no review.
Diffstat (limited to 'src/compiler/scala/tools/ant/templates/tool-unix.tmpl')
-rw-r--r--src/compiler/scala/tools/ant/templates/tool-unix.tmpl43
1 files changed, 33 insertions, 10 deletions
diff --git a/src/compiler/scala/tools/ant/templates/tool-unix.tmpl b/src/compiler/scala/tools/ant/templates/tool-unix.tmpl
index ceb6ec5ad4..25616c171a 100644
--- a/src/compiler/scala/tools/ant/templates/tool-unix.tmpl
+++ b/src/compiler/scala/tools/ant/templates/tool-unix.tmpl
@@ -1,4 +1,4 @@
-#!/bin/sh
+#!/bin/bash
#
##############################################################################
# Copyright 2002-2010, LAMP/EPFL
@@ -63,21 +63,44 @@ fi
# Reminder: substitution ${JAVA_OPTS:=-Xmx256M -Xms16M} DO NOT work on Solaris
[ -n "$JAVA_OPTS" ] || JAVA_OPTS="@javaflags@"
-# break out -D options and add them to JAVA_OPTS as well so they reach the
-# underlying JVM in time to do some good.
-for i
-do
- case "$i" in
+# break out -D and -J options and add them to JAVA_OPTS as well
+# so they reach the underlying JVM in time to do some good. The
+# -D options will be available as system properties.
+declare -a java_args
+declare -a scala_args
+CPSWITCH="-cp \"$TOOL_CLASSPATH\""
+
+while [ $# -gt 0 ]; do
+ case "$1" in
-D*)
- JAVA_OPTS="$JAVA_OPTS $i" ;;
+ java_args=("${java_args[@@]}" "$1")
+ shift
+ ;;
+ -J*)
+ java_args=("${java_args[@@]}" "${1:2}")
+ shift
+ ;;
+ --usebootcp)
+ CPSWITCH="-Xbootclasspath/a:\"$TOOL_CLASSPATH\""
+ shift
+ ;;
*)
+ scala_args=("${scala_args[@@]}" "$1")
+ shift
;;
esac
-done
-
+done
+# reset "$@@" to the remaining args
+set -- "${scala_args[@@]}"
if [ -z "$JAVACMD" -a -n "$JAVA_HOME" -a -x "$JAVA_HOME/bin/java" ]; then
JAVACMD="$JAVA_HOME/bin/java"
fi
-exec "${JAVACMD:=java}" $JAVA_OPTS -cp "$TOOL_CLASSPATH" -Dscala.usejavacp=true -Dscala.home="$SCALA_HOME" -Denv.emacs="$EMACS" @properties@ @class@ @toolflags@ "$@@"
+exec "${JAVACMD:=java}" \
+ "${java_args[@@]}" \
+ $CPSWITCH \
+ -Dscala.usejavacp=true \
+ -Dscala.home="$SCALA_HOME" \
+ -Denv.emacs="$EMACS" \
+ @properties@ @class@ @toolflags@ "$@@"