mirror of
https://github.com/github/codeql.git
synced 2025-12-24 04:36:35 +01:00
Java: Misc performance fixes
This commit is contained in:
@@ -365,6 +365,7 @@ private module ControlFlowGraphImpl {
|
||||
/**
|
||||
* Gets a non-overridable method that always throws an exception or calls `exit`.
|
||||
*/
|
||||
pragma[assume_small_delta]
|
||||
private Method nonReturningMethod() {
|
||||
result instanceof MethodExit
|
||||
or
|
||||
@@ -381,6 +382,7 @@ private module ControlFlowGraphImpl {
|
||||
/**
|
||||
* Gets a virtual method that always throws an exception or calls `exit`.
|
||||
*/
|
||||
pragma[assume_small_delta]
|
||||
private EffectivelyNonVirtualMethod likelyNonReturningMethod() {
|
||||
result.getReturnType() instanceof VoidType and
|
||||
not exists(ReturnStmt ret | ret.getEnclosingCallable() = result) and
|
||||
|
||||
@@ -451,6 +451,7 @@ private module SsaImpl {
|
||||
* Holds if `f` is live in `b` at index `i`. The rank of `i` is `rankix` as
|
||||
* defined by `callDefUseRank`.
|
||||
*/
|
||||
pragma[assume_small_delta]
|
||||
private predicate liveAtRank(TrackedField f, BasicBlock b, int rankix, int i) {
|
||||
callDefUseRank(f, b, rankix, i) and
|
||||
(
|
||||
@@ -564,6 +565,7 @@ private module SsaImpl {
|
||||
}
|
||||
|
||||
/** Holds if a phi node for `v` is needed at the beginning of basic block `b`. */
|
||||
pragma[assume_small_delta]
|
||||
cached
|
||||
predicate phiNode(TrackedVar v, BasicBlock b) {
|
||||
liveAtEntry(v, b) and
|
||||
|
||||
@@ -151,6 +151,7 @@ private module SsaImpl {
|
||||
}
|
||||
|
||||
/** Holds if a phi node for `v` is needed at the beginning of basic block `b`. */
|
||||
pragma[assume_small_delta]
|
||||
cached
|
||||
predicate phiNode(BaseSsaSourceVariable v, BasicBlock b) {
|
||||
liveAtEntry(v, b) and
|
||||
|
||||
@@ -140,10 +140,8 @@ private module LambdaFlow {
|
||||
}
|
||||
|
||||
pragma[nomagic]
|
||||
private TReturnPositionSimple viableReturnPosLambda(
|
||||
DataFlowCall call, DataFlowCallOption lastCall, ReturnKind kind
|
||||
) {
|
||||
result = TReturnPositionSimple0(viableCallableLambda(call, lastCall), kind)
|
||||
private TReturnPositionSimple viableReturnPosLambda(DataFlowCall call, ReturnKind kind) {
|
||||
result = TReturnPositionSimple0(viableCallableLambda(call, _), kind)
|
||||
}
|
||||
|
||||
private predicate viableReturnPosOutNonLambda(
|
||||
@@ -155,11 +153,12 @@ private module LambdaFlow {
|
||||
)
|
||||
}
|
||||
|
||||
pragma[nomagic]
|
||||
private predicate viableReturnPosOutLambda(
|
||||
DataFlowCall call, DataFlowCallOption lastCall, TReturnPositionSimple pos, OutNode out
|
||||
DataFlowCall call, TReturnPositionSimple pos, OutNode out
|
||||
) {
|
||||
exists(ReturnKind kind |
|
||||
pos = viableReturnPosLambda(call, lastCall, kind) and
|
||||
pos = viableReturnPosLambda(call, kind) and
|
||||
out = getAnOutNode(call, kind)
|
||||
)
|
||||
}
|
||||
@@ -188,6 +187,7 @@ private module LambdaFlow {
|
||||
else any()
|
||||
}
|
||||
|
||||
pragma[assume_small_delta]
|
||||
pragma[nomagic]
|
||||
predicate revLambdaFlow0(
|
||||
DataFlowCall lambdaCall, LambdaCallKind kind, Node node, DataFlowType t, boolean toReturn,
|
||||
@@ -274,6 +274,7 @@ private module LambdaFlow {
|
||||
)
|
||||
}
|
||||
|
||||
pragma[assume_small_delta]
|
||||
pragma[nomagic]
|
||||
predicate revLambdaFlowOut(
|
||||
DataFlowCall lambdaCall, LambdaCallKind kind, TReturnPositionSimple pos, DataFlowType t,
|
||||
@@ -285,7 +286,7 @@ private module LambdaFlow {
|
||||
or
|
||||
// non-linear recursion
|
||||
revLambdaFlowOutLambdaCall(lambdaCall, kind, out, t, toJump, call, lastCall) and
|
||||
viableReturnPosOutLambda(call, _, pos, out)
|
||||
viableReturnPosOutLambda(call, pos, out)
|
||||
)
|
||||
}
|
||||
|
||||
|
||||
@@ -109,6 +109,7 @@ module Public {
|
||||
}
|
||||
|
||||
/** Gets the stack obtained by dropping the first `i` elements, if any. */
|
||||
pragma[assume_small_delta]
|
||||
SummaryComponentStack drop(int i) {
|
||||
i = 0 and result = this
|
||||
or
|
||||
|
||||
@@ -53,6 +53,7 @@ private predicate hasPathAnnotation(Annotatable annotatable) {
|
||||
* A method which is annotated with one or more JaxRS resource type annotations e.g. `@GET`, `@POST` etc.
|
||||
*/
|
||||
class JaxRsResourceMethod extends Method {
|
||||
pragma[assume_small_delta]
|
||||
JaxRsResourceMethod() {
|
||||
exists(AnnotationType a |
|
||||
a = this.getAnAnnotation().getType() and
|
||||
@@ -91,6 +92,7 @@ class JaxRsResourceMethod extends Method {
|
||||
* This class contains resource methods, which are executed in response to requests.
|
||||
*/
|
||||
class JaxRsResourceClass extends Class {
|
||||
pragma[assume_small_delta]
|
||||
JaxRsResourceClass() {
|
||||
// A root resource class has a @Path annotation on the class.
|
||||
hasPathAnnotation(this)
|
||||
|
||||
Reference in New Issue
Block a user