Skip to content

Commit 6f0e507

Browse files
committed
outline predicate to fix join-ordering
1 parent 3000486 commit 6f0e507

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed

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

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1207,12 +1207,25 @@ private predicate onPath(DataFlow::Node nd, DataFlow::Configuration cfg, PathSum
12071207
not cfg.isLabeledBarrier(nd, summary.getEndLabel())
12081208
or
12091209
exists(DataFlow::Node mid, PathSummary stepSummary |
1210-
reachableFromSource(nd, cfg, summary) and
1211-
flowStep(nd, id(cfg), mid, stepSummary) and
1210+
onPathStep(nd, cfg, summary, stepSummary, mid) and
12121211
onPath(mid, id(cfg), summary.append(stepSummary))
12131212
)
12141213
}
12151214

1215+
/**
1216+
* Holds if `nd` can be reached from a source under `cfg`,
1217+
* and there is a flowStep from `nd` (with summary `summary`) to `mid` (with summary `stepSummary`).
1218+
*
1219+
* This predicate has been outlined from `onPath` to give the optimizer a hint about join-ordering.
1220+
*/
1221+
private predicate onPathStep(
1222+
DataFlow::Node nd, DataFlow::Configuration cfg, PathSummary summary, PathSummary stepSummary,
1223+
DataFlow::Node mid
1224+
) {
1225+
reachableFromSource(nd, cfg, summary) and
1226+
flowStep(nd, id(cfg), mid, stepSummary)
1227+
}
1228+
12161229
/**
12171230
* Holds if there is a configuration that has at least one source and at least one sink.
12181231
*/

0 commit comments

Comments
 (0)