Skip to content

Commit 36d6258

Browse files
whendrik-cmdV8-internal LUCI CQ
authored andcommitted
Add ManyArgumentsCall CodeGenerator
Calling apply() with an array like this generator does will create a function call with as many arguments as the size of the array. It is meant to cover the discrepencies in max argument counts between turboshaft and maglev. Bug: b/455503442 Change-Id: Ia605368687970369e168796273486d75de4cc811 Reviewed-on: https://chrome-internal-review.googlesource.com/c/v8/fuzzilli/+/8839116 Reviewed-by: Matthias Liedtke <mliedtke@google.com> Commit-Queue: Hendrik Wüthrich <whendrik@google.com>
1 parent cb649fa commit 36d6258

2 files changed

Lines changed: 20 additions & 0 deletions

File tree

Sources/Fuzzilli/CodeGen/CodeGeneratorWeights.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ public let codeGeneratorWeights = [
129129
"ComputedPropertyConfigurationGenerator": 10,
130130
"FunctionCallGenerator": 30,
131131
"FunctionCallWithSpreadGenerator": 3,
132+
"ManyArgumentsCall": 3,
132133
"ConstructorCallGenerator": 20,
133134
"ConstructorCallWithSpreadGenerator": 3,
134135
"MethodCallGenerator": 30,

Sources/Fuzzilli/CodeGen/CodeGenerators.swift

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1846,6 +1846,25 @@ public let CodeGenerators: [CodeGenerator] = [
18461846
f, withArgs: arguments, spreading: spreads, guard: needGuard)
18471847
},
18481848

1849+
1850+
CodeGenerator("ManyArgumentsCall", inputs: .preferred(.function())) { b, f in
1851+
// These sizes are around the max arguments for maglev (2^16 - 10)
1852+
// and turboshaft (2^16).
1853+
let sizes: [Int64] = [65524, 65525, 65526, 65534, 65535, 65536]
1854+
let size = b.loadInt(chooseUniform(from: sizes))
1855+
let constructor = b.createNamedVariable(forBuiltin: "Array")
1856+
let largeArray = b.construct(constructor, withArgs: [size])
1857+
1858+
let needGuard = b.type(of: f).MayNotBe(.function())
1859+
1860+
if probability(0.5) {
1861+
let receiver = probability(0.5) ? b.loadNull() : b.randomVariable(forUseAs: .object())
1862+
b.callMethod("apply", on: f, withArgs: [receiver, largeArray], guard: needGuard)
1863+
} else {
1864+
b.callFunction(f, withArgs: [largeArray], spreading: [true], guard: needGuard)
1865+
}
1866+
},
1867+
18491868
CodeGenerator(
18501869
"ConstructorCallWithSpreadGenerator", inputs: .preferred(.constructor())
18511870
) { b, c in

0 commit comments

Comments
 (0)