@@ -443,27 +443,14 @@ struct ExecutionResults {
443
443
444
444
bool operator !=(ExecutionResults& other) { return !((*this ) == other); }
445
445
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
-
466
446
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
+
467
454
try {
468
455
// call the method
469
456
Literals arguments;
@@ -472,30 +459,25 @@ struct ExecutionResults {
472
459
if (!param.isDefaultable ()) {
473
460
std::cout << " [trap fuzzer can only send defaultable parameters to "
474
461
" exports]\n " ;
475
- instance.clearContinuationStore ();
476
462
return Trap{};
477
463
}
478
464
arguments.push_back (Literal::makeZero (param));
479
465
}
480
466
auto flow = instance.callFunction (func->name , arguments);
481
467
if (flow.suspendTag ) {
482
468
std::cout << " [exception thrown: unhandled suspend]" << std::endl;
483
- instance.clearContinuationStore ();
484
469
return Exception{};
485
470
}
486
471
return flow.values ;
487
472
} catch (const TrapException&) {
488
- instance.clearContinuationStore ();
489
473
return Trap{};
490
474
} catch (const WasmException& e) {
491
- instance.clearContinuationStore ();
492
475
std::cout << " [exception thrown: " << e << " ]" << std::endl;
493
476
return Exception{};
494
477
} catch (const HostLimitException&) {
495
478
// This should be ignored and not compared with, as optimizations can
496
479
// change whether a host limit is reached.
497
480
ignore = true ;
498
- instance.clearContinuationStore ();
499
481
return {};
500
482
}
501
483
}
0 commit comments