[wasm] Remove unneeded code path
We are always passing a valid buffer to WasmMemoryObject::New, hence make it a Handle instead of MaybeHandle, and remove the code to allocate an empty buffer if none was passed. R=ahaas@chromium.org Bug: v8:10949 Change-Id: Ic10dfda741773a8f3d3895f81a83048cfe0eb293 Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/3702805 Commit-Queue: Clemens Backes <clemensb@chromium.org> Reviewed-by: Andreas Haas <ahaas@chromium.org> Cr-Commit-Position: refs/heads/main@{#81172}
This commit is contained in:
parent
21fe5e0fef
commit
d9b5cbaeca
@ -512,9 +512,8 @@ MaybeHandle<WasmInstanceObject> InstanceBuilder::Build() {
|
||||
auto maximum_pages =
|
||||
static_cast<int>(RoundUp(buffer->byte_length(), wasm::kWasmPageSize) /
|
||||
wasm::kWasmPageSize);
|
||||
memory_object_ =
|
||||
WasmMemoryObject::New(isolate_, memory_buffer_, maximum_pages)
|
||||
.ToHandleChecked();
|
||||
memory_object_ = WasmMemoryObject::New(isolate_, buffer, maximum_pages)
|
||||
.ToHandleChecked();
|
||||
} else {
|
||||
// Actual wasm module must have either imported or created memory.
|
||||
CHECK(memory_buffer_.is_null());
|
||||
|
@ -816,16 +816,7 @@ void SetInstanceMemory(Handle<WasmInstanceObject> instance,
|
||||
} // namespace
|
||||
|
||||
MaybeHandle<WasmMemoryObject> WasmMemoryObject::New(
|
||||
Isolate* isolate, MaybeHandle<JSArrayBuffer> maybe_buffer, int maximum) {
|
||||
Handle<JSArrayBuffer> buffer;
|
||||
if (!maybe_buffer.ToHandle(&buffer)) {
|
||||
// If no buffer was provided, create a zero-length one.
|
||||
auto backing_store =
|
||||
BackingStore::AllocateWasmMemory(isolate, 0, 0, SharedFlag::kNotShared);
|
||||
if (!backing_store) return {};
|
||||
buffer = isolate->factory()->NewJSArrayBuffer(std::move(backing_store));
|
||||
}
|
||||
|
||||
Isolate* isolate, Handle<JSArrayBuffer> buffer, int maximum) {
|
||||
Handle<JSFunction> memory_ctor(
|
||||
isolate->native_context()->wasm_memory_constructor(), isolate);
|
||||
|
||||
|
@ -256,7 +256,7 @@ class WasmMemoryObject
|
||||
inline bool has_maximum_pages();
|
||||
|
||||
V8_EXPORT_PRIVATE static MaybeHandle<WasmMemoryObject> New(
|
||||
Isolate* isolate, MaybeHandle<JSArrayBuffer> buffer, int maximum);
|
||||
Isolate* isolate, Handle<JSArrayBuffer> buffer, int maximum);
|
||||
|
||||
V8_EXPORT_PRIVATE static MaybeHandle<WasmMemoryObject> New(Isolate* isolate,
|
||||
int initial,
|
||||
|
Loading…
Reference in New Issue
Block a user