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/wasm.h | 21 ++++++++------------- 1 file changed, 8 insertions(+), 13 deletions(-) (limited to 'src/wasm.h') diff --git a/src/wasm.h b/src/wasm.h index 0b7a09a3c..7090aeff1 100644 --- a/src/wasm.h +++ b/src/wasm.h @@ -1530,20 +1530,15 @@ struct BinaryLocations { // 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 array with one element at the moment (more elements may - // be necessary in the future). - // TODO: If we are sure we won't need more, make this a single value? - struct DelimiterLocations : public std::array { - DelimiterLocations() { - // Ensure zero-initialization. - for (auto& item : *this) { - item = 0; - } - } - }; + // for the common type of instruction which just needs a Span. + // For "else" (from an if) we use index 0, and for catch (from a try) we use + // indexes 0 and above. + // We use automatic zero-initialization here because that indicates a "null" + // debug value, indicating the information is not present. + using DelimiterLocations = ZeroInitSmallVector; + + enum DelimiterId : size_t { Else = 0, Invalid = size_t(-1) }; - enum DelimiterId { Else = 0, Catch = 0, Invalid = -1 }; std::unordered_map delimiters; // DWARF debug info can refer to multiple interesting positions in a function. -- cgit v1.2.3