forked from SOM-st/TruffleSOM
-
Notifications
You must be signed in to change notification settings - Fork 2
/
som
executable file
·274 lines (222 loc) · 12.5 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
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
#!/usr/bin/env python2.7
#For fast running, include -A in the arguments list
#For debugging compilation, include -w and - B and in the arguments list
import argparse
import sys
import os
import shlex
BASE_DIR = os.path.dirname(os.path.realpath(__file__))
GRAALVM_DIR = os.getenv('GRAAL_VM_PATH', None)
if GRAALVM_DIR is None:
if os.path.isdir('./graal'):
GRAALVM_DIR = BASE_DIR + "/graal"
else:
print "Graal was not found. You should specify a path to a valid GRAAL VM via the GRAAL_VM_PATH env var or otherwise with a link named graal within the root directory"
sys.exit()
JAVA_PATH = os.getenv('JAVA_HOME', None)
if JAVA_PATH is None:
JAVA_BIN='java'
else:
JAVA_BIN=JAVA_PATH + '/bin/java'
TRUFFLE_DIR = GRAALVM_DIR + '/jre/lib/truffle'
GRAAL_DIR = GRAALVM_DIR + '/jre/lib'
GRAAL_FLAGS = os.getenv('GRAAL_FLAGS', None)
def addBaseDir( path ):
paths = path.split(":")
return ':'.join([BASE_DIR + '/' + s for s in paths])
defaultClassPath = ['Smalltalk:Smalltalk/Mate/:Smalltalk/Mate/MOP:' +
'Smalltalk/Collections/Streams:' +
'Smalltalk/FileSystem/Core:Smalltalk/FileSystem/Disk:Smalltalk/FileSystem/Streams:' +
'Examples/Benchmarks:Examples/Benchmarks/LanguageFeatures:Examples/Benchmarks/DeltaBlueInstrumented:Examples/Benchmarks/DeltaBlue:Examples/Benchmarks/NBody:Examples/Benchmarks/Mate:Examples/Benchmarks/Mate/DelegationProxies:Examples/Benchmarks/Mate/Tracing:Examples/Benchmarks/Json:Examples/Benchmarks/Mate/IndividualOperations:Examples/Benchmarks/Mate/Profiling:Examples/Benchmarks/Mate/Columnar']
defaultClassPath = ''.join(map(addBaseDir, defaultClassPath))
parser = argparse.ArgumentParser(
description='Helper script to run TruffleMate with/without Graal')
parser.add_argument('-d', '--debug', help='wait for debugger to attach',
dest='debug', action='store_true', default=False)
parser.add_argument('-i', '--igv', help='dump compilation details to IGV',
dest='igv', action='store_true', default=False)
parser.add_argument('-if', '--igv-to-file', help='dump compilation details to file to be loaded by IGV',
dest='igv_to_file', action='store_true', default=False)
parser.add_argument('-l', '--low-level', help='enable low-level optimization output',
dest='low_level', action='store_true', default=False)
parser.add_argument('-ti', '--trace-invalidation', help='trace assumption invalidation and transfers to interpreter',
dest='trace_invalidation', action='store_true', default=False)
parser.add_argument('-it', '--inline_threshold', help='Increase the inlining threshold',
dest='inline_threshold', type=int)
parser.add_argument('-cp', '--classpath', help='classpath, default: all benchs and core-lib',
dest='som_cp', default=defaultClassPath)
profile = parser.add_argument_group('Profile', 'Profile Execution')
parser.add_argument('-gp', '--profile', help='enable profiling after warmup',
dest='profile', action='store_true', default=False)
parser.add_argument('-ga', '--profile-allocations', help='enable profiling after warmup, and profile allocations',
dest='profile_allocations', action='store_true', default=False)
parser.add_argument('-gt', '--profile-times', help='enable profiling after certain time intervals',
dest='profile_timed', action='store_true', default=False)
profile.add_argument('-tp', '--truffle-profile', help='enable Graal-level profiling after warmup',
dest='truffle_profile', action='store_true', default=False)
parser.add_argument('-w', '--perf-warnings', help='enable performance warnings',
dest='perf_warnings', 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('-v', '--visual-vm', help='connect to VisualVM for profiling',
dest='visual_vm', action='store_true', default=False)
parser.add_argument('-t', '--num-threads', help='number of threads to be used',
dest='threads', 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)
tools = parser.add_argument_group('Tools', 'Additional Tools')
tools.add_argument('-dm', '--dynamic-metrics', help='Capture Dynamic Metrics',
dest='dynamic_metrics', action='store_true', default=False)
tools.add_argument('-hl', '--highlight', nargs=1, help='enable highlight tool and define output file',
dest='highlight_file', default=False, metavar='highlight-file')
tools.add_argument('-td', '--truffle-debugger', help='start Truffle debugger',
dest='truffle_debugger', action='store_true', default=False)
tools.add_argument('-wd', '--web-debugger', help='start Web debugger',
dest='web_debugger', action='store_true', default=False)
parser.add_argument('--mate', help='run som with mate nodes',
dest='mate', action='store_true', default=False)
parser.add_argument('--unoptimizedIH', help='enable mate nodes',
dest='unoptimizedIH', action='store_true', default=False)
parser.add_argument('--envInObject', help='metaobjects stored as an extra object field',
dest='envInObject', action='store_true', default=False)
parser.add_argument('-activateMate', help='enable mate nodes',
dest='mateActivated', action='store_true', default=False)
parser.add_argument('-vv', '--verbose', action='store_true', default=False,
dest='verbose', help="print command-line before executing")
parser.add_argument('--print-graal-options', action='store_true', default=False,
dest='print_graal_options', help="print all Graal options")
parser.add_argument('-J', help="Java VM Argument prefix",
dest="java_args", action='append')
parser.add_argument('-D', help="define a Java property",
dest="java_properties", action='append')
parser.add_argument('args', nargs=argparse.REMAINDER,
help='arguments passed to TruffleMate')
parser.add_argument('--oficial', help='run the graal precompiled binaries',
dest='oficial', action='store_true', default=False)
args, unknown = parser.parse_known_args()
if len(sys.argv) < 2:
parser.print_help()
sys.exit(1)
if args.java_interpreter or args.dynamic_metrics:
args.interpreter = True
CLASSPATH = (BASE_DIR + '/build/classes:'
+ BASE_DIR + '/libs/black-diamonds/build/classes:')
BOOT_CLASSPATH = ('-Xbootclasspath/a:'
+ GRAAL_DIR + '/boot/graal-sdk.jar:'
+ TRUFFLE_DIR + '/truffle-api.jar:')
GRAAL_FLAGS = ['-Djvmci.Compiler=graal', '-Djvmci.class.path.append=' + GRAAL_DIR + '/jvmci/graal.jar' ]
#GRAAL_FLAGS = [
# '--module-path=' + GRAAL_DIR + '/boot/graal-sdk.jar:' + TRUFFLE_DIR + '/truffle-api.jar',
# '--upgrade-module-path=' + GRAAL_DIR + '/jvmci/graal.jar:',
# '-XX:+UnlockExperimentalVMOptions', '-XX:+EnableJVMCI', '-XX:-UseJVMCICompiler']
SOM_ARGS = ["som.vm.Universe"]
# == Hotspot -XX:CompileCommand=print,*::callRoot
# Splitting
# -G:+TruffleSplitting
# -G:+TruffleSplittingNew
# == Compiler Settings
if args.inline_threshold:
TWEAK_INLINING = [#'-Dgraal.TruffleCompilationThreshold=191',
'-Dgraal.TruffleInliningMaxCallerSize=' + str(args.inline_threshold)
#'-Dgraal.TruffleSplittingMaxCalleeSize=1000000'
]
else:
TWEAK_INLINING = []
JAVA_ARGS = ['-server', '-d64']
flags = []
if args.dynamic_metrics:
SOM_ARGS += ['--dynamic-metrics']
flags += ['-Dsom.dynamicMetrics=true']
if args.interpreter:
flags += ['-Dtruffle.TruffleRuntime=com.oracle.truffle.api.impl.DefaultTruffleRuntime']
else:
flags += GRAAL_FLAGS
if not args.interpreter:
# Make sure everything gets compiled
flags += ['-Dgraal.TruffleTimeThreshold=10000000']
if args.debug:
flags += ['-Xdebug',
'-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000']
if not args.interpreter and (args.igv or args.igv_to_file):
flags += ['-Dgraal.Dump=Truffle,TruffleTree']
if not args.interpreter and args.igv_to_file:
flags += ['-Dgraal.PrintIdealGraphFile=true']
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']
if args.print_graal_options:
flags += ['-XX:+JVMCIPrintProperties']
if args.truffle_debugger:
SOM_ARGS += ['--debug']
if args.web_debugger:
SOM_ARGS += ['--web-debug']
if (args.truffle_profile or args.truffle_debugger or args.web_debugger or
args.dynamic_metrics or args.highlight_file):
flags += ['-Dsom.instrumentation=true']
if (args.truffle_debugger or args.web_debugger):
flags += ['-Dsom.truffleDebugger=true']
mate_args = []
if args.mate:
mate_args += ['--mate']
if args.envInObject:
mate_args += ['--envInObject']
if args.mateActivated:
mate_args += ['-activateMate']
if args.unoptimizedIH:
mate_args += ['--unoptimizedIH']
if args.java_properties:
flags += ['-D' + property for property in args.java_properties]
if args.java_args:
JAVA_ARGS += ['-' + property for property in args.java_args]
all_args = JAVA_ARGS + ['-classpath', CLASSPATH] + [BOOT_CLASSPATH] + TWEAK_INLINING + flags + SOM_ARGS + mate_args + ['-cp'] + args.som_cp.split() + args.args
os.execvp(JAVA_BIN, all_args)