summaryrefslogtreecommitdiff
path: root/src/wasm/wasm-stack.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm/wasm-stack.cpp')
-rw-r--r--src/wasm/wasm-stack.cpp16
1 files changed, 12 insertions, 4 deletions
diff --git a/src/wasm/wasm-stack.cpp b/src/wasm/wasm-stack.cpp
index 9b5dc3f22..48fe79fa1 100644
--- a/src/wasm/wasm-stack.cpp
+++ b/src/wasm/wasm-stack.cpp
@@ -114,13 +114,21 @@ void BinaryInstWriter::visitLocalSet(LocalSet* curr) {
}
void BinaryInstWriter::visitGlobalGet(GlobalGet* curr) {
- o << int8_t(BinaryConsts::GlobalGet)
- << U32LEB(parent.getGlobalIndex(curr->name));
+ // Emit a global.get for each element if this is a tuple global
+ Index index = parent.getGlobalIndex(curr->name);
+ size_t numValues = curr->type.size();
+ for (Index i = 0; i < numValues; ++i) {
+ o << int8_t(BinaryConsts::GlobalGet) << U32LEB(index + i);
+ }
}
void BinaryInstWriter::visitGlobalSet(GlobalSet* curr) {
- o << int8_t(BinaryConsts::GlobalSet)
- << U32LEB(parent.getGlobalIndex(curr->name));
+ // Emit a global.set for each element if this is a tuple global
+ Index index = parent.getGlobalIndex(curr->name);
+ size_t numValues = parent.getModule()->getGlobal(curr->name)->type.size();
+ for (int i = numValues - 1; i >= 0; --i) {
+ o << int8_t(BinaryConsts::GlobalSet) << U32LEB(index + i);
+ }
}
void BinaryInstWriter::visitLoad(Load* curr) {