@@ -94,16 +94,12 @@ fileprivate let WorkerGenerator = RecursiveCodeGenerator("WorkerGenerator") { b
9494fileprivate let GcGenerator = CodeGenerator ( " GcGenerator " ) { b in
9595 let gc = b. createNamedVariable ( forBuiltin: " gc " )
9696
97- // Do minor GCs more frequently.
98- let type = b. loadString ( probability ( 0.25 ) ? " major " : " minor " )
99- // If the execution type is 'async', gc() returns a Promise, we currently
100- // do not really handle other than typing the return of gc to .undefined |
101- // .jsPromise. One could either chain a .then or create two wrapper
102- // functions that are differently typed such that fuzzilli always knows
103- // what the type of the return value is.
104- let execution = b. loadString ( probability ( 0.5 ) ? " sync " : " async " )
105- b. callFunction ( gc, withArgs: [ b. createObject ( with: [ " type " : type, " execution " : execution] ) ] )
106- }
97+ // `gc()` takes a `type` parameter. If the value is 'async', gc() returns a
98+ // Promise. We currently do not really handle this other than typing the
99+ // return of gc to .undefined | .jsPromise. One could either chain a .then
100+ // or create two wrapper functions that are differently typed such that
101+ // fuzzilli always knows what the type of the return value is.
102+ b. callFunction ( gc, withArgs: b. findOrGenerateArguments ( forSignature: b. fuzzer. environment. type ( ofBuiltin: " gc " ) . signature!) ) }
107103
108104fileprivate let WasmStructGenerator = CodeGenerator ( " WasmStructGenerator " ) { b in
109105 b. eval ( " %WasmStruct() " , hasOutput: true ) ;
@@ -427,6 +423,9 @@ public extension ILType {
427423 static let jsD8FastCAPI = ILType . object ( ofGroup: " D8FastCAPI " , withProperties: [ ] , withMethods: [ " throw_no_fallback " , " add_32bit_int " ] )
428424
429425 static let jsD8FastCAPIConstructor = ILType . constructor ( Signature ( expects: [ ] , returns: ILType . jsD8FastCAPI) )
426+
427+ static let gcTypeEnum = ILType . enumeration ( ofName: " gcType " , withValues: [ " minor " , " major " ] )
428+ static let gcExecutionEnum = ILType . enumeration ( ofName: " gcExecution " , withValues: [ " async " , " sync " ] )
430429}
431430
432431let jsD8 = ObjectGroup ( name: " D8 " , instanceType: . jsD8, properties: [ " test " : . jsD8Test] , methods: [ : ] )
@@ -438,6 +437,13 @@ let jsD8FastCAPI = ObjectGroup(name: "D8FastCAPI", instanceType: .jsD8FastCAPI,
438437 " add_32bit_int " : Signature ( expects: [ Parameter . plain ( ILType . integer) , Parameter . plain ( ILType . integer) ] , returns: ILType . integer)
439438 ] )
440439
440+ let gcOptions = ObjectGroup (
441+ name: " GCOptions " ,
442+ instanceType: . object( ofGroup: " GCOptions " , withProperties: [ " type " , " execution " ] , withMethods: [ ] ) ,
443+ properties: [ " type " : . gcTypeEnum,
444+ " execution " : . gcExecutionEnum] ,
445+ methods: [ : ] )
446+
441447let fastCallables : [ ( group: ILType , method: String ) ] = [
442448 ( group: . jsD8FastCAPI, method: " throw_no_fallback " ) ,
443449 ( group: . jsD8FastCAPI, method: " add_32bit_int " ) ,
@@ -733,12 +739,12 @@ let v8Profile = Profile(
733739 disabledMutators: [ ] ,
734740
735741 additionalBuiltins: [
736- " gc " : . function( [ ] => ( . undefined | . jsPromise) ) ,
742+ " gc " : . function( [ . opt ( gcOptions . instanceType ) ] => ( . undefined | . jsPromise) ) ,
737743 " d8 " : . jsD8,
738744 " Worker " : . constructor( [ . anything, . object( ) ] => . object( withMethods: [ " postMessage " , " getMessage " ] ) ) ,
739745 ] ,
740746
741- additionalObjectGroups: [ jsD8, jsD8Test, jsD8FastCAPI] ,
747+ additionalObjectGroups: [ jsD8, jsD8Test, jsD8FastCAPI, gcOptions ] ,
742748
743749 optionalPostProcessor: nil
744750)
0 commit comments