seafoam 0.2 → 0.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (134) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/workflows.yml +39 -0
  3. data/.rubocop.yml +4 -1
  4. data/README.md +107 -27
  5. data/bin/bgv2isabelle +16 -45
  6. data/bin/bgv2json +18 -36
  7. data/bin/cfg2asm +24 -0
  8. data/bin/seafoam +2 -2
  9. data/demos/box-unbox-stats +65 -0
  10. data/docs/bgv.md +16 -7
  11. data/docs/getting-graphs.md +12 -0
  12. data/docs/json.md +35 -0
  13. data/examples/fib-java.bgv.gz +0 -0
  14. data/examples/fib.js +1 -1
  15. data/examples/java/JavaExamples.java +1 -1
  16. data/examples/ruby/clamps.rb +20 -0
  17. data/examples/ruby/graal.patch +15 -0
  18. data/examples/ruby/ruby_examples.rb +278 -0
  19. data/lib/seafoam.rb +5 -1
  20. data/lib/seafoam/annotators/graal.rb +1 -1
  21. data/lib/seafoam/bgv/bgv_parser.rb +12 -2
  22. data/lib/seafoam/cfg/cfg_parser.rb +93 -0
  23. data/lib/seafoam/cfg/disassembler.rb +70 -0
  24. data/lib/seafoam/commands.rb +196 -36
  25. data/lib/seafoam/graal/source.rb +23 -0
  26. data/lib/seafoam/isabelle_writer.rb +46 -0
  27. data/lib/seafoam/json_writer.rb +58 -0
  28. data/lib/seafoam/version.rb +1 -1
  29. data/seafoam.gemspec +4 -2
  30. data/spec/seafoam/annotators/graal_spec.rb +7 -7
  31. data/spec/seafoam/bgv/bgv_parser_spec.rb +27 -14
  32. data/spec/seafoam/cfg/cfg_parser_spec.rb +21 -0
  33. data/spec/seafoam/cfg/disassembler_spec.rb +32 -0
  34. data/spec/seafoam/command_spec.rb +94 -30
  35. data/spec/seafoam/graphviz_writer_spec.rb +2 -2
  36. data/spec/seafoam/json_writer_spec.rb +14 -0
  37. data/spec/seafoam/spec_helpers.rb +5 -1
  38. data/spec/seafoam/spotlight_spec.rb +1 -1
  39. data/tools/render-all +2 -2
  40. metadata +34 -98
  41. data/.github/workflows/rubocop.yml +0 -10
  42. data/.github/workflows/specs.yml +0 -19
  43. data/examples/fib-java.bgv +0 -0
  44. data/examples/fib-js.bgv +0 -0
  45. data/examples/fib-ruby.bgv +0 -0
  46. data/examples/identity.bgv +0 -0
  47. data/examples/java/exampleArithOperator.bgv +0 -0
  48. data/examples/java/exampleArithOperator.cfg +0 -925
  49. data/examples/java/exampleArrayAllocation.bgv +0 -0
  50. data/examples/java/exampleArrayAllocation.cfg +0 -5268
  51. data/examples/java/exampleArrayRead.bgv +0 -0
  52. data/examples/java/exampleArrayRead.cfg +0 -2263
  53. data/examples/java/exampleArrayWrite.bgv +0 -0
  54. data/examples/java/exampleArrayWrite.cfg +0 -2315
  55. data/examples/java/exampleCatch.bgv +0 -0
  56. data/examples/java/exampleCatch.cfg +0 -4150
  57. data/examples/java/exampleCompareOperator.bgv +0 -0
  58. data/examples/java/exampleCompareOperator.cfg +0 -1109
  59. data/examples/java/exampleDoubleSynchronized.bgv +0 -0
  60. data/examples/java/exampleDoubleSynchronized.cfg +0 -26497
  61. data/examples/java/exampleExactArith.bgv +0 -0
  62. data/examples/java/exampleExactArith.cfg +0 -1888
  63. data/examples/java/exampleFieldRead.bgv +0 -0
  64. data/examples/java/exampleFieldRead.cfg +0 -1228
  65. data/examples/java/exampleFieldWrite.bgv +0 -0
  66. data/examples/java/exampleFieldWrite.cfg +0 -1102
  67. data/examples/java/exampleFor.bgv +0 -0
  68. data/examples/java/exampleFor.cfg +0 -3936
  69. data/examples/java/exampleFullEscape.bgv +0 -0
  70. data/examples/java/exampleFullEscape.cfg +0 -5893
  71. data/examples/java/exampleIf.bgv +0 -0
  72. data/examples/java/exampleIf.cfg +0 -2462
  73. data/examples/java/exampleIfNeverTaken.bgv +0 -0
  74. data/examples/java/exampleIfNeverTaken.cfg +0 -2476
  75. data/examples/java/exampleInstanceOfManyImpls.bgv +0 -0
  76. data/examples/java/exampleInstanceOfManyImpls.cfg +0 -6391
  77. data/examples/java/exampleInstanceOfOneImpl.bgv +0 -0
  78. data/examples/java/exampleInstanceOfOneImpl.cfg +0 -2604
  79. data/examples/java/exampleIntSwitch.bgv +0 -0
  80. data/examples/java/exampleIntSwitch.cfg +0 -3121
  81. data/examples/java/exampleInterfaceCallManyImpls.bgv +0 -0
  82. data/examples/java/exampleInterfaceCallManyImpls.cfg +0 -1358
  83. data/examples/java/exampleInterfaceCallOneImpl.bgv +0 -0
  84. data/examples/java/exampleInterfaceCallOneImpl.cfg +0 -3859
  85. data/examples/java/exampleLocalInstanceOf.bgv +0 -0
  86. data/examples/java/exampleLocalInstanceOf.cfg +0 -5276
  87. data/examples/java/exampleLocalSynchronized.bgv +0 -0
  88. data/examples/java/exampleLocalSynchronized.cfg +0 -1364
  89. data/examples/java/exampleLocalVariables.bgv +0 -0
  90. data/examples/java/exampleLocalVariables.cfg +0 -1195
  91. data/examples/java/exampleLocalVariablesState.bgv +0 -0
  92. data/examples/java/exampleLocalVariablesState.cfg +0 -1673
  93. data/examples/java/exampleNestedWhile.bgv +0 -0
  94. data/examples/java/exampleNestedWhile.cfg +0 -15499
  95. data/examples/java/exampleNestedWhileBreak.bgv +0 -0
  96. data/examples/java/exampleNestedWhileBreak.cfg +0 -11162
  97. data/examples/java/exampleNoEscape.bgv +0 -0
  98. data/examples/java/exampleNoEscape.cfg +0 -974
  99. data/examples/java/exampleObjectAllocation.bgv +0 -0
  100. data/examples/java/exampleObjectAllocation.cfg +0 -5287
  101. data/examples/java/examplePartialEscape.bgv +0 -0
  102. data/examples/java/examplePartialEscape.cfg +0 -7042
  103. data/examples/java/examplePhi.bgv +0 -0
  104. data/examples/java/examplePhi.cfg +0 -3227
  105. data/examples/java/exampleReducible.bgv +0 -0
  106. data/examples/java/exampleReducible.cfg +0 -5578
  107. data/examples/java/exampleSimpleCall.bgv +0 -0
  108. data/examples/java/exampleSimpleCall.cfg +0 -1435
  109. data/examples/java/exampleStamp.bgv +0 -0
  110. data/examples/java/exampleStamp.cfg +0 -913
  111. data/examples/java/exampleStaticCall.bgv +0 -0
  112. data/examples/java/exampleStaticCall.cfg +0 -1154
  113. data/examples/java/exampleStringSwitch.bgv +0 -0
  114. data/examples/java/exampleStringSwitch.cfg +0 -15377
  115. data/examples/java/exampleSynchronized.bgv +0 -0
  116. data/examples/java/exampleSynchronized.cfg +0 -26027
  117. data/examples/java/exampleThrow.bgv +0 -0
  118. data/examples/java/exampleThrow.cfg +0 -780
  119. data/examples/java/exampleThrowCatch.bgv +0 -0
  120. data/examples/java/exampleThrowCatch.cfg +0 -744
  121. data/examples/java/exampleUnsafeRead.bgv +0 -0
  122. data/examples/java/exampleUnsafeRead.cfg +0 -912
  123. data/examples/java/exampleUnsafeWrite.bgv +0 -0
  124. data/examples/java/exampleUnsafeWrite.cfg +0 -962
  125. data/examples/java/exampleWhile.bgv +0 -0
  126. data/examples/java/exampleWhile.cfg +0 -3936
  127. data/examples/java/exampleWhileBreak.bgv +0 -0
  128. data/examples/java/exampleWhileBreak.cfg +0 -5963
  129. data/examples/matmult-java.bgv +0 -0
  130. data/examples/matmult-ruby.bgv +0 -0
  131. data/examples/overflow.bgv +0 -0
  132. data/lib/seafoam/binary/binary_reader.rb +0 -21
  133. data/spec/seafoam/bgv/fixtures/not.bgv +0 -1
  134. data/spec/seafoam/bgv/fixtures/unsupported.bgv +0 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 841e61f7601b4121b7367e9974b9920f8b8513fd6ca7a827c1be0e340bc2b3cf
4
- data.tar.gz: 559e28e6b6a49964f31ac73bc1b1ed8c72fefae9d81381bb3e433bc39d57d0d7
3
+ metadata.gz: a17a259b362af5eef7c3c874e6d796f647c6017d413cba708ac0a27e18043681
4
+ data.tar.gz: 39eba465ba4ed92b3085a276d541072ccff48d62fdd00a317961c7401bcb0ee0
5
5
  SHA512:
6
- metadata.gz: 75c306c0d6b9b8dffae51f62538a6b5e529150b59e5b6ea6ccbcf1b27ca9505fc8b7548086f2826d4f9bb8589648e2281e750a2caabd7b91f7da164065756883
7
- data.tar.gz: c0c307acef6945d1841cc23d2cf5c00bbc52ed70cd74aaa95fc9365f83e796379b86009a16eef522b849e6a279b147e4d8350291b5fcdbebfa81d2ef4178bed5
6
+ metadata.gz: e55cdfa1eea817f24bbaa22ef80916923441393529351df21c258987354cafe98d07ed4bff2fd3e6fc5ab5656ea7f85b938d7a906ee511cd9f06fa19c335431f
7
+ data.tar.gz: '070468e7e9c1fd55b6429c07d8c226e1c0c0e4225a0f9a90bd577e7b57bb8320bcd0a59e1da223632986245f6eb5482a1320b11e6b786f41f456187766664b9b'
@@ -0,0 +1,39 @@
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: bundle install
10
+ - run: bundle exec rubocop
11
+ specs:
12
+ strategy:
13
+ matrix:
14
+ os: [ubuntu, macos]
15
+ ruby: [2.5, 2.6, 2.7]
16
+ runs-on: ${{ matrix.os }}-latest
17
+ steps:
18
+ - uses: actions/checkout@v2
19
+ - uses: ruby/setup-ruby@v1
20
+ with:
21
+ ruby-version: ${{ matrix.ruby }}
22
+ bundler-cache: true
23
+ - run: bundle install
24
+ - run: if [[ $(uname) == "Darwin" ]]; then brew install graphviz capstone; else sudo apt-get install graphviz libcapstone3; fi
25
+ - run: bundle exec rspec
26
+ specs-no-dependencies:
27
+ strategy:
28
+ matrix:
29
+ os: [ubuntu, macos]
30
+ ruby: [2.5, 2.6, 2.7]
31
+ runs-on: ${{ matrix.os }}-latest
32
+ steps:
33
+ - uses: actions/checkout@v2
34
+ - uses: ruby/setup-ruby@v1
35
+ with:
36
+ ruby-version: ${{ matrix.ruby }}
37
+ bundler-cache: true
38
+ - run: bundle install
39
+ - run: NO_DEPENDENCIES_INSTALLED=true bundle exec rspec
data/.rubocop.yml CHANGED
@@ -1,7 +1,7 @@
1
1
  AllCops:
2
2
  TargetRubyVersion: 2.5
3
3
  Exclude:
4
- - examples/*
4
+ - examples/**/*.rb
5
5
 
6
6
  Style/FrozenStringLiteralComment:
7
7
  Enabled: false
@@ -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,13 +10,18 @@ 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
16
- * has easy PDF, SVG and PNG output
17
+ * has easy PDF, SVG, PNG and JSON output
17
18
  * is designed for accessibility
18
19
  * looks prettier, in our opinion
19
20
 
21
+ Additionally, Seafoam adds:
22
+
23
+ * support for disassembling CFG files
24
+
20
25
  Admittedly, Seafoam does not yet have:
21
26
 
22
27
  * an interactive user interface
@@ -37,34 +42,43 @@ Admittedly, Seafoam does not yet have:
37
42
  ### macOS
38
43
 
39
44
  ```
40
- $ brew install graphviz
41
- $ gem install seafoam
42
- $ seafoam --version
45
+ % brew install graphviz
46
+ % gem install seafoam
47
+ % seafoam --version
43
48
  seafoam 0.1
44
49
  ```
45
50
 
46
51
  ### Ubuntu
47
52
 
48
53
  ```
49
- $ sudo apt-get install ruby graphviz
50
- $ gem install seafoam
51
- $ seafoam --version
54
+ % sudo apt-get install ruby graphviz
55
+ % gem install seafoam
56
+ % seafoam --version
52
57
  seafoam 0.1
53
58
  ```
54
59
 
55
- #### RedHat
60
+ ### RedHat
56
61
 
57
62
  ```
58
- $ sudo yum install ruby graphviz
59
- $ gem install seafoam
60
- $ seafoam --version
63
+ % sudo yum install ruby graphviz
64
+ % gem install seafoam
65
+ % seafoam --version
61
66
  seafoam 0.1
62
67
  ```
63
68
 
69
+ ### Capstone
70
+
71
+ To use the `cfg2asm` disassembler, you'll then need to install Capstone.
72
+
73
+ ```
74
+ % brew install capstone # macOS
75
+ % sudo apt-get install libcapstone3 # Ubuntu
76
+ ```
77
+
64
78
  ## Quick-start demo
65
79
 
66
80
  ```
67
- $ seafoam examples/fib-java.bgv:0 render
81
+ % seafoam examples/fib-java.bgv:0 render
68
82
  ```
69
83
 
70
84
  ## Getting compiler graphs
@@ -78,14 +92,20 @@ This is just a quick summary - see more information on
78
92
  ### GraalVM for Java
79
93
 
80
94
  ```
81
- $ javac Fib.java
82
- $ java -XX:CompileOnly=::fib -Dgraal.Dump=:2 Fib 14
95
+ % javac Fib.java
96
+ % java -XX:CompileOnly=::fib -Dgraal.Dump=:2 Fib 14
97
+ ```
98
+
99
+ ### GraalVM Native Image
100
+
101
+ ```
102
+ % native-image -H:Dump=:2 -H:MethodFilter=fib Fib
83
103
  ```
84
104
 
85
105
  ### TruffleRuby and other Truffle languages
86
106
 
87
107
  ```
88
- $ ruby --experimental-options --engine.CompileOnly=fib --engine.Inlining=false --engine.OSR=false --vm.Dgraal.Dump=Truffle:2 fib.rb 14
108
+ % ruby --experimental-options --engine.CompileOnly=fib --engine.Inlining=false --engine.OSR=false --vm.Dgraal.Dump=Truffle:2 fib.rb 14
89
109
  ```
90
110
 
91
111
  You will usually want to look at the *After TruffleTier* graph.
@@ -105,14 +125,14 @@ Note that a *graph ID* is an ID found in BGV files, but is not unique. A
105
125
  #### Print information about a file
106
126
 
107
127
  ```
108
- $ seafoam examples/fib-java.bgv info
128
+ % seafoam examples/fib-java.bgv info
109
129
  BGV 6.1
110
130
  ```
111
131
 
112
132
  #### List graphs in a file
113
133
 
114
134
  ```
115
- $ seafoam examples/fib-java.bgv list
135
+ % seafoam examples/fib-java.bgv list
116
136
  examples/fib-java.bgv:0 2:Fib.fib(int)/After phase org.graalvm.compiler.java.GraphBuilderPhase
117
137
  examples/fib-java.bgv:1 2:Fib.fib(int)/After phase org.graalvm.compiler.phases.PhaseSuite
118
138
  examples/fib-java.bgv:2 2:Fib.fib(int)/After phase org.graalvm.compiler.phases.common.DeadCodeEliminationPhase
@@ -125,7 +145,7 @@ examples/fib-java.bgv:5 2:Fib.fib(int)/After phase org.graalvm.compiler.phases.
125
145
  #### Search for strings in a graph, or node or edge within a graph
126
146
 
127
147
  ```
128
- $ seafoam examples/fib-java.bgv:0 search Start
148
+ % seafoam examples/fib-java.bgv:0 search Start
129
149
  examples/fib-java.bgv:0:0 ...node_class":"org.graalvm.compiler.nodes.StartNode","name_template":"Start","inputs":[...
130
150
  examples/fib-java.bgv:0:0 ...piler.nodes.StartNode","name_template":"Start","inputs":[{"direct":true,"name":"state...
131
151
  ```
@@ -133,9 +153,9 @@ examples/fib-java.bgv:0:0 ...piler.nodes.StartNode","name_template":"Start","in
133
153
  #### Print edges of a graph, or node or edge within a graph
134
154
 
135
155
  ```
136
- $ seafoam examples/fib-java.bgv:0 edges
156
+ % seafoam examples/fib-java.bgv:0 edges
137
157
  22 nodes, 30 edges
138
- $ seafoam examples/fib-java.bgv:0:13 edges
158
+ % seafoam examples/fib-java.bgv:0:13 edges
139
159
  Input:
140
160
  13 (Call Fib.fib) <-() 6 (Begin)
141
161
  13 (Call Fib.fib) <-() 14 (@{:declaring_class=>"Fib", :method_name=>"fib", :signature=>{:args=>["I"], :ret=>"I"}, :modifiers=>9}:13)
@@ -145,14 +165,14 @@ Output:
145
165
  13 (Call Fib.fib) ->(values) 14 (@{:declaring_class=>"Fib", :method_name=>"fib", :signature=>{:args=>["I"], :ret=>"I"}, :modifiers=>9}:13)
146
166
  13 (Call Fib.fib) ->(values) 19 (@{:declaring_class=>"Fib", :method_name=>"fib", :signature=>{:args=>["I"], :ret=>"I"}, :modifiers=>9}:19)
147
167
  13 (Call Fib.fib) ->(x) 20 (+)
148
- $ seafoam examples/fib-java.bgv:0:13-20 edges
168
+ % seafoam examples/fib-java.bgv:0:13-20 edges
149
169
  13 (Call Fib.fib) ->(x) 20 (+)
150
170
  ```
151
171
 
152
172
  #### Print properties of a file, graph, or node or edge within a graph
153
173
 
154
174
  ```
155
- $ seafoam examples/fib-java.bgv:0 props
175
+ % seafoam examples/fib-java.bgv:0 props
156
176
  {
157
177
  "group": [
158
178
  {
@@ -160,7 +180,7 @@ $ seafoam examples/fib-java.bgv:0 props
160
180
  "short_name": "2:Fib.fib(int)",
161
181
  "method": null,
162
182
  ...
163
- $ seafoam examples/fib-java.bgv:0:13 props
183
+ % seafoam examples/fib-java.bgv:0:13 props
164
184
  {
165
185
  "nodeSourcePosition": {
166
186
  "method": {
@@ -168,7 +188,7 @@ $ seafoam examples/fib-java.bgv:0:13 props
168
188
  "method_name": "fib",
169
189
  "signature": {
170
190
  ...
171
- $ seafoam examples/fib-java.bgv:0:13-20 props
191
+ % seafoam examples/fib-java.bgv:0:13-20 props
172
192
  {
173
193
  "direct": true,
174
194
  "name": "x",
@@ -176,19 +196,39 @@ $ seafoam examples/fib-java.bgv:0:13-20 props
176
196
  }
177
197
  ```
178
198
 
199
+ #### Print node source information
200
+
201
+ ```
202
+ % seafoam examples/fib-ruby.bgv:8:2443 source
203
+ java.lang.Math#addExact
204
+ org.truffleruby.core.numeric.IntegerNodes$AddNode#add
205
+ org.truffleruby.core.numeric.IntegerNodesFactory$AddNodeFactory$AddNodeGen#executeAdd
206
+ org.truffleruby.core.inlined.InlinedAddNode#intAdd
207
+ org.truffleruby.core.inlined.InlinedAddNodeGen#execute
208
+ org.truffleruby.language.control.IfElseNode#execute
209
+ org.truffleruby.language.control.SequenceNode#execute
210
+ org.truffleruby.language.arguments.CheckArityNode#execute
211
+ org.truffleruby.language.control.SequenceNode#execute
212
+ org.truffleruby.language.methods.CatchForMethodNode#execute
213
+ org.truffleruby.language.methods.ExceptionTranslatingNode#execute
214
+ org.truffleruby.language.RubyRootNode#execute
215
+ org.graalvm.compiler.truffle.runtime.OptimizedCallTarget#executeRootNode
216
+ org.graalvm.compiler.truffle.runtime.OptimizedCallTarget#profiledPERoot
217
+ ```
218
+
179
219
  #### Render a graph
180
220
 
181
221
  Render a graph as a PDF image and have it opened automatically.
182
222
 
183
223
  ```
184
- $ seafoam examples/fib-java.bgv:0 render
224
+ % seafoam examples/fib-java.bgv:0 render
185
225
  ```
186
226
 
187
227
  Render a graph showing just a few nodes and those surrounding them, similar to
188
228
  the IGV feature of gradually revealing nodes.
189
229
 
190
230
  ```
191
- $ seafoam examples/fib-java.bgv:0 render --spotlight 13,20
231
+ % seafoam examples/fib-java.bgv:0 render --spotlight 13,20
192
232
  ```
193
233
 
194
234
  <p>
@@ -206,7 +246,7 @@ $ seafoam examples/fib-java.bgv:0 render --spotlight 13,20
206
246
  Convert a BGV file to the Isabelle graph format.
207
247
 
208
248
  ```
209
- $ bgv2isabelle examples/fib-java.bgv
249
+ % bgv2isabelle examples/fib-java.bgv
210
250
  graph0 = # 2:Fib.fib(int)/After phase org.graalvm.compiler.java.GraphBuilderPhase
211
251
  (add_node 0 StartNode [2] [8]
212
252
  (add_node 1 (ParameterNode 0) [] [2, 5, 9, 11, 14, 16]
@@ -220,6 +260,46 @@ graph0 = # 2:Fib.fib(int)/After phase org.graalvm.compiler.java.GraphBuilderPhas
220
260
  ...
221
261
  ```
222
262
 
263
+ Convert a BGV file to JSON.
264
+
265
+ ```
266
+ % bgv2json examples/fib-java.bgv
267
+ graph0 = # 2:Fib.fib(int)/After phase org.graalvm.compiler.java.GraphBuilderPhase
268
+ (add_node 0 StartNode [2] [8]
269
+ (add_node 1 (ParameterNode 0) [] [2, 5, 9, 11, 14, 16]
270
+ (add_node 2 FrameState [1] [0]
271
+ (add_node 3 (ConstantNode 1) [] []
272
+ (add_node 4 (ConstantNode 2) [] [5]
273
+ (add_node 5 IntegerLessThanNode [1, 4] [8]
274
+ (add_node 6 BeginNode [8] [13]
275
+ (add_node 7 BeginNode [8] [9]
276
+ (add_node 8 IfNode [0, 5] [7, 6]
277
+ ...
278
+ ```
279
+
280
+ #### Disassembling
281
+
282
+ ```
283
+ % cfg2asm examples/java/exampleArithOperator.cfg
284
+ [examples/java/exampleArithOperator.cfg]
285
+ ;Comment 0: 3
286
+ ;Comment 0: 1
287
+ 0x112e2f660: nop dword ptr [rax + rax]
288
+ ;Comment 5: block B0 null
289
+ ;Comment 5: 0 [rsi|DWORD, rdx|DWORD, rbp|QWORD] = LABEL numbPhis: 0 align: false label: ?
290
+ ;Comment 5: 4 [] = HOTSPOTLOCKSTACK frameMapBuilder: org.graalvm.compiler.lir.amd64.AMD64FrameMapBuilder@143082de0 slotKind: QWORD
291
+ ;Comment 5: 10 rsi|DWORD = ADD (x: rsi|DWORD, y: rdx|DWORD) size: DWORD
292
+ 0x112e2f665: add esi, edx
293
+ ;Comment 7: 12 rax|DWORD = MOVE rsi|DWORD moveKind: DWORD
294
+ 0x112e2f667: mov eax, esi
295
+ ;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
296
+ ;Comment 9: 12
297
+ 0x112e2f669: test dword ptr [rip - 0x46c4669], eax
298
+ 0x112e2f66f: vzeroupper
299
+ 0x112e2f672: ret
300
+ ...
301
+ ```
302
+
223
303
  ## Options for GraalVM graphs
224
304
 
225
305
  * `--show-frame-state` shows frame state nodes, which are hidden by default
data/bin/bgv2isabelle CHANGED
@@ -2,52 +2,23 @@
2
2
 
3
3
  require 'seafoam'
4
4
 
5
- # definition eg_short_cut_or1 :: IRGraph where
6
- # "eg_short_cut_or1 =
7
- # (add_node 14 ReturnNode [13] []
8
- # (add_node 13 PhiNode [10, 11, 12] []
9
- # (add_node 12 (ConstantNode 0) [] []
10
- # (add_node 11 (ConstantNode 42) [] []
11
- # (add_node 10 MergeNode [7, 9] [14]
12
- # (add_node 9 EndNode [] []
13
- # (add_node 8 BeginNode [] [9]
14
- # (add_node 7 EndNode [] []
15
- # (add_node 6 BeginNode [] [7]
16
- # (add_node 5 IfNode [3] [6, 8]
17
- # (add_node 3 (ShortCircuitOrNode False False) [1, 2] []
18
- # (add_node 2 (ParameterNode 1) [] []
19
- # (add_node 1 (ParameterNode 0) [] []
20
- # (add_node 0 StartNode [] [5]
21
- # empty_graph))))))))))))))"
5
+ # This is the 'bgv2isabelle' command line entry point.
22
6
 
23
- ARGV.each do |file|
24
- parser = Seafoam::BGV::BGVParser.new(File.new(file))
25
- parser.read_file_header
26
- parser.skip_document_props
7
+ begin
8
+ # Load configuraiton.
9
+ config = Seafoam::Config.new
10
+ config.load_config
27
11
 
28
- loop do
29
- index, = parser.read_graph_preheader
30
- break unless index
31
-
32
- graph_header = parser.read_graph_header
33
- graph = parser.read_graph
34
-
35
- puts "graph#{index} = # #{parser.graph_name(graph_header)}"
36
-
37
- graph.nodes.each_value do |node|
38
- node_class = node.props[:node_class][:node_class]
39
- case node_class
40
- when 'org.graalvm.compiler.nodes.ConstantNode'
41
- desc = "(ConstantNode #{node.props['rawvalue']})"
42
- when 'org.graalvm.compiler.nodes.ParameterNode'
43
- desc = "(ParameterNode #{node.props['index']})"
44
- else
45
- desc = node_class.split('.').last
46
- end
47
- inputs = node.inputs.map(&:from).map(&:id)
48
- outputs = node.outputs.map(&:to).map(&:id)
49
- puts " (add_node #{node.id} #{desc} #{inputs.inspect} #{outputs.inspect}"
50
- end
51
- puts ' empty_graph' + (')' * graph.nodes.size)
12
+ # Run the command line.
13
+ commands = Seafoam::Commands.new($stdout, config)
14
+ commands.bgv2isabelle(*ARGV)
15
+ rescue StandardError => e
16
+ if $DEBUG
17
+ # Re-raise the exception so the user sees it, if debugging is
18
+ # enabled (ruby -d).
19
+ raise e
20
+ else
21
+ # Otherwise, just print the message.
22
+ warn "seafoam: #{e.message}"
52
23
  end
53
24
  end
data/bin/bgv2json CHANGED
@@ -1,42 +1,24 @@
1
1
  #!/usr/bin/env ruby
2
2
 
3
3
  require 'seafoam'
4
- require 'json'
5
4
 
6
- ARGV.each do |file|
7
- parser = Seafoam::BGV::BGVParser.new(File.new(file))
8
- parser.read_file_header
9
- parser.skip_document_props
10
-
11
- loop do
12
- index, = parser.read_graph_preheader
13
- break unless index
14
-
15
- graph_header = parser.read_graph_header
16
-
17
- graph = parser.read_graph
18
- Seafoam::Annotators.apply graph
19
-
20
- name = parser.graph_name(graph_header)
21
-
22
- nodes = []
23
- edges = []
24
-
25
- graph.nodes.each_value do |node|
26
- nodes.push({
27
- id: node.id,
28
- props: node.props
29
- })
30
-
31
- node.outputs.each do |edge|
32
- edges.push({
33
- from: edge.from.id,
34
- to: edge.to.id,
35
- props: edge.props
36
- })
37
- end
38
- end
39
-
40
- puts JSON.generate({name: name, props: graph.props, nodes: nodes, edges: edges})
5
+ # This is the 'bgv2json' command line entry point.
6
+
7
+ begin
8
+ # Load configuraiton.
9
+ config = Seafoam::Config.new
10
+ config.load_config
11
+
12
+ # Run the command line.
13
+ commands = Seafoam::Commands.new($stdout, config)
14
+ commands.bgv2json(*ARGV)
15
+ rescue StandardError => e
16
+ if $DEBUG
17
+ # Re-raise the exception so the user sees it, if debugging is
18
+ # enabled (ruby -d).
19
+ raise e
20
+ else
21
+ # Otherwise, just print the message.
22
+ warn "seafoam: #{e.message}"
41
23
  end
42
24
  end