forked from SOM-st/TruffleSOM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
som
executable file
·199 lines (168 loc) · 8.36 KB
/
som
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
#!/usr/bin/env python2.7
import argparse
import sys
import os
import shlex
BASE_DIR = os.path.dirname(os.path.realpath(__file__))
JVMCI_BIN = os.getenv('JVMCI_BIN', None)
GRAAL_HOME = os.getenv('GRAAL_HOME', None)
GRAAL_FLAGS = os.getenv('GRAAL_FLAGS', None)
GRAAL_LOCATIONS = ['~/.local/graal-core/',
BASE_DIR + '/../graal/graal-jvmci-8']
JDK_VERSIONS = ['jdk1.8.0_91', 'jdk1.8.0_77', 'jdk1.8.0_72', 'jdk1.8.0_66',
'jdk1.8.0_65', 'jdk1.8.0_60', 'jdk1.8.0_45']
parser = argparse.ArgumentParser(
description='Helper script to run TruffleSOM with/without Graal')
parser.add_argument('-d', '--debug', help='wait for debugger to attach',
dest='debug', action='store_true', default=False)
parser.add_argument('-t', '--num-threads', help='number of threads to be used',
dest='threads', default=None)
explore = parser.add_argument_group('Explore', 'Investigate Execution')
explore.add_argument('-i', '--igv', help='dump compilation details to IGV',
dest='igv', action='store_true', default=False)
explore.add_argument('-l', '--low-level', help='enable low-level optimization output',
dest='low_level', action='store_true', default=False)
explore.add_argument('-ti', '--trace-invalidation', help='trace assumption invalidation and transfers to interpreter',
dest='trace_invalidation', action='store_true', default=False)
explore.add_argument('-w', '--perf-warnings', help='enable performance warnings',
dest='perf_warnings', action='store_true', default=False)
explore.add_argument('-v', '--visual-vm', help='connect to VisualVM for profiling',
dest='visual_vm', action='store_true', default=False)
profile = parser.add_argument_group('Profile', 'Profile Execution')
profile.add_argument('-p', '--profile', help='enable profiling after warmup',
dest='profile', action='store_true', default=False)
profile.add_argument('-a', '--profile-allocations', help='enable profiling after warmup, and profile allocations',
dest='profile_allocations', action='store_true', default=False)
profile.add_argument('-pt', '--profile-times', help='enable profiling after certain time intervals',
dest='profile_timed', action='store_true', default=False)
parser.add_argument('-o', '--only', help='only compile give methods, comma separated list',
dest='only_compile', default=None)
parser.add_argument('-A', '--no-assert', help='execute with assertions disabled',
dest='assert_', action='store_false', default=True)
parser.add_argument('-B', '--no-background', help='disable background compilation',
dest='background_compilation', action='store_false', default=True)
parser.add_argument('-C', '--no-compilation', help='disable Truffle compilation',
dest='no_compilation', action='store_true', default=False)
parser.add_argument('-G', '--interpreter', help='run without Graal',
dest='interpreter', action='store_true', default=False)
parser.add_argument('-X', '--java-interpreter', help='run without Graal, and only the Java interpreter',
dest='java_interpreter', action='store_true', default=False)
parser.add_argument('-T', '--no-trace', help='do not print truffle compilation info',
dest='no_trace', action='store_false', default=True)
parser.add_argument('--no-graph-pe', help='disable Graph PE',
dest='graph_pe', action='store_false', default=True)
parser.add_argument('-vv', '--verbose', action='store_true', default=False,
dest='verbose', help="print command-line before executing")
parser.add_argument('args', nargs=argparse.REMAINDER,
help='arguments passed to SOMns')
args, unknown = parser.parse_known_args()
JAVA_BIN = '/product/bin/java'
JAVA_ARGS = ['-d64']
if args.java_interpreter:
args.interpreter = True
if args.interpreter:
java_bin = "java"
elif JVMCI_BIN:
java_bin = JVMCI_BIN
JAVA_ARGS += ['-server']
else:
# determine graal binary
if GRAAL_HOME:
graal_home = GRAAL_HOME
else:
graal_home = None
for d in GRAAL_LOCATIONS:
d = os.path.expanduser(d)
if os.path.isdir(d):
graal_home = d
break
if not graal_home:
print "Graal couldn't be found. Please set GRAAL_HOME"
sys.exit(1)
if os.path.isdir(graal_home + '/bin'):
java_bin = graal_home + '/bin/java'
else:
java_bin = graal_home
for v in JDK_VERSIONS:
p = graal_home + '/' + v
if os.path.isdir(p):
java_bin = p + JAVA_BIN
break
if java_bin is graal_home or not os.path.isfile(java_bin):
print "No compatible JDK build found, is this script outdated?"
sys.exit(1)
SOM_ARGS = ['-Xbootclasspath/a:'
+ BASE_DIR + '/build/classes:'
+ BASE_DIR + '/libs/black-diamonds/build/classes:'
+ BASE_DIR + '/libs/truffle/sdk/mxbuild/dists/graal-sdk.jar:'
+ BASE_DIR + '/libs/truffle/truffle/mxbuild/dists/truffle-api.jar',
'trufflesom.vm.Universe']
# == Hotspot -XX:CompileCommand=print,*::callRoot
# Splitting
# -G:+TruffleSplitting
# -G:+TruffleSplittingNew
# == Compiler Settings
TWEAK_INLINING = ['-Dgraal.TruffleCompilationThreshold=191',
'-Dgraal.TruffleInliningMaxCallerSize=10000',
'-Dgraal.TruffleSplittingMaxCalleeSize=100000']
if not args.interpreter and GRAAL_FLAGS:
flags = shlex.split(str.strip(GRAAL_FLAGS))
else:
flags = []
# Handle executable names
if sys.argv[0].endswith('fast'):
args.assert_ = False
args.no_trace = True
if sys.argv[0].endswith('debug'):
args.perf_warnings = True
args.background_compilation = False
if args.debug:
flags += ['-Xdebug',
'-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000']
if not args.interpreter and args.igv:
flags += ['-Dgraal.Dump=Truffle,TruffleTree']
if args.low_level:
flags += ['-XX:+UnlockDiagnosticVMOptions', '-XX:+LogCompilation',
'-XX:+TraceDeoptimization']
if not args.interpreter and (args.profile or args.profile_allocations or args.profile_timed):
flags += ['-XX:JVMCICounterSize=5000', '-Dgraal.ProfileCompiledMethods=true',
'-DProfileCompiledMethodsPhase.WITH_SECTION_HEADER=true']
if args.profile_allocations:
flags += ['-Dgraal.ProfileAllocations=true']
if args.profile_timed:
flags += ['-Dgraal.TimedDynamicCounters=1000']
if args.profile:
flags += ['-Dgraal.BenchmarkDynamicCounters=out,completed,total']
if not args.interpreter and args.perf_warnings:
flags += ['-Dgraal.TruffleCompilationExceptionsAreFatal=true',
'-Dgraal.TraceTrufflePerformanceWarnings=true',
'-Dgraal.TraceTruffleCompilation=true',
'-Dgraal.TraceTruffleCompilationDetails=true',
'-Dgraal.TraceTruffleExpansionSource=true']
if not args.interpreter and args.trace_invalidation:
flags += ['-Dgraal.TraceTruffleTransferToInterpreter=true',
'-Dgraal.TraceTruffleAssumptions=true']
if not args.interpreter and args.only_compile:
flags.append("-Dgraal.TruffleCompileOnly=%s" % only_compile)
if args.visual_vm:
flags += ['-agentpath:/Users/smarr/Downloads/visualvm_138/profiler/lib/deployed/jdk16/mac/libprofilerinterface.jnilib=/Users/smarr/Downloads/visualvm_138/profiler/lib,5140']
if args.assert_:
flags += ['-esa', '-ea']
else:
flags += ['-dsa', '-da']
if not args.interpreter and not args.background_compilation:
flags += ['-Dgraal.TruffleBackgroundCompilation=false']
if not args.interpreter and args.no_compilation:
flags.append('-Dgraal.TruffleCompileOnly=__FAKE_METHOD_NON_EXISTING__')
if not args.interpreter and args.no_trace and not args.perf_warnings:
flags += ['-Dgraal.TraceTruffleInlining=false', '-Dgraal.TraceTruffleCompilation=false']
if not args.interpreter and not args.graph_pe:
flags += ['-Dgraal.GraphPE=false']
if args.threads:
flags += ['-Dsom.threads=%s' % args.threads ]
if args.java_interpreter:
flags += ['-Xint']
all_args = JAVA_ARGS + flags + SOM_ARGS + unknown + args.args
if args.verbose:
print "CMD: " + java_bin + ' ' + ' '.join(all_args)
os.execvp(java_bin, all_args)