Skip to content

Commit

Permalink
Remove unused types and functions
Browse files Browse the repository at this point in the history
  • Loading branch information
kateinoigakukun committed Jul 1, 2024
1 parent f620e6b commit 39cef2f
Show file tree
Hide file tree
Showing 5 changed files with 1 addition and 84 deletions.
15 changes: 0 additions & 15 deletions Sources/WasmKit/Execution/Instructions/Expression.swift
Original file line number Diff line number Diff line change
@@ -1,15 +1,5 @@
import WasmParser

/// See spec's
/// [definition](https://webassembly.github.io/spec/core/text/instructions.html?highlight=pseudo#control-instructions).
/// > The `block`, `loop` and `if` instructions are structured instructions. They bracket nested sequences of
/// > instructions, called blocks, terminated with, or separated by, end or else pseudo-instructions. As the
/// > grammar prescribes, they must be well-nested.
enum PseudoInstruction {
case `else`
case end
}

struct InstructionSequence: Equatable {
let instructions: UnsafeBufferPointer<Instruction>

Expand Down Expand Up @@ -52,8 +42,3 @@ struct ExpressionRef: Equatable {
self._relativeOffset = UInt32(relativeOffset)
}
}

/// > Note:
/// <https://webassembly.github.io/spec/core/syntax/instructions.html#expressions>

typealias Expression = [WasmParser.Instruction]
6 changes: 0 additions & 6 deletions Sources/WasmKit/Execution/Runtime/ExecutionState.swift
Original file line number Diff line number Diff line change
Expand Up @@ -82,9 +82,3 @@ extension ExecutionState {
store.module(address: stack.currentFrame.module)
}
}

extension ExecutionState {
mutating func pseudo(runtime: Runtime, pseudoInstruction: PseudoInstruction) throws {
fatalError("Unimplemented instruction: pseudo")
}
}
8 changes: 0 additions & 8 deletions Sources/WasmKit/Execution/Runtime/Stack.swift
Original file line number Diff line number Diff line change
@@ -1,21 +1,13 @@
/// > Note:
/// <https://webassembly.github.io/spec/core/exec/runtime.html#stack>
struct Stack {
enum Element: Equatable {
case value(Value)
case frame(Frame)
}

private var limit: UInt16 { UInt16.max }
private var valueStack: ValueStack
private var numberOfValues: Int { valueStack.count }
private var frames: FixedSizeStack<Frame>
var currentFrame: Frame!

var isEmpty: Bool {
self.frames.isEmpty && self.numberOfValues == 0
}

init() {
let limit = UInt16.max
self.valueStack = ValueStack(capacity: Int(limit))
Expand Down
54 changes: 0 additions & 54 deletions Sources/WasmKit/Execution/Types/Value.swift
Original file line number Diff line number Diff line change
Expand Up @@ -445,30 +445,6 @@ extension Value {
}
}

var leadingZeroBitCount: Value {
switch self {
case let .i32(rawValue): return .i32(UInt32(rawValue.leadingZeroBitCount))
case let .i64(rawValue): return .i64(UInt64(rawValue.leadingZeroBitCount))
default: fatalError("Invalid type \(type) for `Value.\(#function)` implementation")
}
}

var trailingZeroBitCount: Value {
switch self {
case let .i32(rawValue): return .i32(UInt32(rawValue.trailingZeroBitCount))
case let .i64(rawValue): return .i64(UInt64(rawValue.trailingZeroBitCount))
default: fatalError("Invalid type \(type) for `Value.\(#function)` implementation")
}
}

var nonzeroBitCount: Value {
switch self {
case let .i32(rawValue): return .i32(UInt32(rawValue.nonzeroBitCount))
case let .i64(rawValue): return .i64(UInt64(rawValue.nonzeroBitCount))
default: fatalError("Invalid type \(type) for `Value.\(#function)` implementation")
}
}

func rotl(_ l: Self) -> Self {
switch (self, l) {
case let (.i32(rawValue), .i32(l)):
Expand Down Expand Up @@ -527,36 +503,6 @@ extension Value {
}
}

static func + (lhs: Self, rhs: Self) -> Self {
switch (lhs, rhs) {
case let (.i32(lhs), .i32(rhs)): return .i32(lhs &+ rhs)
case let (.i64(lhs), .i64(rhs)): return .i64(lhs &+ rhs)
case let (.f32(lhs), .f32(rhs)): return .f32((Float32(bitPattern: lhs) + Float32(bitPattern: rhs)).bitPattern)
case let (.f64(lhs), .f64(rhs)): return .f64((Float64(bitPattern: lhs) + Float64(bitPattern: rhs)).bitPattern)
default: fatalError("Invalid types \(lhs.type) and \(rhs.type) for `Value.\(#function)` implementation")
}
}

static func - (lhs: Self, rhs: Self) -> Self {
switch (lhs, rhs) {
case let (.i32(lhs), .i32(rhs)): return .i32(lhs &- rhs)
case let (.i64(lhs), .i64(rhs)): return .i64(lhs &- rhs)
case let (.f32(lhs), .f32(rhs)): return .f32((Float32(bitPattern: lhs) - Float32(bitPattern: rhs)).bitPattern)
case let (.f64(lhs), .f64(rhs)): return .f64((Float64(bitPattern: lhs) - Float64(bitPattern: rhs)).bitPattern)
default: fatalError("Invalid types \(lhs.type) and \(rhs.type) for `Value.\(#function)` implementation")
}
}

static func * (lhs: Self, rhs: Self) -> Self {
switch (lhs, rhs) {
case let (.i32(lhs), .i32(rhs)): return .i32(lhs &* rhs)
case let (.i64(lhs), .i64(rhs)): return .i64(lhs &* rhs)
case let (.f32(lhs), .f32(rhs)): return .f32((Float32(bitPattern: lhs) * Float32(bitPattern: rhs)).bitPattern)
case let (.f64(lhs), .f64(rhs)): return .f64((Float64(bitPattern: lhs) * Float64(bitPattern: rhs)).bitPattern)
default: fatalError("Invalid types \(lhs.type) and \(rhs.type) for `Value.\(#function)` implementation")
}
}

static func / (lhs: Self, rhs: Self) -> Self {
switch (lhs, rhs) {
case let (.f32(lhs), .f32(rhs)): return .f32((Float32(bitPattern: lhs) / Float32(bitPattern: rhs)).bitPattern)
Expand Down
2 changes: 1 addition & 1 deletion Tests/WasmKitTests/Execution/HostModuleTests.swift
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ final class HostModuleTests: XCTestCase {
type: 0, locals: [],
body: {
[
.control(.call(functionIndex: 1))
.call(functionIndex: 1)
]
}),
],
Expand Down

0 comments on commit 39cef2f

Please sign in to comment.