seafoam 0.2 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +3 -0
- data/README.md +32 -25
- data/bin/bgv2isabelle +1 -1
- data/bin/bgv2json +6 -6
- data/bin/seafoam +1 -1
- data/docs/bgv.md +16 -7
- data/docs/getting-graphs.md +8 -0
- data/docs/json.md +35 -0
- data/examples/fib-java.bgv.gz +0 -0
- data/lib/seafoam.rb +1 -1
- data/lib/seafoam/bgv/bgv_parser.rb +12 -2
- data/lib/seafoam/commands.rb +11 -7
- data/lib/seafoam/version.rb +1 -1
- data/spec/seafoam/bgv/bgv_parser_spec.rb +25 -12
- data/spec/seafoam/command_spec.rb +16 -0
- data/spec/seafoam/graphviz_writer_spec.rb +2 -2
- data/spec/seafoam/spec_helpers.rb +1 -1
- data/spec/seafoam/spotlight_spec.rb +1 -1
- metadata +4 -3
- data/lib/seafoam/binary/binary_reader.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 85ce198d6b6117c1e691ea871829e0d93d480ab26709f6ba494aa8f73957fefb
|
4
|
+
data.tar.gz: 83275a9095d3827a6f5c7d8eab9d9ea49ed35b6fe3f527d6c6299f6719a65956
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: d5b74e656d6a80af67233f4fcae60bbdfc291bab4a6d4a92ce283450b5dd4e318da59440a4d78d539033910cba2560068c57f112213e4ce8b493e731e92ff799
|
7
|
+
data.tar.gz: a7acdd55bcb41bc5f78b0f06583cb678d7e1d2beaadab02c6e2e42945fac8d6d4c4dfccddabe64c9b47f223722e7808b5fb9dd1353d4912fdbe757ece60950c5
|
data/.rubocop.yml
CHANGED
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
|
-
|
41
|
-
|
42
|
-
|
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
|
-
|
50
|
-
|
51
|
-
|
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
|
-
|
59
|
-
|
60
|
-
|
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
|
-
|
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
|
-
|
82
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
143
|
+
% seafoam examples/fib-java.bgv:0 edges
|
137
144
|
22 nodes, 30 edges
|
138
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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]
|
data/bin/bgv2isabelle
CHANGED
data/bin/bgv2json
CHANGED
@@ -4,7 +4,7 @@ require 'seafoam'
|
|
4
4
|
require 'json'
|
5
5
|
|
6
6
|
ARGV.each do |file|
|
7
|
-
parser = Seafoam::BGV::BGVParser.new(
|
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(
|
40
|
+
puts JSON.generate(name: name, props: graph.props, nodes: nodes, edges: edges)
|
41
41
|
end
|
42
42
|
end
|
data/bin/seafoam
CHANGED
data/docs/bgv.md
CHANGED
@@ -22,11 +22,11 @@ BGV {
|
|
22
22
|
char[4] = 'BIGV'
|
23
23
|
sint8 major
|
24
24
|
sint8 minor
|
25
|
-
|
25
|
+
GroupDocumentGraph*
|
26
26
|
}
|
27
27
|
|
28
|
-
|
29
|
-
BeginGroup
|
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
|
data/docs/getting-graphs.md
CHANGED
@@ -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
|
data/docs/json.md
ADDED
@@ -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
|
data/lib/seafoam.rb
CHANGED
@@ -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(
|
9
|
-
|
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
|
data/lib/seafoam/commands.rb
CHANGED
@@ -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(
|
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(
|
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(
|
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(
|
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(
|
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,
|
422
|
-
|
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('-')
|
data/lib/seafoam/version.rb
CHANGED
@@ -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(
|
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(
|
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(
|
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(
|
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.
|
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.
|
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.
|
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(
|
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(
|
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(
|
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(
|
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(
|
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(
|
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(
|
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(
|
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(
|
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.
|
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
|
+
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
|