| Index: src/runtime/runtime-wasm.cc
|
| diff --git a/src/runtime/runtime-wasm.cc b/src/runtime/runtime-wasm.cc
|
| index e840eb464e9797325d5a89514ff82c3a94b3d3c0..950c2dc8ede2f811d6669614d207aeeb28757030 100644
|
| --- a/src/runtime/runtime-wasm.cc
|
| +++ b/src/runtime/runtime-wasm.cc
|
| @@ -15,6 +15,7 @@
|
| #include "src/v8memory.h"
|
| #include "src/wasm/wasm-module.h"
|
| #include "src/wasm/wasm-objects.h"
|
| +#include "src/wasm/wasm-opcodes.h"
|
|
|
| namespace v8 {
|
| namespace internal {
|
| @@ -61,14 +62,16 @@ RUNTIME_FUNCTION(Runtime_WasmGrowMemory) {
|
| wasm::GrowMemory(isolate, instance, delta_pages));
|
| }
|
|
|
| -RUNTIME_FUNCTION(Runtime_ThrowWasmError) {
|
| +Object* ThrowRuntimeError(Isolate* isolate, int message_id, int byte_offset,
|
| + bool patch_source_position) {
|
| HandleScope scope(isolate);
|
| - DCHECK_EQ(2, args.length());
|
| - CONVERT_SMI_ARG_CHECKED(message_id, 0);
|
| - CONVERT_SMI_ARG_CHECKED(byte_offset, 1);
|
| Handle<Object> error_obj = isolate->factory()->NewWasmRuntimeError(
|
| static_cast<MessageTemplate::Template>(message_id));
|
|
|
| + if (!patch_source_position) {
|
| + return isolate->Throw(*error_obj);
|
| + }
|
| +
|
| // For wasm traps, the byte offset (a.k.a source position) can not be
|
| // determined from relocation info, since the explicit checks for traps
|
| // converge in one singe block which calls this runtime function.
|
| @@ -115,6 +118,21 @@ RUNTIME_FUNCTION(Runtime_ThrowWasmError) {
|
| return isolate->Throw(*error_obj);
|
| }
|
|
|
| +RUNTIME_FUNCTION(Runtime_ThrowWasmError) {
|
| + DCHECK_EQ(2, args.length());
|
| + CONVERT_SMI_ARG_CHECKED(message_id, 0);
|
| + CONVERT_SMI_ARG_CHECKED(byte_offset, 1);
|
| + return ThrowRuntimeError(isolate, message_id, byte_offset, true);
|
| +}
|
| +
|
| +#define DECLARE_ENUM(name) \
|
| + RUNTIME_FUNCTION(Runtime_ThrowWasm##name) { \
|
| + int message_id = wasm::WasmOpcodes::TrapReasonToMessageId(wasm::k##name); \
|
| + return ThrowRuntimeError(isolate, message_id, 0, false); \
|
| + }
|
| +FOREACH_WASM_TRAPREASON(DECLARE_ENUM)
|
| +#undef DECLARE_ENUM
|
| +
|
| RUNTIME_FUNCTION(Runtime_WasmThrowTypeError) {
|
| HandleScope scope(isolate);
|
| DCHECK_EQ(0, args.length());
|
|
|