runopt.sh revision 1060:ca67ae7c46cb
1#!/bin/sh
2#
3# Copyright (c) 2010, 2014, Oracle and/or its affiliates. All rights reserved.
4# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5# 
6# This code is free software; you can redistribute it and/or modify it
7# under the terms of the GNU General Public License version 2 only, as
8# published by the Free Software Foundation.
9# 
10# This code is distributed in the hope that it will be useful, but WITHOUT
11# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12# FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13# version 2 for more details (a copy is included in the LICENSE file that
14# accompanied this code).
15# 
16# You should have received a copy of the GNU General Public License version
17# 2 along with this work; if not, write to the Free Software Foundation,
18# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19# 
20# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21# or visit www.oracle.com if you need additional information or have any
22# questions.
23#
24
25###########################################################################################
26# This is a helper script to evaluate nashorn with optimistic types
27# it produces a flight recording for every run, and uses the best 
28# known flags for performance for the current configration
29###########################################################################################
30
31# Flags to enable assertions, we need the system assertions too, since
32# this script runs Nashorn in the BCP to override any nashorn.jar that might
33# reside in your $JAVA_HOME/jre/lib/ext/nashorn.jar
34#
35ENABLE_ASSERTIONS_FLAGS="-ea -esa"
36
37# Flags to instrument lambdaform computation, caching, interpretation and compilation
38# Default compile threshold for lambdaforms is 30
39#
40#LAMBDAFORM_FLAGS="\
41#    -Djava.lang.invoke.MethodHandle.COMPILE_THRESHOLD=3 \
42#    -Djava.lang.invoke.MethodHandle.DUMP_CLASS_FILES=true \
43#    -Djava.lang.invoke.MethodHandle.TRACE_METHOD_LINKAGE=true \
44#    -Djava.lang.invoke.MethodHandle.TRACE_INTERPRETER=true"
45
46# Flags to run trusted tests from the Nashorn test suite
47#
48#TRUSTED_TEST_FLAGS="\
49#-Djava.security.manager \
50#-Djava.security.policy=../build/nashorn.policy -Dnashorn.debug"
51
52# Testing out new code optimizations using the generic hotspot "new code" parameter
53#
54#USE_NEW_CODE_FLAGS=-XX:+UnlockDiagnosticVMOptions -XX:+UseNewCode
55
56#
57#-Dnashorn.typeInfo.disabled=false \
58# and for Nashorn options: 
59# --class-cache-size=0 --persistent-code-cache=false 
60
61# Unique timestamped file name for JFR recordings. For JFR, we also have to
62# crank up the stack cutoff depth to 1024, because of ridiculously long lambda form
63# stack traces.
64#
65# It is also recommended that you go into $JAVA_HOME/jre/lib/jfr/default.jfc and
66# set the "method-sampling-interval" Normal and Maximum sample time as low as you
67# can go (10 ms on most platforms). The default is normally higher. The increased
68# sampling overhead is usually negligible for Nashorn runs, but the data is better
69
70if [ -z $JFR_FILENAME ]; then
71    JFR_FILENAME="./nashorn_$(date|sed "s/ /_/g"|sed "s/:/_/g").jfr"
72    echo "Using default JFR filename: ${JFR_FILENAME}..."
73fi
74
75# Flight recorder
76#
77# see above - already in place, copy the flags down here to disable
78ENABLE_FLIGHT_RECORDER_FLAGS="\
79    -XX:+UnlockCommercialFeatures \
80    -XX:+FlightRecorder \
81    -XX:FlightRecorderOptions=defaultrecording=true,disk=true,dumponexit=true,dumponexitpath=$JFR_FILENAME,stackdepth=1024"
82
83# Type specialization and math intrinsic replacement should be enabled by default in 8u20 and nine,
84# keeping this flag around for experimental reasons. Replace + with - to switch it off
85#
86#ENABLE_TYPE_SPECIALIZATION_FLAGS=-XX:+UseTypeSpeculation
87
88# Same with math intrinsics. They should be enabled by default in 8u20 and 9, so
89# this disables them if needed
90#
91#DISABLE_MATH_INTRINSICS_FLAGS=-XX:-UseMathExactIntrinsics
92
93# Add timing to time the compilation phases.
94#ENABLE_TIME_FLAGS=--log=time
95
96# Add ShowHiddenFrames to get lambda form internals on the stack traces
97#ENABLE_SHOW_HIDDEN_FRAMES_FLAGS=-XX:+ShowHiddenFrames
98
99# Add print optoassembly to get an asm dump. This requires 1) a debug build, not product,
100# That tired compilation is switched off, for C2 only output and that the number of
101# compiler threads is set to 1 for determinsm.
102#
103#PRINT_ASM_FLAGS=-XX:+PrintOptoAssembly -XX:-TieredCompilation -XX:CICompilerCount=1 \
104
105# Tier compile threasholds. Default value is 10. (1-100 is useful for experiments)
106#TIER_COMPILATION_THRESHOLD_FLAGS=-XX:IncreaseFirstTierCompileThresholdAt=10
107
108# Directory where to look for nashorn.jar in a dist folder. The default is "..", assuming
109# that we run the script from the make dir
110DIR=..
111NASHORN_JAR=$DIR/dist/nashorn.jar
112
113
114# The built Nashorn jar is placed first in the bootclasspath to override the JDK
115# nashorn.jar in $JAVA_HOME/jre/lib/ext. Thus, we also need -esa, as assertions in
116# nashorn count as system assertions in this configuration
117
118# Type profiling default level is 111, 222 adds some compile time, but is faster
119
120$JAVA_HOME/bin/java \
121$ENABLE_ASSERTIONS_FLAGS \
122$LAMBDAFORM_FLAGS \
123$TRUSTED_FLAGS \
124$USE_NEW_CODE_FLAGS \
125$ENABLE_SHOW_HIDDEN_FRAMES_FLAGS \
126$ENABLE_FLIGHT_RECORDER_FLAGS \
127$ENABLE_TYPE_SPECIALIZATION_FLAGS \
128$TIERED_COMPILATION_THRESOLD_FLAGS \
129$DISABLE_MATH_INTRINSICS_FLAGS \
130$PRINT_ASM_FLAGS \
131-Xbootclasspath/p:$NASHORN_JAR \
132-Xms2G -Xmx2G \
133-XX:TypeProfileLevel=222 \
134-cp $CLASSPATH:../build/test/classes/ \
135jdk.nashorn.tools.Shell $ENABLE_TIME_FLAGS ${@}
136
137
138