diff --git a/src/shell-interface.h b/src/shell-interface.h index 7a42617e711..03b4c819e73 100644 --- a/src/shell-interface.h +++ b/src/shell-interface.h @@ -325,16 +325,15 @@ struct ShellExternalInterface : ModuleRunner::ExternalInterface { return true; } - void trap(const char* why) override { + void trap(std::string_view why) override { std::cout << "[trap " << why << "]\n"; throw TrapException(); } - void hostLimit(const char* why) override { + void hostLimit(std::string_view why) override { std::cout << "[host limit " << why << "]\n"; throw HostLimitException(); } - void throwException(const WasmException& exn) override { throw exn; } }; diff --git a/src/tools/wasm-ctor-eval.cpp b/src/tools/wasm-ctor-eval.cpp index b33fb5aa999..455c247ccd7 100644 --- a/src/tools/wasm-ctor-eval.cpp +++ b/src/tools/wasm-ctor-eval.cpp @@ -451,12 +451,12 @@ struct CtorEvalExternalInterface : EvallingModuleRunner::ExternalInterface { throw FailToEvalException("grow table"); } - void trap(const char* why) override { - throw FailToEvalException(std::string("trap: ") + why); + void trap(std::string_view why) override { + throw FailToEvalException(std::string("trap: ") + std::string(why)); } - void hostLimit(const char* why) override { - throw FailToEvalException(std::string("trap: ") + why); + void hostLimit(std::string_view why) override { + throw FailToEvalException(std::string("trap: ") + std::string(why)); } void throwException(const WasmException& exn) override { diff --git a/src/wasm-interpreter.h b/src/wasm-interpreter.h index 3dad2780203..d46dde4d102 100644 --- a/src/wasm-interpreter.h +++ b/src/wasm-interpreter.h @@ -86,7 +86,7 @@ class Flow { } Literals values; - Name breakTo; // if non-null, a break is going on + Name breakTo; // if non-null, a break is going on Tag* suspendTag = nullptr; // if non-null, breakTo must be SUSPEND_FLOW, and // this is the tag being suspended @@ -2694,9 +2694,9 @@ class ExpressionRunner : public OverriddenVisitor { return makeGCData(std::move(contents), curr->type); } - virtual void trap(const char* why) { WASM_UNREACHABLE("unimp"); } + virtual void trap(std::string_view why) { WASM_UNREACHABLE("unimp"); } - virtual void hostLimit(const char* why) { WASM_UNREACHABLE("unimp"); } + virtual void hostLimit(std::string_view why) { WASM_UNREACHABLE("unimp"); } virtual void throwException(const WasmException& exn) { WASM_UNREACHABLE("unimp"); @@ -2929,9 +2929,11 @@ class ConstantExpressionRunner : public ExpressionRunner { Flow visitResumeThrow(ResumeThrow* curr) { return Flow(NONCONSTANT_FLOW); } Flow visitStackSwitch(StackSwitch* curr) { return Flow(NONCONSTANT_FLOW); } - void trap(const char* why) override { throw NonconstantException(); } + void trap(std::string_view why) override { throw NonconstantException(); } - void hostLimit(const char* why) override { throw NonconstantException(); } + void hostLimit(std::string_view why) override { + throw NonconstantException(); + } virtual void throwException(const WasmException& exn) override { throw NonconstantException(); @@ -2974,8 +2976,8 @@ class ModuleRunnerBase : public ExpressionRunner { const Literal& value, Index oldSize, Index newSize) = 0; - virtual void trap(const char* why) = 0; - virtual void hostLimit(const char* why) = 0; + virtual void trap(std::string_view why) = 0; + virtual void hostLimit(std::string_view why) = 0; virtual void throwException(const WasmException& exn) = 0; // Get the Tag instance for a tag implemented in the host, that is, not // among the linked ModuleRunner instances, but imported from the host. @@ -4741,13 +4743,13 @@ class ModuleRunnerBase : public ExpressionRunner { Flow visitResumeThrow(ResumeThrow* curr) { return doResume(curr); } Flow visitStackSwitch(StackSwitch* curr) { return Flow(NONCONSTANT_FLOW); } - void trap(const char* why) override { + void trap(std::string_view why) override { // Traps break all current continuations - they will never be resumable. self()->clearContinuationStore(); externalInterface->trap(why); } - void hostLimit(const char* why) override { + void hostLimit(std::string_view why) override { self()->clearContinuationStore(); externalInterface->hostLimit(why); }