seafoam 0.6 → 0.10
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/bgv/bgv_parser.rb +10 -2
- data/lib/seafoam/commands.rb +107 -32
- data/lib/seafoam/graal/pi.rb +18 -0
- data/lib/seafoam/graph.rb +33 -1
- data/lib/seafoam/graphviz_writer.rb +24 -2
- 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 +5 -4
- metadata +26 -62
- data/.github/probots.yml +0 -2
- data/.github/workflows/workflows.yml +0 -39
- data/.gitignore +0 -7
- 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/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 -293
- data/docs/getting-graphs.md +0 -59
- 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 -21
- 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 -157
- 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 -316
- 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,157 +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 alternate skipping and reading full files' do
|
56
|
-
Seafoam::SpecHelpers::SAMPLE_BGV.each do |file|
|
57
|
-
parser = Seafoam::BGV::BGVParser.new(file)
|
58
|
-
parser.read_file_header
|
59
|
-
parser.skip_document_props
|
60
|
-
skip = false
|
61
|
-
loop do
|
62
|
-
index, = parser.read_graph_preheader
|
63
|
-
break unless index
|
64
|
-
|
65
|
-
if skip
|
66
|
-
parser.skip_graph_header
|
67
|
-
parser.skip_graph
|
68
|
-
else
|
69
|
-
parser.read_graph_header
|
70
|
-
parser.read_graph
|
71
|
-
end
|
72
|
-
skip = !skip
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
describe '#read_file_header' do
|
78
|
-
it 'produces a version' do
|
79
|
-
parser = Seafoam::BGV::BGVParser.new(@fib_java_bgv)
|
80
|
-
expect(parser.read_file_header).to eq [7, 0]
|
81
|
-
end
|
82
|
-
|
83
|
-
it 'raises an error for files which are not BGV' do
|
84
|
-
parser = Seafoam::BGV::BGVParser.new(File.expand_path('fixtures/not.bgv', __dir__))
|
85
|
-
expect { parser.read_file_header }.to raise_error(EncodingError)
|
86
|
-
end
|
87
|
-
|
88
|
-
it 'raises an error for files which are an unsupported version of BGV' do
|
89
|
-
parser = Seafoam::BGV::BGVParser.new(File.expand_path('fixtures/unsupported.bgv', __dir__))
|
90
|
-
expect { parser.read_file_header }.to raise_error(NotImplementedError)
|
91
|
-
end
|
92
|
-
|
93
|
-
it 'does not raise an error for an unsupported version of BGV if version_check is disabled' do
|
94
|
-
parser = Seafoam::BGV::BGVParser.new(File.expand_path('fixtures/unsupported.bgv', __dir__))
|
95
|
-
expect(parser.read_file_header(version_check: false)).to eq [7, 2]
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
describe '#read_graph_preheader' do
|
100
|
-
it 'produces an index and id' do
|
101
|
-
parser = Seafoam::BGV::BGVParser.new(@fib_java_bgv)
|
102
|
-
parser.read_file_header
|
103
|
-
parser.skip_document_props
|
104
|
-
expect(parser.read_graph_preheader).to eq [0, 0]
|
105
|
-
end
|
106
|
-
|
107
|
-
it 'returns nil for end of file' do
|
108
|
-
parser = Seafoam::BGV::BGVParser.new(@fib_java_bgv)
|
109
|
-
parser.read_file_header
|
110
|
-
parser.skip_document_props
|
111
|
-
54.times do
|
112
|
-
expect(parser.read_graph_preheader).to_not be_nil
|
113
|
-
parser.skip_graph_header
|
114
|
-
parser.skip_graph
|
115
|
-
end
|
116
|
-
expect(parser.read_graph_preheader).to be_nil
|
117
|
-
end
|
118
|
-
|
119
|
-
it 'returns unique indicies' do
|
120
|
-
parser = Seafoam::BGV::BGVParser.new(@fib_java_bgv)
|
121
|
-
parser.read_file_header
|
122
|
-
parser.skip_document_props
|
123
|
-
indicies = []
|
124
|
-
5.times do
|
125
|
-
index, = parser.read_graph_preheader
|
126
|
-
expect(indicies).to_not include index
|
127
|
-
indicies.push index
|
128
|
-
parser.skip_graph_header
|
129
|
-
parser.skip_graph
|
130
|
-
end
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
describe '#read_graph_header' do
|
135
|
-
it 'produces an expected header' do
|
136
|
-
parser = Seafoam::BGV::BGVParser.new(@fib_java_bgv)
|
137
|
-
parser.read_file_header
|
138
|
-
parser.skip_document_props
|
139
|
-
parser.read_graph_preheader
|
140
|
-
header = parser.read_graph_header
|
141
|
-
expect(header[:props]['scope']).to eq 'main.Compiling.GraalCompiler.FrontEnd.PhaseSuite.GraphBuilderPhase'
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
|
-
describe '#read_graph' do
|
146
|
-
it 'produces an expected graph' do
|
147
|
-
parser = Seafoam::BGV::BGVParser.new(@fib_java_bgv)
|
148
|
-
parser.read_file_header
|
149
|
-
parser.skip_document_props
|
150
|
-
parser.read_graph_preheader
|
151
|
-
parser.read_graph_header
|
152
|
-
graph = parser.read_graph
|
153
|
-
expect(graph.nodes.size).to eq 22
|
154
|
-
expect(graph.edges.size).to eq 30
|
155
|
-
end
|
156
|
-
end
|
157
|
-
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
|