Skip to content

Commit ab7ed52

Browse files
Add more detail about pointer comparison, and remove resolved todo in the code
1 parent 6322fcb commit ab7ed52

2 files changed

Lines changed: 9 additions & 7 deletions

File tree

src/wasm-interpreter.h

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -167,12 +167,7 @@ struct FuncData {
167167

168168
// The data of a (ref exn) literal.
169169
struct ExnData {
170-
// The tag of this exn data.
171-
// TODO: Add self, like in FuncData, to handle the case of a module that is
172-
// instantiated multiple times.
173170
const Tag* tag;
174-
175-
// The payload of this exn data.
176171
Literals payload;
177172

178173
ExnData(const Tag* tag, Literals payload) : tag(tag), payload(payload) {}
@@ -4662,7 +4657,14 @@ class ModuleRunnerBase : public ExpressionRunner<SubType> {
46624657

46634658
// note: allTags[catchTag] will be null if it's a tag that we don't know
46644659
// about, i.e. an unimported tag.
4665-
// Pointer comparison.
4660+
// We do a pointer comparison here (`tag->second == exnData->tag`)
4661+
// because a tag just consists of a signature, and two tags may look the
4662+
// same but have different identities, e.g. given
4663+
// (tag $a (param i32))
4664+
// (tag $b (param i32))
4665+
// a catch clause for $b won't catch $a and vice versa.
4666+
// This can also happen when a module is instantiated twice and the same
4667+
// tag is imported from each instance. See the instance.wast spec test.
46664668
if (auto tag = allTags.find(catchTag);
46674669
!catchTag.is() ||
46684670
((tag != allTags.end()) && tag->second == exnData->tag)) {

test/spec/instance.wast

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
;; Copy of test/spec/testsuite/instance.wast
2-
;; TODO: Use the upstream test after adding support for default values for tables and module splitting testing with module instances.
2+
;; TODO: Use the upstream test after adding support for default values for tables.
33

44
;; Instantiation is generative
55

0 commit comments

Comments
 (0)