Skip to content

Commit d9c265b

Browse files
LiedtkeV8-internal LUCI CQ
authored andcommitted
[wasm] Remove return types from wasmReturn
Bug: 445356784 Change-Id: Ia9ced154e6f1ce465c257e0e17c53782ec13f442 Reviewed-on: https://chrome-internal-review.googlesource.com/c/v8/fuzzilli/+/8926836 Reviewed-by: Doga Yüksel <dyuksel@google.com> Commit-Queue: Matthias Liedtke <mliedtke@google.com>
1 parent 39b3f84 commit d9c265b

5 files changed

Lines changed: 12 additions & 31 deletions

File tree

Sources/Fuzzilli/Base/ProgramBuilder.swift

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4203,17 +4203,16 @@ public class ProgramBuilder {
42034203
}
42044204

42054205
public func wasmReturn(_ values: [Variable]) {
4206-
b.emit(WasmReturn(returnTypes: values.map(b.type)), withInputs: values, types: signature.outputTypes)
4206+
b.emit(WasmReturn(returnCount: values.count), withInputs: values, types: signature.outputTypes)
42074207
}
42084208

42094209
public func wasmReturn(_ returnVariable: Variable) {
4210-
let returnType = b.type(of: returnVariable)
4211-
b.emit(WasmReturn(returnTypes: [returnType]), withInputs: [returnVariable], types: signature.outputTypes)
4210+
b.emit(WasmReturn(returnCount: 1), withInputs: [returnVariable], types: signature.outputTypes)
42124211
}
42134212

42144213
public func wasmReturn() {
42154214
assert(signature.outputTypes.isEmpty)
4216-
b.emit(WasmReturn(returnTypes: []), withInputs: [])
4215+
b.emit(WasmReturn(returnCount: 0), withInputs: [])
42174216
}
42184217

42194218
@discardableResult

Sources/Fuzzilli/FuzzIL/Instruction.swift

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,10 +1127,8 @@ extension Instruction: ProtobufConvertible {
11271127
$0.constf64 = Fuzzilli_Protobuf_Constf64.with { $0.value = op.value }
11281128
case .constf32(let op):
11291129
$0.constf32 = Fuzzilli_Protobuf_Constf32.with { $0.value = op.value }
1130-
case .wasmReturn(let op):
1131-
$0.wasmReturn = Fuzzilli_Protobuf_WasmReturn.with {
1132-
$0.returnTypes = op.returnTypes.map(ILTypeToWasmTypeEnum)
1133-
}
1130+
case .wasmReturn(_):
1131+
$0.wasmReturn = Fuzzilli_Protobuf_WasmReturn()
11341132
case .wasmJsCall(let op):
11351133
$0.wasmJsCall = Fuzzilli_Protobuf_WasmJsCall.with {
11361134
$0.parameterTypes = op.functionSignature.parameterTypes.map(ILTypeToWasmTypeEnum)
@@ -2279,8 +2277,8 @@ extension Instruction: ProtobufConvertible {
22792277
op = Constf32(value: p.value)
22802278
case .constf64(let p):
22812279
op = Constf64(value: Float64(p.value))
2282-
case .wasmReturn(let p):
2283-
op = WasmReturn(returnTypes: p.returnTypes.map(WasmTypeEnumToILType))
2280+
case .wasmReturn(_):
2281+
op = WasmReturn(returnCount: inouts.count)
22842282
case .wasmJsCall(let p):
22852283
let parameters = p.parameterTypes.map(WasmTypeEnumToILType)
22862284
let outputs = p.outputTypes.map(WasmTypeEnumToILType)

Sources/Fuzzilli/FuzzIL/WasmOperations.swift

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,11 +74,9 @@ final class Constf64: WasmOperation {
7474

7575
final class WasmReturn: WasmOperation {
7676
override var opcode: Opcode { .wasmReturn(self) }
77-
let returnTypes: [ILType]
7877

79-
init(returnTypes: [ILType]) {
80-
self.returnTypes = returnTypes
81-
super.init(numInputs: returnTypes.count, attributes: [.isJump], requiredContext: [.wasmFunction])
78+
init(returnCount: Int) {
79+
super.init(numInputs: returnCount, attributes: [.isJump], requiredContext: [.wasmFunction])
8280
}
8381
}
8482

Sources/Fuzzilli/Protobuf/operations.pb.swift

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

4125-
public var returnTypes: [Fuzzilli_Protobuf_WasmILType] = []
4126-
41274125
public var unknownFields = SwiftProtobuf.UnknownStorage()
41284126

41294127
public init() {}
@@ -11529,29 +11527,18 @@ extension Fuzzilli_Protobuf_Constf64: SwiftProtobuf.Message, SwiftProtobuf._Mess
1152911527

1153011528
extension Fuzzilli_Protobuf_WasmReturn: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
1153111529
public static let protoMessageName: String = _protobuf_package + ".WasmReturn"
11532-
public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}returnTypes\0")
11530+
public static let _protobuf_nameMap = SwiftProtobuf._NameMap()
1153311531

1153411532
public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
11535-
while let fieldNumber = try decoder.nextFieldNumber() {
11536-
// The use of inline closures is to circumvent an issue where the compiler
11537-
// allocates stack space for every case branch when no optimizations are
11538-
// enabled. https://github.com/apple/swift-protobuf/issues/1034
11539-
switch fieldNumber {
11540-
case 1: try { try decoder.decodeRepeatedMessageField(value: &self.returnTypes) }()
11541-
default: break
11542-
}
11543-
}
11533+
// Load everything into unknown fields
11534+
while try decoder.nextFieldNumber() != nil {}
1154411535
}
1154511536

1154611537
public func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
11547-
if !self.returnTypes.isEmpty {
11548-
try visitor.visitRepeatedMessageField(value: self.returnTypes, fieldNumber: 1)
11549-
}
1155011538
try unknownFields.traverse(visitor: &visitor)
1155111539
}
1155211540

1155311541
public static func ==(lhs: Fuzzilli_Protobuf_WasmReturn, rhs: Fuzzilli_Protobuf_WasmReturn) -> Bool {
11554-
if lhs.returnTypes != rhs.returnTypes {return false}
1155511542
if lhs.unknownFields != rhs.unknownFields {return false}
1155611543
return true
1155711544
}

Sources/Fuzzilli/Protobuf/operations.proto

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -884,7 +884,6 @@ message Constf64 {
884884
}
885885

886886
message WasmReturn {
887-
repeated WasmILType returnTypes = 1;
888887
}
889888

890889
// We only serialize the wasm types as the rest would be overkill and are not needed.

0 commit comments

Comments
 (0)