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

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

Issue 2216443002: [wasm] Grow memory should return -1 on failure. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Created 4 years, 4 months 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
Index: src/runtime/runtime-wasm.cc
diff --git a/src/runtime/runtime-wasm.cc b/src/runtime/runtime-wasm.cc
index c883fb7e1a94fee7c4c064a8e1e64bd4e270e6bd..2bfbad34523ca04b9cb7bec4315579cea3e25d38 100644
--- a/src/runtime/runtime-wasm.cc
+++ b/src/runtime/runtime-wasm.cc
@@ -58,15 +58,13 @@ RUNTIME_FUNCTION(Runtime_WasmGrowMemory) {
// TODO(gdeepti): Fix bounds check to take into account size of memtype.
new_size = delta_pages * wasm::WasmModule::kPageSize;
if (delta_pages > wasm::WasmModule::kMaxMemPages) {
- THROW_NEW_ERROR_RETURN_FAILURE(
- isolate, NewRangeError(MessageTemplate::kWasmTrapMemOutOfBounds));
+ return *isolate->factory()->NewNumberFromInt(-1);
}
new_mem_start =
static_cast<Address>(isolate->array_buffer_allocator()->Allocate(
static_cast<uint32_t>(new_size)));
if (new_mem_start == NULL) {
- THROW_NEW_ERROR_RETURN_FAILURE(
- isolate, NewRangeError(MessageTemplate::kWasmTrapMemAllocationFail));
+ return *isolate->factory()->NewNumberFromInt(-1);
}
#if DEBUG
// Double check the API allocator actually zero-initialized the memory.
@@ -86,13 +84,11 @@ RUNTIME_FUNCTION(Runtime_WasmGrowMemory) {
new_size = old_size + delta_pages * wasm::WasmModule::kPageSize;
if (new_size >
wasm::WasmModule::kMaxMemPages * wasm::WasmModule::kPageSize) {
- THROW_NEW_ERROR_RETURN_FAILURE(
- isolate, NewRangeError(MessageTemplate::kWasmTrapMemOutOfBounds));
+ return *isolate->factory()->NewNumberFromInt(-1);
}
new_mem_start = static_cast<Address>(realloc(old_mem_start, new_size));
if (new_mem_start == NULL) {
- THROW_NEW_ERROR_RETURN_FAILURE(
- isolate, NewRangeError(MessageTemplate::kWasmTrapMemAllocationFail));
+ return *isolate->factory()->NewNumberFromInt(-1);
}
old_buffer->set_is_external(true);
isolate->heap()->UnregisterArrayBuffer(*old_buffer);
« no previous file with comments | « src/messages.h ('k') | src/wasm/wasm-opcodes.h » ('j') | test/mjsunit/wasm/grow-memory.js » ('J')

Powered by Google App Engine
This is Rietveld 408576698