Skip to content

Commit 252f805

Browse files
committed
performance improvement
1 parent 21e5a52 commit 252f805

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

javascript/ql/src/semmle/javascript/GlobalAccessPaths.qll

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,7 @@ module AccessPath {
421421
}
422422

423423
/**
424-
* A module for reasoning dominating reads and writes to access-paths.
424+
* A module for reasoning dominating reads and writes to access-paths.
425425
*/
426426
module DominatingPaths {
427427
/**
@@ -463,15 +463,14 @@ module AccessPath {
463463
(path = fromRhs(result, root) or result = root.getAPropertyWrite(path)) and
464464
type = AccessPathWrite()
465465
}
466-
466+
467467
/**
468-
* Gets a basicblock that is domminated by a assignment to an access-path identified by `root` and `path`.
468+
* Gets a basic-block where the access path defined by `root` and `path` is written to.
469+
* And a read to the same access path exists.
469470
*/
470-
private ReachableBasicBlock getADominatedBlock(Root root, string path) {
471-
getAccessTo(root, path, AccessPathWrite())
472-
.getBasicBlock()
473-
.(ReachableBasicBlock)
474-
.strictlyDominates(result)
471+
private ReachableBasicBlock getAWriteBlock(Root root, string path) {
472+
result = getAccessTo(root, path, AccessPathWrite()).getBasicBlock() and
473+
exists(getAccessTo(root, path, AccessPathRead())) // helps performance
475474
}
476475

477476
/**
@@ -490,7 +489,7 @@ module AccessPath {
490489
// across basic blocks.
491490
exists(Root root, string path |
492491
read = getAccessTo(root, path, AccessPathRead()) and
493-
read.getBasicBlock() = getADominatedBlock(root, path)
492+
getAWriteBlock(root, path).strictlyDominates(read.getBasicBlock())
494493
)
495494
}
496495
}

0 commit comments

Comments
 (0)