Skip to content

Commit 6c60634

Browse files
Dominik KlembaV8-internal LUCI CQ
authored andcommitted
Refactor chooseArgumentLists to use arguments history list
The goal is to improve readability. It affects probability distribution: - Allows up to 4 distinct argument sets (previously capped at 3). - When reusing arguments, selects uniformly from all previously generated sets, eliminating the bias towards the first set found in the previous implementation. Original implementation added in: crrev/i/9020237 Change-Id: I590149d3d0cf7f1889c68c30fc8d4b0f0d71e6e5 Reviewed-on: https://chrome-internal-review.googlesource.com/c/v8/fuzzilli/+/9022358 Commit-Queue: Dominik Klemba <tacet@google.com> Commit-Queue: Matthias Liedtke <mliedtke@google.com> Reviewed-by: Michael Achenbach <machenbach@google.com> Reviewed-by: Matthias Liedtke <mliedtke@google.com> Auto-Submit: Dominik Klemba <tacet@google.com>
1 parent afeb461 commit 6c60634

1 file changed

Lines changed: 10 additions & 13 deletions

File tree

Sources/FuzzilliCli/Profiles/V8CommonProfile.swift

Lines changed: 10 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -76,23 +76,20 @@ public let ForceJITCompilationThroughLoopGenerator = CodeGenerator("ForceJITComp
7676
// Choose argument lists for four function calls of the same function with
7777
// interesting optimization patterns.
7878
func chooseArgumentLists(_ b: ProgramBuilder, forCalling f: Variable) -> ([Variable], [Variable], [Variable], [Variable]) {
79-
var pool: [[Variable]?] = [nil, nil, nil]
79+
var reusePool: [[Variable]] = [b.randomArguments(forCalling: f)]
80+
let reuseProbabilities = [1.0, 0.9, 0.9, 0.5]
8081

81-
let getArg = { (i: Int) -> [Variable] in
82-
if pool[i] == nil {
83-
pool[i] = b.randomArguments(forCalling: f)
82+
let argumentLists = reuseProbabilities.map { p in
83+
if probability(p) {
84+
return reusePool.randomElement()!
85+
} else {
86+
reusePool.append(b.randomArguments(forCalling: f))
87+
return reusePool.last!
8488
}
85-
return pool[i]!
86-
}
87-
88-
let keepRates = [1.0, 0.97, 0.85, 0.75]
89-
90-
let args = (0..<4).map { i in
91-
probability(keepRates[i]) ? getArg(0) : getArg(probability(0.5) ? 1 : 2)
9289
}
9390

94-
assert(args.count == 4)
95-
return (args[0], args[1], args[2], args[3])
91+
assert(argumentLists.count == 4)
92+
return (argumentLists[0], argumentLists[1], argumentLists[2], argumentLists[3])
9693
}
9794

9895
private func forceCompilationGenerator(_ generatorName: String, optimizeName: String) -> CodeGenerator {

0 commit comments

Comments
 (0)