Skip to content

Commit c5ae8d2

Browse files
authored
Merge pull request github#5210 from erik-krogh/barrierPerf
Approved by asgerf
2 parents b1bed27 + 814b557 commit c5ae8d2

File tree

1 file changed

+13
-4
lines changed

1 file changed

+13
-4
lines changed

javascript/ql/src/semmle/javascript/dataflow/Configuration.qll

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -474,20 +474,29 @@ pragma[nomagic]
474474
private predicate barrierGuardBlocksEdge(
475475
BarrierGuardNode guard, DataFlow::Node pred, DataFlow::Node succ, string label
476476
) {
477-
barrierGuardIsRelevant(guard) and
478477
exists(
479478
SsaVariable input, SsaPhiNode phi, BasicBlock bb, ConditionGuardNode cond, boolean outcome
480479
|
480+
bb = getADominatedBasicBlock(guard, cond) and
481481
pred = DataFlow::ssaDefinitionNode(input) and
482482
succ = DataFlow::ssaDefinitionNode(phi) and
483483
input = phi.getInputFromBlock(bb) and
484-
guard.getEnclosingExpr() = cond.getTest() and
485484
outcome = cond.getOutcome() and
486-
barrierGuardBlocksExpr(guard, outcome, input.getAUse(), label) and
487-
cond.dominates(bb)
485+
barrierGuardBlocksExpr(guard, outcome, input.getAUse(), label)
488486
)
489487
}
490488

489+
/**
490+
* Gets a basicblock that is dominated by `cond`, where the test for `cond` cond is `guard`.
491+
*
492+
* This predicate exists to get a better join-order for the `barrierGuardBlocksEdge` predicate above.
493+
*/
494+
private BasicBlock getADominatedBasicBlock(BarrierGuardNode guard, ConditionGuardNode cond) {
495+
barrierGuardIsRelevant(guard) and
496+
guard.getEnclosingExpr() = cond.getTest() and
497+
cond.dominates(result)
498+
}
499+
491500
/**
492501
* Holds if there is a barrier edge `pred -> succ` in `cfg` either through an explicit barrier edge
493502
* or one implied by a barrier guard.

0 commit comments

Comments
 (0)