Skip to content

Commit b43891a

Browse files
committed
JS: Improve performance of DominatingPaths::hasDominatingWrite
Check that the read node is in a *reachable* basic block before looking for a dominating write block.
1 parent 0eaba2b commit b43891a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

javascript/ql/lib/semmle/javascript/GlobalAccessPaths.qll

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -565,9 +565,12 @@ module AccessPath {
565565
)
566566
or
567567
// across basic blocks.
568-
exists(Root root, string path |
568+
exists(Root root, string path, ReachableBasicBlock readBlock |
569569
read.asExpr() = getAccessTo(root, path, AccessPathRead()) and
570-
getAWriteBlock(root, path).strictlyDominates(read.getBasicBlock())
570+
readBlock = read.getBasicBlock() and
571+
// Performance optimisation: check that `read` is in a *reachable* basic block
572+
// before looking for a dominating write block.
573+
getAWriteBlock(root, path).strictlyDominates(pragma[only_bind_out](readBlock))
571574
)
572575
}
573576
}

0 commit comments

Comments
 (0)