Skip to content

Commit e6744c8

Browse files
LiedtkeV8-internal LUCI CQ
authored andcommitted
[wasm] Allow abstract heap types in more places
Bug: 445356784 Change-Id: I488149208dcda6e632ff1fc36d7c959978c3d470 Reviewed-on: https://chrome-internal-review.googlesource.com/c/v8/fuzzilli/+/9078876 Commit-Queue: Matthias Liedtke <mliedtke@google.com> Auto-Submit: Matthias Liedtke <mliedtke@google.com> Reviewed-by: Manos Koukoutos <manoskouk@google.com>
1 parent aa00846 commit e6744c8

File tree

2 files changed

+10
-12
lines changed

2 files changed

+10
-12
lines changed

Sources/Fuzzilli/Base/ProgramBuilder.swift

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -4610,19 +4610,16 @@ public class ProgramBuilder {
46104610

46114611
let fields = (0..<Int.random(in: 0...10)).map { _ in
46124612
var type: ILType
4613-
if let elementType = randomVariable(ofType: .wasmTypeDef()),
4614-
probability(0.25)
4615-
{
4616-
// TODO(mliedtke): Allow non-nullable reference types. Right now we can't do this as
4617-
// the WasmStructNewGenerator might then fail to generate a struct.
4618-
let nullability = true
4613+
// TODO(mliedtke): Allow non-nullable reference types. Right now we can't do this as
4614+
// the WasmStructNewGenerator might then fail to generate a struct.
4615+
let nullability = true
4616+
if let elementType = randomVariable(ofType: .wasmTypeDef()), probability(0.25) {
46194617
indexTypes.append(elementType)
46204618
type = .wasmRef(.Index(), nullability: nullability)
46214619
} else {
4622-
// TODO(mliedtke): Extend list with abstract heap types.
46234620
type = chooseUniform(from: [
46244621
.wasmPackedI8, .wasmPackedI16, .wasmi32, .wasmi64, .wasmf32, .wasmf64, .wasmSimd128,
4625-
])
4622+
] + WasmAbstractHeapType.allCases.map {ILType.wasmRef($0, nullability: nullability)})
46264623
}
46274624
return WasmStructTypeDescription.Field(
46284625
type: type, mutability: probability(0.75))
@@ -4705,8 +4702,9 @@ public class ProgramBuilder {
47054702
indexTypes.append(elementType)
47064703
return ILType.wasmRef(.Index(), nullability: nullability)
47074704
} else {
4708-
// TODO(mliedtke): Extend list with abstract heap types.
4709-
return chooseUniform(from: [.wasmi32, .wasmi64, .wasmf32, .wasmf64, .wasmSimd128])
4705+
let nullability = !allowNonNullable || probability(0.5)
4706+
return chooseUniform(from: [.wasmi32, .wasmi64, .wasmf32, .wasmf64, .wasmSimd128]
4707+
+ WasmAbstractHeapType.allCases.map {ILType.wasmRef($0, nullability: nullability)})
47104708
}
47114709
}
47124710
let signature = (0..<parameterCount).map {_ in chooseType()}

Sources/Fuzzilli/CodeGen/WasmCodeGenerators.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2005,11 +2005,11 @@ fileprivate let wasmArrayTypeGenerator = GeneratorStub(
20052005
elementType: .wasmRef(.Index(), nullability: nullability),
20062006
mutability: mutability, indexType: elementType)
20072007
} else {
2008-
// TODO(mliedtke): Extend list with abstract heap types.
20092008
b.wasmDefineArrayType(
20102009
elementType: chooseUniform(from: [
20112010
.wasmPackedI8, .wasmPackedI16, .wasmi32, .wasmi64, .wasmf32, .wasmf64, .wasmSimd128,
2012-
]), mutability: mutability)
2011+
] + WasmAbstractHeapType.allCases.map {ILType.wasmRef($0, nullability: Bool.random())}),
2012+
mutability: mutability)
20132013
}
20142014
}
20152015

0 commit comments

Comments
 (0)