Skip to content

Commit c2261db

Browse files
LiedtkeV8-internal LUCI CQ
authored andcommitted
[wasm] Prepare WasmThrow to use wasm-gc types
By removing the types from the WasmThrow, this prepares Fuzzilli to adapt the tags as a next step to use wasm-gc signatures instead of static parameter types (there might be more dependencies for that). Bug: 445356784 Change-Id: I852a84efd928ed593bbb84105a95ab7a09cde9a7 Reviewed-on: https://chrome-internal-review.googlesource.com/c/v8/fuzzilli/+/8926696 Commit-Queue: Matthias Liedtke <mliedtke@google.com> Reviewed-by: Doga Yüksel <dyuksel@google.com>
1 parent 7f04c16 commit c2261db

5 files changed

Lines changed: 10 additions & 28 deletions

File tree

Sources/Fuzzilli/Base/ProgramBuilder.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4115,7 +4115,7 @@ public class ProgramBuilder {
41154115

41164116
public func WasmBuildThrow(tag: Variable, inputs: [Variable]) {
41174117
let tagType = b.type(of: tag).wasmType as! WasmTagType
4118-
b.emit(WasmThrow(parameterTypes: tagType.parameters), withInputs: [tag] + inputs, types: [.object(ofGroup: "WasmTag")] + tagType.parameters)
4118+
b.emit(WasmThrow(parameterCount: tagType.parameters.count), withInputs: [tag] + inputs, types: [.object(ofGroup: "WasmTag")] + tagType.parameters)
41194119
}
41204120

41214121
public func wasmBuildThrowRef(exception: Variable) {

Sources/Fuzzilli/FuzzIL/Instruction.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1437,10 +1437,8 @@ extension Instruction: ProtobufConvertible {
14371437
$0.wasmEndTryDelegate = Fuzzilli_Protobuf_WasmEndTryDelegate.with {
14381438
$0.outputTypes = op.outputTypes.map(ILTypeToWasmTypeEnum)
14391439
}
1440-
case .wasmThrow(let op):
1441-
$0.wasmThrow = Fuzzilli_Protobuf_WasmThrow.with {
1442-
$0.parameterTypes = op.parameterTypes.map(ILTypeToWasmTypeEnum)
1443-
}
1440+
case .wasmThrow(_):
1441+
$0.wasmThrow = Fuzzilli_Protobuf_WasmThrow()
14441442
case .wasmThrowRef(_):
14451443
$0.wasmThrowRef = Fuzzilli_Protobuf_WasmThrowRef()
14461444
case .wasmRethrow(_):
@@ -2488,8 +2486,8 @@ extension Instruction: ProtobufConvertible {
24882486
op = WasmBeginTryDelegate(with: parameters => outputs)
24892487
case .wasmEndTryDelegate(let p):
24902488
op = WasmEndTryDelegate(outputTypes: p.outputTypes.map(WasmTypeEnumToILType))
2491-
case .wasmThrow(let p):
2492-
op = WasmThrow(parameterTypes: p.parameterTypes.map(WasmTypeEnumToILType))
2489+
case .wasmThrow(_):
2490+
op = WasmThrow(parameterCount: inouts.count - 1)
24932491
case .wasmThrowRef(_):
24942492
op = WasmThrowRef()
24952493
case .wasmRethrow(_):

Sources/Fuzzilli/FuzzIL/WasmOperations.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,12 +1467,10 @@ final class WasmEndTryDelegate: WasmOperation {
14671467

14681468
final class WasmThrow: WasmOperation {
14691469
override var opcode: Opcode { .wasmThrow(self) }
1470-
public let parameterTypes: [ILType]
14711470

1472-
init(parameterTypes: [ILType]) {
1473-
self.parameterTypes = parameterTypes
1471+
init(parameterCount: Int) {
14741472
// Inputs: the tag to be thrown plus the arguments for each parameter type of the tag.
1475-
super.init(numInputs: 1 + parameterTypes.count, attributes: [.isJump], requiredContext: [.wasmFunction])
1473+
super.init(numInputs: 1 + parameterCount, attributes: [.isJump], requiredContext: [.wasmFunction])
14761474
}
14771475
}
14781476

Sources/Fuzzilli/Protobuf/operations.pb.swift

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -5301,8 +5301,6 @@ public struct Fuzzilli_Protobuf_WasmThrow: Sendable {
53015301
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
53025302
// methods supported on all messages.
53035303

5304-
public var parameterTypes: [Fuzzilli_Protobuf_WasmILType] = []
5305-
53065304
public var unknownFields = SwiftProtobuf.UnknownStorage()
53075305

53085306
public init() {}
@@ -14054,29 +14052,18 @@ extension Fuzzilli_Protobuf_WasmEndTryDelegate: SwiftProtobuf.Message, SwiftProt
1405414052

1405514053
extension Fuzzilli_Protobuf_WasmThrow: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
1405614054
public static let protoMessageName: String = _protobuf_package + ".WasmThrow"
14057-
public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}parameterTypes\0")
14055+
public static let _protobuf_nameMap = SwiftProtobuf._NameMap()
1405814056

1405914057
public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
14060-
while let fieldNumber = try decoder.nextFieldNumber() {
14061-
// The use of inline closures is to circumvent an issue where the compiler
14062-
// allocates stack space for every case branch when no optimizations are
14063-
// enabled. https://github.com/apple/swift-protobuf/issues/1034
14064-
switch fieldNumber {
14065-
case 1: try { try decoder.decodeRepeatedMessageField(value: &self.parameterTypes) }()
14066-
default: break
14067-
}
14068-
}
14058+
// Load everything into unknown fields
14059+
while try decoder.nextFieldNumber() != nil {}
1406914060
}
1407014061

1407114062
public func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
14072-
if !self.parameterTypes.isEmpty {
14073-
try visitor.visitRepeatedMessageField(value: self.parameterTypes, fieldNumber: 1)
14074-
}
1407514063
try unknownFields.traverse(visitor: &visitor)
1407614064
}
1407714065

1407814066
public static func ==(lhs: Fuzzilli_Protobuf_WasmThrow, rhs: Fuzzilli_Protobuf_WasmThrow) -> Bool {
14079-
if lhs.parameterTypes != rhs.parameterTypes {return false}
1408014067
if lhs.unknownFields != rhs.unknownFields {return false}
1408114068
return true
1408214069
}

Sources/Fuzzilli/Protobuf/operations.proto

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1298,7 +1298,6 @@ message WasmEndTryDelegate {
12981298
}
12991299

13001300
message WasmThrow {
1301-
repeated WasmILType parameterTypes = 1;
13021301
}
13031302

13041303
message WasmThrowRef {

0 commit comments

Comments
 (0)