@@ -38,19 +38,19 @@ def self.compile(cfg)
38
38
# blocks.
39
39
block_flows = { }
40
40
cfg . blocks . each do |block |
41
- block_flows [ block . block_start ] = DataFlow . new
41
+ block_flows [ block . id ] = DataFlow . new
42
42
end
43
43
44
44
# Now, discover the data flow within each basic block. Using an abstract
45
45
# stack, connect from consumers of data to the producers of that data.
46
46
cfg . blocks . each do |block |
47
- block_flow = block_flows . fetch ( block . block_start )
47
+ block_flow = block_flows . fetch ( block . id )
48
48
49
49
stack = [ ]
50
50
stack_initial_depth = 0
51
51
52
52
# Go through each instruction in the block...
53
- block . insns . each . with_index ( block . block_start ) do |insn , index |
53
+ block . each_with_index do |insn , index |
54
54
insn_flow = insn_flows [ index ]
55
55
56
56
# How many values will be missing from the local stack to run this
@@ -107,9 +107,9 @@ def self.compile(cfg)
107
107
stack = [ *cfg . blocks ]
108
108
until stack . empty?
109
109
succ = stack . pop
110
- succ_flow = block_flows . fetch ( succ . block_start )
110
+ succ_flow = block_flows . fetch ( succ . id )
111
111
succ . predecessors . each do |pred |
112
- pred_flow = block_flows . fetch ( pred . block_start )
112
+ pred_flow = block_flows . fetch ( pred . id )
113
113
114
114
# Does a predecessor block have fewer outputs than the successor
115
115
# has inputs?
@@ -132,20 +132,20 @@ def self.compile(cfg)
132
132
133
133
# Verify that we constructed the data flow graph correctly. Check that
134
134
# the first block has no arguments.
135
- raise unless block_flows . fetch ( cfg . blocks . first . block_start ) . in . empty?
135
+ raise unless block_flows . fetch ( cfg . blocks . first . id ) . in . empty?
136
136
137
137
# Check all control flow edges between blocks pass the right number of
138
138
# arguments.
139
139
cfg . blocks . each do |pred |
140
- pred_flow = block_flows . fetch ( pred . block_start )
140
+ pred_flow = block_flows . fetch ( pred . id )
141
141
142
142
if pred . successors . empty?
143
143
# With no successors, there should be no output arguments.
144
144
raise unless pred_flow . out . empty?
145
145
else
146
146
# Check with successor...
147
147
pred . successors . each do |succ |
148
- succ_flow = block_flows . fetch ( succ . block_start )
148
+ succ_flow = block_flows . fetch ( succ . id )
149
149
150
150
# The predecessor should have as many output arguments as the
151
151
# success has input arguments.
@@ -170,12 +170,12 @@ def disasm
170
170
end
171
171
output . puts
172
172
173
- block_flow = block_flows . fetch ( block . block_start )
173
+ block_flow = block_flows . fetch ( block . id )
174
174
unless block_flow . in . empty?
175
175
output . puts " # in: #{ block_flow . in . join ( ", " ) } "
176
176
end
177
177
178
- block . insns . each . with_index ( block . block_start ) do |insn , index |
178
+ block . each_with_index do |insn , index |
179
179
output . print ( " " )
180
180
output . print ( insn . disasm ( fmt ) )
181
181
0 commit comments