void SharedArrayRawBuffer::dropReference() { // Drop the reference to the buffer. uint32_t refcount = --this->refcount; // Atomic. // If this was the final reference, release the buffer. if (refcount == 0) { SharedMem<uint8_t*> p = this->dataPointerShared() - AsmJSPageSize; MOZ_ASSERT(p.asValue() % AsmJSPageSize == 0); uint8_t* address = p.unwrap(/*safe - only reference*/); #if defined(ASMJS_MAY_USE_SIGNAL_HANDLERS_FOR_OOB) numLive--; UnmapMemory(address, SharedArrayMappedSize); # if defined(MOZ_VALGRIND) \ && defined(VALGRIND_ENABLE_ADDR_ERROR_REPORTING_IN_RANGE) // Tell Valgrind/Memcheck to recommence reporting accesses in the // previously-inaccessible region. VALGRIND_ENABLE_ADDR_ERROR_REPORTING_IN_RANGE(address, SharedArrayMappedSize); # endif #else UnmapMemory(address, this->length + AsmJSPageSize); #endif } }
void SharedArrayRawBuffer::dropReference() { // Drop the reference to the buffer. uint32_t refcount = --this->refcount_; // Atomic. if (refcount) return; // If this was the final reference, release the buffer. SharedMem<uint8_t*> p = this->dataPointerShared() - gc::SystemPageSize(); MOZ_ASSERT(p.asValue() % gc::SystemPageSize() == 0); uint8_t* address = p.unwrap(/*safe - only reference*/); uint32_t allocSize = SharedArrayAllocSize(this->length); if (this->preparedForAsmJS) { numLive--; uint32_t mappedSize = SharedArrayMappedSize(allocSize); UnmapMemory(address, mappedSize); # if defined(MOZ_VALGRIND) && defined(VALGRIND_ENABLE_ADDR_ERROR_REPORTING_IN_RANGE) // Tell Valgrind/Memcheck to recommence reporting accesses in the // previously-inaccessible region. VALGRIND_ENABLE_ADDR_ERROR_REPORTING_IN_RANGE(address, mappedSize); # endif } else { UnmapMemory(address, allocSize); } }
void SharedArrayRawBuffer::dropReference() { // Normally if the refcount is zero then the memory will have been unmapped // and this test may just crash, but if the memory has been retained for any // reason we will catch the underflow here. MOZ_RELEASE_ASSERT(this->refcount_ > 0); // Drop the reference to the buffer. uint32_t refcount = --this->refcount_; // Atomic. if (refcount) return; // If this was the final reference, release the buffer. #ifdef DEBUG liveBuffers_--; #endif SharedMem<uint8_t*> p = this->dataPointerShared() - gc::SystemPageSize(); MOZ_ASSERT(p.asValue() % gc::SystemPageSize() == 0); uint8_t* address = p.unwrap(/*safe - only reference*/); uint32_t allocSize = SharedArrayAllocSize(this->length); if (this->preparedForAsmJS) { numLive--; uint32_t mappedSize = SharedArrayMappedSize(allocSize); UnmapMemory(address, mappedSize); # if defined(MOZ_VALGRIND) && defined(VALGRIND_ENABLE_ADDR_ERROR_REPORTING_IN_RANGE) // Tell Valgrind/Memcheck to recommence reporting accesses in the // previously-inaccessible region. VALGRIND_ENABLE_ADDR_ERROR_REPORTING_IN_RANGE(address, mappedSize); # endif } else { UnmapMemory(address, allocSize); } }