From c74acc0baece1296ad58a0ff44119fb36d98d2c6 Mon Sep 17 00:00:00 2001 From: Alon Zakai Date: Mon, 25 Jan 2021 18:12:37 +0000 Subject: Debug info handling for new EH try-catch (#3496) We now have multiple catches in each try, and a possible catch-all. This changes our "extra delimiter" storage to store either an "else" (unchanged from before) or an arbitrary list of things - we use that for catches. --- src/support/small_vector.h | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) (limited to 'src/support/small_vector.h') diff --git a/src/support/small_vector.h b/src/support/small_vector.h index 2e65eda41..8ab10c05b 100644 --- a/src/support/small_vector.h +++ b/src/support/small_vector.h @@ -181,6 +181,30 @@ public: ConstIterator end() const { return ConstIterator(this, size()); } }; +// A SmallVector for which some values may be read before they are written, and +// in that case they have the value zero. +template +struct ZeroInitSmallVector : public SmallVector { + T& operator[](size_t i) { + if (i >= this->size()) { + resize(i + 1); + } + return SmallVector::operator[](i); + } + + const T& operator[](size_t i) const { + return const_cast&>(*this)[i]; + } + + void resize(size_t newSize) { + auto oldSize = this->size(); + SmallVector::resize(newSize); + for (size_t i = oldSize; i < this->size(); i++) { + (*this)[i] = 0; + } + } +}; + } // namespace wasm #endif // wasm_support_small_vector_h -- cgit v1.2.3