Skip to content

[WebAssembly] Add wasm32 support to stdlib String #29881

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 1 commit into from
Feb 18, 2020
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: 2 additions & 2 deletions stdlib/public/core/SmallString.swift
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ internal struct _SmallString {
extension _SmallString {
@inlinable @inline(__always)
internal static var capacity: Int {
#if arch(i386) || arch(arm)
#if arch(i386) || arch(arm) || arch(wasm32)
return 10
#else
return 15
Expand Down Expand Up @@ -264,7 +264,7 @@ extension _SmallString {

self.init(leading: leading, trailing: trailing, count: count)
}

@inline(__always)
internal init(
initializingUTF8With initializer: (
Expand Down
8 changes: 4 additions & 4 deletions stdlib/public/core/StringObject.swift
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ internal struct _StringObject {
internal init(zero: ()) { self._storage = 0 }
}

#if arch(i386) || arch(arm)
#if arch(i386) || arch(arm) || arch(wasm32)
@usableFromInline @frozen
internal enum Variant {
case immortal(UInt)
Expand Down Expand Up @@ -512,7 +512,7 @@ extension _StringObject {
// spare bits (the most significant nibble) in a pointer.
let word1 = small.rawBits.0.littleEndian
let word2 = small.rawBits.1.littleEndian
#if arch(i386) || arch(arm)
#if arch(i386) || arch(arm) || arch(wasm32)
// On 32-bit, we need to unpack the small string.
let smallStringDiscriminatorAndCount: UInt64 = 0xFF00_0000_0000_0000

Expand Down Expand Up @@ -819,7 +819,7 @@ extension _StringObject {

@inline(__always)
internal var nativeStorage: __StringStorage {
#if arch(i386) || arch(arm)
#if arch(i386) || arch(arm) || arch(wasm32)
guard case .native(let storage) = _variant else {
_internalInvariantFailure()
}
Expand Down Expand Up @@ -987,7 +987,7 @@ extension _StringObject {
) {
let countAndFlags = CountAndFlags(sharedCount: length, isASCII: isASCII)
let discriminator = Nibbles.largeCocoa(providesFastUTF8: providesFastUTF8)
#if arch(i386) || arch(arm)
#if arch(i386) || arch(arm) || arch(wasm32)
self.init(
variant: .bridged(cocoa),
discriminator: discriminator,
Expand Down
2 changes: 1 addition & 1 deletion stdlib/public/core/StringStorage.swift
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ extension __StringStorage {
let count = try initializer(buffer)

let countAndFlags = CountAndFlags(mortalCount: count, isASCII: false)
#if arch(i386) || arch(arm)
#if arch(i386) || arch(arm) || arch(wasm32)
storage._count = countAndFlags.count
storage._flags = countAndFlags.flags
#else
Expand Down