Skip to content

Commit a5fbe75

Browse files
committed
Ruby: Reduce size of input predicate for non-linear recursion
Before, we would be recursive in all of `MethodCall::getMethodName`: ``` Evaluated named local Synthesis#d9ff06b1::AssignOperationDesugar::SetterAssignOperation::getCallKind#ffff#shared#3@Synthesi in 9803ms on iteration 14 (size: 31006941). Evaluated relational algebra for predicate Synthesis#d9ff06b1::AssignOperationDesugar::SetterAssignOperation::getCallKind#ffff#shared#3@Synthesi on iteration 14 running pipeline main with tuple counts: 256419 ~1% {2} r1 = SCAN Call#841c84e8::MethodCall::getMethodName#0#dispred#ff#prev_delta OUTPUT In.1, In.0 31006941 ~8% {4} r2 = JOIN r1 WITH Synthesis#d9ff06b1::MethodCallKind#ffff#prev ON FIRST 1 OUTPUT Lhs.1, Rhs.1, Rhs.2, Rhs.3 return r2 ``` Now, we have restricted that to only the relevant method names.
1 parent cda05ed commit a5fbe75

File tree

1 file changed

+10
-4
lines changed

1 file changed

+10
-4
lines changed

ruby/ql/lib/codeql/ruby/ast/internal/Synthesis.qll

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -255,8 +255,11 @@ private module SetterDesugar {
255255
MethodCall getMethodCall() { result = mc }
256256

257257
pragma[nomagic]
258-
MethodCallKind getCallKind(boolean setter, int arity) {
259-
result = MethodCallKind(mc.getMethodName(), setter, arity)
258+
private string getMethodName() { result = mc.getMethodName() }
259+
260+
pragma[nomagic]
261+
MethodCallKind getCallKind(int arity) {
262+
result = MethodCallKind(this.getMethodName(), true, arity)
260263
}
261264

262265
pragma[nomagic]
@@ -282,7 +285,7 @@ private module SetterDesugar {
282285
exists(AstNode seq | seq = TStmtSequenceSynth(sae, -1) |
283286
parent = seq and
284287
i = 0 and
285-
child = SynthChild(sae.getCallKind(true, sae.getNumberOfArguments() + 1))
288+
child = SynthChild(sae.getCallKind(sae.getNumberOfArguments() + 1))
286289
or
287290
exists(AstNode call | call = TMethodCallSynth(seq, 0, _, _, _) |
288291
parent = call and
@@ -492,9 +495,12 @@ private module AssignOperationDesugar {
492495

493496
MethodCall getMethodCall() { result = mc }
494497

498+
pragma[nomagic]
499+
private string getMethodName() { result = mc.getMethodName() }
500+
495501
pragma[nomagic]
496502
MethodCallKind getCallKind(boolean setter, int arity) {
497-
result = MethodCallKind(mc.getMethodName(), setter, arity)
503+
result = MethodCallKind(this.getMethodName(), setter, arity)
498504
}
499505

500506
pragma[nomagic]

0 commit comments

Comments
 (0)