seafoam 0.8 → 0.9
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/cfg2asm +1 -5
- data/bin/seafoam +1 -5
- data/lib/seafoam/commands.rb +48 -31
- data/lib/seafoam/graal/pi.rb +18 -0
- 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 -13
- 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 +5 -4
- metadata +23 -60
- 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/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/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,167 +0,0 @@
|
|
1
|
-
require 'seafoam'
|
2
|
-
|
3
|
-
require 'rspec'
|
4
|
-
|
5
|
-
require_relative '../spec_helpers'
|
6
|
-
|
7
|
-
describe Seafoam::BGV::BGVParser do
|
8
|
-
before :all do
|
9
|
-
@fib_java_bgv = File.expand_path('../../../examples/fib-java.bgv', __dir__)
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'can read full files' do
|
13
|
-
Seafoam::SpecHelpers::SAMPLE_BGV.each do |file|
|
14
|
-
parser = Seafoam::BGV::BGVParser.new(file)
|
15
|
-
parser.read_file_header
|
16
|
-
parser.skip_document_props
|
17
|
-
loop do
|
18
|
-
index, = parser.read_graph_preheader
|
19
|
-
break unless index
|
20
|
-
|
21
|
-
parser.read_graph_header
|
22
|
-
parser.read_graph
|
23
|
-
end
|
24
|
-
end
|
25
|
-
end
|
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
|
-
|
40
|
-
it 'can skip full files' do
|
41
|
-
Seafoam::SpecHelpers::SAMPLE_BGV.each do |file|
|
42
|
-
parser = Seafoam::BGV::BGVParser.new(file)
|
43
|
-
parser.read_file_header
|
44
|
-
parser.skip_document_props
|
45
|
-
loop do
|
46
|
-
index, = parser.read_graph_preheader
|
47
|
-
break unless index
|
48
|
-
|
49
|
-
parser.skip_graph_header
|
50
|
-
parser.skip_graph
|
51
|
-
end
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'can read basic blocks' do
|
56
|
-
parser = Seafoam::BGV::BGVParser.new(File.expand_path('../../../examples/fib-java.bgv', __dir__))
|
57
|
-
parser.read_file_header
|
58
|
-
parser.skip_document_props
|
59
|
-
parser.read_graph_preheader
|
60
|
-
parser.skip_graph_header
|
61
|
-
graph = parser.read_graph
|
62
|
-
expect(graph.blocks.size).to eq 3
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'can alternate skipping and reading full files' do
|
66
|
-
Seafoam::SpecHelpers::SAMPLE_BGV.each do |file|
|
67
|
-
parser = Seafoam::BGV::BGVParser.new(file)
|
68
|
-
parser.read_file_header
|
69
|
-
parser.skip_document_props
|
70
|
-
skip = false
|
71
|
-
loop do
|
72
|
-
index, = parser.read_graph_preheader
|
73
|
-
break unless index
|
74
|
-
|
75
|
-
if skip
|
76
|
-
parser.skip_graph_header
|
77
|
-
parser.skip_graph
|
78
|
-
else
|
79
|
-
parser.read_graph_header
|
80
|
-
parser.read_graph
|
81
|
-
end
|
82
|
-
skip = !skip
|
83
|
-
end
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
describe '#read_file_header' do
|
88
|
-
it 'produces a version' do
|
89
|
-
parser = Seafoam::BGV::BGVParser.new(@fib_java_bgv)
|
90
|
-
expect(parser.read_file_header).to eq [7, 0]
|
91
|
-
end
|
92
|
-
|
93
|
-
it 'raises an error for files which are not BGV' do
|
94
|
-
parser = Seafoam::BGV::BGVParser.new(File.expand_path('fixtures/not.bgv', __dir__))
|
95
|
-
expect { parser.read_file_header }.to raise_error(EncodingError)
|
96
|
-
end
|
97
|
-
|
98
|
-
it 'raises an error for files which are an unsupported version of BGV' do
|
99
|
-
parser = Seafoam::BGV::BGVParser.new(File.expand_path('fixtures/unsupported.bgv', __dir__))
|
100
|
-
expect { parser.read_file_header }.to raise_error(NotImplementedError)
|
101
|
-
end
|
102
|
-
|
103
|
-
it 'does not raise an error for an unsupported version of BGV if version_check is disabled' do
|
104
|
-
parser = Seafoam::BGV::BGVParser.new(File.expand_path('fixtures/unsupported.bgv', __dir__))
|
105
|
-
expect(parser.read_file_header(version_check: false)).to eq [7, 2]
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
describe '#read_graph_preheader' do
|
110
|
-
it 'produces an index and id' do
|
111
|
-
parser = Seafoam::BGV::BGVParser.new(@fib_java_bgv)
|
112
|
-
parser.read_file_header
|
113
|
-
parser.skip_document_props
|
114
|
-
expect(parser.read_graph_preheader).to eq [0, 0]
|
115
|
-
end
|
116
|
-
|
117
|
-
it 'returns nil for end of file' do
|
118
|
-
parser = Seafoam::BGV::BGVParser.new(@fib_java_bgv)
|
119
|
-
parser.read_file_header
|
120
|
-
parser.skip_document_props
|
121
|
-
56.times do
|
122
|
-
expect(parser.read_graph_preheader).to_not be_nil
|
123
|
-
parser.skip_graph_header
|
124
|
-
parser.skip_graph
|
125
|
-
end
|
126
|
-
expect(parser.read_graph_preheader).to be_nil
|
127
|
-
end
|
128
|
-
|
129
|
-
it 'returns unique indicies' do
|
130
|
-
parser = Seafoam::BGV::BGVParser.new(@fib_java_bgv)
|
131
|
-
parser.read_file_header
|
132
|
-
parser.skip_document_props
|
133
|
-
indicies = []
|
134
|
-
5.times do
|
135
|
-
index, = parser.read_graph_preheader
|
136
|
-
expect(indicies).to_not include index
|
137
|
-
indicies.push index
|
138
|
-
parser.skip_graph_header
|
139
|
-
parser.skip_graph
|
140
|
-
end
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
|
-
describe '#read_graph_header' do
|
145
|
-
it 'produces an expected header' do
|
146
|
-
parser = Seafoam::BGV::BGVParser.new(@fib_java_bgv)
|
147
|
-
parser.read_file_header
|
148
|
-
parser.skip_document_props
|
149
|
-
parser.read_graph_preheader
|
150
|
-
header = parser.read_graph_header
|
151
|
-
expect(header[:props]['scope']).to eq 'main.Compiling.GraalCompiler.FrontEnd.PhaseSuite.GraphBuilderPhase'
|
152
|
-
end
|
153
|
-
end
|
154
|
-
|
155
|
-
describe '#read_graph' do
|
156
|
-
it 'produces an expected graph' do
|
157
|
-
parser = Seafoam::BGV::BGVParser.new(@fib_java_bgv)
|
158
|
-
parser.read_file_header
|
159
|
-
parser.skip_document_props
|
160
|
-
parser.read_graph_preheader
|
161
|
-
parser.read_graph_header
|
162
|
-
graph = parser.read_graph
|
163
|
-
expect(graph.nodes.size).to eq 21
|
164
|
-
expect(graph.edges.size).to eq 30
|
165
|
-
end
|
166
|
-
end
|
167
|
-
end
|
@@ -1,176 +0,0 @@
|
|
1
|
-
require 'stringio'
|
2
|
-
|
3
|
-
require 'seafoam'
|
4
|
-
|
5
|
-
require 'rspec'
|
6
|
-
|
7
|
-
describe Seafoam::Binary::IOBinaryReader do
|
8
|
-
describe '#read_utf8' do
|
9
|
-
it 'reads a UTF-8 string' do
|
10
|
-
string = 'abc😀'
|
11
|
-
reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new(string))
|
12
|
-
expect(reader.read_utf8(string.bytesize)).to eq string
|
13
|
-
end
|
14
|
-
end
|
15
|
-
|
16
|
-
describe '#read_bytes' do
|
17
|
-
it 'reads bytes' do
|
18
|
-
string = 'abc😀'
|
19
|
-
reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new(string))
|
20
|
-
expect(reader.read_bytes(string.bytesize)).to eq "abc\xF0\x9F\x98\x80".force_encoding(Encoding::ASCII_8BIT)
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe '#read_float64' do
|
25
|
-
it 'reads a double-precision float' do
|
26
|
-
reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new("#{[1.5].pack('G')}hello"))
|
27
|
-
expect(reader.read_float64).to eq 1.5
|
28
|
-
end
|
29
|
-
end
|
30
|
-
|
31
|
-
describe '#read_float32' do
|
32
|
-
it 'reads a single-precision float' do
|
33
|
-
reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new("#{[1.5].pack('g')}hello"))
|
34
|
-
expect(reader.read_float32).to eq 1.5
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
describe '#read_sint64' do
|
39
|
-
it 'reads a signed 64-bit network-endian integer' do
|
40
|
-
reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new("#{[1234].pack('q>')}hello"))
|
41
|
-
expect(reader.read_sint64).to eq 1234
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
describe '#read_sint32' do
|
46
|
-
it 'reads a signed 32-bit network-endian integer' do
|
47
|
-
reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new("#{[1234].pack('l>')}hello"))
|
48
|
-
expect(reader.read_sint32).to eq 1234
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
describe '#read_sint16' do
|
53
|
-
it 'reads a signed 16-bit network-endian integer' do
|
54
|
-
reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new("#{[1234].pack('s>')}hello"))
|
55
|
-
expect(reader.read_sint16).to eq 1234
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
describe '#read_sint8' do
|
60
|
-
it 'reads a signed 8-bit integer' do
|
61
|
-
reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new("#{[-123].pack('c')}hello"))
|
62
|
-
expect(reader.read_sint8).to eq(-123)
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
describe '#read_uint8' do
|
67
|
-
it 'reads an unsigned 8-bit integer' do
|
68
|
-
reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new("#{[212].pack('C')}hello"))
|
69
|
-
expect(reader.read_uint8).to eq 212
|
70
|
-
end
|
71
|
-
end
|
72
|
-
|
73
|
-
describe '#skip_float64' do
|
74
|
-
it 'skips 8 bytes' do
|
75
|
-
reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new('12345678x'))
|
76
|
-
reader.skip_float64
|
77
|
-
expect(reader.read_uint8).to eq 'x'.ord
|
78
|
-
end
|
79
|
-
|
80
|
-
it 'accepts a count' do
|
81
|
-
reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new('1234567812345678x'))
|
82
|
-
reader.skip_float64 2
|
83
|
-
expect(reader.read_uint8).to eq 'x'.ord
|
84
|
-
end
|
85
|
-
end
|
86
|
-
|
87
|
-
describe '#skip_float32' do
|
88
|
-
it 'skips 4 bytes' do
|
89
|
-
reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new('1234x'))
|
90
|
-
reader.skip_float32
|
91
|
-
expect(reader.read_uint8).to eq 'x'.ord
|
92
|
-
end
|
93
|
-
|
94
|
-
it 'accepts a count' do
|
95
|
-
reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new('12341234x'))
|
96
|
-
reader.skip_float32 2
|
97
|
-
expect(reader.read_uint8).to eq 'x'.ord
|
98
|
-
end
|
99
|
-
|
100
|
-
describe '#skip_int64' do
|
101
|
-
it 'skips 8 bytes' do
|
102
|
-
reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new('12345678x'))
|
103
|
-
reader.skip_int64
|
104
|
-
expect(reader.read_uint8).to eq 'x'.ord
|
105
|
-
end
|
106
|
-
|
107
|
-
it 'accepts a count' do
|
108
|
-
reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new('1234567812345678x'))
|
109
|
-
reader.skip_int64 2
|
110
|
-
expect(reader.read_uint8).to eq 'x'.ord
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
describe '#skip_int32' do
|
115
|
-
it 'skips 4 bytes' do
|
116
|
-
reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new('1234x'))
|
117
|
-
reader.skip_int32
|
118
|
-
expect(reader.read_uint8).to eq 'x'.ord
|
119
|
-
end
|
120
|
-
|
121
|
-
it 'accepts a count' do
|
122
|
-
reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new('12341234x'))
|
123
|
-
reader.skip_int32 2
|
124
|
-
expect(reader.read_uint8).to eq 'x'.ord
|
125
|
-
end
|
126
|
-
end
|
127
|
-
|
128
|
-
describe '#skip_int16' do
|
129
|
-
it 'skips 2 bytes' do
|
130
|
-
reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new('12x'))
|
131
|
-
reader.skip_int16
|
132
|
-
expect(reader.read_uint8).to eq 'x'.ord
|
133
|
-
end
|
134
|
-
|
135
|
-
it 'accepts a count' do
|
136
|
-
reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new('1212x'))
|
137
|
-
reader.skip_int16 2
|
138
|
-
expect(reader.read_uint8).to eq 'x'.ord
|
139
|
-
end
|
140
|
-
end
|
141
|
-
|
142
|
-
describe '#skip_int8' do
|
143
|
-
it 'skips 1 byte' do
|
144
|
-
reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new('1x'))
|
145
|
-
reader.skip_int8
|
146
|
-
expect(reader.read_uint8).to eq 'x'.ord
|
147
|
-
end
|
148
|
-
|
149
|
-
it 'accepts a count' do
|
150
|
-
reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new('11x'))
|
151
|
-
reader.skip_int8 2
|
152
|
-
expect(reader.read_uint8).to eq 'x'.ord
|
153
|
-
end
|
154
|
-
end
|
155
|
-
|
156
|
-
describe '#skip' do
|
157
|
-
it 'skips n bytes' do
|
158
|
-
reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new('123x'))
|
159
|
-
reader.skip 3
|
160
|
-
expect(reader.read_uint8).to eq 'x'.ord
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
describe '#eof?' do
|
165
|
-
it 'returns false when not at the end of file' do
|
166
|
-
reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new('123'))
|
167
|
-
expect(reader.eof?).to be false
|
168
|
-
end
|
169
|
-
|
170
|
-
it 'returns true when at the end of file' do
|
171
|
-
reader = Seafoam::Binary::IOBinaryReader.new(StringIO.new(''))
|
172
|
-
expect(reader.eof?).to be true
|
173
|
-
end
|
174
|
-
end
|
175
|
-
end
|
176
|
-
end
|
@@ -1,21 +0,0 @@
|
|
1
|
-
require 'seafoam'
|
2
|
-
|
3
|
-
require 'rspec'
|
4
|
-
|
5
|
-
require_relative '../spec_helpers'
|
6
|
-
|
7
|
-
describe Seafoam::CFG::CFGParser do
|
8
|
-
before :all do
|
9
|
-
@example_cfg = File.expand_path('../../../examples/java/exampleIf.cfg', __dir__)
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'correctly parses information from an nmethod' do
|
13
|
-
parser = Seafoam::CFG::CFGParser.new($stdout, @example_cfg)
|
14
|
-
parser.skip_over_cfg 'After code installation'
|
15
|
-
nmethod = parser.read_nmethod
|
16
|
-
expect(nmethod.code.arch).to eq 'AMD64'
|
17
|
-
expect(nmethod.code.arch_width).to eq '64'
|
18
|
-
expect(nmethod.code.base).to eq 0x1183037a0
|
19
|
-
expect(nmethod.comments.size).to eq 25
|
20
|
-
end
|
21
|
-
end
|
@@ -1,32 +0,0 @@
|
|
1
|
-
require 'seafoam'
|
2
|
-
|
3
|
-
require 'rspec'
|
4
|
-
|
5
|
-
require_relative '../spec_helpers'
|
6
|
-
|
7
|
-
describe Seafoam::CFG::Disassembler do
|
8
|
-
if Seafoam::SpecHelpers.dependencies_installed?
|
9
|
-
it 'can start Capstone Disassembler disassemble an nmethod with and without comments' do
|
10
|
-
@example_cfg = File.expand_path('../../../examples/java/exampleIf.cfg', __dir__)
|
11
|
-
@file = File.open('tempfile_disassembler_spec.txt', 'w')
|
12
|
-
parser = Seafoam::CFG::CFGParser.new(@file, @example_cfg)
|
13
|
-
parser.skip_over_cfg 'After code installation'
|
14
|
-
@nmethod = parser.read_nmethod
|
15
|
-
|
16
|
-
disassembler = Seafoam::CFG::Disassembler.new(@file)
|
17
|
-
disassembler.disassemble(@nmethod, 0)
|
18
|
-
@file.close
|
19
|
-
|
20
|
-
expect(`wc -l 'tempfile_disassembler_spec.txt'`.to_i).to eq 46
|
21
|
-
|
22
|
-
@file = File.open('tempfile_disassembler_spec.txt', 'w')
|
23
|
-
disassembler = Seafoam::CFG::Disassembler.new(@file)
|
24
|
-
disassembler.disassemble(@nmethod, 2)
|
25
|
-
@file.close
|
26
|
-
|
27
|
-
expect(`wc -l 'tempfile_disassembler_spec.txt'`.to_i).to eq 46
|
28
|
-
|
29
|
-
File.delete(@file)
|
30
|
-
end
|
31
|
-
end
|
32
|
-
end
|