Skip to content

Commit becaeb1

Browse files
committed
Remove changes unrelated to the protocol
1 parent a35b73e commit becaeb1

File tree

10 files changed

+33
-127
lines changed

10 files changed

+33
-127
lines changed

Sources/WAT/Encoder.swift

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@ extension TableType: WasmEncodable {
158158
struct ElementExprCollector: AnyInstructionVisitor {
159159
typealias Output = Void
160160

161-
var binaryOffset: Int = 0
162161
var isAllRefFunc: Bool = true
163162
var instructions: [Instruction] = []
164163

@@ -444,7 +443,6 @@ extension WatParser.DataSegmentDecl {
444443
}
445444

446445
struct ExpressionEncoder: BinaryInstructionEncoder {
447-
var binaryOffset: Int = 0
448446
var encoder = Encoder()
449447
var hasDataSegmentInstruction: Bool = false
450448

Sources/WAT/Parser/WastParser.swift

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,6 @@ struct WastParser {
5454
}
5555

5656
struct ConstExpressionCollector: WastConstInstructionVisitor {
57-
var binaryOffset: Int = 0
5857
let addValue: (Value) -> Void
5958

6059
mutating func visitI32Const(value: Int32) throws { addValue(.i32(UInt32(bitPattern: value))) }

Sources/WasmKit/Execution/Errors.swift

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -5,21 +5,19 @@ import struct WasmParser.Import
55
/// The backtrace of the trap.
66
struct Backtrace: CustomStringConvertible, Sendable {
77
/// A symbol in the backtrace.
8-
struct Symbol: @unchecked Sendable {
8+
struct Symbol {
99
/// The name of the symbol.
1010
let name: String?
11-
let address: Pc
1211
}
1312

1413
/// The symbols in the backtrace.
15-
let symbols: [Symbol]
14+
let symbols: [Symbol?]
1615

1716
/// Textual description of the backtrace.
1817
var description: String {
19-
print("backtrace contains \(symbols.count) symbols")
20-
return symbols.enumerated().map { (index, symbol) in
21-
let name = symbol.name ?? "unknown"
22-
return " \(index): (\(symbol.address)) \(name)"
18+
symbols.enumerated().map { (index, symbol) in
19+
let name = symbol?.name ?? "unknown"
20+
return " \(index): \(name)"
2321
}.joined(separator: "\n")
2422
}
2523
}

Sources/WasmKit/Execution/Execution.swift

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import _CWasmKit
44
///
55
/// Each new invocation through exported function has a separate ``Execution``
66
/// even though the invocation happens during another invocation.
7-
struct Execution: ~Copyable {
7+
struct Execution {
88
/// The reference to the ``Store`` associated with the execution.
99
let store: StoreRef
1010
/// The end of the VM stack space.
@@ -14,13 +14,6 @@ struct Execution: ~Copyable {
1414
/// - Note: If the trap is set, it must be released manually.
1515
private var trap: (error: UnsafeRawPointer, sp: Sp)? = nil
1616

17-
#if WasmDebuggingSupport
18-
package init(store: StoreRef, stackEnd: UnsafeMutablePointer<StackSlot>) {
19-
self.store = store
20-
self.stackEnd = stackEnd
21-
}
22-
#endif
23-
2417
/// Executes the given closure with a new execution state associated with
2518
/// the given ``Store`` instance.
2619
static func with<T>(
@@ -68,15 +61,18 @@ struct Execution: ~Copyable {
6861

6962
static func captureBacktrace(sp: Sp, store: Store) -> Backtrace {
7063
var frames = FrameIterator(sp: sp)
71-
var symbols: [Backtrace.Symbol] = []
72-
64+
var symbols: [Backtrace.Symbol?] = []
7365
while let frame = frames.next() {
7466
guard let function = frame.function else {
75-
symbols.append(.init(name: nil, address: frame.pc))
67+
symbols.append(nil)
7668
continue
7769
}
7870
let symbolName = store.nameRegistry.symbolicate(.wasm(function))
79-
symbols.append(.init(name: symbolName, address: frame.pc))
71+
symbols.append(
72+
Backtrace.Symbol(
73+
name: symbolName
74+
)
75+
)
8076
}
8177
return Backtrace(symbols: symbols)
8278
}
@@ -252,7 +248,7 @@ extension Sp {
252248
nonmutating set { self[-1] = UInt64(UInt(bitPattern: newValue)) }
253249
}
254250

255-
var currentInstance: InternalInstance? {
251+
fileprivate var currentInstance: InternalInstance? {
256252
currentFunction?.instance
257253
}
258254
}

Sources/WasmKit/Execution/Function.swift

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -243,7 +243,7 @@ struct WasmFunctionEntity {
243243
switch code {
244244
case .uncompiled(let code):
245245
return try compile(store: store, code: code)
246-
case .compiled(let iseq), .debuggable(_, let iseq):
246+
case .compiled(let iseq), .compiledAndPatchable(_, let iseq):
247247
return iseq
248248
}
249249
}
@@ -280,14 +280,10 @@ extension EntityHandle<WasmFunctionEntity> {
280280
case .uncompiled(let code):
281281
return try self.withValue {
282282
let iseq = try $0.compile(store: store, code: code)
283-
if $0.instance.isDebuggable {
284-
$0.code = .debuggable(code, iseq)
285-
} else {
286-
$0.code = .compiled(iseq)
287-
}
283+
$0.code = .compiled(iseq)
288284
return iseq
289285
}
290-
case .compiled(let iseq), .debuggable(_, let iseq):
286+
case .compiled(let iseq), .compiledAndPatchable(_, let iseq):
291287
return iseq
292288
}
293289
}
@@ -320,7 +316,7 @@ struct InstructionSequence {
320316
enum CodeBody {
321317
case uncompiled(InternalUncompiledCode)
322318
case compiled(InstructionSequence)
323-
case debuggable(InternalUncompiledCode, InstructionSequence)
319+
case compiledAndPatchable(InternalUncompiledCode, InstructionSequence)
324320
}
325321

326322
extension Reference {

Sources/WasmKit/Execution/Instances.swift

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,6 @@ struct InstanceEntity /* : ~Copyable */ {
8383
var functionRefs: Set<InternalFunction>
8484
var features: WasmFeatureSet
8585
var dataCount: UInt32?
86-
var isDebuggable: Bool
87-
88-
/// Mapping from iSeq Pc to instruction addresses in the original binary.
89-
/// Used for handling current call stack requests issued by a ``Debugger`` instance.
90-
var iseqToWasmMapping: [Pc: Int]
91-
92-
/// Mapping from Wasm instruction addresses in the original binary to iSeq instruction addresses.
93-
/// Used for handling breakpoint requests issued by a ``Debugger`` instance.
94-
var wasmToIseqMapping: [Int: Pc]
9586

9687
static var empty: InstanceEntity {
9788
InstanceEntity(
@@ -105,10 +96,7 @@ struct InstanceEntity /* : ~Copyable */ {
10596
exports: [:],
10697
functionRefs: [],
10798
features: [],
108-
dataCount: nil,
109-
isDebuggable: false,
110-
iseqToWasmMapping: [:],
111-
wasmToIseqMapping: [:]
99+
dataCount: nil
112100
)
113101
}
114102

Sources/WasmKit/Execution/StoreAllocator.swift

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -251,8 +251,7 @@ extension StoreAllocator {
251251
module: Module,
252252
engine: Engine,
253253
resourceLimiter: any ResourceLimiter,
254-
imports: Imports,
255-
isDebuggable: Bool
254+
imports: Imports
256255
) throws -> InternalInstance {
257256
// Step 1 of module allocation algorithm, according to Wasm 2.0 spec.
258257

@@ -451,10 +450,7 @@ extension StoreAllocator {
451450
exports: exports,
452451
functionRefs: functionRefs,
453452
features: module.features,
454-
dataCount: module.dataCount,
455-
isDebuggable: isDebuggable,
456-
iseqToWasmMapping: [:],
457-
wasmToIseqMapping: [:]
453+
dataCount: module.dataCount
458454
)
459455
instancePointer.initialize(to: instanceEntity)
460456
instanceInitialized = true

Sources/WasmKit/Module.swift

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -138,23 +138,9 @@ public struct Module {
138138
Instance(handle: try self.instantiateHandle(store: store, imports: imports), store: store)
139139
}
140140

141-
#if WasmDebuggingSupport
142-
/// Instantiate this module in the given imports.
143-
///
144-
/// - Parameters:
145-
/// - store: The ``Store`` to allocate the instance in.
146-
/// - imports: The imports to use for instantiation. All imported entities
147-
/// must be allocated in the given store.
148-
/// - isDebuggable: Whether the module should support debugging actions
149-
/// (breakpoints etc) after instantiation.
150-
public func instantiate(store: Store, imports: Imports = [:], isDebuggable: Bool) throws -> Instance {
151-
Instance(handle: try self.instantiateHandle(store: store, imports: imports, isDebuggable: isDebuggable), store: store)
152-
}
153-
#endif
154-
155141
/// > Note:
156142
/// <https://webassembly.github.io/spec/core/exec/modules.html#instantiation>
157-
private func instantiateHandle(store: Store, imports: Imports, isDebuggable: Bool = false) throws -> InternalInstance {
143+
private func instantiateHandle(store: Store, imports: Imports) throws -> InternalInstance {
158144
try ModuleValidator(module: self).validate()
159145

160146
// Steps 5-8.
@@ -166,8 +152,7 @@ public struct Module {
166152
let instance = try store.allocator.allocate(
167153
module: self, engine: store.engine,
168154
resourceLimiter: store.resourceLimiter,
169-
imports: imports,
170-
isDebuggable: isDebuggable
155+
imports: imports
171156
)
172157

173158
if let nameSection = customSections.first(where: { $0.name == "name" }) {

0 commit comments

Comments
 (0)