Skip to content
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
8 changes: 6 additions & 2 deletions lib/Driver/WebAssemblyToolChains.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -188,12 +188,16 @@ toolchains::WebAssembly::constructInvocation(const DynamicLinkJobAction &job,

// WebAssembly doesn't reserve low addresses But without "extra inhabitants"
// of the pointer representation, runtime performance and memory footprint are
// worse. So assume that compiler driver uses wasm-ld and --global-base=1024
// to reserve low 1KB.
// worse. So assume that compiler driver uses wasm-ld and --global-base=4096
// to reserve low 4KB.
Arguments.push_back("-Xlinker");
Arguments.push_back(context.Args.MakeArgString(
Twine("--global-base=") +
std::to_string(SWIFT_ABI_WASM32_LEAST_VALID_POINTER)));
Arguments.push_back("-Xlinker");
Arguments.push_back(context.Args.MakeArgString(
Twine("--table-base=") +
std::to_string(SWIFT_ABI_WASM32_LEAST_VALID_POINTER)));

// These custom arguments should be right before the object file at the end.
context.Args.AddAllArgs(Arguments, options::OPT_linker_option_Group);
Expand Down
4 changes: 2 additions & 2 deletions stdlib/public/SwiftShims/swift/shims/System.h
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,8 @@

// WebAssembly doesn't reserve low addresses. But without "extra inhabitants" of
// the pointer representation, runtime performance and memory footprint are
// worse. So assume that compiler driver uses wasm-ld and --global-base=1024 to
// reserve low 1KB.
// worse. So assume that compiler driver uses wasm-ld and --global-base=4096 to
// reserve low 4KB.
#define SWIFT_ABI_WASM32_LEAST_VALID_POINTER 4096

#endif // SWIFT_STDLIB_SHIMS_ABI_SYSTEM_H
42 changes: 42 additions & 0 deletions test/Interpreter/enum.swift
Original file line number Diff line number Diff line change
Expand Up @@ -745,3 +745,45 @@ func reproduction<T: Init>(_ x: Int, _ y: Int, _ t: T) {

// CHECK: there is no byte
reproduction(2, 3, TrailingByte())

do {
// regression test for https://github.com/swiftlang/swift-driver/pull/1987
@inline(never) func blackhole<T>(_ t: T) { }

final class Context {
func doSomething() {}
deinit {
print("Context deinit")
}
}

enum MyOptional<Value> {
case some(Value)
case none
}

final class _GenericStorage<Value> {
let value: MyOptional<Value>

init(value: Value) {
self.value = .some(value)
}

func unwrapAndCopy() {
if case .some(let value) = value {
blackhole(value)
}
}
}

let test = _GenericStorage(
value: Context().doSomething,
)
// CHECK: test.unwrapAndCopy
print("test.unwrapAndCopy")
test.unwrapAndCopy()
// CHECK: test.unwrapAndCopy
print("test.unwrapAndCopy")
test.unwrapAndCopy()
// CHECK: Context deinit
}
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,11 @@ def _build_stdlib(self, host_target, target_triple, llvm_cmake_dir):
# Test configuration
self.cmake_options.define('SWIFT_INCLUDE_TESTS:BOOL', 'TRUE')
self.cmake_options.define('SWIFT_ENABLE_SOURCEKIT_TESTS:BOOL', 'FALSE')
lit_test_paths = ['IRGen', 'stdlib', 'Concurrency/Runtime', 'embedded']
lit_test_paths = [
'IRGen', 'stdlib', 'Concurrency/Runtime', 'embedded',
# TODO(katei): Enable all interpreter tests
'Interpreter/enum.swift',
]
lit_test_paths = [os.path.join(
self.build_dir, 'test-wasi-wasm32', path) for path in lit_test_paths]
self.cmake_options.define('SWIFT_LIT_TEST_PATHS:STRING',
Expand Down