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

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

Issue 2818903002: [wasm] Handle no memory case when memory is exported
Patch Set: q Created 3 years, 8 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/wasm/wasm-objects.h ('k') | test/mjsunit/regress/wasm/regression-699485.js » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/wasm/wasm-objects.cc
diff --git a/src/wasm/wasm-objects.cc b/src/wasm/wasm-objects.cc
index e69df8e64fc3e80477011be91d4d4f6ebc6b05cc..e9e70db568f1e6aba6ecf957b6d45c53ed353b04 100644
--- a/src/wasm/wasm-objects.cc
+++ b/src/wasm/wasm-objects.cc
@@ -382,8 +382,9 @@ Handle<WasmMemoryObject> WasmMemoryObject::New(Isolate* isolate,
Handle<JSObject> memory_obj =
isolate->factory()->NewJSObject(memory_ctor, TENURED);
memory_obj->SetEmbedderField(kWrapperTracerHeader, Smi::kZero);
-
- memory_obj->SetEmbedderField(kArrayBuffer, *buffer);
+ buffer.is_null() ? memory_obj->SetEmbedderField(
+ kArrayBuffer, isolate->heap()->undefined_value())
+ : memory_obj->SetEmbedderField(kArrayBuffer, *buffer);
Handle<Object> max = isolate->factory()->NewNumber(maximum);
memory_obj->SetEmbedderField(kMaximum, *max);
Handle<Symbol> memory_sym(isolate->native_context()->wasm_memory_sym());
@@ -391,7 +392,8 @@ Handle<WasmMemoryObject> WasmMemoryObject::New(Isolate* isolate,
return Handle<WasmMemoryObject>::cast(memory_obj);
}
-DEFINE_OBJ_ACCESSORS(WasmMemoryObject, buffer, kArrayBuffer, JSArrayBuffer)
+DEFINE_OPTIONAL_OBJ_ACCESSORS(WasmMemoryObject, buffer, kArrayBuffer,
+ JSArrayBuffer)
DEFINE_OPTIONAL_OBJ_ACCESSORS(WasmMemoryObject, instances_link, kInstancesLink,
WasmInstanceWrapper)
@@ -438,11 +440,11 @@ void WasmMemoryObject::ResetInstancesLink(Isolate* isolate) {
int32_t WasmMemoryObject::Grow(Isolate* isolate,
Handle<WasmMemoryObject> memory_object,
uint32_t pages) {
- Handle<JSArrayBuffer> old_buffer(memory_object->buffer(), isolate);
+ Handle<JSArrayBuffer> old_buffer;
uint32_t old_size = 0;
Address old_mem_start = nullptr;
- // Force byte_length to 0, if byte_length fails IsNumber() check.
- if (!old_buffer.is_null()) {
+ if (memory_object->has_buffer()) {
+ old_buffer = handle(memory_object->buffer());
old_size = old_buffer->byte_length()->Number();
old_mem_start = static_cast<Address>(old_buffer->backing_store());
}
« no previous file with comments | « src/wasm/wasm-objects.h ('k') | test/mjsunit/regress/wasm/regression-699485.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698