Skip to content

Commit e65520d

Browse files
LiedtkeV8-internal LUCI CQ
authored andcommitted
[v8] Add ProgramTemplate for tierup with non-inlined function
Change-Id: Icee437b92f284e7f9f7dc339d31ee157c6f876ae Reviewed-on: https://chrome-internal-review.googlesource.com/c/v8/fuzzilli/+/9032277 Reviewed-by: Samuel Groß <saelo@google.com> Commit-Queue: Matthias Liedtke <mliedtke@google.com>
1 parent 3a8d559 commit e65520d

2 files changed

Lines changed: 41 additions & 9 deletions

File tree

Sources/FuzzilliCli/Profiles/V8CommonProfile.swift

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -760,6 +760,37 @@ public let ProtoAssignSeqOptFuzzer = ProgramTemplate("ProtoAssignSeqOptFuzzer")
760760
b.build(n: 10)
761761
}
762762

763+
public let TurbofanTierUpNonInlinedCallFuzzer =
764+
ProgramTemplate("TurbofanTierUpNonInlinedCallFuzzer") { b in
765+
b.buildPrefix()
766+
b.build(n: 50)
767+
// Find a function (or generate a new one) to be marked as "never optimize".
768+
let unoptimizedFunction = b.randomVariable(ofType: .function())
769+
?? b.buildPlainFunction(with: .parameters(n: 2)) { _ in
770+
b.build(n: 20)
771+
b.doReturn(b.randomJsVariable())
772+
}
773+
b.eval("%NeverOptimizeFunction(%@)", with: [unoptimizedFunction])
774+
// Create another function that calls the unoptimized function. This will always create a real
775+
// call instead of inlining it.
776+
let optimizedFunction = b.buildPlainFunction(with: .parameters(n: 0)) { _ in
777+
// This should be able to generate interesting things including calls to the unoptimized
778+
// function in all kinds of control flow.
779+
b.build(n: 30)
780+
// Also explicitly emit a call to the unoptimized function.
781+
b.callFunction(unoptimizedFunction, withArgs: b.randomArguments(forCalling: unoptimizedFunction))
782+
b.build(n: 10)
783+
}
784+
// Collect feedback and optimize the function.
785+
// Guard all calls. The path where they throw is still interesting as there are
786+
// optimizations that affect the unwinding logic which we'd like to get coverage for as well.
787+
b.eval("%PrepareFunctionForOptimization(%@)", with: [optimizedFunction]);
788+
b.callFunction(optimizedFunction, guard: true)
789+
b.callFunction(optimizedFunction, guard: true)
790+
b.eval("%OptimizeFunctionOnNextCall(%@)", with: [optimizedFunction]);
791+
b.callFunction(optimizedFunction, guard: true)
792+
}
793+
763794
// Configure V8 invocation arguments. `forSandbox` is used by the V8SandboxProfile. As the sandbox
764795
// fuzzer does not crash on regular assertions, most validation flags do not make sense in that
765796
// configuraiton.

Sources/FuzzilliCli/Profiles/V8Profile.swift

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -78,15 +78,16 @@ let v8Profile = Profile(
7878
],
7979

8080
additionalProgramTemplates: WeightedList<ProgramTemplate>([
81-
(MapTransitionFuzzer, 1),
82-
(ValueSerializerFuzzer, 1),
83-
(V8RegExpFuzzer, 1),
84-
(WasmFastCallFuzzer, 1),
85-
(FastApiCallFuzzer, 1),
86-
(LazyDeoptFuzzer, 1),
87-
(WasmDeoptFuzzer, 1),
88-
(WasmTurbofanFuzzer, 1),
89-
(ProtoAssignSeqOptFuzzer, 1),
81+
(MapTransitionFuzzer, 1),
82+
(ValueSerializerFuzzer, 1),
83+
(V8RegExpFuzzer, 1),
84+
(WasmFastCallFuzzer, 1),
85+
(FastApiCallFuzzer, 1),
86+
(LazyDeoptFuzzer, 1),
87+
(WasmDeoptFuzzer, 1),
88+
(WasmTurbofanFuzzer, 1),
89+
(ProtoAssignSeqOptFuzzer, 1),
90+
(TurbofanTierUpNonInlinedCallFuzzer, 1),
9091
]),
9192

9293
disabledCodeGenerators: [],

0 commit comments

Comments
 (0)