seafoam 0.8 → 0.12

Sign up to get free protection for your applications and to get access to all the features.
Files changed (79) hide show
  1. checksums.yaml +4 -4
  2. data/bin/bgv2isabelle +1 -5
  3. data/bin/bgv2json +1 -5
  4. data/bin/seafoam +1 -5
  5. data/lib/seafoam/bgv/bgv_parser.rb +1 -2
  6. data/lib/seafoam/commands.rb +135 -101
  7. data/lib/seafoam/formatters/base.rb +88 -0
  8. data/lib/seafoam/formatters/formatters.rb +8 -0
  9. data/lib/seafoam/formatters/json.rb +82 -0
  10. data/lib/seafoam/formatters/text.rb +70 -0
  11. data/lib/seafoam/graal/graph_description.rb +22 -0
  12. data/lib/seafoam/graal/pi.rb +18 -0
  13. data/lib/seafoam/graal/source.rb +5 -9
  14. data/lib/seafoam/graph.rb +9 -1
  15. data/lib/seafoam/graphviz_writer.rb +3 -0
  16. data/lib/seafoam/json_writer.rb +1 -3
  17. data/lib/seafoam/{annotators → passes}/fallback.rb +4 -4
  18. data/lib/seafoam/{annotators → passes}/graal.rb +43 -15
  19. data/lib/seafoam/passes/truffle.rb +58 -0
  20. data/lib/seafoam/passes.rb +61 -0
  21. data/lib/seafoam/version.rb +1 -1
  22. data/lib/seafoam.rb +7 -6
  23. metadata +17 -81
  24. data/.github/probots.yml +0 -2
  25. data/.github/workflows/workflows.yml +0 -40
  26. data/.gitignore +0 -6
  27. data/.rubocop.yml +0 -37
  28. data/.ruby-version +0 -1
  29. data/.seafoam/config +0 -1
  30. data/CODE_OF_CONDUCT.md +0 -128
  31. data/CONTRIBUTING.md +0 -5
  32. data/Gemfile +0 -2
  33. data/Gemfile.lock +0 -59
  34. data/LICENSE.md +0 -7
  35. data/README.md +0 -378
  36. data/bin/cfg2asm +0 -24
  37. data/demos/box-unbox-stats +0 -65
  38. data/docs/annotators.md +0 -43
  39. data/docs/bgv.md +0 -294
  40. data/docs/getting-graphs.md +0 -63
  41. data/docs/images/igv.png +0 -0
  42. data/docs/images/seafoam.png +0 -0
  43. data/docs/images/spotlight-igv.png +0 -0
  44. data/docs/images/spotlight-seafoam.png +0 -0
  45. data/docs/json.md +0 -35
  46. data/examples/Fib.java +0 -24
  47. data/examples/MatMult.java +0 -39
  48. data/examples/fib-java.bgv.gz +0 -0
  49. data/examples/fib.js +0 -15
  50. data/examples/fib.rb +0 -15
  51. data/examples/identity.rb +0 -13
  52. data/examples/java/Irreducible.class +0 -0
  53. data/examples/java/Irreducible.j +0 -35
  54. data/examples/java/IrreducibleDecompiled.java +0 -21
  55. data/examples/java/JavaExamples.java +0 -418
  56. data/examples/matmult.rb +0 -29
  57. data/examples/overflow.rb +0 -13
  58. data/examples/ruby/clamps.rb +0 -20
  59. data/examples/ruby/graal.patch +0 -15
  60. data/examples/ruby/ruby_examples.rb +0 -278
  61. data/lib/seafoam/annotators.rb +0 -54
  62. data/lib/seafoam/cfg/cfg_parser.rb +0 -93
  63. data/lib/seafoam/cfg/disassembler.rb +0 -70
  64. data/lib/seafoam/config.rb +0 -34
  65. data/seafoam.gemspec +0 -22
  66. data/spec/seafoam/annotators/fallback_spec.rb +0 -69
  67. data/spec/seafoam/annotators/graal_spec.rb +0 -96
  68. data/spec/seafoam/annotators_spec.rb +0 -61
  69. data/spec/seafoam/bgv/bgv_parser_spec.rb +0 -167
  70. data/spec/seafoam/binary/io_binary_reader_spec.rb +0 -176
  71. data/spec/seafoam/cfg/cfg_parser_spec.rb +0 -21
  72. data/spec/seafoam/cfg/disassembler_spec.rb +0 -32
  73. data/spec/seafoam/command_spec.rb +0 -314
  74. data/spec/seafoam/graph_spec.rb +0 -172
  75. data/spec/seafoam/graphviz_writer_spec.rb +0 -63
  76. data/spec/seafoam/json_writer_spec.rb +0 -14
  77. data/spec/seafoam/spec_helpers.rb +0 -34
  78. data/spec/seafoam/spotlight_spec.rb +0 -38
  79. data/tools/render-all +0 -36
data/bin/cfg2asm DELETED
@@ -1,24 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- require 'seafoam'
4
-
5
- # This is the 'cfg2asm' 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.cfg2asm(*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}"
23
- end
24
- end
@@ -1,65 +0,0 @@
1
- #!/usr/bin/env ruby
2
-
3
- # This demo analyses a directory full of graphs and looks for how many box nodes
4
- # take their value directly from an unbox node.
5
-
6
- require 'seafoam'
7
-
8
- box_nodes_count = 0
9
- box_nodes_from_unbox_count = 0
10
-
11
- graph_count = 0
12
- graph_match_count = 0
13
-
14
- ARGV.each do |dir|
15
- Dir.glob(['*.bgv', '*.bgv.gz'], base: dir) do |file|
16
- parser = Seafoam::BGV::BGVParser.new(File.join(dir, file))
17
- parser.read_file_header
18
- parser.skip_document_props
19
-
20
- loop do
21
- index, = parser.read_graph_preheader
22
- break unless index
23
-
24
- parser.skip_graph_header
25
- graph = parser.read_graph
26
-
27
- contains_box_unbox = false
28
-
29
- graph.nodes.each_value do |node|
30
- next unless node.props.dig(:node_class, :node_class).start_with?('org.graalvm.compiler.nodes.extended.BoxNode')
31
-
32
- box_node = node
33
- box_nodes_count += 1
34
- value_edge = node.edges.find { |e| e.props[:name] == 'value' }
35
- raise unless value_edge
36
-
37
- value_node = value_edge.from
38
- next unless value_node.props.dig(:node_class, :node_class).start_with?('org.graalvm.compiler.nodes.extended.UnboxNode')
39
-
40
- unbox_node = value_node
41
- box_nodes_from_unbox_count += 1
42
- contains_box_unbox = true
43
- puts "seafoam '#{File.join(dir, file)}:#{index}' render --spotlight #{box_node.id},#{unbox_node.id}"
44
- end
45
-
46
- graph_count += 1
47
- graph_match_count += 1 if contains_box_unbox
48
- end
49
- end
50
- end
51
-
52
- if box_nodes_count.positive?
53
- box_nodes_percent = (box_nodes_from_unbox_count / box_nodes_count.to_f) * 100
54
- else
55
- box_nodes_percent = 0.0
56
- end
57
-
58
- if graph_count.positive?
59
- graph_percent = (graph_match_count / graph_count.to_f) * 100
60
- else
61
- graph_percent = 0.0
62
- end
63
-
64
- puts " How many boxes take a value from an unbox? #{box_nodes_percent.round(1)}%"
65
- puts "How many graphs contain at least one box-unbox? #{graph_percent.round(1)}%"
data/docs/annotators.md DELETED
@@ -1,43 +0,0 @@
1
- # Annotators
2
-
3
- The model of Seafoam is that it is a directed graph, with nodes annotated with a
4
- bag of key-value properties. When graphs are read they'll have some initial
5
- properties. Seafoam may add more properties. The output routines then draw the
6
- graph using the graph structure itself and also the properties.
7
-
8
- *Annotators* are routines that add extra properties to graphs to help the user
9
- understand them. They usually have knowledge of how the graph is structured, and
10
- use this to make the graph easier to read or to make important information in
11
- them stand out.
12
-
13
- We call properties with symbol keys *annotations*, as they're added by the
14
- annotators.
15
-
16
- Annotators are similar to filters in IGV.
17
-
18
- Appropriate annotators are automatically selected and applied to graphs.
19
-
20
- The rendering commands recognize these annotations, so annotators will probably
21
- want to add them:
22
-
23
- * `:label` on nodes and edges
24
- * `:out_annotation` on nodes
25
- * `:hidden` on nodes only, to not show them (*remove frame state* for example in IGV terminology)
26
- * `:inlined` on nodes only, to indicate the node should be shown immediately above each node using it (*reduce edges* in IGV terminology)
27
- * `:kind` on nodes only, which can be `info`, `input`, `control`, `effect`, `virtual`, `calc`, `guard`, or `other`
28
- * `:kind` on edges only, which can be `info`, `control`, `loop`, or `data`
29
- * `:reverse` on edges only
30
- * `:spotlight` for nodes as part of spotlighting (`lit` are shown, `shaded` are shown but greyed out, and edges from `shaded` to `:hidden` nodes are also shown greyed out)
31
-
32
- Seafoam ships with an annotator for generic GraalVM graphs. If you work with a
33
- different compiler you'll probably want to write your own annotators - subclass
34
- `Seafoam::Annotator` and implement `#annotate(graph)`. You can add custom
35
- annotators by requiring them in your `.seafoam/config`. All subclasses of
36
- `Annotator` will be found, so you just need to define the subclass.
37
-
38
- A fallback annotator, run after all others, just labels the node with the
39
- `'label'` property if there is one.
40
-
41
- Options for annotations can be set on the command line with `--option key
42
- value`. Some options are built into Seafoam commands, like `--show-frame-state`,
43
- but they're doing the same thing as `--option hide_frame_state false`.
data/docs/bgv.md DELETED
@@ -1,294 +0,0 @@
1
- # BGV File Format
2
-
3
- The BGV (*binary graph*, sometimes also called *BIGV*) file format is dumped by
4
- Graal graphs.
5
-
6
- The BGV parser was implemented from the [open-source writer code][graph-protocol]
7
- in the GraalVM compiler.
8
-
9
- [graph-protocol]: https://github.com/oracle/graal/blob/master/compiler/src/org.graalvm.graphio/src/org/graalvm/graphio/GraphProtocol.java
10
-
11
- ## Format
12
-
13
- Seafoam supports BGV versions:
14
-
15
- * 7.0 (GraalVM 20.1.0 and up)
16
- * 6.1 (GraalVM 1.0.0-rc16 and up)
17
-
18
- The BGV file format is network-endian.
19
-
20
- ```c
21
- BGV {
22
- char[4] = 'BIGV'
23
- sint8 major
24
- sint8 minor
25
- GroupDocumentGraph*
26
- }
27
-
28
- GroupDocumentGraph {
29
- BeginGroup GroupDocumentGraph* CloseGroup | Document | Graph
30
- }
31
-
32
- BeginGroup {
33
- sint8 token = BEGIN_GROUP
34
- PoolObject name
35
- PoolObject method
36
- sint32 bci
37
- Props props
38
- }
39
-
40
- CloseGroup {
41
- sint8 token = CLOSE_GROUP
42
- }
43
-
44
- Document {
45
- sint8 token = BEGIN_DOCUMENT
46
- Pops props
47
- }
48
-
49
- Graph {
50
- sint8 token = BEGIN_GRAPH
51
- String format
52
- Args args
53
- GraphBody body
54
- }
55
-
56
- GraphBody {
57
- Props props
58
- sint32 nodes_count
59
- Node[nodes_count] nodes
60
- sint32 blocks_count
61
- Blocks[blocks_count] blocks
62
- }
63
-
64
- Node {
65
- sint32 id
66
- PoolObject node_class
67
- bool has_predecessor
68
- Pops props
69
- Edge[node_class.inputs.size] edges_in
70
- Edge[node_class.outputs.size] edges_out
71
- }
72
-
73
- Edge {
74
- sint32[inputs_count] nodes
75
- }
76
-
77
- Blocks {
78
- sint32 id
79
- sint32 nodes_count
80
- sint32[nodes_count] nodes
81
- sint32 followers_count
82
- sint32[followers_count] followers
83
- }
84
-
85
- Props {
86
- sint16 props_count
87
- Prop[props_count] props
88
- }
89
-
90
- Prop {
91
- PoolObject key
92
- PropObject value
93
- }
94
-
95
- PropObject {
96
- union {
97
- struct {
98
- sint8 PROPERTY_POOL
99
- PoolObject object
100
- }
101
- struct {
102
- sint8 PROPERTY_INT
103
- sint32 value
104
- }
105
- struct {
106
- sint8 PROPERTY_LONG
107
- sint64 value
108
- }
109
- struct {
110
- sint8 PROPERTY_DOUBLE
111
- float64 value
112
- }
113
- struct {
114
- sint8 PROPERTY_FLOAT
115
- float32 value
116
- }
117
- struct {
118
- sint8 PROPERTY_TRUE
119
- }
120
- struct {
121
- sint8 PROPERTY_FALSE
122
- }
123
- struct {
124
- sint8 PROPERTY_ARRAY
125
- union {
126
- struct {
127
- sint8 PROPERTY_POOL
128
- sint32 times
129
- PoolObject[times] values
130
- }
131
- }
132
- }
133
- struct {
134
- sint8 PROPERTY_SUBGRAPH
135
- GraphBody graph
136
- }
137
- }
138
- }
139
-
140
- PoolObject {
141
- union {
142
- POOL_NULL
143
- struct {
144
- sint8 token = POOL_NEW
145
- uint16 id
146
- union {
147
- struct {
148
- sint8 type = POOL_STRING
149
- String string
150
- }
151
- struct {
152
- sint8 type = POOL_ENUM
153
- PoolObject enum_class
154
- sint32 enum_ordinal
155
- }
156
- struct {
157
- sint8 type = POOL_CLASS
158
- String type_name
159
- union {
160
- struct {
161
- sint8 type = ENUM_KLASS
162
- sint32 values_count
163
- PoolObject values[values_count]
164
- }
165
- struct {
166
- sint8 type = KLASS
167
- }
168
- }
169
- }
170
- struct {
171
- sint8 type = POOL_METHOD
172
- PoolObject declaring_class
173
- PoolObject method_name
174
- PoolObject signature
175
- sint32 modifiers
176
- sint32 bytes_length
177
- uint8[bytes_length] bytes
178
- }
179
- struct {
180
- sint8 type = POOL_NODE_CLASS
181
- PoolObject node_class
182
- String name_template
183
- sint16 input_count
184
- InputEdgeInfo inputs[input_count]
185
- sint16 output_count
186
- OutputEdgeInfo outputs[output_count]
187
- }
188
- struct {
189
- sint8 type = POOL_FIELD
190
- PoolObject field_class
191
- PoolObject name
192
- PoolObject type_name
193
- sint32 modifiers
194
- }
195
- struct {
196
- sint8 type = POOL_NODE_SIGNATURE
197
- sint16 args_count
198
- PoolObject args[args_count]
199
- }
200
- struct {
201
- sint8 type = POOL_NODE_SOURCE_POSITION
202
- PoolObject method
203
- sint32 bci
204
- SourcePosition source_positions[...until SourcePosition.uri = null]
205
- PoolObject caller
206
- }
207
- struct {
208
- sint8 type = POOL_NODE
209
- sint32 node_id
210
- PoolObject node_class
211
- }
212
- }
213
- }
214
- struct {
215
- sint8 token = POOL_STRING | POOL_ENUM | POOL_CLASS | POOL_METHOD | POOL_NODE_CLASS | POOL_FIELD | POOL_SIGNATURE | POOL_NODE_SOURCE_POSITION | POOL_NODE
216
- uint16 pool_id
217
- }
218
- }
219
- }
220
-
221
- InputEdgeInfo {
222
- sint8 indirect
223
- PoolObject name
224
- PoolObject type
225
- }
226
-
227
- OutputEdgeInfo {
228
- sint8 indirect
229
- PoolObject name
230
- }
231
-
232
- SourcePosition {
233
- PoolObject uri
234
- String location
235
- sint32 line
236
- sint32 start
237
- sint32 end
238
- }
239
-
240
- String {
241
- sint32 length
242
- char[length] chars
243
- }
244
-
245
- BEGIN_GROUP = 0x00
246
- BEGIN_GRAPH = 0x01
247
- CLOSE_GROUP = 0x02
248
- BEGIN_DOCUMENT = 0x03
249
-
250
- POOL_NEW = 0x00
251
- POOL_STRING = 0x01
252
- POOL_ENUM = 0x02
253
- POOL_CLASS = 0x03
254
- POOL_METHOD = 0x04
255
- POOL_NULL = 0x05
256
- POOL_NODE_CLASS = 0x06
257
- POOL_FIELD = 0x07
258
- POOL_SIGNATURE = 0x08
259
- POOL_NODE_SOURCE_POSITION = 0x09
260
- POOL_NODE = 0x0a
261
-
262
- PROPERTY_POOL = 0x00
263
- PROPERTY_INT = 0x01
264
- PROPERTY_LONG = 0x02
265
- PROPERTY_DOUBLE = 0x03
266
- PROPERTY_FLOAT = 0x04
267
- PROPERTY_TRUE = 0x05
268
- PROPERTY_FALSE = 0x06
269
- PROPERTY_ARRAY = 0x07
270
- PROPERTY_SUBGRAPH = 0x08
271
-
272
- KLASS = 0x00
273
- ENUM_KLASS = 0x01
274
- ```
275
-
276
- ## Seeking
277
-
278
- The BGV format is not particularly amenable to seeking. You must read each prior
279
- graph in order to read any subsequent graph, the length of nodes and edges
280
- depends on values within them, and there is an object pool that is incrementally
281
- built.
282
-
283
- In order to 'seek' BGV files we have two code paths for reading the file, one
284
- with loads the data and one which loads as little as possible to know just how
285
- much further to advance in the file.
286
-
287
- ## Compression
288
-
289
- Seafoam supports compressed BGV files in the gzip file format.
290
-
291
- ## Other information
292
-
293
- `seafoam file.bgv debug` checks that a file can be parsed and prints information
294
- as it does so.
@@ -1,63 +0,0 @@
1
- # Getting Graphs
2
-
3
- ## GraalVM Compiler as a Java compiler
4
-
5
- `-Dgraal.Dump=:2` is a simple option to enable Graal graph dumping.
6
-
7
- The value of `Dump` is a *dump filter*. The format of dump filters is
8
- [documented][dump-filters], but in simple cases `:2` will be enough and will
9
- give you everything.
10
-
11
- [dump-filters]: https://github.com/oracle/graal/blob/master/compiler/src/org.graalvm.compiler.debug/src/org/graalvm/compiler/debug/doc-files/DumpHelp.txt
12
-
13
- You may want to combine with `-XX:CompileOnly=Foo::foo` (you can omit the class
14
- part) to restrict compilation to a single method to give smaller dumps, and to
15
- some extent make graphs simpler by avoiding what you want to look at being
16
- inlined, or other things being inlined into it.
17
-
18
- Graal tends to be quite aggressive about loop unrolling, which can produce
19
- massive graphs with the logic repeated. I often use these flags to simplify the
20
- graph without significantly effecting too much how the logic in it is compiled.
21
-
22
- ```
23
- -Dgraal.FullUnroll=false \
24
- -Dgraal.PartialUnroll=false \
25
- -Dgraal.LoopPeeling=false \
26
- -Dgraal.LoopUnswitch=false \
27
- -Dgraal.OptLoopTransform=false \
28
- -Dgraal.OptScheduleOutOfLoops=false \
29
- -Dgraal.VectorizeLoops=false
30
- ```
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
-
40
- ## TruffleRuby and other Truffle languages
41
-
42
- Use the same options as for GraalVM for Java, except they're prefixed with
43
- `--vm.`, for example `--vm.Dgraal.Dump=Truffle:2`.
44
-
45
- Use with `--engine.CompileOnly=foo`.
46
-
47
- A good filter to use for Truffle languages is `--vm.Dgraal.Dump=Truffle:1`,
48
- which will only give you Truffle compilations if you don't care about the
49
- whole Graal compilation pipeline.
50
-
51
- You may want to disable on-stack-replacement and inlining with
52
- `--engine.Inlining=false` and `--engine.OSR=false` in order to make graphs
53
- easier to understand.
54
-
55
- You may need to use `--experimental-options`.
56
-
57
- ## Getting basic blocks
58
-
59
- To get the graph when scheduled, so that you can see basic blocks, use `-Dgraal.PrintGraphWithSchedule=true`. Truffle graphs beyond the initial stages have scheduling information by default.
60
-
61
- ## Getting CFG files
62
-
63
- To also get CFG files, add `-Dgraal.PrintBackendCFG=true`, or `--vm.Dgraal.PrintBackendCFG=true` for Truffle.
data/docs/images/igv.png DELETED
Binary file
Binary file
Binary file
Binary file
data/docs/json.md DELETED
@@ -1,35 +0,0 @@
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.
data/examples/Fib.java DELETED
@@ -1,24 +0,0 @@
1
- /*
2
- * % javac Fib.java
3
- * % java -XX:CompileOnly=::fib -Dgraal.Dump=:2 -Dgraal.PrintGraphWithSchedule=true Fib 14
4
- */
5
-
6
- class Fib {
7
-
8
- public static void main(String[] args) {
9
- while (true) {
10
- for (String arg : args) {
11
- fib(Integer.parseInt(args[0]));
12
- }
13
- }
14
- }
15
-
16
- public static int fib(int n) {
17
- if (n <= 1) {
18
- return n;
19
- } else {
20
- return fib(n - 1) + fib(n - 2);
21
- }
22
- }
23
-
24
- }
@@ -1,39 +0,0 @@
1
- /*
2
- * % javac MatMult.java
3
- * % java -XX:CompileOnly=::matmult -Dgraal.Dump=:2 MatMult 100
4
- */
5
-
6
- class MatMult {
7
-
8
- public static void main(String[] args) {
9
- while (true) {
10
- for (String arg : args) {
11
- final int size = Integer.parseInt(args[0]);
12
- final double[][] a = new double[size][];
13
- final double[][] b = new double[size][];
14
- final double[][] c = new double[size][];
15
- for (int n = 0; n < size; n++) {
16
- a[n] = new double[size];
17
- b[n] = new double[size];
18
- c[n] = new double[size];
19
- for (int m = 0; m < size; m++) {
20
- a[n][m] = Math.random();
21
- b[n][m] = Math.random();
22
- }
23
- }
24
- matmult(size, a, b, c);
25
- }
26
- }
27
- }
28
-
29
- public static void matmult(int size, double[][] a, double[][] b, double[][] c) {
30
- for(int i = 0; i < size; i++) {
31
- for (int j = 0; j < size; j++) {
32
- for (int k = 0; k < size; k++) {
33
- c[i][j] += a[i][k] * b[k][j];
34
- }
35
- }
36
- }
37
- }
38
-
39
- }
Binary file
data/examples/fib.js DELETED
@@ -1,15 +0,0 @@
1
- // % node --experimental-options --engine.CompileOnly=fib --engine.Inlining=false --vm.Dgraal.Dump=Truffle:2 fib.js 14
2
-
3
- function fib(n) {
4
- if (n <= 1) {
5
- return n;
6
- } else {
7
- return fib(n - 1) + fib(n - 2);
8
- }
9
- }
10
-
11
- while (true) {
12
- for (let n = 2; n < process.argv.length; n++) {
13
- fib(parseInt(process.argv[n]));
14
- }
15
- }
data/examples/fib.rb DELETED
@@ -1,15 +0,0 @@
1
- # % ruby --experimental-options --engine.CompileOnly=fib --engine.Inlining=false --engine.OSR=false --vm.Dgraal.Dump=Truffle:2 fib.rb 14
2
-
3
- def fib(n)
4
- if n <= 1
5
- n
6
- else
7
- fib(n - 1) + fib(n - 2)
8
- end
9
- end
10
-
11
- loop do
12
- ARGV.each do |arg|
13
- fib(Integer(arg))
14
- end
15
- end
data/examples/identity.rb DELETED
@@ -1,13 +0,0 @@
1
- # % ruby --experimental-options --engine.CompileOnly=identity --engine.Inlining=false --engine.OSR=false --vm.Dgraal.Dump=Truffle:2 identity.rb 1 2 3
2
-
3
- # The purpose of this identity function is to learn what the Truffle prelude looks like.
4
-
5
- def identity(arg)
6
- arg
7
- end
8
-
9
- loop do
10
- ARGV.each do |arg|
11
- identity(Integer(arg))
12
- end
13
- end
Binary file
@@ -1,35 +0,0 @@
1
- ; https://github.com/Storyyeller/Krakatau
2
- ; Krakatau/assemble.py Irreducible.j
3
-
4
- .class public Irreducible
5
- .super java/lang/Object
6
- .field private static volatile intField I
7
-
8
- .method public static exampleIrreducible : (ZI)I
9
- .code stack 1 locals 3
10
-
11
- iload_1
12
- istore_2
13
- iload_0
14
- ifeq L_start_of_loop
15
-
16
- goto L_inside_loop
17
-
18
- L_start_of_loop:
19
- iload_2
20
- ifle L_end_of_loop
21
- iload_2
22
- putstatic Field Irreducible intField I
23
-
24
- L_inside_loop:
25
- iinc 2 -1
26
- goto L_start_of_loop
27
-
28
- L_end_of_loop:
29
- iload_1
30
- ireturn
31
-
32
- .end code
33
- .end method
34
-
35
- .end class