Skip to content

Commit 56288eb

Browse files
committed
Java: Misc performance fixes
1 parent caa25f7 commit 56288eb

File tree

6 files changed

+16
-7
lines changed

6 files changed

+16
-7
lines changed

java/ql/lib/semmle/code/java/ControlFlowGraph.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -365,6 +365,7 @@ private module ControlFlowGraphImpl {
365365
/**
366366
* Gets a non-overridable method that always throws an exception or calls `exit`.
367367
*/
368+
pragma[assume_small_delta]
368369
private Method nonReturningMethod() {
369370
result instanceof MethodExit
370371
or
@@ -381,6 +382,7 @@ private module ControlFlowGraphImpl {
381382
/**
382383
* Gets a virtual method that always throws an exception or calls `exit`.
383384
*/
385+
pragma[assume_small_delta]
384386
private EffectivelyNonVirtualMethod likelyNonReturningMethod() {
385387
result.getReturnType() instanceof VoidType and
386388
not exists(ReturnStmt ret | ret.getEnclosingCallable() = result) and

java/ql/lib/semmle/code/java/dataflow/SSA.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,7 @@ private module SsaImpl {
451451
* Holds if `f` is live in `b` at index `i`. The rank of `i` is `rankix` as
452452
* defined by `callDefUseRank`.
453453
*/
454+
pragma[assume_small_delta]
454455
private predicate liveAtRank(TrackedField f, BasicBlock b, int rankix, int i) {
455456
callDefUseRank(f, b, rankix, i) and
456457
(
@@ -564,6 +565,7 @@ private module SsaImpl {
564565
}
565566

566567
/** Holds if a phi node for `v` is needed at the beginning of basic block `b`. */
568+
pragma[assume_small_delta]
567569
cached
568570
predicate phiNode(TrackedVar v, BasicBlock b) {
569571
liveAtEntry(v, b) and

java/ql/lib/semmle/code/java/dataflow/internal/BaseSSA.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,7 @@ private module SsaImpl {
151151
}
152152

153153
/** Holds if a phi node for `v` is needed at the beginning of basic block `b`. */
154+
pragma[assume_small_delta]
154155
cached
155156
predicate phiNode(BaseSsaSourceVariable v, BasicBlock b) {
156157
liveAtEntry(v, b) and

java/ql/lib/semmle/code/java/dataflow/internal/DataFlowImplCommon.qll

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -140,10 +140,8 @@ private module LambdaFlow {
140140
}
141141

142142
pragma[nomagic]
143-
private TReturnPositionSimple viableReturnPosLambda(
144-
DataFlowCall call, DataFlowCallOption lastCall, ReturnKind kind
145-
) {
146-
result = TReturnPositionSimple0(viableCallableLambda(call, lastCall), kind)
143+
private TReturnPositionSimple viableReturnPosLambda(DataFlowCall call, ReturnKind kind) {
144+
result = TReturnPositionSimple0(viableCallableLambda(call, _), kind)
147145
}
148146

149147
private predicate viableReturnPosOutNonLambda(
@@ -155,11 +153,12 @@ private module LambdaFlow {
155153
)
156154
}
157155

156+
pragma[nomagic]
158157
private predicate viableReturnPosOutLambda(
159-
DataFlowCall call, DataFlowCallOption lastCall, TReturnPositionSimple pos, OutNode out
158+
DataFlowCall call, TReturnPositionSimple pos, OutNode out
160159
) {
161160
exists(ReturnKind kind |
162-
pos = viableReturnPosLambda(call, lastCall, kind) and
161+
pos = viableReturnPosLambda(call, kind) and
163162
out = getAnOutNode(call, kind)
164163
)
165164
}
@@ -188,6 +187,7 @@ private module LambdaFlow {
188187
else any()
189188
}
190189

190+
pragma[assume_small_delta]
191191
pragma[nomagic]
192192
predicate revLambdaFlow0(
193193
DataFlowCall lambdaCall, LambdaCallKind kind, Node node, DataFlowType t, boolean toReturn,
@@ -274,6 +274,7 @@ private module LambdaFlow {
274274
)
275275
}
276276

277+
pragma[assume_small_delta]
277278
pragma[nomagic]
278279
predicate revLambdaFlowOut(
279280
DataFlowCall lambdaCall, LambdaCallKind kind, TReturnPositionSimple pos, DataFlowType t,
@@ -285,7 +286,7 @@ private module LambdaFlow {
285286
or
286287
// non-linear recursion
287288
revLambdaFlowOutLambdaCall(lambdaCall, kind, out, t, toJump, call, lastCall) and
288-
viableReturnPosOutLambda(call, _, pos, out)
289+
viableReturnPosOutLambda(call, pos, out)
289290
)
290291
}
291292

java/ql/lib/semmle/code/java/dataflow/internal/FlowSummaryImpl.qll

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,7 @@ module Public {
109109
}
110110

111111
/** Gets the stack obtained by dropping the first `i` elements, if any. */
112+
pragma[assume_small_delta]
112113
SummaryComponentStack drop(int i) {
113114
i = 0 and result = this
114115
or

java/ql/lib/semmle/code/java/frameworks/JaxWS.qll

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@ private predicate hasPathAnnotation(Annotatable annotatable) {
5353
* A method which is annotated with one or more JaxRS resource type annotations e.g. `@GET`, `@POST` etc.
5454
*/
5555
class JaxRsResourceMethod extends Method {
56+
pragma[assume_small_delta]
5657
JaxRsResourceMethod() {
5758
exists(AnnotationType a |
5859
a = this.getAnAnnotation().getType() and
@@ -91,6 +92,7 @@ class JaxRsResourceMethod extends Method {
9192
* This class contains resource methods, which are executed in response to requests.
9293
*/
9394
class JaxRsResourceClass extends Class {
95+
pragma[assume_small_delta]
9496
JaxRsResourceClass() {
9597
// A root resource class has a @Path annotation on the class.
9698
hasPathAnnotation(this)

0 commit comments

Comments
 (0)