Skip to content

Commit 39b3f84

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

6 files changed

Lines changed: 11 additions & 41 deletions

File tree

Sources/Fuzzilli/Base/ProgramBuilder.swift

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3906,8 +3906,8 @@ public class ProgramBuilder {
39063906
}
39073907

39083908
public func wasmReassign(variable: Variable, to: Variable) {
3909-
assert(b.type(of: variable) == b.type(of: to))
3910-
b.emit(WasmReassign(variableType: b.type(of: variable)), withInputs: [variable, to])
3909+
assert(b.type(of: to).Is(b.type(of: variable)))
3910+
b.emit(WasmReassign(), withInputs: [variable, to])
39113911
}
39123912

39133913
public enum wasmBlockType {

Sources/Fuzzilli/FuzzIL/Instruction.swift

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1234,8 +1234,8 @@ extension Instruction: ProtobufConvertible {
12341234
case .wasmTruncateSatf64Toi64(let op):
12351235
$0.wasmTruncateSatf64Toi64 = Fuzzilli_Protobuf_WasmTruncateSatf64Toi64.with { $0.isSigned = op.isSigned }
12361236

1237-
case .wasmReassign(let op):
1238-
$0.wasmReassign = Fuzzilli_Protobuf_WasmReassign.with { $0.variableType = ILTypeToWasmTypeEnum(op.variableType) }
1237+
case .wasmReassign(_):
1238+
$0.wasmReassign = Fuzzilli_Protobuf_WasmReassign()
12391239
case .wasmDefineGlobal(let op):
12401240
$0.wasmDefineGlobal = Fuzzilli_Protobuf_WasmDefineGlobal.with {
12411241
$0.wasmGlobal.isMutable = op.isMutable
@@ -2369,8 +2369,8 @@ extension Instruction: ProtobufConvertible {
23692369
case .wasmTruncateSatf64Toi64(let p):
23702370
op = WasmTruncateSatf64Toi64(isSigned: p.isSigned)
23712371

2372-
case .wasmReassign(let p):
2373-
op = WasmReassign(variableType: WasmTypeEnumToILType(p.variableType))
2372+
case .wasmReassign(_):
2373+
op = WasmReassign()
23742374
case .wasmDefineGlobal(let p):
23752375
op = WasmDefineGlobal(wasmGlobal: convertWasmGlobal(p.wasmGlobal), isMutable: p.wasmGlobal.isMutable)
23762376
case .wasmDefineTable(let p):

Sources/Fuzzilli/FuzzIL/WasmOperations.swift

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1535,10 +1535,7 @@ final class WasmBranchTable: WasmOperation {
15351535
final class WasmReassign: WasmOperation {
15361536
override var opcode: Opcode { .wasmReassign(self) }
15371537

1538-
let variableType: ILType
1539-
1540-
init(variableType: ILType) {
1541-
self.variableType = variableType
1538+
init() {
15421539
super.init(numInputs: 2, attributes: [.isNotInputMutable], requiredContext: [.wasmFunction])
15431540
}
15441541
}

Sources/Fuzzilli/Lifting/WasmLifter.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1980,7 +1980,7 @@ public class WasmLifter {
19801980
// wasmReassign is quite special, it needs to work for variables stored in various places, e.g. local slots or even globals. As such the lifting here first needs to locate the destination variable.
19811981
var out = Data()
19821982

1983-
var storeInstruction = Data()
1983+
let storeInstruction: Data
19841984
// If the variable is a local, we load the stack slot.
19851985
// Check for the stack location of the `to` variable.
19861986
if let stackSlot = currentFunction!.getStackSlot(for: wasmInstruction.input(0)) {

Sources/Fuzzilli/Protobuf/operations.pb.swift

Lines changed: 3 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -5377,20 +5377,9 @@ public struct Fuzzilli_Protobuf_WasmReassign: Sendable {
53775377
// `Message` and `Message+*Additions` files in the SwiftProtobuf library for
53785378
// methods supported on all messages.
53795379

5380-
public var variableType: Fuzzilli_Protobuf_WasmILType {
5381-
get {return _variableType ?? Fuzzilli_Protobuf_WasmILType()}
5382-
set {_variableType = newValue}
5383-
}
5384-
/// Returns true if `variableType` has been explicitly set.
5385-
public var hasVariableType: Bool {return self._variableType != nil}
5386-
/// Clears the value of `variableType`. Subsequent reads from it will return its default value.
5387-
public mutating func clearVariableType() {self._variableType = nil}
5388-
53895380
public var unknownFields = SwiftProtobuf.UnknownStorage()
53905381

53915382
public init() {}
5392-
5393-
fileprivate var _variableType: Fuzzilli_Protobuf_WasmILType? = nil
53945383
}
53955384

53965385
public struct Fuzzilli_Protobuf_WasmBeginIf: Sendable {
@@ -14212,33 +14201,18 @@ extension Fuzzilli_Protobuf_WasmBranchTable: SwiftProtobuf.Message, SwiftProtobu
1421214201

1421314202
extension Fuzzilli_Protobuf_WasmReassign: SwiftProtobuf.Message, SwiftProtobuf._MessageImplementationBase, SwiftProtobuf._ProtoNameProviding {
1421414203
public static let protoMessageName: String = _protobuf_package + ".WasmReassign"
14215-
public static let _protobuf_nameMap = SwiftProtobuf._NameMap(bytecode: "\0\u{1}variableType\0")
14204+
public static let _protobuf_nameMap = SwiftProtobuf._NameMap()
1421614205

1421714206
public mutating func decodeMessage<D: SwiftProtobuf.Decoder>(decoder: inout D) throws {
14218-
while let fieldNumber = try decoder.nextFieldNumber() {
14219-
// The use of inline closures is to circumvent an issue where the compiler
14220-
// allocates stack space for every case branch when no optimizations are
14221-
// enabled. https://github.com/apple/swift-protobuf/issues/1034
14222-
switch fieldNumber {
14223-
case 1: try { try decoder.decodeSingularMessageField(value: &self._variableType) }()
14224-
default: break
14225-
}
14226-
}
14207+
// Load everything into unknown fields
14208+
while try decoder.nextFieldNumber() != nil {}
1422714209
}
1422814210

1422914211
public func traverse<V: SwiftProtobuf.Visitor>(visitor: inout V) throws {
14230-
// The use of inline closures is to circumvent an issue where the compiler
14231-
// allocates stack space for every if/case branch local when no optimizations
14232-
// are enabled. https://github.com/apple/swift-protobuf/issues/1034 and
14233-
// https://github.com/apple/swift-protobuf/issues/1182
14234-
try { if let v = self._variableType {
14235-
try visitor.visitSingularMessageField(value: v, fieldNumber: 1)
14236-
} }()
1423714212
try unknownFields.traverse(visitor: &visitor)
1423814213
}
1423914214

1424014215
public static func ==(lhs: Fuzzilli_Protobuf_WasmReassign, rhs: Fuzzilli_Protobuf_WasmReassign) -> Bool {
14241-
if lhs._variableType != rhs._variableType {return false}
1424214216
if lhs.unknownFields != rhs.unknownFields {return false}
1424314217
return true
1424414218
}

Sources/Fuzzilli/Protobuf/operations.proto

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1328,7 +1328,6 @@ message WasmBranchTable {
13281328
}
13291329

13301330
message WasmReassign {
1331-
WasmILType variableType = 1;
13321331
}
13331332

13341333
message WasmBeginIf {

0 commit comments

Comments
 (0)