Index: src/runtime/runtime-wasm.cc |
diff --git a/src/runtime/runtime-wasm.cc b/src/runtime/runtime-wasm.cc |
index 80468306ca846c84a11130bf7fcffd6833a72ee3..6fc72767ea57bba5cbb4fe9c9be65433ebb4bca0 100644 |
--- a/src/runtime/runtime-wasm.cc |
+++ b/src/runtime/runtime-wasm.cc |
@@ -18,12 +18,16 @@ |
namespace v8 { |
namespace internal { |
+namespace { |
+const int kWasmMemArrayBuffer = 2; |
+} |
+ |
RUNTIME_FUNCTION(Runtime_WasmGrowMemory) { |
HandleScope scope(isolate); |
DCHECK_EQ(1, args.length()); |
uint32_t delta_pages = 0; |
CHECK(args[0]->ToUint32(&delta_pages)); |
- Handle<JSObject> module_instance; |
+ Handle<JSObject> module_object; |
{ |
// Get the module JSObject |
@@ -37,17 +41,17 @@ |
Object* owning_instance = wasm::GetOwningWasmInstance(undefined, code); |
CHECK_NOT_NULL(owning_instance); |
CHECK_NE(owning_instance, undefined); |
- module_instance = handle(JSObject::cast(owning_instance), isolate); |
+ module_object = handle(JSObject::cast(owning_instance), isolate); |
} |
Address old_mem_start, new_mem_start; |
uint32_t old_size, new_size; |
// Get mem buffer associated with module object |
- MaybeHandle<JSArrayBuffer> maybe_mem_buffer = |
- wasm::GetInstanceMemory(isolate, module_instance); |
- Handle<JSArrayBuffer> old_buffer; |
- if (!maybe_mem_buffer.ToHandle(&old_buffer)) { |
+ Handle<Object> obj(module_object->GetInternalField(kWasmMemArrayBuffer), |
+ isolate); |
+ |
+ if (obj->IsUndefined(isolate)) { |
// If module object does not have linear memory associated with it, |
// Allocate new array buffer of given size. |
old_mem_start = nullptr; |
@@ -69,6 +73,7 @@ |
} |
#endif |
} else { |
+ Handle<JSArrayBuffer> old_buffer = Handle<JSArrayBuffer>::cast(obj); |
old_mem_start = static_cast<Address>(old_buffer->backing_store()); |
old_size = old_buffer->byte_length()->Number(); |
// If the old memory was zero-sized, we should have been in the |
@@ -96,10 +101,9 @@ |
buffer->set_is_neuterable(false); |
// Set new buffer to be wasm memory |
+ module_object->SetInternalField(kWasmMemArrayBuffer, *buffer); |
- wasm::SetInstanceMemory(module_instance, *buffer); |
- |
- CHECK(wasm::UpdateWasmModuleMemory(module_instance, old_mem_start, |
+ CHECK(wasm::UpdateWasmModuleMemory(module_object, old_mem_start, |
new_mem_start, old_size, new_size)); |
return *isolate->factory()->NewNumberFromInt(old_size / |