llvm.org GIT mirror llvm / 992cf17
[WebAssembly] Add shared memory support to limits field Support the IS_SHARED bit in the memory limits flag word. The compiler does not create object files with memory definitions, but the field is used by the linker. Differential Revision: https://reviews.llvm.org/D54131 git-svn-id: https://llvm.org/svn/llvm-project/llvm/trunk@346246 91177308-0d34-0410-b5e6-96231b3b80d8 Derek Schuff 9 months ago
4 changed file(s) with 39 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
213213
214214 enum : unsigned {
215215 WASM_LIMITS_FLAG_HAS_MAX = 0x1,
216 WASM_LIMITS_FLAG_IS_SHARED = 0x2,
216217 };
217218
218219 // Kind codes used in the custom "name" section
192192
193193 static wasm::WasmLimits readLimits(WasmObjectFile::ReadContext &Ctx) {
194194 wasm::WasmLimits Result;
195 Result.Flags = readVaruint1(Ctx);
195 Result.Flags = readVaruint32(Ctx);
196196 Result.Initial = readVaruint32(Ctx);
197197 if (Result.Flags & wasm::WASM_LIMITS_FLAG_HAS_MAX)
198198 Result.Maximum = readVaruint32(Ctx);
415415 IO &IO, WasmYAML::LimitFlags &Value) {
416416 #define BCase(X) IO.bitSetCase(Value, #X, wasm::WASM_LIMITS_FLAG_##X)
417417 BCase(HAS_MAX);
418 BCase(IS_SHARED);
418419 #undef BCase
419420 }
420421
0 # RUN: yaml2obj %s | obj2yaml | FileCheck %s
1 --- !WASM
2 FileHeader:
3 Version: 0x00000001
4 Sections:
5 - Type: TYPE
6 Signatures:
7 - Index: 0
8 ReturnType: I32
9 ParamTypes:
10 - I32
11 - Type: IMPORT
12 Imports:
13 - Module: foo
14 Field: imported_memory
15 Kind: MEMORY
16 Memory:
17 Flags: [ HAS_MAX, IS_SHARED ]
18 Initial: 0x00000010
19 Maximum: 0x00000011
20
21 ...
22 # CHECK: --- !WASM
23 # CHECK: FileHeader:
24 # CHECK: Version: 0x00000001
25 # CHECK: Sections:
26 # CHECK: - Type: IMPORT
27 # CHECK: Imports:
28 # CHECK: - Module: foo
29 # CHECK: Field: imported_memory
30 # CHECK: Kind: MEMORY
31 # CHECK: Memory:
32 # CHECK: Flags: [ HAS_MAX, IS_SHARED ]
33 # CHECK: Initial: 0x00000010
34 # CHECK: Maximum: 0x00000011
35 # CHECK: ...