@@ -443,27 +443,14 @@ struct ExecutionResults {
443443
444444 bool operator !=(ExecutionResults& other) { return !((*this ) == other); }
445445
446- FunctionResult run (Function* func, Module& wasm) {
447- LoggingExternalInterface interface (loggings, wasm);
448- try {
449- ModuleRunner instance (wasm, &interface);
450- instance.setRelaxedBehavior (ModuleRunner::RelaxedBehavior::Execute);
451- instance.instantiate ();
452- interface.setModuleRunner (&instance);
453- return run (func, wasm, instance);
454- } catch (const TrapException&) {
455- // May throw in instance creation (init of offsets).
456- return {};
457- } catch (const HostLimitException&) {
458- // May throw in instance creation (e.g. array.new of huge size).
459- // This should be ignored and not compared with, as optimizations can
460- // change whether a host limit is reached.
461- ignore = true ;
462- return {};
463- }
464- }
465-
466446 FunctionResult run (Function* func, Module& wasm, ModuleRunner& instance) {
447+ // Clear the continuation state after each run of an export.
448+ struct CleanUp {
449+ ModuleRunner& instance;
450+ CleanUp (ModuleRunner& instance) : instance(instance) {}
451+ ~CleanUp () { instance.clearContinuationStore (); }
452+ } cleanUp (instance);
453+
467454 try {
468455 // call the method
469456 Literals arguments;
@@ -472,30 +459,25 @@ struct ExecutionResults {
472459 if (!param.isDefaultable ()) {
473460 std::cout << " [trap fuzzer can only send defaultable parameters to "
474461 " exports]\n " ;
475- instance.clearContinuationStore ();
476462 return Trap{};
477463 }
478464 arguments.push_back (Literal::makeZero (param));
479465 }
480466 auto flow = instance.callFunction (func->name , arguments);
481467 if (flow.suspendTag ) {
482468 std::cout << " [exception thrown: unhandled suspend]" << std::endl;
483- instance.clearContinuationStore ();
484469 return Exception{};
485470 }
486471 return flow.values ;
487472 } catch (const TrapException&) {
488- instance.clearContinuationStore ();
489473 return Trap{};
490474 } catch (const WasmException& e) {
491- instance.clearContinuationStore ();
492475 std::cout << " [exception thrown: " << e << " ]" << std::endl;
493476 return Exception{};
494477 } catch (const HostLimitException&) {
495478 // This should be ignored and not compared with, as optimizations can
496479 // change whether a host limit is reached.
497480 ignore = true ;
498- instance.clearContinuationStore ();
499481 return {};
500482 }
501483 }
0 commit comments