diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/passes/hash-stringify-walker.cpp | 5 | ||||
-rw-r--r-- | src/passes/stringify-walker.h | 11 |
2 files changed, 10 insertions, 6 deletions
diff --git a/src/passes/hash-stringify-walker.cpp b/src/passes/hash-stringify-walker.cpp index 8d76aeec9..3df01b290 100644 --- a/src/passes/hash-stringify-walker.cpp +++ b/src/passes/hash-stringify-walker.cpp @@ -55,8 +55,9 @@ bool StringifyEquator::operator()(Expression* lhs, Expression* rhs) const { void HashStringifyWalker::addUniqueSymbol() { // Use a negative value to distinguish symbols for separators from symbols // for Expressions - hashString.push_back((uint64_t)-nextVal); - nextVal++; + assert((uint32_t)nextSeparatorVal >= nextVal); + hashString.push_back((uint32_t)nextSeparatorVal); + nextSeparatorVal--; } void HashStringifyWalker::visitExpression(Expression* curr) { diff --git a/src/passes/stringify-walker.h b/src/passes/stringify-walker.h index 9563000d0..7e18d3d9e 100644 --- a/src/passes/stringify-walker.h +++ b/src/passes/stringify-walker.h @@ -113,17 +113,20 @@ struct StringifyEquator { struct HashStringifyWalker : public StringifyWalker<HashStringifyWalker> { // After calling walkModule, this vector contains the result of encoding a - // wasm module as a string of uint64_t values. Each value represents either an + // wasm module as a string of uint32_t values. Each value represents either an // Expression or a separator to mark the end of control flow. - std::vector<uint64_t> hashString; + std::vector<uint32_t> hashString; // A monotonic counter used to ensure that unique expressions in the // module are assigned a unique value in the hashString - uint64_t nextVal = 0; + uint32_t nextVal = 0; + // A monotonic counter used to ensure that each separator in the + // module is assigned a unique value in the hashString + int32_t nextSeparatorVal = -1; // Contains a mapping of expression pointer to value to ensure we // use the same value for matching expressions. A custom hasher and // equator is provided in order to separate out evaluation of the if-condition // when evaluating if expressions. - std::unordered_map<Expression*, uint64_t, StringifyHasher, StringifyEquator> + std::unordered_map<Expression*, uint32_t, StringifyHasher, StringifyEquator> exprToCounter; void addUniqueSymbol(); |