@@ -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.
0 commit comments