@@ -80,15 +80,15 @@ class Flow {
80
80
Flow (Name breakTo, Literal value) : values{value}, breakTo(breakTo) {}
81
81
Flow (Name breakTo, Literals&& values)
82
82
: values(std::move(values)), breakTo(breakTo) {}
83
- Flow (Name breakTo, Name suspendTag, Literals&& values)
83
+ Flow (Name breakTo, Tag* suspendTag, Literals&& values)
84
84
: values(std::move(values)), breakTo(breakTo), suspendTag(suspendTag) {
85
85
assert (breakTo == SUSPEND_FLOW);
86
86
}
87
87
88
88
Literals values;
89
89
Name breakTo; // if non-null, a break is going on
90
- Name suspendTag; // if non-null, breakTo must be SUSPEND_FLOW, and this is the
91
- // tag being suspended
90
+ Tag* suspendTag = nullptr ; // if non-null, breakTo must be SUSPEND_FLOW, and
91
+ // this is the tag being suspended
92
92
93
93
// A helper function for the common case where there is only one value
94
94
const Literal& getSingleValue () {
@@ -123,7 +123,7 @@ class Flow {
123
123
o << flow.values [i];
124
124
}
125
125
if (flow.suspendTag ) {
126
- o << " [suspend:" << flow.suspendTag << ' ]' ;
126
+ o << " [suspend:" << flow.suspendTag -> name << ' ]' ;
127
127
}
128
128
o << " })" ;
129
129
return o;
@@ -3056,8 +3056,7 @@ class ModuleRunnerBase : public ExpressionRunner<SubType> {
3056
3056
virtual ~ExternalInterface () = default ;
3057
3057
virtual void init (Module& wasm, SubType& instance) {}
3058
3058
virtual void importGlobals (GlobalValueSet& globals, Module& wasm) = 0;
3059
- virtual Literals callImport (Function* import ,
3060
- const Literals& arguments) = 0;
3059
+ virtual Flow callImport (Function* import , const Literals& arguments) = 0;
3061
3060
virtual bool growMemory (Name name, Address oldSize, Address newSize) = 0;
3062
3061
virtual bool growTable (Name name,
3063
3062
const Literal& value,
@@ -3564,6 +3563,21 @@ class ModuleRunnerBase : public ExpressionRunner<SubType> {
3564
3563
return inst->globals [global->name ];
3565
3564
}
3566
3565
3566
+ // Get a tag object while looking through imports, i.e., this uses the name as
3567
+ // the name of the tag in the current module, and finds the actual canonical
3568
+ // Tag* object for it: the Tag in this module, if not imported, and if
3569
+ // imported, the Tag in the originating module.
3570
+ Tag* getCanonicalTag (Name name) {
3571
+ auto * inst = self ();
3572
+ auto * tag = inst->wasm .getTag (name);
3573
+ while (tag->imported ()) {
3574
+ inst = inst->linkedInstances .at (tag->module ).get ();
3575
+ auto * tagExport = inst->wasm .getExport (tag->base );
3576
+ tag = inst->wasm .getTag (*tagExport->getInternalName ());
3577
+ }
3578
+ return tag;
3579
+ }
3580
+
3567
3581
public:
3568
3582
Flow visitCall (Call* curr) {
3569
3583
Name target = curr->target ;
@@ -4775,7 +4789,8 @@ class ModuleRunnerBase : public ExpressionRunner<SubType> {
4775
4789
// We will resume from this precise spot, when the new continuation is
4776
4790
// resumed.
4777
4791
new_->resumeExpr = curr;
4778
- return Flow (SUSPEND_FLOW, curr->tag , std::move (arguments));
4792
+ return Flow (
4793
+ SUSPEND_FLOW, self ()->getCanonicalTag (curr->tag ), std::move (arguments));
4779
4794
}
4780
4795
Flow visitResume (Resume* curr) {
4781
4796
Literals arguments;
@@ -4825,10 +4840,10 @@ class ModuleRunnerBase : public ExpressionRunner<SubType> {
4825
4840
} else {
4826
4841
// We are suspending. See if a suspension arrived that we support.
4827
4842
for (size_t i = 0 ; i < curr->handlerTags .size (); i++) {
4828
- auto handlerTag = curr->handlerTags [i];
4843
+ auto * handlerTag = self ()-> getCanonicalTag ( curr->handlerTags [i]) ;
4829
4844
if (handlerTag == ret.suspendTag ) {
4830
4845
// Switch the flow from suspending to branching.
4831
- ret.suspendTag = Name () ;
4846
+ ret.suspendTag = nullptr ;
4832
4847
ret.breakTo = curr->handlerBlocks [i];
4833
4848
// We can now update the continuation type, which was wrong until now
4834
4849
// (see comment in visitSuspend). The type is taken from the block we
@@ -4978,7 +4993,7 @@ class ModuleRunnerBase : public ExpressionRunner<SubType> {
4978
4993
4979
4994
#if WASM_INTERPRETER_DEBUG
4980
4995
std::cout << self ()->indent () << " exiting " << function->name << " with "
4981
- << flow. values << ' \n ' ;
4996
+ << flow << ' \n ' ;
4982
4997
#endif
4983
4998
4984
4999
if (flow.suspendTag ) {
0 commit comments