[PATCH] D54131: [WebAssembly] Add shared memory support to limits field
Derek Schuff via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Mon Nov 5 17:36:15 PST 2018
dschuff created this revision.
dschuff added reviewers: aheejin, sbc100.
Herald added subscribers: sunfish, jgravelle-google.
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.
Repository:
rL LLVM
https://reviews.llvm.org/D54131
Files:
include/llvm/BinaryFormat/Wasm.h
lib/Object/WasmObjectFile.cpp
lib/ObjectYAML/WasmYAML.cpp
test/ObjectYAML/wasm/import_memory_shared.yaml
Index: test/ObjectYAML/wasm/import_memory_shared.yaml
===================================================================
--- /dev/null
+++ test/ObjectYAML/wasm/import_memory_shared.yaml
@@ -0,0 +1,36 @@
+# RUN: yaml2obj %s | obj2yaml | FileCheck %s
+--- !WASM
+FileHeader:
+ Version: 0x00000001
+Sections:
+ - Type: TYPE
+ Signatures:
+ - Index: 0
+ ReturnType: I32
+ ParamTypes:
+ - I32
+ - Type: IMPORT
+ Imports:
+ - Module: foo
+ Field: imported_memory
+ Kind: MEMORY
+ Memory:
+ Flags: [ HAS_MAX, IS_SHARED ]
+ Initial: 0x00000010
+ Maximum: 0x00000011
+
+...
+# CHECK: --- !WASM
+# CHECK: FileHeader:
+# CHECK: Version: 0x00000001
+# CHECK: Sections:
+# CHECK: - Type: IMPORT
+# CHECK: Imports:
+# CHECK: - Module: foo
+# CHECK: Field: imported_memory
+# CHECK: Kind: MEMORY
+# CHECK: Memory:
+# CHECK: Flags: [ HAS_MAX, IS_SHARED ]
+# CHECK: Initial: 0x00000010
+# CHECK: Maximum: 0x00000011
+# CHECK: ...
Index: lib/ObjectYAML/WasmYAML.cpp
===================================================================
--- lib/ObjectYAML/WasmYAML.cpp
+++ lib/ObjectYAML/WasmYAML.cpp
@@ -416,6 +416,7 @@
IO &IO, WasmYAML::LimitFlags &Value) {
#define BCase(X) IO.bitSetCase(Value, #X, wasm::WASM_LIMITS_FLAG_##X)
BCase(HAS_MAX);
+ BCase(IS_SHARED);
#undef BCase
}
Index: lib/Object/WasmObjectFile.cpp
===================================================================
--- lib/Object/WasmObjectFile.cpp
+++ lib/Object/WasmObjectFile.cpp
@@ -193,7 +193,7 @@
static wasm::WasmLimits readLimits(WasmObjectFile::ReadContext &Ctx) {
wasm::WasmLimits Result;
- Result.Flags = readVaruint1(Ctx);
+ Result.Flags = readVaruint32(Ctx);
Result.Initial = readVaruint32(Ctx);
if (Result.Flags & wasm::WASM_LIMITS_FLAG_HAS_MAX)
Result.Maximum = readVaruint32(Ctx);
Index: include/llvm/BinaryFormat/Wasm.h
===================================================================
--- include/llvm/BinaryFormat/Wasm.h
+++ include/llvm/BinaryFormat/Wasm.h
@@ -214,6 +214,7 @@
enum : unsigned {
WASM_LIMITS_FLAG_HAS_MAX = 0x1,
+ WASM_LIMITS_FLAG_IS_SHARED = 0x2,
};
// Kind codes used in the custom "name" section
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D54131.172690.patch
Type: text/x-patch
Size: 2476 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20181106/16651755/attachment.bin>
More information about the llvm-commits
mailing list