summaryrefslogtreecommitdiff
path: root/src/s2wasm.h
diff options
context:
space:
mode:
authorAlon Zakai <alonzakai@gmail.com>2015-12-11 18:46:13 -0500
committerAlon Zakai <alonzakai@gmail.com>2015-12-11 18:46:13 -0500
commit15f1677713a2b9eb6180788ae3f26bc1ecffec5a (patch)
treef2d617a0e3175991f51769ee09c56c0b1c46f29b /src/s2wasm.h
parent32240a18abfdfcf70796bb72b0851163f0314e19 (diff)
downloadbinaryen-15f1677713a2b9eb6180788ae3f26bc1ecffec5a.tar.gz
binaryen-15f1677713a2b9eb6180788ae3f26bc1ecffec5a.tar.bz2
binaryen-15f1677713a2b9eb6180788ae3f26bc1ecffec5a.zip
fix up static allocation code in s2wasm
Diffstat (limited to 'src/s2wasm.h')
-rw-r--r--src/s2wasm.h7
1 files changed, 5 insertions, 2 deletions
diff --git a/src/s2wasm.h b/src/s2wasm.h
index e1e913836..1731aa2e4 100644
--- a/src/s2wasm.h
+++ b/src/s2wasm.h
@@ -28,6 +28,9 @@ private:
// state
size_t nextStatic = 0; // location of next static allocation, i.e., the data segment
+ std::map<Name, size_t> staticAddresses; // name => address
+ typedef std::pair<Const*, Name> Addressing;
+ std::vector<Addressing> addressings; // we fix these up
// utilities
@@ -284,8 +287,6 @@ private:
setOutput(curr, assign);
};
// fixups
- typedef std::pair<Const*, Name> Addressing;
- std::vector<Addressing> addressings;
std::vector<Block*> loopBlocks; // we need to clear their names
std::set<Name> seenLabels; // if we already used a label, we don't need it in a loop (there is a block above it, with that label)
// main loop
@@ -454,6 +455,8 @@ private:
assert(strlen(buffer.str) == size);
const int ALIGN = 16;
if (nextStatic == 0) nextStatic = ALIGN;
+ // assign the address, add to memory, and increment for the next one
+ staticAddresses[name] = nextStatic;
wasm.memory.segments.emplace_back(nextStatic, buffer.str, size);
nextStatic += size;
nextStatic = (nextStatic + ALIGN - 1) & -ALIGN;