Skip to content

WasmParser: Specialize more hot paths #153

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion Sources/WasmParser/LEB.swift
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
@usableFromInline
enum LEBError: Swift.Error, Equatable {
case overflow
case integerRepresentationTooLong
case insufficientBytes
}

@inline(__always)
@inlinable
func decodeLEB128<IntType, Stream>(
stream: Stream
) throws -> IntType where IntType: FixedWidthInteger, IntType: UnsignedInteger, Stream: ByteStream {
Expand Down Expand Up @@ -32,6 +33,7 @@ func decodeLEB128<IntType, Stream>(
return result
}

@inlinable
func decodeLEB128<IntType, Stream>(
stream: Stream
) throws -> IntType where IntType: FixedWidthInteger, IntType: RawSignedInteger, Stream: ByteStream {
Expand Down
2 changes: 2 additions & 0 deletions Sources/WasmParser/ParsingLimits.swift
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
/// Limits for parsing WebAssembly modules.
@usableFromInline
struct ParsingLimits {
/// Maximum number of locals in a function.
@usableFromInline
var maxFunctionLocals: UInt64

/// The default limits for parsing.
Expand Down
1 change: 1 addition & 0 deletions Sources/WasmParser/Stream/Stream.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
@usableFromInline
enum StreamError<Element>: Swift.Error, Equatable where Element: Hashable {
case unexpectedEnd(expected: Set<Element>?)
case unexpected(Element, index: Int, expected: Set<Element>?)
Expand Down
Loading