Skip to content

Commit a4a95f5

Browse files
Merge pull request #84286 from kateinoigakukun/yt/fix-tagged-funcptr-6.2
[6.2][Legacy Driver][wasm] Pass `--table-base` to reserve low function addresses
2 parents 5bae58a + d8ae012 commit a4a95f5

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

lib/Driver/WebAssemblyToolChains.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -188,12 +188,16 @@ toolchains::WebAssembly::constructInvocation(const DynamicLinkJobAction &job,
188188

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

198202
// These custom arguments should be right before the object file at the end.
199203
context.Args.AddAllArgs(Arguments, options::OPT_linker_option_Group);

stdlib/public/SwiftShims/swift/shims/System.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -220,8 +220,8 @@
220220

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

227227
#endif // SWIFT_STDLIB_SHIMS_ABI_SYSTEM_H

0 commit comments

Comments
 (0)