Commit 9ffacb58 authored by Deepti Gandluri's avatar Deepti Gandluri Committed by Commit Bot

[wasm] Rename FreeMemoryIfIsWasm memory to FreeWasmMemory

Previously it was possible for this function to fall back to the
ArrayBuffer methods to free the memory in the cases where the
is_wasm_memory flag on the JSArrayBuffer is not propagated.
This is no longer the case, as we check for the actual allocation
so all memory allocated by the WasmMemoryTracker should be freed by
it as well. Rename the method to match the existing implementation.

Change-Id: I50c9844bfdae1c378812df5add2253752532d0ad
Reviewed-on: https://chromium-review.googlesource.com/c/v8/v8/+/1587795
Commit-Queue: Deepti Gandluri <gdeepti@chromium.org>
Reviewed-by: 's avatarAndreas Haas <ahaas@chromium.org>
Cr-Commit-Position: refs/heads/master@{#61066}
parent ff28636c
......@@ -7492,7 +7492,7 @@ v8::ArrayBuffer::Contents::Contents(void* data, size_t byte_length,
void WasmMemoryDeleter(void* buffer, size_t lenght, void* info) {
internal::wasm::WasmEngine* engine =
reinterpret_cast<internal::wasm::WasmEngine*>(info);
CHECK(engine->memory_tracker()->FreeMemoryIfIsWasmMemory(nullptr, buffer));
CHECK(engine->memory_tracker()->FreeWasmMemory(nullptr, buffer));
}
void ArrayBufferDeleter(void* buffer, size_t length, void* info) {
......
......@@ -69,7 +69,7 @@ void JSArrayBuffer::FreeBackingStore(Isolate* isolate, Allocation allocation) {
if (allocation.is_wasm_memory) {
wasm::WasmMemoryTracker* memory_tracker =
isolate->wasm_engine()->memory_tracker();
memory_tracker->FreeMemoryIfIsWasmMemory(isolate, allocation.backing_store);
memory_tracker->FreeWasmMemory(isolate, allocation.backing_store);
} else {
isolate->array_buffer_allocator()->Free(allocation.allocation_base,
allocation.length);
......
......@@ -260,8 +260,8 @@ bool WasmMemoryTracker::IsWasmMemoryGrowable(Handle<JSArrayBuffer> buffer) {
return allocation->second.is_growable;
}
bool WasmMemoryTracker::FreeMemoryIfIsWasmMemory(Isolate* isolate,
const void* buffer_start) {
bool WasmMemoryTracker::FreeWasmMemory(Isolate* isolate,
const void* buffer_start) {
base::MutexGuard scope_lock(&mutex_);
const auto& result = allocations_.find(buffer_start);
if (result == allocations_.end()) return false;
......
......@@ -107,10 +107,8 @@ class WasmMemoryTracker {
V8_EXPORT_PRIVATE const AllocationData* FindAllocationData(
const void* buffer_start);
// Checks if a buffer points to a Wasm memory and if so does any necessary
// work to reclaim the buffer. If this function returns false, the caller must
// free the buffer manually.
bool FreeMemoryIfIsWasmMemory(Isolate* isolate, const void* buffer_start);
// Free Memory allocated by the Wasm memory tracker
bool FreeWasmMemory(Isolate* isolate, const void* buffer_start);
void MarkWasmMemoryNotGrowable(Handle<JSArrayBuffer> buffer);
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment