Skip to content

Commit ae62fbc

Browse files
authored
Merge pull request github#5382 from erik-krogh/moreCache
Approved by asgerf
2 parents b37da7c + 3005439 commit ae62fbc

File tree

5 files changed

+18
-2
lines changed

5 files changed

+18
-2
lines changed

javascript/ql/src/semmle/javascript/BasicBlocks.qll

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,8 @@ private predicate bbIPostDominates(BasicBlock dom, BasicBlock bb) =
119119
* At the database level, a basic block is represented by its first control flow node.
120120
*/
121121
class BasicBlock extends @cfg_node, NodeInStmtContainer {
122-
BasicBlock() { startsBB(this) }
122+
cached
123+
BasicBlock() { Stages::BasicBlocks::ref() and startsBB(this) }
123124

124125
/** Gets a basic block succeeding this one. */
125126
BasicBlock getASuccessor() { succBB(this, result) }

javascript/ql/src/semmle/javascript/SSA.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -627,6 +627,7 @@ abstract class SsaPseudoDefinition extends SsaImplicitDefinition {
627627
/**
628628
* Gets an input of this pseudo-definition.
629629
*/
630+
cached
630631
abstract SsaVariable getAnInput();
631632

632633
override VarDef getAContributingVarDef() {
@@ -649,6 +650,7 @@ class SsaPhiNode extends SsaPseudoDefinition, TPhi {
649650
/**
650651
* Gets the input to this phi node coming from the given predecessor block.
651652
*/
653+
cached
652654
SsaVariable getInputFromBlock(BasicBlock bb) {
653655
bb = getBasicBlock().getAPredecessor() and
654656
result = getDefReachingEndOf(bb, getSourceVariable())

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,7 @@ module DataFlow {
149149
* For more information, see
150150
* [Locations](https://help.semmle.com/QL/learn-ql/ql/locations.html).
151151
*/
152+
cached
152153
predicate hasLocationInfo(
153154
string filepath, int startline, int startcolumn, int endline, int endcolumn
154155
) {
@@ -171,6 +172,7 @@ module DataFlow {
171172
int getEndColumn() { hasLocationInfo(_, _, _, _, result) }
172173

173174
/** Gets a textual representation of this element. */
175+
cached
174176
string toString() { none() }
175177

176178
/**
@@ -294,12 +296,13 @@ module DataFlow {
294296
override predicate hasLocationInfo(
295297
string filepath, int startline, int startcolumn, int endline, int endcolumn
296298
) {
299+
Stages::DataFlowStage::ref() and
297300
astNode.getLocation().hasLocationInfo(filepath, startline, startcolumn, endline, endcolumn)
298301
}
299302

300303
override File getFile() { result = astNode.getFile() }
301304

302-
override string toString() { result = astNode.toString() }
305+
override string toString() { Stages::DataFlowStage::ref() and result = astNode.toString() }
303306
}
304307

305308
/**

javascript/ql/src/semmle/javascript/dataflow/internal/AccessPaths.qll

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
*/
1717

1818
import javascript
19+
private import semmle.javascript.internal.CachedStages
1920

2021
/**
2122
* A representation of a property name that is either statically known or is
@@ -88,7 +89,9 @@ class AccessPath extends TAccessPath {
8889
/**
8990
* Gets an expression in `bb` represented by this access path.
9091
*/
92+
cached
9193
Expr getAnInstanceIn(BasicBlock bb) {
94+
Stages::DataFlowStage::ref() and
9295
exists(SsaVariable var |
9396
this = MkSsaRoot(var) and
9497
result = getARefinementOf*(var).getAUseIn(bb)

javascript/ql/src/semmle/javascript/internal/CachedStages.qll

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import javascript
2424
private import StmtContainers
2525
private import semmle.javascript.dataflow.internal.PreCallGraphStep
2626
private import semmle.javascript.dataflow.internal.FlowSteps
27+
private import semmle.javascript.dataflow.internal.AccessPaths
2728

2829
/**
2930
* Contains a `cached module` for each stage.
@@ -126,6 +127,12 @@ module Stages {
126127
exists(any(Expr e).getExceptionTarget())
127128
or
128129
exists(DataFlow::ssaDefinitionNode(_))
130+
or
131+
any(DataFlow::Node node).hasLocationInfo(_, _, _, _, _)
132+
or
133+
exists(any(DataFlow::Node node).toString())
134+
or
135+
exists(any(AccessPath a).getAnInstanceIn(_))
129136
}
130137
}
131138

0 commit comments

Comments
 (0)