JavaScript: Pull out auxiliary predicates to improve join order in liveAfterDef.

This commit is contained in:
Max Schaefer
2018-10-11 09:26:45 +01:00
parent 59bbd025a5
commit 09ef1a719a

View File

@@ -224,6 +224,13 @@ private cached module Internal {
ref(bb, i, v, tp)
}
/**
* Gets the maximum rank among all references to `v` in basic block `bb`.
*/
private int maxRefRank(ReachableBasicBlock bb, SsaSourceVariable v) {
result = max(refRank(bb, _, v, _))
}
/**
* Holds if variable `v` is live after the `i`th node of basic block `bb`, where
* `i` is the index of a node that may assign or capture `v`.
@@ -238,8 +245,8 @@ private cached module Internal {
or
// this is the last reference to `v` inside `bb`, but `v` is live at entry
// to a successor basic block of `bb`
r = max(refRank(bb, _, v, _)) and
liveAtEntry(bb.getASuccessor(), v)
r = maxRefRank(bb, v) and
liveAtSuccEntry(bb, v)
)
}
@@ -256,6 +263,13 @@ private cached module Internal {
// there is no reference to `v` inside `bb`, but `v` is live at entry
// to a successor basic block of `bb`
not exists(refRank(bb, _, v, _)) and
liveAtSuccEntry(bb, v)
}
/**
* Holds if `v` is live at the beginning of any successor of basic block `bb`.
*/
private predicate liveAtSuccEntry(ReachableBasicBlock bb, SsaSourceVariable v) {
liveAtEntry(bb.getASuccessor(), v)
}