seafoam 0.2 → 0.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 841e61f7601b4121b7367e9974b9920f8b8513fd6ca7a827c1be0e340bc2b3cf
4
- data.tar.gz: 559e28e6b6a49964f31ac73bc1b1ed8c72fefae9d81381bb3e433bc39d57d0d7
3
+ metadata.gz: 85ce198d6b6117c1e691ea871829e0d93d480ab26709f6ba494aa8f73957fefb
4
+ data.tar.gz: 83275a9095d3827a6f5c7d8eab9d9ea49ed35b6fe3f527d6c6299f6719a65956
5
5
  SHA512:
6
- metadata.gz: 75c306c0d6b9b8dffae51f62538a6b5e529150b59e5b6ea6ccbcf1b27ca9505fc8b7548086f2826d4f9bb8589648e2281e750a2caabd7b91f7da164065756883
7
- data.tar.gz: c0c307acef6945d1841cc23d2cf5c00bbc52ed70cd74aaa95fc9365f83e796379b86009a16eef522b849e6a279b147e4d8350291b5fcdbebfa81d2ef4178bed5
6
+ metadata.gz: d5b74e656d6a80af67233f4fcae60bbdfc291bab4a6d4a92ce283450b5dd4e318da59440a4d78d539033910cba2560068c57f112213e4ce8b493e731e92ff799
7
+ data.tar.gz: a7acdd55bcb41bc5f78b0f06583cb678d7e1d2beaadab02c6e2e42945fac8d6d4c4dfccddabe64c9b47f223722e7808b5fb9dd1353d4912fdbe757ece60950c5
@@ -32,3 +32,6 @@ Security/Eval:
32
32
 
33
33
  Naming/FileName:
34
34
  Enabled: false
35
+
36
+ Metrics/LineLength:
37
+ Max: 300
data/README.md CHANGED
@@ -10,6 +10,7 @@ GraalVM compiler graphs. Seafoam aims to solve several problems with IGV. Unlike
10
10
  IGV, Seafoam:
11
11
 
12
12
  * is open source and can be used according to the MIT license
13
+ * supports gzip-compressed BGV files
13
14
  * is able to some extent seek BGV files to load specific graphs without loading the rest of the file
14
15
  * has a command-line interface
15
16
  * can be used as a library
@@ -37,34 +38,34 @@ Admittedly, Seafoam does not yet have:
37
38
  ### macOS
38
39
 
39
40
  ```
40
- $ brew install graphviz
41
- $ gem install seafoam
42
- $ seafoam --version
41
+ % brew install graphviz
42
+ % gem install seafoam
43
+ % seafoam --version
43
44
  seafoam 0.1
44
45
  ```
45
46
 
46
47
  ### Ubuntu
47
48
 
48
49
  ```
49
- $ sudo apt-get install ruby graphviz
50
- $ gem install seafoam
51
- $ seafoam --version
50
+ % sudo apt-get install ruby graphviz
51
+ % gem install seafoam
52
+ % seafoam --version
52
53
  seafoam 0.1
53
54
  ```
54
55
 
55
56
  #### RedHat
56
57
 
57
58
  ```
58
- $ sudo yum install ruby graphviz
59
- $ gem install seafoam
60
- $ seafoam --version
59
+ % sudo yum install ruby graphviz
60
+ % gem install seafoam
61
+ % seafoam --version
61
62
  seafoam 0.1
62
63
  ```
63
64
 
64
65
  ## Quick-start demo
65
66
 
66
67
  ```
67
- $ seafoam examples/fib-java.bgv:0 render
68
+ % seafoam examples/fib-java.bgv:0 render
68
69
  ```
69
70
 
70
71
  ## Getting compiler graphs
@@ -78,14 +79,20 @@ This is just a quick summary - see more information on
78
79
  ### GraalVM for Java
79
80
 
80
81
  ```
81
- $ javac Fib.java
82
- $ java -XX:CompileOnly=::fib -Dgraal.Dump=:2 Fib 14
82
+ % javac Fib.java
83
+ % java -XX:CompileOnly=::fib -Dgraal.Dump=:2 Fib 14
84
+ ```
85
+
86
+ ### GraalVM Native Image
87
+
88
+ ```
89
+ % native-image -H:Dump=:2 -H:MethodFilter=fib Fib
83
90
  ```
84
91
 
85
92
  ### TruffleRuby and other Truffle languages
86
93
 
87
94
  ```
88
- $ ruby --experimental-options --engine.CompileOnly=fib --engine.Inlining=false --engine.OSR=false --vm.Dgraal.Dump=Truffle:2 fib.rb 14
95
+ % ruby --experimental-options --engine.CompileOnly=fib --engine.Inlining=false --engine.OSR=false --vm.Dgraal.Dump=Truffle:2 fib.rb 14
89
96
  ```
90
97
 
91
98
  You will usually want to look at the *After TruffleTier* graph.
@@ -105,14 +112,14 @@ Note that a *graph ID* is an ID found in BGV files, but is not unique. A
105
112
  #### Print information about a file
106
113
 
107
114
  ```
108
- $ seafoam examples/fib-java.bgv info
115
+ % seafoam examples/fib-java.bgv info
109
116
  BGV 6.1
110
117
  ```
111
118
 
112
119
  #### List graphs in a file
113
120
 
114
121
  ```
115
- $ seafoam examples/fib-java.bgv list
122
+ % seafoam examples/fib-java.bgv list
116
123
  examples/fib-java.bgv:0 2:Fib.fib(int)/After phase org.graalvm.compiler.java.GraphBuilderPhase
117
124
  examples/fib-java.bgv:1 2:Fib.fib(int)/After phase org.graalvm.compiler.phases.PhaseSuite
118
125
  examples/fib-java.bgv:2 2:Fib.fib(int)/After phase org.graalvm.compiler.phases.common.DeadCodeEliminationPhase
@@ -125,7 +132,7 @@ examples/fib-java.bgv:5 2:Fib.fib(int)/After phase org.graalvm.compiler.phases.
125
132
  #### Search for strings in a graph, or node or edge within a graph
126
133
 
127
134
  ```
128
- $ seafoam examples/fib-java.bgv:0 search Start
135
+ % seafoam examples/fib-java.bgv:0 search Start
129
136
  examples/fib-java.bgv:0:0 ...node_class":"org.graalvm.compiler.nodes.StartNode","name_template":"Start","inputs":[...
130
137
  examples/fib-java.bgv:0:0 ...piler.nodes.StartNode","name_template":"Start","inputs":[{"direct":true,"name":"state...
131
138
  ```
@@ -133,9 +140,9 @@ examples/fib-java.bgv:0:0 ...piler.nodes.StartNode","name_template":"Start","in
133
140
  #### Print edges of a graph, or node or edge within a graph
134
141
 
135
142
  ```
136
- $ seafoam examples/fib-java.bgv:0 edges
143
+ % seafoam examples/fib-java.bgv:0 edges
137
144
  22 nodes, 30 edges
138
- $ seafoam examples/fib-java.bgv:0:13 edges
145
+ % seafoam examples/fib-java.bgv:0:13 edges
139
146
  Input:
140
147
  13 (Call Fib.fib) <-() 6 (Begin)
141
148
  13 (Call Fib.fib) <-() 14 (@{:declaring_class=>"Fib", :method_name=>"fib", :signature=>{:args=>["I"], :ret=>"I"}, :modifiers=>9}:13)
@@ -145,14 +152,14 @@ Output:
145
152
  13 (Call Fib.fib) ->(values) 14 (@{:declaring_class=>"Fib", :method_name=>"fib", :signature=>{:args=>["I"], :ret=>"I"}, :modifiers=>9}:13)
146
153
  13 (Call Fib.fib) ->(values) 19 (@{:declaring_class=>"Fib", :method_name=>"fib", :signature=>{:args=>["I"], :ret=>"I"}, :modifiers=>9}:19)
147
154
  13 (Call Fib.fib) ->(x) 20 (+)
148
- $ seafoam examples/fib-java.bgv:0:13-20 edges
155
+ % seafoam examples/fib-java.bgv:0:13-20 edges
149
156
  13 (Call Fib.fib) ->(x) 20 (+)
150
157
  ```
151
158
 
152
159
  #### Print properties of a file, graph, or node or edge within a graph
153
160
 
154
161
  ```
155
- $ seafoam examples/fib-java.bgv:0 props
162
+ % seafoam examples/fib-java.bgv:0 props
156
163
  {
157
164
  "group": [
158
165
  {
@@ -160,7 +167,7 @@ $ seafoam examples/fib-java.bgv:0 props
160
167
  "short_name": "2:Fib.fib(int)",
161
168
  "method": null,
162
169
  ...
163
- $ seafoam examples/fib-java.bgv:0:13 props
170
+ % seafoam examples/fib-java.bgv:0:13 props
164
171
  {
165
172
  "nodeSourcePosition": {
166
173
  "method": {
@@ -168,7 +175,7 @@ $ seafoam examples/fib-java.bgv:0:13 props
168
175
  "method_name": "fib",
169
176
  "signature": {
170
177
  ...
171
- $ seafoam examples/fib-java.bgv:0:13-20 props
178
+ % seafoam examples/fib-java.bgv:0:13-20 props
172
179
  {
173
180
  "direct": true,
174
181
  "name": "x",
@@ -181,14 +188,14 @@ $ seafoam examples/fib-java.bgv:0:13-20 props
181
188
  Render a graph as a PDF image and have it opened automatically.
182
189
 
183
190
  ```
184
- $ seafoam examples/fib-java.bgv:0 render
191
+ % seafoam examples/fib-java.bgv:0 render
185
192
  ```
186
193
 
187
194
  Render a graph showing just a few nodes and those surrounding them, similar to
188
195
  the IGV feature of gradually revealing nodes.
189
196
 
190
197
  ```
191
- $ seafoam examples/fib-java.bgv:0 render --spotlight 13,20
198
+ % seafoam examples/fib-java.bgv:0 render --spotlight 13,20
192
199
  ```
193
200
 
194
201
  <p>
@@ -206,7 +213,7 @@ $ seafoam examples/fib-java.bgv:0 render --spotlight 13,20
206
213
  Convert a BGV file to the Isabelle graph format.
207
214
 
208
215
  ```
209
- $ bgv2isabelle examples/fib-java.bgv
216
+ % bgv2isabelle examples/fib-java.bgv
210
217
  graph0 = # 2:Fib.fib(int)/After phase org.graalvm.compiler.java.GraphBuilderPhase
211
218
  (add_node 0 StartNode [2] [8]
212
219
  (add_node 1 (ParameterNode 0) [] [2, 5, 9, 11, 14, 16]
@@ -21,7 +21,7 @@ require 'seafoam'
21
21
  # empty_graph))))))))))))))"
22
22
 
23
23
  ARGV.each do |file|
24
- parser = Seafoam::BGV::BGVParser.new(File.new(file))
24
+ parser = Seafoam::BGV::BGVParser.new(file)
25
25
  parser.read_file_header
26
26
  parser.skip_document_props
27
27
 
@@ -4,7 +4,7 @@ require 'seafoam'
4
4
  require 'json'
5
5
 
6
6
  ARGV.each do |file|
7
- parser = Seafoam::BGV::BGVParser.new(File.new(file))
7
+ parser = Seafoam::BGV::BGVParser.new(file)
8
8
  parser.read_file_header
9
9
  parser.skip_document_props
10
10
 
@@ -23,20 +23,20 @@ ARGV.each do |file|
23
23
  edges = []
24
24
 
25
25
  graph.nodes.each_value do |node|
26
- nodes.push({
26
+ nodes.push(
27
27
  id: node.id,
28
28
  props: node.props
29
- })
29
+ )
30
30
 
31
31
  node.outputs.each do |edge|
32
- edges.push({
32
+ edges.push(
33
33
  from: edge.from.id,
34
34
  to: edge.to.id,
35
35
  props: edge.props
36
- })
36
+ )
37
37
  end
38
38
  end
39
39
 
40
- puts JSON.generate({name: name, props: graph.props, nodes: nodes, edges: edges})
40
+ puts JSON.generate(name: name, props: graph.props, nodes: nodes, edges: edges)
41
41
  end
42
42
  end
@@ -14,7 +14,7 @@ begin
14
14
  commands.run(*ARGV)
15
15
  rescue StandardError => e
16
16
  if $DEBUG
17
- # Re-raise the exception so the user sees it, it debugging is
17
+ # Re-raise the exception so the user sees it, if debugging is
18
18
  # enabled (ruby -d).
19
19
  raise e
20
20
  else
@@ -22,11 +22,11 @@ BGV {
22
22
  char[4] = 'BIGV'
23
23
  sint8 major
24
24
  sint8 minor
25
- GroupOrGraph*
25
+ GroupDocumentGraph*
26
26
  }
27
27
 
28
- GroupOrGraph {
29
- BeginGroup GroupOrGraph* CloseGroup | Graph
28
+ GroupDocumentGraph {
29
+ BeginGroup GroupDocumentGraph* CloseGroup | Document | Graph
30
30
  }
31
31
 
32
32
  BeginGroup {
@@ -37,6 +37,15 @@ BeginGroup {
37
37
  Props props
38
38
  }
39
39
 
40
+ CloseGroup {
41
+ sint8 token = CLOSE_GROUP
42
+ }
43
+
44
+ Document {
45
+ sint8 token = BEGIN_DOCUMENT
46
+ Pops props
47
+ }
48
+
40
49
  Graph {
41
50
  sint8 token = BEGIN_GRAPH
42
51
  String format
@@ -72,10 +81,6 @@ Blocks {
72
81
  sint32[followers_count] followers
73
82
  }
74
83
 
75
- CloseGroup {
76
- sint8 token = CLOSE_GROUP
77
- }
78
-
79
84
  Props {
80
85
  sint16 props_count
81
86
  Prop[props_count] props
@@ -278,6 +283,10 @@ In order to 'seek' BGV files we have two code paths for reading the file, one
278
283
  with loads the data and one which loads as little as possible to know just how
279
284
  much further to advance in the file.
280
285
 
286
+ ## Compression
287
+
288
+ Seafoam supports compressed BGV files in the gzip file format.
289
+
281
290
  ## Other information
282
291
 
283
292
  `seafoam file.bgv debug` checks that a file can be parsed and prints information
@@ -29,6 +29,14 @@ graph without significantly effecting too much how the logic in it is compiled.
29
29
  -Dgraal.VectorizeLoops=false
30
30
  ```
31
31
 
32
+ ## GraalVM's Native Image compiler
33
+
34
+ When using `native-image` you will want to use the `-H:` format.
35
+
36
+ ```
37
+ % native-image -H:Dump=:2 -H:MethodFilter=fib Fib
38
+ ```
39
+
32
40
  ## TruffleRuby and other Truffle languages
33
41
 
34
42
  Use the same options as for GraalVM for Java, except they're prefixed with
@@ -0,0 +1,35 @@
1
+ # JSON Output Format
2
+
3
+ The `bgv2json` command outputs files in [JSON Lines](https://jsonlines.org/) format - one JSON object for each graph, one per line.
4
+
5
+ Each graph is of the format:
6
+
7
+ ```js
8
+ {
9
+ "name": ...,
10
+ "props": {...},
11
+ "nodes": [...],
12
+ "edges": [...]
13
+ }
14
+ ```
15
+
16
+ Each node is of the format:
17
+
18
+ ```js
19
+ {
20
+ "id": ...,
21
+ "props": {...}
22
+ }
23
+ ```
24
+
25
+ Each edge is of the format:
26
+
27
+ ```js
28
+ {
29
+ "from": ..., // node id
30
+ "to": ..., // node id
31
+ "props": {...}
32
+ }
33
+ ```
34
+
35
+ Note that `bgv2json` runs annotations, so for example all nodes have a `"label"` property with an easy-to-use name.
Binary file
@@ -1,9 +1,9 @@
1
1
  require 'seafoam/version'
2
2
  require 'seafoam/binary/io_binary_reader'
3
- require 'seafoam/binary/binary_reader'
4
3
  require 'seafoam/bgv/bgv_parser'
5
4
  require 'seafoam/colors'
6
5
  require 'seafoam/graph'
6
+ require 'seafoam/graal'
7
7
  require 'seafoam/annotators'
8
8
  require 'seafoam/annotators/graal'
9
9
  require 'seafoam/annotators/fallback'
@@ -1,3 +1,6 @@
1
+ require 'stringio'
2
+ require 'zlib'
3
+
1
4
  module Seafoam
2
5
  module BGV
3
6
  # A parser for BGV files. It's a push-pull streaming interface that you need
@@ -5,8 +8,12 @@ module Seafoam
5
8
  # and some code is duplicated in order to support skipping over parts of the
6
9
  # file that you don't need.
7
10
  class BGVParser
8
- def initialize(source)
9
- @reader = Binary::BinaryReader.for(source)
11
+ def initialize(file)
12
+ data = File.read(file, encoding: Encoding::ASCII_8BIT)
13
+ if data[0..1].bytes == [0x1f, 0x8b]
14
+ data = Zlib.gunzip(data)
15
+ end
16
+ @reader = Binary::IOBinaryReader.new(StringIO.new(data))
10
17
  @group_stack = []
11
18
  @pool = {}
12
19
  @index = 0
@@ -164,6 +171,9 @@ module Seafoam
164
171
  break true
165
172
  when CLOSE_GROUP
166
173
  read_close_group
174
+ when BEGIN_DOCUMENT
175
+ # But what should we do with them?
176
+ skip_props
167
177
  else
168
178
  raise EncodingError, "unknown token 0x#{token.to_s(16)} beginning BGV object"
169
179
  end
@@ -51,7 +51,7 @@ module Seafoam
51
51
 
52
52
  raise ArgumentError, 'info does not take arguments' unless args.empty?
53
53
 
54
- parser = BGV::BGVParser.new(File.new(file))
54
+ parser = BGV::BGVParser.new(file)
55
55
  major, minor = parser.read_file_header(version_check: false)
56
56
  @out.puts "BGV #{major}.#{minor}"
57
57
  end
@@ -63,7 +63,7 @@ module Seafoam
63
63
 
64
64
  raise ArgumentError, 'list does not take arguments' unless args.empty?
65
65
 
66
- parser = BGV::BGVParser.new(File.new(file))
66
+ parser = BGV::BGVParser.new(file)
67
67
  parser.read_file_header
68
68
  parser.skip_document_props
69
69
  loop do
@@ -81,7 +81,7 @@ module Seafoam
81
81
  file, graph_index, node_id, = parse_name(name)
82
82
  raise ArgumentError, 'search only works with a file or graph' if node_id
83
83
 
84
- parser = BGV::BGVParser.new(File.new(file))
84
+ parser = BGV::BGVParser.new(file)
85
85
  parser.read_file_header
86
86
  parser.skip_document_props
87
87
  loop do
@@ -211,7 +211,7 @@ module Seafoam
211
211
  end
212
212
  end
213
213
  else
214
- parser = BGV::BGVParser.new(File.new(file))
214
+ parser = BGV::BGVParser.new(file)
215
215
  parser.read_file_header
216
216
  document_props = parser.read_document_props
217
217
  pretty_print document_props || {}
@@ -368,7 +368,7 @@ module Seafoam
368
368
  # Reads a file and yields just the graph requested by the index - skipping
369
369
  # the rest of the file as best as possible.
370
370
  def with_graph(file, graph_index)
371
- parser = BGV::BGVParser.new(File.new(file))
371
+ parser = BGV::BGVParser.new(file)
372
372
  parser.read_file_header
373
373
  parser.skip_document_props
374
374
  graph_found = false
@@ -418,8 +418,12 @@ module Seafoam
418
418
 
419
419
  # Parse a name like file.bgv:g:n-e to [file.bgv, g, n, e].
420
420
  def parse_name(name)
421
- *pre, file, graph, node = name.split(':')
422
- file = [*pre, file].join(':')
421
+ *pre, post = name.split('.')
422
+
423
+ file_ext, graph, node, *rest = post.split(':')
424
+ raise ArgumentError, "too many parts to .ext:g:n-e in #{name}" unless rest.empty?
425
+
426
+ file = [*pre, file_ext].join('.')
423
427
 
424
428
  if node
425
429
  node, edge, *rest = node.split('-')
@@ -1,5 +1,5 @@
1
1
  module Seafoam
2
2
  MAJOR_VERSION = 0
3
- MINOR_VERSION = 2
3
+ MINOR_VERSION = 3
4
4
  VERSION = "#{MAJOR_VERSION}.#{MINOR_VERSION}"
5
5
  end
@@ -11,7 +11,7 @@ describe Seafoam::BGV::BGVParser do
11
11
 
12
12
  it 'can read full files' do
13
13
  Seafoam::SpecHelpers::SAMPLE_BGV.each do |file|
14
- parser = Seafoam::BGV::BGVParser.new(File.new(file))
14
+ parser = Seafoam::BGV::BGVParser.new(file)
15
15
  parser.read_file_header
16
16
  parser.skip_document_props
17
17
  loop do
@@ -24,9 +24,22 @@ describe Seafoam::BGV::BGVParser do
24
24
  end
25
25
  end
26
26
 
27
+ it 'can read full gzipped files' do
28
+ parser = Seafoam::BGV::BGVParser.new(File.expand_path('../../../examples/fib-java.bgv.gz', __dir__))
29
+ parser.read_file_header
30
+ parser.skip_document_props
31
+ loop do
32
+ index, = parser.read_graph_preheader
33
+ break unless index
34
+
35
+ parser.read_graph_header
36
+ parser.read_graph
37
+ end
38
+ end
39
+
27
40
  it 'can skip full files' do
28
41
  Seafoam::SpecHelpers::SAMPLE_BGV.each do |file|
29
- parser = Seafoam::BGV::BGVParser.new(File.new(file))
42
+ parser = Seafoam::BGV::BGVParser.new(file)
30
43
  parser.read_file_header
31
44
  parser.skip_document_props
32
45
  loop do
@@ -41,7 +54,7 @@ describe Seafoam::BGV::BGVParser do
41
54
 
42
55
  it 'can alternate skipping and reading full files' do
43
56
  Seafoam::SpecHelpers::SAMPLE_BGV.each do |file|
44
- parser = Seafoam::BGV::BGVParser.new(File.new(file))
57
+ parser = Seafoam::BGV::BGVParser.new(file)
45
58
  parser.read_file_header
46
59
  parser.skip_document_props
47
60
  skip = false
@@ -63,36 +76,36 @@ describe Seafoam::BGV::BGVParser do
63
76
 
64
77
  describe '#read_file_header' do
65
78
  it 'produces a version' do
66
- parser = Seafoam::BGV::BGVParser.new(File.new(@fib_java_bgv))
79
+ parser = Seafoam::BGV::BGVParser.new(@fib_java_bgv)
67
80
  expect(parser.read_file_header).to eq [6, 1]
68
81
  end
69
82
 
70
83
  it 'raises an error for files which are not BGV' do
71
- parser = Seafoam::BGV::BGVParser.new(File.new(File.expand_path('fixtures/not.bgv', __dir__)))
84
+ parser = Seafoam::BGV::BGVParser.new(File.expand_path('fixtures/not.bgv', __dir__))
72
85
  expect { parser.read_file_header }.to raise_error(EncodingError)
73
86
  end
74
87
 
75
88
  it 'raises an error for files which are an unsupported version of BGV' do
76
- parser = Seafoam::BGV::BGVParser.new(File.new(File.expand_path('fixtures/unsupported.bgv', __dir__)))
89
+ parser = Seafoam::BGV::BGVParser.new(File.expand_path('fixtures/unsupported.bgv', __dir__))
77
90
  expect { parser.read_file_header }.to raise_error(NotImplementedError)
78
91
  end
79
92
 
80
93
  it 'does not raise an error for an unsupported version of BGV if version_check is disabled' do
81
- parser = Seafoam::BGV::BGVParser.new(File.new(File.expand_path('fixtures/unsupported.bgv', __dir__)))
94
+ parser = Seafoam::BGV::BGVParser.new(File.expand_path('fixtures/unsupported.bgv', __dir__))
82
95
  expect(parser.read_file_header(version_check: false)).to eq [7, 2]
83
96
  end
84
97
  end
85
98
 
86
99
  describe '#read_graph_preheader' do
87
100
  it 'produces an index and id' do
88
- parser = Seafoam::BGV::BGVParser.new(File.new(@fib_java_bgv))
101
+ parser = Seafoam::BGV::BGVParser.new(@fib_java_bgv)
89
102
  parser.read_file_header
90
103
  parser.skip_document_props
91
104
  expect(parser.read_graph_preheader).to eq [0, 0]
92
105
  end
93
106
 
94
107
  it 'returns nil for end of file' do
95
- parser = Seafoam::BGV::BGVParser.new(File.new(@fib_java_bgv))
108
+ parser = Seafoam::BGV::BGVParser.new(@fib_java_bgv)
96
109
  parser.read_file_header
97
110
  parser.skip_document_props
98
111
  51.times do
@@ -104,7 +117,7 @@ describe Seafoam::BGV::BGVParser do
104
117
  end
105
118
 
106
119
  it 'returns unique indicies' do
107
- parser = Seafoam::BGV::BGVParser.new(File.new(@fib_java_bgv))
120
+ parser = Seafoam::BGV::BGVParser.new(@fib_java_bgv)
108
121
  parser.read_file_header
109
122
  parser.skip_document_props
110
123
  indicies = []
@@ -120,7 +133,7 @@ describe Seafoam::BGV::BGVParser do
120
133
 
121
134
  describe '#read_graph_header' do
122
135
  it 'produces an expected header' do
123
- parser = Seafoam::BGV::BGVParser.new(File.new(@fib_java_bgv))
136
+ parser = Seafoam::BGV::BGVParser.new(@fib_java_bgv)
124
137
  parser.read_file_header
125
138
  parser.skip_document_props
126
139
  parser.read_graph_preheader
@@ -131,7 +144,7 @@ describe Seafoam::BGV::BGVParser do
131
144
 
132
145
  describe '#read_graph' do
133
146
  it 'produces an expected graph' do
134
- parser = Seafoam::BGV::BGVParser.new(File.new(@fib_java_bgv))
147
+ parser = Seafoam::BGV::BGVParser.new(@fib_java_bgv)
135
148
  parser.read_file_header
136
149
  parser.skip_document_props
137
150
  parser.read_graph_preheader
@@ -248,5 +248,21 @@ describe Seafoam::Commands do
248
248
  expect(node).to eq 12
249
249
  expect(edge).to eq 81
250
250
  end
251
+
252
+ it 'parses a BGV file name with periods and colons' do
253
+ file, graph, node, edge = @commands.send(:parse_name, 'TruffleHotSpotCompilation-13029[Truffle::ThreadOperations.detect_recursion_<split-3a5973bc>].bgv:4')
254
+ expect(file).to eq 'TruffleHotSpotCompilation-13029[Truffle::ThreadOperations.detect_recursion_<split-3a5973bc>].bgv'
255
+ expect(graph).to eq 4
256
+ expect(node).to be_nil
257
+ expect(edge).to be_nil
258
+ end
259
+
260
+ it 'parses a BGV.gz file name with periods and colons' do
261
+ file, graph, node, edge = @commands.send(:parse_name, 'TruffleHotSpotCompilation-13029[Truffle::ThreadOperations.detect_recursion_<split-3a5973bc>].bgv.gz:4')
262
+ expect(file).to eq 'TruffleHotSpotCompilation-13029[Truffle::ThreadOperations.detect_recursion_<split-3a5973bc>].bgv.gz'
263
+ expect(graph).to eq 4
264
+ expect(node).to be_nil
265
+ expect(edge).to be_nil
266
+ end
251
267
  end
252
268
  end
@@ -10,7 +10,7 @@ describe Seafoam::GraphvizWriter do
10
10
  describe '#write_graph' do
11
11
  before :all do
12
12
  file = File.expand_path('../../examples/fib-java.bgv', __dir__)
13
- parser = Seafoam::BGV::BGVParser.new(File.new(file))
13
+ parser = Seafoam::BGV::BGVParser.new(file)
14
14
  parser.read_file_header
15
15
  parser.read_graph_preheader
16
16
  parser.read_graph_header
@@ -29,7 +29,7 @@ describe Seafoam::GraphvizWriter do
29
29
 
30
30
  it 'writes all graphs' do
31
31
  Seafoam::SpecHelpers::SAMPLE_BGV.each do |file|
32
- parser = Seafoam::BGV::BGVParser.new(File.new(file))
32
+ parser = Seafoam::BGV::BGVParser.new(file)
33
33
  parser.read_file_header
34
34
  parser.skip_document_props
35
35
  parser.skip_document_props
@@ -10,7 +10,7 @@ module Seafoam
10
10
 
11
11
  def self.example_graph(file, graph_index)
12
12
  file = File.expand_path("../../examples/#{file}.bgv", __dir__)
13
- parser = Seafoam::BGV::BGVParser.new(File.new(file))
13
+ parser = Seafoam::BGV::BGVParser.new(file)
14
14
  parser.read_file_header
15
15
  parser.skip_document_props
16
16
  loop do
@@ -5,7 +5,7 @@ require 'rspec'
5
5
  describe Seafoam::Spotlight do
6
6
  before :each do
7
7
  file = File.expand_path('../../examples/fib-java.bgv', __dir__)
8
- parser = Seafoam::BGV::BGVParser.new(File.new(file))
8
+ parser = Seafoam::BGV::BGVParser.new(file)
9
9
  parser.read_file_header
10
10
  parser.skip_document_props
11
11
  parser.read_graph_preheader
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.2'
4
+ version: '0.3'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Chris Seaton
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-11-03 00:00:00.000000000 Z
11
+ date: 2020-12-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: benchmark-ips
@@ -83,9 +83,11 @@ files:
83
83
  - docs/images/seafoam.png
84
84
  - docs/images/spotlight-igv.png
85
85
  - docs/images/spotlight-seafoam.png
86
+ - docs/json.md
86
87
  - examples/Fib.java
87
88
  - examples/MatMult.java
88
89
  - examples/fib-java.bgv
90
+ - examples/fib-java.bgv.gz
89
91
  - examples/fib-js.bgv
90
92
  - examples/fib-ruby.bgv
91
93
  - examples/fib.js
@@ -188,7 +190,6 @@ files:
188
190
  - lib/seafoam/annotators/fallback.rb
189
191
  - lib/seafoam/annotators/graal.rb
190
192
  - lib/seafoam/bgv/bgv_parser.rb
191
- - lib/seafoam/binary/binary_reader.rb
192
193
  - lib/seafoam/binary/io_binary_reader.rb
193
194
  - lib/seafoam/colors.rb
194
195
  - lib/seafoam/commands.rb
@@ -1,21 +0,0 @@
1
- require 'stringio'
2
-
3
- module Seafoam
4
- module Binary
5
- # Factory for binary readers based on the input.
6
- module BinaryReader
7
- def self.for(source)
8
- case source
9
- when File
10
- IOBinaryReader.new(StringIO.new(File.read(source)))
11
- when IO
12
- IOBinaryReader.new(source)
13
- when String
14
- IOBinaryReader.new(StringIO.new(source))
15
- else
16
- raise source.class
17
- end
18
- end
19
- end
20
- end
21
- end