mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-28 07:13:20 +00:00
Bug 1778077 part 4 - Call WasmSharedArrayRawBuffer's destructor to ensure the mutex is destroyed. r=sfink
This fixes a pre-existing issue: `Mutex` has a destructor so we should call it. Depends on D151010 Differential Revision: https://phabricator.services.mozilla.com/D151016
This commit is contained in:
parent
e83b79317b
commit
423773ff84
@ -26,6 +26,7 @@
|
||||
# include <sys/mman.h>
|
||||
#endif
|
||||
#include <tuple> // std::tuple
|
||||
#include <type_traits>
|
||||
#ifdef MOZ_VALGRIND
|
||||
# include <valgrind/memcheck.h>
|
||||
#endif
|
||||
@ -722,6 +723,9 @@ void WasmArrayRawBuffer::Release(void* mem) {
|
||||
MOZ_RELEASE_ASSERT(header->mappedSize() <= SIZE_MAX - gc::SystemPageSize());
|
||||
size_t mappedSizeWithHeader = header->mappedSize() + gc::SystemPageSize();
|
||||
|
||||
static_assert(std::is_trivially_destructible_v<WasmArrayRawBuffer>,
|
||||
"no need to call the destructor");
|
||||
|
||||
UnmapBufferMemory(header->indexType(), header->basePointer(),
|
||||
mappedSizeWithHeader);
|
||||
}
|
||||
|
@ -204,10 +204,13 @@ void SharedArrayRawBuffer::dropReference() {
|
||||
// This was the final reference, so release the buffer.
|
||||
if (isWasm()) {
|
||||
WasmSharedArrayRawBuffer* wasmBuf = toWasmBuffer();
|
||||
wasm::IndexType indexType = wasmBuf->wasmIndexType();
|
||||
uint8_t* basePointer = wasmBuf->basePointer();
|
||||
size_t mappedSizeWithHeader =
|
||||
wasmBuf->wasmMappedSize() + gc::SystemPageSize();
|
||||
UnmapBufferMemory(wasmBuf->wasmIndexType(), wasmBuf->basePointer(),
|
||||
mappedSizeWithHeader);
|
||||
// Call the destructor to destroy the growLock_ Mutex.
|
||||
wasmBuf->~WasmSharedArrayRawBuffer();
|
||||
UnmapBufferMemory(indexType, basePointer, mappedSizeWithHeader);
|
||||
} else {
|
||||
js_delete(this);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user