Skip to content

Commit

Permalink
Fix #3969: AddMissingInts: Rescue bbs shd. receive state from pred.in
Browse files Browse the repository at this point in the history
* This (conservatively) ensures that even if the very first instruction
  of the BB might raise an exception, the rescue block sees state from
  entry of the BB, rather than (optimistically) from the end of the BB
  which control might never reach.

* The conservative assumption also matches the JVM verifier's assumption
  and should ensure that generated bytecode passes the verifier

* Verified that the generated IR is correct on the following snippet.
--------
def foo
  saved = bar()
ensure
  bar(saved)
end
--------
subbuss committed Jun 15, 2016
1 parent fd4c8d3 commit f3f5776
Showing 1 changed file with 5 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -43,18 +43,20 @@ public void applyPreMeetHandler() {

@Override
public void compute_MEET(Edge e, DefinedVariableNode pred) {
BitSet predState = basicBlock.isRescueEntry() ? pred.in : pred.out;

// If pred.out is TOP, in doesn't change.
if (pred.out != null) {
if (predState != null) {
// if in is TOP, init in to a bitset with all 1's
// so the intersection computes the right value.
if (in == null) {
// Make sure 'in' and 'out' are the same size!
int n = pred.out.size();
int n = predState.size();
in = new BitSet(n);
in.set(0, n);
}

in.and(pred.out);
in.and(predState);
}
}

0 comments on commit f3f5776

Please sign in to comment.