summaryrefslogtreecommitdiff
path: root/src/wasm.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/wasm.h')
-rw-r--r--src/wasm.h34
1 files changed, 34 insertions, 0 deletions
diff --git a/src/wasm.h b/src/wasm.h
index 8b60885e3..f30a24d6b 100644
--- a/src/wasm.h
+++ b/src/wasm.h
@@ -1172,7 +1172,39 @@ struct BinaryLocations {
struct Span {
BinaryLocation start = 0, end = 0;
};
+
+ // Track the range of addresses an expressions appears at. This is the
+ // contiguous range that all instructions have - control flow instructions
+ // have additional opcodes later (like an end for a block or loop), see
+ // just after this.
std::unordered_map<Expression*, Span> expressions;
+
+ // Track the extra delimiter positions that some instructions, in particular
+ // control flow, have, like 'end' for loop and block. We keep these in a
+ // separate map because they are rare and we optimize for the storage space
+ // for the common type of instruction which just needs a Span. We implement
+ // this as a simple struct with two elements (as two extra elements is the
+ // maximum currently needed; due to 'catch' and 'end' for try-catch). The
+ // second value may be 0, indicating it is not used.
+ struct DelimiterLocations : public std::array<BinaryLocation, 2> {
+ DelimiterLocations() {
+ // Ensure zero-initialization.
+ for (auto& item : *this) {
+ item = 0;
+ }
+ }
+ };
+
+ enum DelimiterId {
+ // All control flow structures have an end, so use index 0 for that.
+ End = 0,
+ // Use index 1 for all other current things.
+ Else = 1,
+ Catch = 1,
+ Invalid = -1
+ };
+ std::unordered_map<Expression*, DelimiterLocations> delimiters;
+
std::unordered_map<Function*, Span> functions;
};
@@ -1231,6 +1263,8 @@ public:
// General debugging info support: track instructions and the function itself.
std::unordered_map<Expression*, BinaryLocations::Span> expressionLocations;
+ std::unordered_map<Expression*, BinaryLocations::DelimiterLocations>
+ delimiterLocations;
BinaryLocations::Span funcLocation;
size_t getNumParams();