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

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: Review comments 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
« no previous file with comments | « src/messages.h ('k') | src/wasm/wasm-opcodes.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 c883fb7e1a94fee7c4c064a8e1e64bd4e270e6bd..924ca0df01a9f31974704268ca588ed6c4a5a56f 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);
@@ -110,8 +106,8 @@ RUNTIME_FUNCTION(Runtime_WasmGrowMemory) {
CHECK(wasm::UpdateWasmModuleMemory(module_object, old_mem_start,
new_mem_start, old_size, new_size));
- return *isolate->factory()->NewNumberFromUint(old_size /
- wasm::WasmModule::kPageSize);
+ return *isolate->factory()->NewNumberFromInt(old_size /
+ wasm::WasmModule::kPageSize);
}
RUNTIME_FUNCTION(Runtime_JITSingleFunction) {
« no previous file with comments | « src/messages.h ('k') | src/wasm/wasm-opcodes.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698