@@ -94,16 +94,12 @@ fileprivate let WorkerGenerator = RecursiveCodeGenerator("WorkerGenerator") { b
94
94
fileprivate let GcGenerator = CodeGenerator ( " GcGenerator " ) { b in
95
95
let gc = b. createNamedVariable ( forBuiltin: " gc " )
96
96
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!) ) }
107
103
108
104
fileprivate let WasmStructGenerator = CodeGenerator ( " WasmStructGenerator " ) { b in
109
105
b. eval ( " %WasmStruct() " , hasOutput: true ) ;
@@ -427,6 +423,9 @@ public extension ILType {
427
423
static let jsD8FastCAPI = ILType . object ( ofGroup: " D8FastCAPI " , withProperties: [ ] , withMethods: [ " throw_no_fallback " , " add_32bit_int " ] )
428
424
429
425
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 " ] )
430
429
}
431
430
432
431
let jsD8 = ObjectGroup ( name: " D8 " , instanceType: . jsD8, properties: [ " test " : . jsD8Test] , methods: [ : ] )
@@ -438,6 +437,13 @@ let jsD8FastCAPI = ObjectGroup(name: "D8FastCAPI", instanceType: .jsD8FastCAPI,
438
437
" add_32bit_int " : Signature ( expects: [ Parameter . plain ( ILType . integer) , Parameter . plain ( ILType . integer) ] , returns: ILType . integer)
439
438
] )
440
439
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
+
441
447
let fastCallables : [ ( group: ILType , method: String ) ] = [
442
448
( group: . jsD8FastCAPI, method: " throw_no_fallback " ) ,
443
449
( group: . jsD8FastCAPI, method: " add_32bit_int " ) ,
@@ -733,12 +739,12 @@ let v8Profile = Profile(
733
739
disabledMutators: [ ] ,
734
740
735
741
additionalBuiltins: [
736
- " gc " : . function( [ ] => ( . undefined | . jsPromise) ) ,
742
+ " gc " : . function( [ . opt ( gcOptions . instanceType ) ] => ( . undefined | . jsPromise) ) ,
737
743
" d8 " : . jsD8,
738
744
" Worker " : . constructor( [ . anything, . object( ) ] => . object( withMethods: [ " postMessage " , " getMessage " ] ) ) ,
739
745
] ,
740
746
741
- additionalObjectGroups: [ jsD8, jsD8Test, jsD8FastCAPI] ,
747
+ additionalObjectGroups: [ jsD8, jsD8Test, jsD8FastCAPI, gcOptions ] ,
742
748
743
749
optionalPostProcessor: nil
744
750
)
0 commit comments