seafoam 0.8 → 0.12
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/bgv2isabelle +1 -5
- data/bin/bgv2json +1 -5
- data/bin/seafoam +1 -5
- data/lib/seafoam/bgv/bgv_parser.rb +1 -2
- data/lib/seafoam/commands.rb +135 -101
- data/lib/seafoam/formatters/base.rb +88 -0
- data/lib/seafoam/formatters/formatters.rb +8 -0
- data/lib/seafoam/formatters/json.rb +82 -0
- data/lib/seafoam/formatters/text.rb +70 -0
- data/lib/seafoam/graal/graph_description.rb +22 -0
- data/lib/seafoam/graal/pi.rb +18 -0
- data/lib/seafoam/graal/source.rb +5 -9
- data/lib/seafoam/graph.rb +9 -1
- data/lib/seafoam/graphviz_writer.rb +3 -0
- data/lib/seafoam/json_writer.rb +1 -3
- data/lib/seafoam/{annotators → passes}/fallback.rb +4 -4
- data/lib/seafoam/{annotators → passes}/graal.rb +43 -15
- data/lib/seafoam/passes/truffle.rb +58 -0
- data/lib/seafoam/passes.rb +61 -0
- data/lib/seafoam/version.rb +1 -1
- data/lib/seafoam.rb +7 -6
- metadata +17 -81
- data/.github/probots.yml +0 -2
- data/.github/workflows/workflows.yml +0 -40
- data/.gitignore +0 -6
- data/.rubocop.yml +0 -37
- data/.ruby-version +0 -1
- data/.seafoam/config +0 -1
- data/CODE_OF_CONDUCT.md +0 -128
- data/CONTRIBUTING.md +0 -5
- data/Gemfile +0 -2
- data/Gemfile.lock +0 -59
- data/LICENSE.md +0 -7
- data/README.md +0 -378
- data/bin/cfg2asm +0 -24
- data/demos/box-unbox-stats +0 -65
- data/docs/annotators.md +0 -43
- data/docs/bgv.md +0 -294
- data/docs/getting-graphs.md +0 -63
- data/docs/images/igv.png +0 -0
- data/docs/images/seafoam.png +0 -0
- data/docs/images/spotlight-igv.png +0 -0
- data/docs/images/spotlight-seafoam.png +0 -0
- data/docs/json.md +0 -35
- data/examples/Fib.java +0 -24
- data/examples/MatMult.java +0 -39
- data/examples/fib-java.bgv.gz +0 -0
- data/examples/fib.js +0 -15
- data/examples/fib.rb +0 -15
- data/examples/identity.rb +0 -13
- data/examples/java/Irreducible.class +0 -0
- data/examples/java/Irreducible.j +0 -35
- data/examples/java/IrreducibleDecompiled.java +0 -21
- data/examples/java/JavaExamples.java +0 -418
- data/examples/matmult.rb +0 -29
- data/examples/overflow.rb +0 -13
- data/examples/ruby/clamps.rb +0 -20
- data/examples/ruby/graal.patch +0 -15
- data/examples/ruby/ruby_examples.rb +0 -278
- data/lib/seafoam/annotators.rb +0 -54
- data/lib/seafoam/cfg/cfg_parser.rb +0 -93
- data/lib/seafoam/cfg/disassembler.rb +0 -70
- data/lib/seafoam/config.rb +0 -34
- data/seafoam.gemspec +0 -22
- data/spec/seafoam/annotators/fallback_spec.rb +0 -69
- data/spec/seafoam/annotators/graal_spec.rb +0 -96
- data/spec/seafoam/annotators_spec.rb +0 -61
- data/spec/seafoam/bgv/bgv_parser_spec.rb +0 -167
- data/spec/seafoam/binary/io_binary_reader_spec.rb +0 -176
- data/spec/seafoam/cfg/cfg_parser_spec.rb +0 -21
- data/spec/seafoam/cfg/disassembler_spec.rb +0 -32
- data/spec/seafoam/command_spec.rb +0 -314
- data/spec/seafoam/graph_spec.rb +0 -172
- data/spec/seafoam/graphviz_writer_spec.rb +0 -63
- data/spec/seafoam/json_writer_spec.rb +0 -14
- data/spec/seafoam/spec_helpers.rb +0 -34
- data/spec/seafoam/spotlight_spec.rb +0 -38
- data/tools/render-all +0 -36
@@ -1,40 +0,0 @@
|
|
1
|
-
name: Workflows
|
2
|
-
on: [push]
|
3
|
-
jobs:
|
4
|
-
rubocop:
|
5
|
-
runs-on: ubuntu-latest
|
6
|
-
steps:
|
7
|
-
- uses: actions/checkout@v2
|
8
|
-
- uses: ruby/setup-ruby@v1
|
9
|
-
- run: gem install bundler:1.17.2
|
10
|
-
- run: bundle install
|
11
|
-
- run: bundle exec rubocop
|
12
|
-
specs:
|
13
|
-
strategy:
|
14
|
-
matrix:
|
15
|
-
os: [ubuntu, macos]
|
16
|
-
ruby: [2.5, 2.6, 2.7, 3.0]
|
17
|
-
runs-on: ${{ matrix.os }}-latest
|
18
|
-
steps:
|
19
|
-
- uses: actions/checkout@v2
|
20
|
-
- uses: ruby/setup-ruby@v1
|
21
|
-
with:
|
22
|
-
ruby-version: ${{ matrix.ruby }}
|
23
|
-
bundler-cache: true
|
24
|
-
- run: bundle install
|
25
|
-
- run: if [[ $(uname) == "Darwin" ]]; then brew install graphviz capstone; else sudo apt-get install graphviz libcapstone3; fi
|
26
|
-
- run: bundle exec rspec
|
27
|
-
specs-no-dependencies:
|
28
|
-
strategy:
|
29
|
-
matrix:
|
30
|
-
os: [ubuntu, macos]
|
31
|
-
ruby: [2.5, 2.6, 2.7, 3.0]
|
32
|
-
runs-on: ${{ matrix.os }}-latest
|
33
|
-
steps:
|
34
|
-
- uses: actions/checkout@v2
|
35
|
-
- uses: ruby/setup-ruby@v1
|
36
|
-
with:
|
37
|
-
ruby-version: ${{ matrix.ruby }}
|
38
|
-
bundler-cache: true
|
39
|
-
- run: bundle install
|
40
|
-
- run: NO_DEPENDENCIES_INSTALLED=true bundle exec rspec
|
data/.gitignore
DELETED
data/.rubocop.yml
DELETED
@@ -1,37 +0,0 @@
|
|
1
|
-
AllCops:
|
2
|
-
TargetRubyVersion: 2.5
|
3
|
-
Exclude:
|
4
|
-
- examples/**/*.rb
|
5
|
-
|
6
|
-
Style/FrozenStringLiteralComment:
|
7
|
-
Enabled: false
|
8
|
-
|
9
|
-
Style/MutableConstant:
|
10
|
-
Enabled: false
|
11
|
-
|
12
|
-
Metrics:
|
13
|
-
Enabled: false
|
14
|
-
|
15
|
-
Lint/EmptyWhen:
|
16
|
-
Enabled: false
|
17
|
-
|
18
|
-
Style/ConditionalAssignment:
|
19
|
-
Enabled: false
|
20
|
-
|
21
|
-
Style/GuardClause:
|
22
|
-
Enabled: false
|
23
|
-
|
24
|
-
Style/IfUnlessModifier:
|
25
|
-
Enabled: false
|
26
|
-
|
27
|
-
Lint/InterpolationCheck:
|
28
|
-
Enabled: false
|
29
|
-
|
30
|
-
Security/Eval:
|
31
|
-
Enabled: false
|
32
|
-
|
33
|
-
Naming/FileName:
|
34
|
-
Enabled: false
|
35
|
-
|
36
|
-
Metrics/LineLength:
|
37
|
-
Max: 300
|
data/.ruby-version
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
2.5.9
|
data/.seafoam/config
DELETED
@@ -1 +0,0 @@
|
|
1
|
-
# Empty configuration file
|
data/CODE_OF_CONDUCT.md
DELETED
@@ -1,128 +0,0 @@
|
|
1
|
-
# Contributor Covenant Code of Conduct
|
2
|
-
|
3
|
-
## Our Pledge
|
4
|
-
|
5
|
-
We as members, contributors, and leaders pledge to make participation in our
|
6
|
-
community a harassment-free experience for everyone, regardless of age, body
|
7
|
-
size, visible or invisible disability, ethnicity, sex characteristics, gender
|
8
|
-
identity and expression, level of experience, education, socio-economic status,
|
9
|
-
nationality, personal appearance, race, religion, or sexual identity
|
10
|
-
and orientation.
|
11
|
-
|
12
|
-
We pledge to act and interact in ways that contribute to an open, welcoming,
|
13
|
-
diverse, inclusive, and healthy community.
|
14
|
-
|
15
|
-
## Our Standards
|
16
|
-
|
17
|
-
Examples of behavior that contributes to a positive environment for our
|
18
|
-
community include:
|
19
|
-
|
20
|
-
* Demonstrating empathy and kindness toward other people
|
21
|
-
* Being respectful of differing opinions, viewpoints, and experiences
|
22
|
-
* Giving and gracefully accepting constructive feedback
|
23
|
-
* Accepting responsibility and apologizing to those affected by our mistakes,
|
24
|
-
and learning from the experience
|
25
|
-
* Focusing on what is best not just for us as individuals, but for the
|
26
|
-
overall community
|
27
|
-
|
28
|
-
Examples of unacceptable behavior include:
|
29
|
-
|
30
|
-
* The use of sexualized language or imagery, and sexual attention or
|
31
|
-
advances of any kind
|
32
|
-
* Trolling, insulting or derogatory comments, and personal or political attacks
|
33
|
-
* Public or private harassment
|
34
|
-
* Publishing others' private information, such as a physical or email
|
35
|
-
address, without their explicit permission
|
36
|
-
* Other conduct which could reasonably be considered inappropriate in a
|
37
|
-
professional setting
|
38
|
-
|
39
|
-
## Enforcement Responsibilities
|
40
|
-
|
41
|
-
Community leaders are responsible for clarifying and enforcing our standards of
|
42
|
-
acceptable behavior and will take appropriate and fair corrective action in
|
43
|
-
response to any behavior that they deem inappropriate, threatening, offensive,
|
44
|
-
or harmful.
|
45
|
-
|
46
|
-
Community leaders have the right and responsibility to remove, edit, or reject
|
47
|
-
comments, commits, code, wiki edits, issues, and other contributions that are
|
48
|
-
not aligned to this Code of Conduct, and will communicate reasons for moderation
|
49
|
-
decisions when appropriate.
|
50
|
-
|
51
|
-
## Scope
|
52
|
-
|
53
|
-
This Code of Conduct applies within all community spaces, and also applies when
|
54
|
-
an individual is officially representing the community in public spaces.
|
55
|
-
Examples of representing our community include using an official e-mail address,
|
56
|
-
posting via an official social media account, or acting as an appointed
|
57
|
-
representative at an online or offline event.
|
58
|
-
|
59
|
-
## Enforcement
|
60
|
-
|
61
|
-
Instances of abusive, harassing, or otherwise unacceptable behavior may be
|
62
|
-
reported to the community leaders responsible for enforcement at
|
63
|
-
opensource@shopify.com.
|
64
|
-
All complaints will be reviewed and investigated promptly and fairly.
|
65
|
-
|
66
|
-
All community leaders are obligated to respect the privacy and security of the
|
67
|
-
reporter of any incident.
|
68
|
-
|
69
|
-
## Enforcement Guidelines
|
70
|
-
|
71
|
-
Community leaders will follow these Community Impact Guidelines in determining
|
72
|
-
the consequences for any action they deem in violation of this Code of Conduct:
|
73
|
-
|
74
|
-
### 1. Correction
|
75
|
-
|
76
|
-
**Community Impact**: Use of inappropriate language or other behavior deemed
|
77
|
-
unprofessional or unwelcome in the community.
|
78
|
-
|
79
|
-
**Consequence**: A private, written warning from community leaders, providing
|
80
|
-
clarity around the nature of the violation and an explanation of why the
|
81
|
-
behavior was inappropriate. A public apology may be requested.
|
82
|
-
|
83
|
-
### 2. Warning
|
84
|
-
|
85
|
-
**Community Impact**: A violation through a single incident or series
|
86
|
-
of actions.
|
87
|
-
|
88
|
-
**Consequence**: A warning with consequences for continued behavior. No
|
89
|
-
interaction with the people involved, including unsolicited interaction with
|
90
|
-
those enforcing the Code of Conduct, for a specified period of time. This
|
91
|
-
includes avoiding interactions in community spaces as well as external channels
|
92
|
-
like social media. Violating these terms may lead to a temporary or
|
93
|
-
permanent ban.
|
94
|
-
|
95
|
-
### 3. Temporary Ban
|
96
|
-
|
97
|
-
**Community Impact**: A serious violation of community standards, including
|
98
|
-
sustained inappropriate behavior.
|
99
|
-
|
100
|
-
**Consequence**: A temporary ban from any sort of interaction or public
|
101
|
-
communication with the community for a specified period of time. No public or
|
102
|
-
private interaction with the people involved, including unsolicited interaction
|
103
|
-
with those enforcing the Code of Conduct, is allowed during this period.
|
104
|
-
Violating these terms may lead to a permanent ban.
|
105
|
-
|
106
|
-
### 4. Permanent Ban
|
107
|
-
|
108
|
-
**Community Impact**: Demonstrating a pattern of violation of community
|
109
|
-
standards, including sustained inappropriate behavior, harassment of an
|
110
|
-
individual, or aggression toward or disparagement of classes of individuals.
|
111
|
-
|
112
|
-
**Consequence**: A permanent ban from any sort of public interaction within
|
113
|
-
the community.
|
114
|
-
|
115
|
-
## Attribution
|
116
|
-
|
117
|
-
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
|
118
|
-
version 2.0, available at
|
119
|
-
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
|
120
|
-
|
121
|
-
Community Impact Guidelines were inspired by [Mozilla's code of conduct
|
122
|
-
enforcement ladder](https://github.com/mozilla/diversity).
|
123
|
-
|
124
|
-
[homepage]: https://www.contributor-covenant.org
|
125
|
-
|
126
|
-
For answers to common questions about this code of conduct, see the FAQ at
|
127
|
-
https://www.contributor-covenant.org/faq. Translations are available at
|
128
|
-
https://www.contributor-covenant.org/translations.
|
data/CONTRIBUTING.md
DELETED
data/Gemfile
DELETED
data/Gemfile.lock
DELETED
@@ -1,59 +0,0 @@
|
|
1
|
-
PATH
|
2
|
-
remote: .
|
3
|
-
specs:
|
4
|
-
seafoam (0.7)
|
5
|
-
crabstone (~> 4.0)
|
6
|
-
|
7
|
-
GEM
|
8
|
-
remote: https://rubygems.org/
|
9
|
-
specs:
|
10
|
-
ast (2.4.2)
|
11
|
-
benchmark-ips (2.8.4)
|
12
|
-
crabstone (4.0.3)
|
13
|
-
ffi
|
14
|
-
diff-lcs (1.4.4)
|
15
|
-
ffi (1.15.0)
|
16
|
-
parallel (1.20.1)
|
17
|
-
parser (3.0.1.1)
|
18
|
-
ast (~> 2.4.1)
|
19
|
-
rainbow (3.0.0)
|
20
|
-
regexp_parser (2.1.1)
|
21
|
-
rexml (3.2.5)
|
22
|
-
rspec (3.10.0)
|
23
|
-
rspec-core (~> 3.10.0)
|
24
|
-
rspec-expectations (~> 3.10.0)
|
25
|
-
rspec-mocks (~> 3.10.0)
|
26
|
-
rspec-core (3.10.1)
|
27
|
-
rspec-support (~> 3.10.0)
|
28
|
-
rspec-expectations (3.10.1)
|
29
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
30
|
-
rspec-support (~> 3.10.0)
|
31
|
-
rspec-mocks (3.10.2)
|
32
|
-
diff-lcs (>= 1.2.0, < 2.0)
|
33
|
-
rspec-support (~> 3.10.0)
|
34
|
-
rspec-support (3.10.2)
|
35
|
-
rubocop (0.93.1)
|
36
|
-
parallel (~> 1.10)
|
37
|
-
parser (>= 2.7.1.5)
|
38
|
-
rainbow (>= 2.2.2, < 4.0)
|
39
|
-
regexp_parser (>= 1.8)
|
40
|
-
rexml
|
41
|
-
rubocop-ast (>= 0.6.0)
|
42
|
-
ruby-progressbar (~> 1.7)
|
43
|
-
unicode-display_width (>= 1.4.0, < 2.0)
|
44
|
-
rubocop-ast (1.5.0)
|
45
|
-
parser (>= 3.0.1.1)
|
46
|
-
ruby-progressbar (1.11.0)
|
47
|
-
unicode-display_width (1.7.0)
|
48
|
-
|
49
|
-
PLATFORMS
|
50
|
-
ruby
|
51
|
-
|
52
|
-
DEPENDENCIES
|
53
|
-
benchmark-ips (~> 2.7)
|
54
|
-
rspec (~> 3.8)
|
55
|
-
rubocop (~> 0.74)
|
56
|
-
seafoam!
|
57
|
-
|
58
|
-
BUNDLED WITH
|
59
|
-
1.17.2
|
data/LICENSE.md
DELETED
@@ -1,7 +0,0 @@
|
|
1
|
-
Copyright 2019-present, Shopify Inc.
|
2
|
-
|
3
|
-
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
4
|
-
|
5
|
-
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
6
|
-
|
7
|
-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
DELETED
@@ -1,378 +0,0 @@
|
|
1
|
-
# Seafoam
|
2
|
-
|
3
|
-
*Seafoam* is a tool for working with compiler graphs. It's designed primarily
|
4
|
-
for working with the graph files dumped by the GraalVM compiler, such as in
|
5
|
-
TruffleRuby, but it could be used with other compilers and graph dump file
|
6
|
-
formats.
|
7
|
-
|
8
|
-
The *Ideal Graph Visualizer*, or *IGV*, is the tool usually used to work with
|
9
|
-
GraalVM compiler graphs. Seafoam aims to solve several problems with IGV. Unlike
|
10
|
-
IGV, Seafoam:
|
11
|
-
|
12
|
-
* is open source and can be used according to the MIT license
|
13
|
-
* supports gzip-compressed BGV files
|
14
|
-
* is able to some extent seek BGV files to load specific graphs without loading the rest of the file
|
15
|
-
* has a command-line interface
|
16
|
-
* can be used as a library
|
17
|
-
* has easy PDF, SVG, PNG and JSON output
|
18
|
-
* is designed for accessibility
|
19
|
-
* looks prettier, in our opinion
|
20
|
-
|
21
|
-
Additionally, Seafoam adds:
|
22
|
-
|
23
|
-
* support for disassembling CFG files
|
24
|
-
|
25
|
-
Admittedly, Seafoam does not yet have:
|
26
|
-
|
27
|
-
* an interactive user interface
|
28
|
-
* diffing of graphs
|
29
|
-
* breaking of edges for very congested graphs
|
30
|
-
* the same speed in rendering big graphs - Seafoam is best suited for looking at graphs before lowering, which is what language developers are usually doing, or use spotlight
|
31
|
-
|
32
|
-
## Seafoam compared to IGV
|
33
|
-
|
34
|
-
<p>
|
35
|
-
<img src="docs/images/seafoam.png" width="350">
|
36
|
-
<img src="docs/images/igv.png" width="350">
|
37
|
-
</p>
|
38
|
-
|
39
|
-
## Installation
|
40
|
-
|
41
|
-
### macOS
|
42
|
-
|
43
|
-
```
|
44
|
-
% brew install graphviz
|
45
|
-
% gem install seafoam
|
46
|
-
% seafoam --version
|
47
|
-
seafoam 0.1
|
48
|
-
```
|
49
|
-
|
50
|
-
### Ubuntu
|
51
|
-
|
52
|
-
```
|
53
|
-
% sudo apt-get install ruby graphviz
|
54
|
-
% gem install seafoam
|
55
|
-
% seafoam --version
|
56
|
-
seafoam 0.1
|
57
|
-
```
|
58
|
-
|
59
|
-
### RedHat
|
60
|
-
|
61
|
-
```
|
62
|
-
% sudo yum install ruby graphviz
|
63
|
-
% gem install seafoam
|
64
|
-
% seafoam --version
|
65
|
-
seafoam 0.1
|
66
|
-
```
|
67
|
-
|
68
|
-
### Capstone
|
69
|
-
|
70
|
-
To use the `cfg2asm` disassembler, you'll then need to install Capstone.
|
71
|
-
|
72
|
-
```
|
73
|
-
% brew install capstone # macOS
|
74
|
-
% sudo apt-get install libcapstone3 # Ubuntu
|
75
|
-
```
|
76
|
-
|
77
|
-
## Quick-start demo
|
78
|
-
|
79
|
-
```
|
80
|
-
% seafoam examples/fib-java.bgv:0 render
|
81
|
-
```
|
82
|
-
|
83
|
-
## Getting compiler graphs
|
84
|
-
|
85
|
-
If you are just experimenting, there are example graphs such as
|
86
|
-
`examples/fib-java.bgv`.
|
87
|
-
|
88
|
-
This is just a quick summary - see more information on
|
89
|
-
[getting graphs out of compilers](docs/getting-graphs.md).
|
90
|
-
|
91
|
-
### GraalVM for Java
|
92
|
-
|
93
|
-
```
|
94
|
-
% javac Fib.java
|
95
|
-
% java -XX:CompileOnly=::fib -Dgraal.Dump=:2 Fib 14
|
96
|
-
```
|
97
|
-
|
98
|
-
### GraalVM Native Image
|
99
|
-
|
100
|
-
```
|
101
|
-
% native-image -H:Dump=:2 -H:MethodFilter=fib Fib
|
102
|
-
```
|
103
|
-
|
104
|
-
### TruffleRuby and other Truffle languages
|
105
|
-
|
106
|
-
```
|
107
|
-
% ruby --experimental-options --engine.CompileOnly=fib --engine.Inlining=false --engine.OSR=false --vm.Dgraal.Dump=Truffle:2 fib.rb 14
|
108
|
-
```
|
109
|
-
|
110
|
-
You will usually want to look at the *After TruffleTier* graph.
|
111
|
-
|
112
|
-
## Name syntax
|
113
|
-
|
114
|
-
When using a command-line interface, Seafoam refers to
|
115
|
-
`file.bgv[:graph][:node[-edge]]`, where `file.bgv` is a file, `graph` is a graph
|
116
|
-
index, `node` is a node index, and `to` is another node index to form an edge
|
117
|
-
from `node` to another node `edge`.
|
118
|
-
|
119
|
-
Note that a *graph ID* is an ID found in BGV files, but is not unique. A
|
120
|
-
*graph index* is what we use in names, and is unique.
|
121
|
-
|
122
|
-
## Use cases
|
123
|
-
|
124
|
-
#### Print information about a file
|
125
|
-
|
126
|
-
```
|
127
|
-
% seafoam examples/fib-java.bgv info
|
128
|
-
BGV 6.1
|
129
|
-
```
|
130
|
-
|
131
|
-
#### List graphs in a file
|
132
|
-
|
133
|
-
```
|
134
|
-
% seafoam examples/fib-java.bgv list
|
135
|
-
examples/fib-java.bgv:0 2:Fib.fib(int)/After phase org.graalvm.compiler.java.GraphBuilderPhase
|
136
|
-
examples/fib-java.bgv:1 2:Fib.fib(int)/After phase org.graalvm.compiler.phases.PhaseSuite
|
137
|
-
examples/fib-java.bgv:2 2:Fib.fib(int)/After phase org.graalvm.compiler.phases.common.DeadCodeEliminationPhase
|
138
|
-
examples/fib-java.bgv:3 2:Fib.fib(int)/After parsing
|
139
|
-
examples/fib-java.bgv:4 2:Fib.fib(int)/After phase org.graalvm.compiler.phases.common.CanonicalizerPhase
|
140
|
-
examples/fib-java.bgv:5 2:Fib.fib(int)/After phase org.graalvm.compiler.phases.common.inlining.InliningPhase
|
141
|
-
...
|
142
|
-
```
|
143
|
-
|
144
|
-
#### Search for strings in a graph, or node or edge within a graph
|
145
|
-
|
146
|
-
```
|
147
|
-
% seafoam examples/fib-java.bgv:0 search Start
|
148
|
-
examples/fib-java.bgv:0:0 ...node_class":"org.graalvm.compiler.nodes.StartNode","name_template":"Start","inputs":[...
|
149
|
-
examples/fib-java.bgv:0:0 ...piler.nodes.StartNode","name_template":"Start","inputs":[{"direct":true,"name":"state...
|
150
|
-
```
|
151
|
-
|
152
|
-
#### Print edges of a graph, or node or edge within a graph
|
153
|
-
|
154
|
-
```
|
155
|
-
% seafoam examples/fib-java.bgv:0 edges
|
156
|
-
22 nodes, 30 edges
|
157
|
-
% seafoam examples/fib-java.bgv:0:13 edges
|
158
|
-
Input:
|
159
|
-
13 (Call Fib.fib) <-() 6 (Begin)
|
160
|
-
13 (Call Fib.fib) <-() 14 (@{:declaring_class=>"Fib", :method_name=>"fib", :signature=>{:args=>["I"], :ret=>"I"}, :modifiers=>9}:13)
|
161
|
-
13 (Call Fib.fib) <-() 12 (MethodCallTarget)
|
162
|
-
Output:
|
163
|
-
13 (Call Fib.fib) ->() 18 (Call Fib.fib)
|
164
|
-
13 (Call Fib.fib) ->(values) 14 (@{:declaring_class=>"Fib", :method_name=>"fib", :signature=>{:args=>["I"], :ret=>"I"}, :modifiers=>9}:13)
|
165
|
-
13 (Call Fib.fib) ->(values) 19 (@{:declaring_class=>"Fib", :method_name=>"fib", :signature=>{:args=>["I"], :ret=>"I"}, :modifiers=>9}:19)
|
166
|
-
13 (Call Fib.fib) ->(x) 20 (+)
|
167
|
-
% seafoam examples/fib-java.bgv:0:13-20 edges
|
168
|
-
13 (Call Fib.fib) ->(x) 20 (+)
|
169
|
-
```
|
170
|
-
|
171
|
-
#### Print properties of a file, graph, or node or edge within a graph
|
172
|
-
|
173
|
-
```
|
174
|
-
% seafoam examples/fib-java.bgv:0 props
|
175
|
-
{
|
176
|
-
"group": [
|
177
|
-
{
|
178
|
-
"name": "2:Fib.fib(int)",
|
179
|
-
"short_name": "2:Fib.fib(int)",
|
180
|
-
"method": null,
|
181
|
-
...
|
182
|
-
% seafoam examples/fib-java.bgv:0:13 props
|
183
|
-
{
|
184
|
-
"nodeSourcePosition": {
|
185
|
-
"method": {
|
186
|
-
"declaring_class": "Fib",
|
187
|
-
"method_name": "fib",
|
188
|
-
"signature": {
|
189
|
-
...
|
190
|
-
% seafoam examples/fib-java.bgv:0:13-20 props
|
191
|
-
{
|
192
|
-
"direct": true,
|
193
|
-
"name": "x",
|
194
|
-
"type": "Value"
|
195
|
-
}
|
196
|
-
```
|
197
|
-
|
198
|
-
#### Print node source information
|
199
|
-
|
200
|
-
```
|
201
|
-
% seafoam examples/fib-ruby.bgv:8:2443 source
|
202
|
-
java.lang.Math#addExact
|
203
|
-
org.truffleruby.core.numeric.IntegerNodes$AddNode#add
|
204
|
-
org.truffleruby.core.numeric.IntegerNodesFactory$AddNodeFactory$AddNodeGen#executeAdd
|
205
|
-
org.truffleruby.core.inlined.InlinedAddNode#intAdd
|
206
|
-
org.truffleruby.core.inlined.InlinedAddNodeGen#execute
|
207
|
-
org.truffleruby.language.control.IfElseNode#execute
|
208
|
-
org.truffleruby.language.control.SequenceNode#execute
|
209
|
-
org.truffleruby.language.arguments.CheckArityNode#execute
|
210
|
-
org.truffleruby.language.control.SequenceNode#execute
|
211
|
-
org.truffleruby.language.methods.CatchForMethodNode#execute
|
212
|
-
org.truffleruby.language.methods.ExceptionTranslatingNode#execute
|
213
|
-
org.truffleruby.language.RubyRootNode#execute
|
214
|
-
org.graalvm.compiler.truffle.runtime.OptimizedCallTarget#executeRootNode
|
215
|
-
org.graalvm.compiler.truffle.runtime.OptimizedCallTarget#profiledPERoot
|
216
|
-
```
|
217
|
-
|
218
|
-
#### Render a graph
|
219
|
-
|
220
|
-
Render a graph as a PDF image and have it opened automatically.
|
221
|
-
|
222
|
-
```
|
223
|
-
% seafoam examples/fib-java.bgv:0 render
|
224
|
-
```
|
225
|
-
|
226
|
-
Render a graph showing just a few nodes and those surrounding them, similar to
|
227
|
-
the IGV feature of gradually revealing nodes.
|
228
|
-
|
229
|
-
```
|
230
|
-
% seafoam examples/fib-java.bgv:0 render --spotlight 13,20
|
231
|
-
```
|
232
|
-
|
233
|
-
<p>
|
234
|
-
<img src="docs/images/spotlight-seafoam.png" width="200">
|
235
|
-
<img src="docs/images/spotlight-igv.png" width="350">
|
236
|
-
</p>
|
237
|
-
|
238
|
-
`render` supports these options:
|
239
|
-
|
240
|
-
* `--out filename.pdf` or `.pdf`, `.svg`, `.png`, `.dot`
|
241
|
-
* `--option key value` for custom annotators
|
242
|
-
|
243
|
-
#### Convert a file
|
244
|
-
|
245
|
-
Convert a BGV file to the Isabelle graph format.
|
246
|
-
|
247
|
-
```
|
248
|
-
% bgv2isabelle examples/fib-java.bgv
|
249
|
-
graph0 = # 2:Fib.fib(int)/After phase org.graalvm.compiler.java.GraphBuilderPhase
|
250
|
-
(add_node 0 StartNode [2] [8]
|
251
|
-
(add_node 1 (ParameterNode 0) [] [2, 5, 9, 11, 14, 16]
|
252
|
-
(add_node 2 FrameState [1] [0]
|
253
|
-
(add_node 3 (ConstantNode 1) [] []
|
254
|
-
(add_node 4 (ConstantNode 2) [] [5]
|
255
|
-
(add_node 5 IntegerLessThanNode [1, 4] [8]
|
256
|
-
(add_node 6 BeginNode [8] [13]
|
257
|
-
(add_node 7 BeginNode [8] [9]
|
258
|
-
(add_node 8 IfNode [0, 5] [7, 6]
|
259
|
-
...
|
260
|
-
```
|
261
|
-
|
262
|
-
Convert a BGV file to JSON.
|
263
|
-
|
264
|
-
```
|
265
|
-
% bgv2json examples/fib-java.bgv
|
266
|
-
graph0 = # 2:Fib.fib(int)/After phase org.graalvm.compiler.java.GraphBuilderPhase
|
267
|
-
(add_node 0 StartNode [2] [8]
|
268
|
-
(add_node 1 (ParameterNode 0) [] [2, 5, 9, 11, 14, 16]
|
269
|
-
(add_node 2 FrameState [1] [0]
|
270
|
-
(add_node 3 (ConstantNode 1) [] []
|
271
|
-
(add_node 4 (ConstantNode 2) [] [5]
|
272
|
-
(add_node 5 IntegerLessThanNode [1, 4] [8]
|
273
|
-
(add_node 6 BeginNode [8] [13]
|
274
|
-
(add_node 7 BeginNode [8] [9]
|
275
|
-
(add_node 8 IfNode [0, 5] [7, 6]
|
276
|
-
...
|
277
|
-
```
|
278
|
-
|
279
|
-
#### Disassembling
|
280
|
-
|
281
|
-
```
|
282
|
-
% cfg2asm examples/java/exampleArithOperator.cfg
|
283
|
-
[examples/java/exampleArithOperator.cfg]
|
284
|
-
;Comment 0: 3
|
285
|
-
;Comment 0: 1
|
286
|
-
0x112e2f660: nop dword ptr [rax + rax]
|
287
|
-
;Comment 5: block B0 null
|
288
|
-
;Comment 5: 0 [rsi|DWORD, rdx|DWORD, rbp|QWORD] = LABEL numbPhis: 0 align: false label: ?
|
289
|
-
;Comment 5: 4 [] = HOTSPOTLOCKSTACK frameMapBuilder: org.graalvm.compiler.lir.amd64.AMD64FrameMapBuilder@143082de0 slotKind: QWORD
|
290
|
-
;Comment 5: 10 rsi|DWORD = ADD (x: rsi|DWORD, y: rdx|DWORD) size: DWORD
|
291
|
-
0x112e2f665: add esi, edx
|
292
|
-
;Comment 7: 12 rax|DWORD = MOVE rsi|DWORD moveKind: DWORD
|
293
|
-
0x112e2f667: mov eax, esi
|
294
|
-
;Comment 9: 14 RETURN (savedRbp: rbp|QWORD, value: rax|DWORD) isStub: false requiresReservedStackAccessCheck: false thread: r15 scratchForSafepointOnReturn: rcx config: org.graalvm.compiler.hotspot.GraalHotSpotVMConfig@137f187d8
|
295
|
-
;Comment 9: 12
|
296
|
-
0x112e2f669: test dword ptr [rip - 0x46c4669], eax
|
297
|
-
0x112e2f66f: vzeroupper
|
298
|
-
0x112e2f672: ret
|
299
|
-
...
|
300
|
-
```
|
301
|
-
|
302
|
-
## Options for GraalVM graphs
|
303
|
-
|
304
|
-
* `--show-frame-state` shows frame state nodes, which are hidden by default
|
305
|
-
* `--hide-floating` hides nodes that aren't fixed by control flow
|
306
|
-
* `--no-reduce-edges` turns off the option to reduce the number of edges by inlining simple nodes above their users
|
307
|
-
* `--draw-blocks` to draw basic block information if available
|
308
|
-
|
309
|
-
## Configuration
|
310
|
-
|
311
|
-
Seafoam loads and runs a Ruby script called `~/.seafoam/config` in the first
|
312
|
-
directory it finds starting with the current working directory and moving up.
|
313
|
-
You can require or configure extra [annotators](docs/annotators.md) in this
|
314
|
-
file.
|
315
|
-
|
316
|
-
## Debugging
|
317
|
-
|
318
|
-
Exception backtraces are printed if `$DEBUG` (`-d`) is set.
|
319
|
-
|
320
|
-
Use `seafoam file.bgv debug` to debug file parsing.
|
321
|
-
|
322
|
-
## More documentation
|
323
|
-
|
324
|
-
* [Graph annotators](docs/annotators.md)
|
325
|
-
* [Details of the BGV file format](docs/bgv.md)
|
326
|
-
* [How to get graphs from various compilers](docs/getting-graphs.md)
|
327
|
-
|
328
|
-
## Frequently asked questions
|
329
|
-
|
330
|
-
#### Why is it called *Seafoam*?
|
331
|
-
|
332
|
-
GraalVM graphs are *seas of nodes*. Seafoam is a shade of green, and Seafoam was
|
333
|
-
written at Shopify, which has green as a brand colour. Graphs can sometimes be
|
334
|
-
very complicated, appearing like a foam without any structure - Seafoam tries to
|
335
|
-
help you make sense of it all.
|
336
|
-
|
337
|
-
#### What do you mean by *graphs*, and *seas* or *soups* of nodes?
|
338
|
-
|
339
|
-
Graphs, as in edges and nodes, are the data structure some compilers use to
|
340
|
-
represent your program while they're compiling it. It's a form of *intermediate
|
341
|
-
representation*. Graphs are how the compiler understands the programs and if the
|
342
|
-
compiler isn't doing what you want you need to look at the graph and make sense
|
343
|
-
of it. Some graphs are loosely structured and large, making them like a sea or
|
344
|
-
soup of nodes.
|
345
|
-
|
346
|
-
#### Doesn't *reduce edges* actually introduce more edges?
|
347
|
-
|
348
|
-
Yes, but they're shorter edges, and it achieves the intended effect of less
|
349
|
-
edges crossing over the graph.
|
350
|
-
|
351
|
-
## Related work
|
352
|
-
|
353
|
-
The graph layout algorithm we use, via Graphviz, is
|
354
|
-
|
355
|
-
* E. R. Gansner, et al, [*A Technique for Drawing Directed Graphs*](http://citeseerx.ist.psu.edu/viewdoc/summary?doi=10.1.1.3.8982), IEEE Transactions on Software Engineering, 1993
|
356
|
-
|
357
|
-
IGV is the existing tool for working with Graal graphs. It uses a *hierarchical*
|
358
|
-
layout algorithm, rather than the *force directed* algorithm we use when we use
|
359
|
-
Graphviz. It's based on the NetBeans IDE platform. It's related to the *C1
|
360
|
-
Visualiser*, for control-flow graphs. The C1 Visualiser can also be used with
|
361
|
-
Graal as the backend of Graal is similar enough to C1. IGV is closed-source and
|
362
|
-
available under a proprietary licence.
|
363
|
-
|
364
|
-
* T. Würthinger, [*Visualization of Program Dependence Graphs*](http://www.ssw.uni-linz.ac.at/Research/Papers/Wuerthinger07Master/), Master Thesis, Linz 2007
|
365
|
-
* T. Würthinger, [*Visualization of Java Control Flow Graphs*](http://www.ssw.uni-linz.ac.at/General/Staff/TW/Wuerthinger06Bachelor.pdf), Bachelor Thesis, Linz 2006
|
366
|
-
|
367
|
-
[*Turbolizer*][turbolizer] is a similar tool for the intermediate representation
|
368
|
-
in the V8 JavaScript compiler.
|
369
|
-
|
370
|
-
[turbolizer]: https://github.com/v8/v8/blob/4b9b23521e6fd42373ebbcb20ebe03bf445494f9/tools/turbolizer
|
371
|
-
|
372
|
-
## Author
|
373
|
-
|
374
|
-
Seafoam was written by Chris Seaton at Shopify, chris.seaton@shopify.com.
|
375
|
-
|
376
|
-
## License
|
377
|
-
|
378
|
-
MIT
|