diff options
author | Alon Zakai <alonzakai@gmail.com> | 2016-08-15 14:29:57 -0700 |
---|---|---|
committer | Alon Zakai <alonzakai@gmail.com> | 2016-08-15 15:03:36 -0700 |
commit | 113efcaa1e814304662ccc56312d8c59014a3a6c (patch) | |
tree | 5639a4a9d834947c9fc190e5916b9961e545cfba /src/asm2wasm.h | |
parent | 086c4c0f89bbe626f4c98ae95716084db0541b0d (diff) | |
download | binaryen-113efcaa1e814304662ccc56312d8c59014a3a6c.tar.gz binaryen-113efcaa1e814304662ccc56312d8c59014a3a6c.tar.bz2 binaryen-113efcaa1e814304662ccc56312d8c59014a3a6c.zip |
offset support in table
Diffstat (limited to 'src/asm2wasm.h')
-rw-r--r-- | src/asm2wasm.h | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/src/asm2wasm.h b/src/asm2wasm.h index 868aa31d3..a5754f725 100644 --- a/src/asm2wasm.h +++ b/src/asm2wasm.h @@ -660,13 +660,17 @@ void Asm2WasmBuilder::processAsm(Ref ast) { // TODO: when not using aliasing function pointers, we could merge them by noticing that // index 0 in each table is the null func, and each other index should only have one // non-null func. However, that breaks down when function pointer casts are emulated. - functionTableStarts[name] = wasm.table.names.size(); // this table starts here + if (wasm.table.segments.size() == 0) { + wasm.table.segments.emplace_back(wasm.allocator.alloc<Const>()->set(Literal(uint32_t(0)))); + } + auto& segment = wasm.table.segments[0]; + functionTableStarts[name] = segment.data.size(); // this table starts here Ref contents = value[1]; for (unsigned k = 0; k < contents->size(); k++) { IString curr = contents[k][1]->getIString(); - wasm.table.names.push_back(curr); + segment.data.push_back(curr); } - wasm.table.initial = wasm.table.max = wasm.table.names.size(); + wasm.table.initial = wasm.table.max = segment.data.size(); } else { abort_on("invalid var element", pair); } |