seafoam 0.9 → 0.10

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 49d090779b04322f8c82aae0cf11ea2e39cd4cef1f3d9dc2b51de1f27e565f9c
4
- data.tar.gz: 121f1c7bb327c30f1a388960012c43dab49e0f1079d5a420811ab2332de9663b
3
+ metadata.gz: f8665fe768d4900820ca676269cd25028306e8253c2109c71ff4cb31dd7c6e44
4
+ data.tar.gz: fd8c52e5cf3daafa9b2673265067b743cc644755c3772c02904c2b815b3a93d2
5
5
  SHA512:
6
- metadata.gz: dd13ee2efe4fe4118fc5f6bdb56c55b3c1c5f28b86a3d37ce3cf4fc72bcdcbeb161968260b62626047b9f9f9eedec53cbc743d79512a11bd77b195f054c54262
7
- data.tar.gz: 67e06a4e89fdf9e6297e3d68da7f7b0e7d4f1de95a97c9be17c12e6c9114476ee6e747c6306c3bc472e549317f20c19c315c9789d1814c68fdd85501327c432b
6
+ metadata.gz: 815e7031027718cea7a933b7fc5ad822f754f05e3ae5bdc2066775183a9ca98c841b54e682a148c4437a29b1f95c4ede5833a2a1f2995d2c55296a800e71b269
7
+ data.tar.gz: 462aaad5134c8b6cce229e8456742151354333c5e7c02283e2e90917fa7ad238f3f4f71770519357117f42b1579928ddb0bba3f04b31ddef68d7e41e92f8c016
@@ -1,4 +1,5 @@
1
1
  require 'json'
2
+ require 'set'
2
3
 
3
4
  module Seafoam
4
5
  # Implementations of the command-line commands that you can run in Seafoam.
@@ -39,6 +40,8 @@ module Seafoam
39
40
  render name, *args
40
41
  when 'debug'
41
42
  debug name, *args
43
+ when 'describe'
44
+ describe name, *args
42
45
  else
43
46
  raise ArgumentError, "unknown command #{command}"
44
47
  end
@@ -373,6 +376,56 @@ module Seafoam
373
376
  end
374
377
  end
375
378
 
379
+ # seafoam file.bgv:n describe
380
+ def describe(name, *args)
381
+ file, graph_index, *rest = parse_name(name)
382
+
383
+ if graph_index.nil? || !rest.all?(&:nil?)
384
+ raise ArgumentError, 'describe only works with a graph'
385
+ end
386
+ raise ArgumentError, 'describe does not take arguments' unless args.empty?
387
+
388
+ parser = BGV::BGVParser.new(file)
389
+ parser.read_file_header
390
+ parser.skip_document_props
391
+
392
+ loop do
393
+ index, = parser.read_graph_preheader
394
+ break unless index
395
+
396
+ parser.skip_graph_header
397
+
398
+ if index != graph_index
399
+ parser.skip_graph
400
+ next
401
+ end
402
+
403
+ graph = parser.read_graph
404
+ notes = Set.new
405
+
406
+ graph.nodes.each_value do |node|
407
+ node_class = node.props.dig(:node_class, :node_class)
408
+ case node_class
409
+ when 'org.graalvm.compiler.nodes.IfNode'
410
+ notes.add 'branches'
411
+ when 'org.graalvm.compiler.nodes.LoopBeginNode'
412
+ notes.add 'loops'
413
+ when 'org.graalvm.compiler.nodes.InvokeNode', 'org.graalvm.compiler.nodes.InvokeWithExceptionNode'
414
+ notes.add 'calls'
415
+ end
416
+ end
417
+
418
+ notes.add 'deopts' if graph.nodes[0].outputs.map(&:to)
419
+ .all? { |t| t.props.dig(:node_class, :node_class) == 'org.graalvm.compiler.nodes.DeoptimizeNode' }
420
+
421
+ notes.add 'linear' unless notes.include?('branches') || notes.include?('loops')
422
+
423
+ @out.puts ["#{graph.nodes.size} nodes", *notes].join(', ')
424
+
425
+ break
426
+ end
427
+ end
428
+
376
429
  # seafoam file.bgv:n render options...
377
430
  def render(name, *args)
378
431
  file, graph_index, *rest = parse_name(name)
@@ -564,6 +617,7 @@ module Seafoam
564
617
  @out.puts ' file.bgv[:graph][:node[-edge]] edges'
565
618
  @out.puts ' file.bgv[:graph][:node[-edge]] props'
566
619
  @out.puts ' file.bgv:graph:node source'
620
+ @out.puts ' file.bgv:graph describe'
567
621
  @out.puts ' file.bgv:graph render'
568
622
  @out.puts ' --spotlight n,n,n...'
569
623
  @out.puts ' --out graph.pdf'
@@ -262,8 +262,6 @@ module Seafoam
262
262
  # loopBegin edges point from LoopEndNode (continue) and LoopExitNode
263
263
  # (break) to the LoopBeginNode. Both are drawn reversed.
264
264
  when 'loopBegin'
265
- edge.props[:hidden] = true
266
-
267
265
  case edge.to.props.dig(:node_class, :node_class)
268
266
  when 'org.graalvm.compiler.nodes.LoopEndNode'
269
267
  # If it's from the LoopEnd then it's the control edge to follow.
@@ -1,5 +1,5 @@
1
1
  module Seafoam
2
2
  MAJOR_VERSION = 0
3
- MINOR_VERSION = 9
3
+ MINOR_VERSION = 10
4
4
  VERSION = "#{MAJOR_VERSION}.#{MINOR_VERSION}"
5
5
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: seafoam
3
3
  version: !ruby/object:Gem::Version
4
- version: '0.9'
4
+ version: '0.10'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Seaton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-09-27 00:00:00.000000000 Z
11
+ date: 2021-12-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: crabstone