Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Unified Diff: src/runtime/runtime-wasm.cc

Issue 2562393002: [wasm] Introduce the TrapIf and TrapUnless operators to generate trap code. (Closed)
Patch Set: Rename UseSourcePosition to IsSourcePositionUsed Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/runtime/runtime.h ('k') | src/wasm/wasm-external-refs.h » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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());
« no previous file with comments | « src/runtime/runtime.h ('k') | src/wasm/wasm-external-refs.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698