Skip to content

Commit 7581d45

Browse files
committed
Make it easy to use seafoam from a specified directory
1 parent fb25021 commit 7581d45

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

tool/jt.rb

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -841,6 +841,7 @@ def help
841841
--simplify simplify the graph by disabling some optimizations which tend to duplicate parts of the graph
842842
--igv send the graphs to IGV over the network instead of using seafoam
843843
--describe describe the shape of the graph (linear, branches, loops, calls, deopts)
844+
SEAFOAM_DIR use the seafoam in the given directory
844845
jt igv launches IdealGraphVisualizer
845846
jt next tell you what to work on next (give you a random core library spec)
846847
jt install [jvmci|eclipse] install [the right JVMCI JDK | Eclipse] in the parent directory
@@ -2079,8 +2080,9 @@ def graph(*args)
20792080
describe = false
20802081
json = false
20812082
seafoam_args = []
2082-
igv = args.delete('--igv')
20832083

2084+
# Must be handled before ruby_options() otherwise that would consume it
2085+
igv = args.delete('--igv')
20842086
args.unshift '--igv-network' if igv
20852087

20862088
vm_args, remaining_args, _parsed_options = ruby_options({}, args)
@@ -2175,7 +2177,7 @@ def graph(*args)
21752177
FileUtils.cp graph, 'graph.bgv'
21762178
graph = 'graph.bgv'
21772179

2178-
list = run_gem_test_pack_gem_or_install('seafoam', SEAFOAM_VERSION, '--json', graph, 'list', capture: :out, no_print_cmd: true)
2180+
list = seafoam('--json', graph, 'list', capture: :out, no_print_cmd: true)
21792181
decoded = JSON.parse(list)
21802182
graph_names = decoded.map { |entry| entry.fetch('graph_name_components').last }
21812183
before_lowering_regexp = /Before.+Lowering/
@@ -2185,7 +2187,7 @@ def graph(*args)
21852187

21862188
json_args = json ? %w[--json] : []
21872189
action = describe ? 'describe' : 'render'
2188-
run_gem_test_pack_gem_or_install('seafoam', SEAFOAM_VERSION, *json_args, "#{graph}:#{n}", action, *seafoam_args)
2190+
seafoam(*json_args, "#{graph}:#{n}", action, *seafoam_args)
21892191
end
21902192

21912193
break unless watch
@@ -2197,6 +2199,16 @@ def graph(*args)
21972199
end
21982200
end
21992201

2202+
private def seafoam(*args)
2203+
seafoam_dir = ENV['SEAFOAM_DIR']
2204+
if seafoam_dir
2205+
sh(RbConfig.ruby, "-I#{seafoam_dir}/lib", "#{seafoam_dir}/bin/seafoam", *args)
2206+
else
2207+
run_gem_test_pack_gem_or_install('seafoam', SEAFOAM_VERSION, *args)
2208+
end
2209+
end
2210+
ruby2_keywords :seafoam if respond_to?(:ruby2_keywords, true)
2211+
22002212
def igv
22012213
clone_enterprise
22022214
graal_enterprise = File.expand_path '../graal-enterprise/graal-enterprise', TRUFFLERUBY_DIR

0 commit comments

Comments
 (0)