[PATCH] D41320: [WebAssembly] Export some more information on wasm functions
Phabricator via Phabricator via llvm-commits
llvm-commits at lists.llvm.org
Sun Dec 17 09:51:07 PST 2017
This revision was not accepted when it landed; it landed in state "Needs Review".
This revision was automatically updated to reflect the committed changes.
Closed by commit rL320946: [WebAssembly] Export some more info on wasm funtions (authored by sbc, committed by ).
Repository:
rL LLVM
https://reviews.llvm.org/D41320
Files:
llvm/trunk/include/llvm/BinaryFormat/Wasm.h
llvm/trunk/include/llvm/Object/Wasm.h
llvm/trunk/lib/Object/WasmObjectFile.cpp
Index: llvm/trunk/lib/Object/WasmObjectFile.cpp
===================================================================
--- llvm/trunk/lib/Object/WasmObjectFile.cpp
+++ llvm/trunk/lib/Object/WasmObjectFile.cpp
@@ -684,18 +684,21 @@
}
Error WasmObjectFile::parseCodeSection(const uint8_t *Ptr, const uint8_t *End) {
+ const uint8_t *CodeSectionStart = Ptr;
uint32_t FunctionCount = readVaruint32(Ptr);
if (FunctionCount != FunctionTypes.size()) {
return make_error<GenericBinaryError>("Invalid function count",
object_error::parse_failed);
}
- CodeSection = ArrayRef<uint8_t>(Ptr, End - Ptr);
-
while (FunctionCount--) {
wasm::WasmFunction Function;
- uint32_t FunctionSize = readVaruint32(Ptr);
- const uint8_t *FunctionEnd = Ptr + FunctionSize;
+ const uint8_t *FunctionStart = Ptr;
+ uint32_t Size = readVaruint32(Ptr);
+ const uint8_t *FunctionEnd = Ptr + Size;
+
+ Function.CodeSectionOffset = FunctionStart - CodeSectionStart;
+ Function.Size = FunctionEnd - FunctionStart;
uint32_t NumLocalDecls = readVaruint32(Ptr);
Function.Locals.reserve(NumLocalDecls);
Index: llvm/trunk/include/llvm/BinaryFormat/Wasm.h
===================================================================
--- llvm/trunk/include/llvm/BinaryFormat/Wasm.h
+++ llvm/trunk/include/llvm/BinaryFormat/Wasm.h
@@ -91,6 +91,8 @@
struct WasmFunction {
std::vector<WasmLocalDecl> Locals;
ArrayRef<uint8_t> Body;
+ size_t CodeSectionOffset;
+ size_t Size;
};
struct WasmDataSegment {
Index: llvm/trunk/include/llvm/Object/Wasm.h
===================================================================
--- llvm/trunk/include/llvm/Object/Wasm.h
+++ llvm/trunk/include/llvm/Object/Wasm.h
@@ -140,7 +140,6 @@
ArrayRef<wasm::WasmElemSegment> elements() const { return ElemSegments; }
ArrayRef<WasmSegment> dataSegments() const { return DataSegments; }
ArrayRef<wasm::WasmFunction> functions() const { return Functions; }
- const ArrayRef<uint8_t>& code() const { return CodeSection; }
uint32_t startFunction() const { return StartFunction; }
void moveSymbolNext(DataRefImpl &Symb) const override;
@@ -242,7 +241,6 @@
std::vector<WasmSegment> DataSegments;
std::vector<wasm::WasmFunction> Functions;
std::vector<WasmSymbol> Symbols;
- ArrayRef<uint8_t> CodeSection;
uint32_t StartFunction = -1;
bool HasLinkingSection = false;
wasm::WasmLinkingData LinkingData;
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D41320.127286.patch
Type: text/x-patch
Size: 2469 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/llvm-commits/attachments/20171217/3e2dbed9/attachment-0001.bin>
More information about the llvm-commits
mailing list