Skip to content

Commit ebc7eb4

Browse files
committed
[ldd][WebAssembly] Add support for the custom-page-sizes proposal
This commit adds support for WebAssembly's custom-page-sizes proposal to `wasm-ld`. An overview of the proposal can be found [here](https://github.com/WebAssembly/custom-page-sizes/blob/main/proposals/custom-page-sizes/Overview.md). In a sentence, it allows customizing a Wasm memory's page size, enabling Wasm to target environments with less than 64KiB of memory (the default WebAssembly page size) available for Wasm memories. This commit contains the following: * Adds a `--page-size=N` CLI flag to `wasm-ld` for configuring the linked Wasm binary's linear memory's page size. * When the page size is configured to a non-default value, then the final Wasm binary will use the encodings defined in the custom-page-sizes proposal to declare the linear memory's page size. * Defines a `__wasm_first_page_end` symbol, whose address points to the first page in the Wasm linear memory, a.k.a. is the Wasm memory's page size. This allows writing code that is compatible with any page size, and doesn't require re-compiling its object code. At the same time, because it just lowers to a constant rather than a memory access or something, it enables link-time optimization. * Adds tests for these new features.
1 parent a36a67c commit ebc7eb4

23 files changed

+116
-25
lines changed

lld/test/wasm/initial-heap.test

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ RUN: not wasm-ld %t.o -o %t5.wasm --stack-first -z stack-size=131072 --initial-h
2020
RUN: not wasm-ld %t.o -o %t6.wasm --stack-first -z stack-size=65536 --initial-heap=131072 --initial-memory=131072 2>&1 | FileCheck %s --check-prefix INITIAL-MEMORY-TOO-SMALL
2121
RUN: not wasm-ld %t.o -o %t7.wasm --stack-first -z stack-size=65536 --initial-heap=131072 --max-memory=131072 2>&1 | FileCheck %s --check-prefix MAX-MEMORY-TOO-SMALL
2222

23-
NOT-PAGE-MULTIPLE: initial heap must be 65536-byte aligned
23+
NOT-PAGE-MULTIPLE: initial heap must be aligned to the page size (65536 bytes)
2424
TOO-LARGE-BY-ITSELF: initial heap too large, cannot be greater than 4294901760
2525
TOO-LARGE-WITH-STACK: initial heap too large, cannot be greater than 4294836224
2626
INITIAL-MEMORY-TOO-SMALL: initial memory too small, 196608 bytes needed

lld/test/wasm/mutable-global-exports.s

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,9 @@ _start:
101101
# CHECK-ALL-NEXT: - Name: __table_base
102102
# CHECK-ALL-NEXT: Kind: GLOBAL
103103
# CHECK-ALL-NEXT: Index: 10
104+
# CHECK-ALL-NEXT: - Name: __wasm_first_page_end
105+
# CHECK-ALL-NEXT: Kind: GLOBAL
106+
# CHECK-ALL-NEXT: Index: 11
104107
# CHECK-ALL-NEXT: - Type: CODE
105108

106109
# CHECK-ALL: Name: target_features
@@ -110,4 +113,3 @@ _start:
110113
# CHECK-ALL-NEXT: - Prefix: USED
111114
# CHECK-ALL-NEXT: Name: mutable-globals
112115
# CHECK-ALL-NEXT: ...
113-

lld/test/wasm/page-size.s

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
# RUN: llvm-mc -filetype=obj -triple=wasm32-unknown-unknown %s -o %t.o
2+
3+
.globl _start
4+
_start:
5+
.functype _start () -> (i32)
6+
i32.const __wasm_first_page_end
7+
end_function
8+
9+
# Add a symbol to smoke test that `__wasm_first_page_end` is absolute and not
10+
# relative to other data.
11+
.section .data.foo,"",@
12+
foo:
13+
.int32 0x11111111
14+
.size foo, 4
15+
16+
# RUN: wasm-ld -no-gc-sections -o %t.custom.wasm %t.o --page-size=1
17+
# RUN: obj2yaml %t.custom.wasm | FileCheck %s --check-prefix=CHECK-CUSTOM
18+
19+
# CHECK-CUSTOM: - Type: MEMORY
20+
# CHECK-CUSTOM-NEXT: Memories:
21+
# CHECK-CUSTOM-NEXT: - Flags: [ HAS_PAGE_SIZE ]
22+
# CHECK-CUSTOM-NEXT: Minimum: 0x10410
23+
# CHECK-CUSTOM-NEXT: PageSize: 0x1
24+
25+
# RUN: llvm-objdump --disassemble-symbols=_start %t.custom.wasm | FileCheck %s --check-prefix=CHECK-CUSTOM-DIS
26+
27+
# CHECK-CUSTOM-DIS: <_start>:
28+
# CHECK-CUSTOM-DIS: i32.const 1
29+
# CHECK-CUSTOM-DIS-NEXT: end
30+
31+
# RUN: wasm-ld -no-gc-sections -o %t.default.wasm %t.o
32+
# RUN: obj2yaml %t.default.wasm | FileCheck %s --check-prefix=CHECK-DEFAULT
33+
34+
# CHECK-DEFAULT: - Type: MEMORY
35+
# CHECK-DEFAULT-NEXT: Memories:
36+
# CHECK-DEFAULT-NEXT: Minimum: 0x2
37+
# CHECK-DEFAULT-NEXT: - Type: GLOBAL
38+
39+
# RUN: llvm-objdump --disassemble-symbols=_start %t.default.wasm | FileCheck %s --check-prefix=CHECK-DEFAULT-DIS
40+
41+
# CHECK-DEFAULT-DIS: <_start>:
42+
# CHECK-DEFAULT-DIS: i32.const 65536
43+
# CHECK-DEFAULT-DIS-NEXT: end

lld/test/wasm/shared-memory.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ Sections:
5656
Flags: [ ]
5757
...
5858

59-
# SHARED-UNALIGNED: maximum memory must be 65536-byte aligned{{$}}
59+
# SHARED-UNALIGNED: maximum memory must be aligned to the page size (65536 bytes)
6060

6161
# SHARED-NO-ATOMICS: 'atomics' feature must be used in order to use shared memory
6262

lld/wasm/Config.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,7 @@ struct Config {
9494
// runtime).
9595
uint64_t tableBase;
9696
uint64_t zStackSize;
97+
uint64_t pageSize;
9798
unsigned ltoPartitions;
9899
unsigned ltoo;
99100
llvm::CodeGenOptLevel ltoCgo;

lld/wasm/Driver.cpp

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,10 @@ static void readConfigs(opt::InputArgList &args) {
643643
ctx.arg.maxMemory = args::getInteger(args, OPT_max_memory, 0);
644644
ctx.arg.noGrowableMemory = args.hasArg(OPT_no_growable_memory);
645645
ctx.arg.zStackSize =
646-
args::getZOptionValue(args, OPT_z, "stack-size", WasmPageSize);
646+
args::getZOptionValue(args, OPT_z, "stack-size", WasmDefaultPageSize);
647+
ctx.arg.pageSize = args::getInteger(args, OPT_page_size, WasmDefaultPageSize);
648+
if (ctx.arg.pageSize != 1 && ctx.arg.pageSize != WasmDefaultPageSize)
649+
error("--page_size=N must be either 1 or 65536");
647650

648651
// -Bdynamic by default if -pie or -shared is specified.
649652
if (ctx.arg.pie || ctx.arg.shared)
@@ -1000,6 +1003,11 @@ static void createOptionalSymbols() {
10001003
WasmSym::definedTableBase = symtab->addOptionalDataSymbol("__table_base");
10011004
}
10021005

1006+
WasmSym::firstPageEnd =
1007+
symtab->addOptionalDataSymbol("__wasm_first_page_end");
1008+
if (WasmSym::firstPageEnd)
1009+
WasmSym::firstPageEnd->setVA(ctx.arg.pageSize);
1010+
10031011
// For non-shared memory programs we still need to define __tls_base since we
10041012
// allow object files built with TLS to be linked into single threaded
10051013
// programs, and such object files can contain references to this symbol.

lld/wasm/Options.td

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,9 @@ def import_table: FF<"import-table">,
232232
def initial_heap: JJ<"initial-heap=">,
233233
HelpText<"Initial size of the heap">;
234234

235+
def page_size: JJ<"page-size=">,
236+
HelpText<"The Wasm page size (Defaults to 65536)">;
237+
235238
def initial_memory: JJ<"initial-memory=">,
236239
HelpText<"Initial size of the linear memory">;
237240

lld/wasm/SymbolTable.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -792,7 +792,7 @@ Symbol *SymbolTable::addUndefinedTag(StringRef name,
792792
}
793793

794794
TableSymbol *SymbolTable::createUndefinedIndirectFunctionTable(StringRef name) {
795-
WasmLimits limits{0, 0, 0}; // Set by the writer.
795+
WasmLimits limits{0, 0, 0, 0}; // Set by the writer.
796796
WasmTableType *type = make<WasmTableType>();
797797
type->ElemType = ValType::FUNCREF;
798798
type->Limits = limits;
@@ -807,7 +807,7 @@ TableSymbol *SymbolTable::createUndefinedIndirectFunctionTable(StringRef name) {
807807

808808
TableSymbol *SymbolTable::createDefinedIndirectFunctionTable(StringRef name) {
809809
const uint32_t invalidIndex = -1;
810-
WasmLimits limits{0, 0, 0}; // Set by the writer.
810+
WasmLimits limits{0, 0, 0, 0}; // Set by the writer.
811811
WasmTableType type{ValType::FUNCREF, limits};
812812
WasmTable desc{invalidIndex, type, name};
813813
InputTable *table = make<InputTable>(desc, nullptr);

lld/wasm/Symbols.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ DefinedFunction *WasmSym::applyGlobalRelocs;
8484
DefinedFunction *WasmSym::applyTLSRelocs;
8585
DefinedFunction *WasmSym::applyGlobalTLSRelocs;
8686
DefinedFunction *WasmSym::initTLS;
87+
DefinedData *WasmSym::firstPageEnd;
8788
DefinedFunction *WasmSym::startFunction;
8889
DefinedData *WasmSym::dsoHandle;
8990
DefinedData *WasmSym::dataEnd;

lld/wasm/Symbols.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -577,6 +577,10 @@ struct WasmSym {
577577
static DefinedData *heapBase;
578578
static DefinedData *heapEnd;
579579

580+
// __wasm_first_page_end
581+
// A symbol whose address is the end of the first page in memory (if any).
582+
static DefinedData *firstPageEnd;
583+
580584
// __wasm_init_memory_flag
581585
// Symbol whose contents are nonzero iff memory has already been initialized.
582586
static DefinedData *initMemoryFlag;

lld/wasm/SyntheticSections.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -369,10 +369,14 @@ void MemorySection::writeBody() {
369369
flags |= WASM_LIMITS_FLAG_IS_SHARED;
370370
if (ctx.arg.is64.value_or(false))
371371
flags |= WASM_LIMITS_FLAG_IS_64;
372+
if (ctx.arg.pageSize != WasmDefaultPageSize)
373+
flags |= WASM_LIMITS_FLAG_HAS_PAGE_SIZE;
372374
writeUleb128(os, flags, "memory limits flags");
373375
writeUleb128(os, numMemoryPages, "initial pages");
374376
if (hasMax)
375377
writeUleb128(os, maxMemoryPages, "max pages");
378+
if (ctx.arg.pageSize != WasmDefaultPageSize)
379+
writeUleb128(os, llvm::Log2_64(ctx.arg.pageSize), "page size");
376380
}
377381

378382
void TagSection::writeBody() {

lld/wasm/Writer.cpp

Lines changed: 13 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -320,6 +320,12 @@ static void setGlobalPtr(DefinedGlobal *g, uint64_t memoryPtr) {
320320
g->global->setPointerValue(memoryPtr);
321321
}
322322

323+
static void checkPageAligned(StringRef name, uint64_t value) {
324+
if (value != alignTo(value, ctx.arg.pageSize))
325+
error(name + " must be aligned to the page size (" +
326+
Twine(ctx.arg.pageSize) + " bytes)");
327+
}
328+
323329
// Fix the memory layout of the output binary. This assigns memory offsets
324330
// to each of the input data sections as well as the explicit stack region.
325331
// The default memory layout is as follows, from low to high.
@@ -445,8 +451,7 @@ void Writer::layoutMemory() {
445451
}
446452

447453
if (ctx.arg.initialHeap != 0) {
448-
if (ctx.arg.initialHeap != alignTo(ctx.arg.initialHeap, WasmPageSize))
449-
error("initial heap must be " + Twine(WasmPageSize) + "-byte aligned");
454+
checkPageAligned("initial heap", ctx.arg.initialHeap);
450455
uint64_t maxInitialHeap = maxMemorySetting - memoryPtr;
451456
if (ctx.arg.initialHeap > maxInitialHeap)
452457
error("initial heap too large, cannot be greater than " +
@@ -455,8 +460,7 @@ void Writer::layoutMemory() {
455460
}
456461

457462
if (ctx.arg.initialMemory != 0) {
458-
if (ctx.arg.initialMemory != alignTo(ctx.arg.initialMemory, WasmPageSize))
459-
error("initial memory must be " + Twine(WasmPageSize) + "-byte aligned");
463+
checkPageAligned("initial memory", ctx.arg.initialMemory);
460464
if (memoryPtr > ctx.arg.initialMemory)
461465
error("initial memory too small, " + Twine(memoryPtr) + " bytes needed");
462466
if (ctx.arg.initialMemory > maxMemorySetting)
@@ -465,9 +469,9 @@ void Writer::layoutMemory() {
465469
memoryPtr = ctx.arg.initialMemory;
466470
}
467471

468-
memoryPtr = alignTo(memoryPtr, WasmPageSize);
472+
memoryPtr = alignTo(memoryPtr, ctx.arg.pageSize);
469473

470-
out.memorySec->numMemoryPages = memoryPtr / WasmPageSize;
474+
out.memorySec->numMemoryPages = memoryPtr / ctx.arg.pageSize;
471475
log("mem: total pages = " + Twine(out.memorySec->numMemoryPages));
472476

473477
if (WasmSym::heapEnd) {
@@ -480,8 +484,7 @@ void Writer::layoutMemory() {
480484

481485
uint64_t maxMemory = 0;
482486
if (ctx.arg.maxMemory != 0) {
483-
if (ctx.arg.maxMemory != alignTo(ctx.arg.maxMemory, WasmPageSize))
484-
error("maximum memory must be " + Twine(WasmPageSize) + "-byte aligned");
487+
checkPageAligned("maximum memory", ctx.arg.maxMemory);
485488
if (memoryPtr > ctx.arg.maxMemory)
486489
error("maximum memory too small, " + Twine(memoryPtr) + " bytes needed");
487490
if (ctx.arg.maxMemory > maxMemorySetting)
@@ -503,7 +506,7 @@ void Writer::layoutMemory() {
503506
}
504507

505508
if (maxMemory != 0) {
506-
out.memorySec->maxMemoryPages = maxMemory / WasmPageSize;
509+
out.memorySec->maxMemoryPages = maxMemory / ctx.arg.pageSize;
507510
log("mem: max pages = " + Twine(out.memorySec->maxMemoryPages));
508511
}
509512
}
@@ -932,7 +935,7 @@ static void finalizeIndirectFunctionTable() {
932935
}
933936

934937
uint32_t tableSize = ctx.arg.tableBase + out.elemSec->numEntries();
935-
WasmLimits limits = {0, tableSize, 0};
938+
WasmLimits limits = {0, tableSize, 0, 0};
936939
if (WasmSym::indirectFunctionTable->isDefined() && !ctx.arg.growableTable) {
937940
limits.Flags |= WASM_LIMITS_FLAG_HAS_MAX;
938941
limits.Maximum = limits.Minimum;

lld/wasm/WriterUtils.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,8 @@ static std::string toString(const llvm::wasm::WasmLimits &limits) {
6969
ret += "; min=" + std::to_string(limits.Minimum);
7070
if (limits.Flags & WASM_LIMITS_FLAG_HAS_MAX)
7171
ret += "; max=" + std::to_string(limits.Maximum);
72+
if (limits.Flags & WASM_LIMITS_FLAG_HAS_PAGE_SIZE)
73+
ret += "; pagesize=" + std::to_string(limits.PageSize);
7274
return ret;
7375
}
7476

@@ -200,6 +202,8 @@ void writeLimits(raw_ostream &os, const WasmLimits &limits) {
200202
writeUleb128(os, limits.Minimum, "limits min");
201203
if (limits.Flags & WASM_LIMITS_FLAG_HAS_MAX)
202204
writeUleb128(os, limits.Maximum, "limits max");
205+
if (limits.Flags & WASM_LIMITS_FLAG_HAS_PAGE_SIZE)
206+
writeUleb128(os, llvm::Log2_64(limits.PageSize), "page size");
203207
}
204208

205209
void writeGlobalType(raw_ostream &os, const WasmGlobalType &type) {

llvm/include/llvm/BinaryFormat/Wasm.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,8 +28,9 @@ const char WasmMagic[] = {'\0', 'a', 's', 'm'};
2828
const uint32_t WasmVersion = 0x1;
2929
// Wasm linking metadata version
3030
const uint32_t WasmMetadataVersion = 0x2;
31-
// Wasm uses a 64k page size
32-
const uint32_t WasmPageSize = 65536;
31+
// Wasm uses a 64k page size by default (but the custom-page-sizes proposal
32+
// allows changing it)
33+
const uint32_t WasmDefaultPageSize = 65536;
3334

3435
enum : unsigned {
3536
WASM_SEC_CUSTOM = 0, // Custom / User-defined section
@@ -157,6 +158,7 @@ enum : unsigned {
157158
WASM_LIMITS_FLAG_HAS_MAX = 0x1,
158159
WASM_LIMITS_FLAG_IS_SHARED = 0x2,
159160
WASM_LIMITS_FLAG_IS_64 = 0x4,
161+
WASM_LIMITS_FLAG_HAS_PAGE_SIZE = 0x8,
160162
};
161163

162164
enum : unsigned {
@@ -319,6 +321,7 @@ struct WasmLimits {
319321
uint8_t Flags;
320322
uint64_t Minimum;
321323
uint64_t Maximum;
324+
uint32_t PageSize;
322325
};
323326

324327
struct WasmTableType {
@@ -534,7 +537,10 @@ inline bool operator!=(const WasmGlobalType &LHS, const WasmGlobalType &RHS) {
534537
inline bool operator==(const WasmLimits &LHS, const WasmLimits &RHS) {
535538
return LHS.Flags == RHS.Flags && LHS.Minimum == RHS.Minimum &&
536539
(LHS.Flags & WASM_LIMITS_FLAG_HAS_MAX ? LHS.Maximum == RHS.Maximum
537-
: true);
540+
: true) &&
541+
(LHS.Flags & WASM_LIMITS_FLAG_HAS_PAGE_SIZE
542+
? LHS.PageSize == RHS.PageSize
543+
: true);
538544
}
539545

540546
inline bool operator==(const WasmTableType &LHS, const WasmTableType &RHS) {

llvm/include/llvm/BinaryFormat/WasmTraits.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,10 +64,10 @@ template <> struct DenseMapInfo<wasm::WasmGlobalType, void> {
6464
// Traits for using WasmLimits in a DenseMap
6565
template <> struct DenseMapInfo<wasm::WasmLimits, void> {
6666
static wasm::WasmLimits getEmptyKey() {
67-
return wasm::WasmLimits{0xff, 0xff, 0xff};
67+
return wasm::WasmLimits{0xff, 0xff, 0xff, 0xff};
6868
}
6969
static wasm::WasmLimits getTombstoneKey() {
70-
return wasm::WasmLimits{0xee, 0xee, 0xee};
70+
return wasm::WasmLimits{0xee, 0xee, 0xee, 0xee};
7171
}
7272
static unsigned getHashValue(const wasm::WasmLimits &Limits) {
7373
unsigned Hash = hash_value(Limits.Flags);

llvm/include/llvm/MC/MCSymbolWasm.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@ class MCSymbolWasm : public MCSymbol {
147147
uint8_t flags = wasm::WASM_LIMITS_FLAG_NONE) {
148148
// Declare a table with element type VT and no limits (min size 0, no max
149149
// size).
150-
wasm::WasmLimits Limits = {flags, 0, 0};
150+
wasm::WasmLimits Limits = {flags, 0, 0, 0};
151151
setTableType({VT, Limits});
152152
}
153153
};

llvm/include/llvm/ObjectYAML/WasmYAML.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ struct Limits {
4848
LimitFlags Flags;
4949
yaml::Hex32 Minimum;
5050
yaml::Hex32 Maximum;
51+
yaml::Hex32 PageSize;
5152
};
5253

5354
struct Table {

llvm/lib/MC/WasmObjectWriter.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -845,7 +845,8 @@ void WasmObjectWriter::writeImportSection(ArrayRef<wasm::WasmImport> Imports,
845845
if (Imports.empty())
846846
return;
847847

848-
uint64_t NumPages = (DataSize + wasm::WasmPageSize - 1) / wasm::WasmPageSize;
848+
uint64_t NumPages =
849+
(DataSize + wasm::WasmDefaultPageSize - 1) / wasm::WasmDefaultPageSize;
849850

850851
SectionBookkeeping Section;
851852
startSection(Section, wasm::WASM_SEC_IMPORT);

llvm/lib/Object/WasmObjectFile.cpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -291,6 +291,12 @@ static wasm::WasmLimits readLimits(WasmObjectFile::ReadContext &Ctx) {
291291
Result.Minimum = readVaruint64(Ctx);
292292
if (Result.Flags & wasm::WASM_LIMITS_FLAG_HAS_MAX)
293293
Result.Maximum = readVaruint64(Ctx);
294+
if (Result.Flags & wasm::WASM_LIMITS_FLAG_HAS_PAGE_SIZE) {
295+
uint32_t PageSizeLog2 = readVaruint32(Ctx);
296+
if (PageSizeLog2 >= 32)
297+
report_fatal_error("log2(wasm page size) too large");
298+
Result.PageSize = 1 << PageSizeLog2;
299+
}
294300
return Result;
295301
}
296302

llvm/lib/ObjectYAML/WasmYAML.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -373,6 +373,8 @@ void MappingTraits<WasmYAML::Limits>::mapping(IO &IO,
373373
IO.mapRequired("Minimum", Limits.Minimum);
374374
if (!IO.outputting() || Limits.Flags & wasm::WASM_LIMITS_FLAG_HAS_MAX)
375375
IO.mapOptional("Maximum", Limits.Maximum);
376+
if (!IO.outputting() || Limits.Flags & wasm::WASM_LIMITS_FLAG_HAS_PAGE_SIZE)
377+
IO.mapOptional("PageSize", Limits.PageSize);
376378
}
377379

378380
void MappingTraits<WasmYAML::ElemSegment>::mapping(
@@ -553,6 +555,7 @@ void ScalarBitSetTraits<WasmYAML::LimitFlags>::bitset(
553555
BCase(HAS_MAX);
554556
BCase(IS_SHARED);
555557
BCase(IS_64);
558+
BCase(HAS_PAGE_SIZE);
556559
#undef BCase
557560
}
558561

llvm/lib/Target/WebAssembly/AsmParser/WebAssemblyAsmParser.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -204,7 +204,7 @@ struct WebAssemblyOperand : public MCParsedAsmOperand {
204204

205205
// Perhaps this should go somewhere common.
206206
static wasm::WasmLimits defaultLimits() {
207-
return {wasm::WASM_LIMITS_FLAG_NONE, 0, 0};
207+
return {wasm::WASM_LIMITS_FLAG_NONE, 0, 0, 0};
208208
}
209209

210210
static MCSymbolWasm *getOrCreateFunctionTableSymbol(MCContext &Ctx,

llvm/lib/Target/WebAssembly/WebAssemblyUtilities.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ MCSymbolWasm *WebAssembly::getOrCreateFuncrefCallTableSymbol(
135135
// modules define the table.
136136
Sym->setWeak(true);
137137

138-
wasm::WasmLimits Limits = {0, 1, 1};
138+
wasm::WasmLimits Limits = {0, 1, 1, 0};
139139
wasm::WasmTableType TableType = {wasm::ValType::FUNCREF, Limits};
140140
Sym->setType(wasm::WASM_SYMBOL_TYPE_TABLE);
141141
Sym->setTableType(TableType);

llvm/tools/obj2yaml/wasm2yaml.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ static WasmYAML::Limits makeLimits(const wasm::WasmLimits &Limits) {
3737
L.Flags = Limits.Flags;
3838
L.Minimum = Limits.Minimum;
3939
L.Maximum = Limits.Maximum;
40+
L.PageSize = Limits.PageSize;
4041
return L;
4142
}
4243

0 commit comments

Comments
 (0)