Heap::Heap(VM* vm, HeapType heapType) : m_heapType(heapType) , m_ramSize(ramSize()) , m_minBytesPerCycle(minHeapSize(m_heapType, m_ramSize)) , m_sizeAfterLastCollect(0) , m_bytesAllocatedLimit(m_minBytesPerCycle) , m_bytesAllocated(0) , m_bytesAbandoned(0) , m_totalBytesVisited(0) , m_totalBytesCopied(0) , m_operationInProgress(NoOperation) , m_blockAllocator() , m_objectSpace(this) , m_storageSpace(this) , m_extraMemoryUsage(0) , m_machineThreads(this) , m_sharedData(vm) , m_slotVisitor(m_sharedData) , m_copyVisitor(m_sharedData) , m_handleSet(vm) , m_isSafeToCollect(false) , m_vm(vm) , m_lastGCLength(0) , m_lastCodeDiscardTime(WTF::monotonicallyIncreasingTime()) , m_activityCallback(DefaultGCActivityCallback::create(this)) , m_sweeper(IncrementalSweeper::create(this)) , m_deferralDepth(0) { m_storageSpace.init(); }
Heap::Heap(JSGlobalData* globalData, HeapType heapType) : m_heapType(heapType) , m_ramSize(ramSize()) , m_minBytesPerCycle(minHeapSize(m_heapType, m_ramSize)) , m_sizeAfterLastCollect(0) , m_bytesAllocatedLimit(m_minBytesPerCycle) , m_bytesAllocated(0) , m_bytesAbandoned(0) , m_operationInProgress(NoOperation) , m_blockAllocator() , m_objectSpace(this) , m_storageSpace(this) , m_machineThreads(this) , m_sharedData(globalData) , m_slotVisitor(m_sharedData) , m_copyVisitor(m_sharedData) , m_handleSet(globalData) , m_isSafeToCollect(false) , m_globalData(globalData) , m_lastGCLength(0) , m_lastCodeDiscardTime(WTF::currentTime()) , m_activityCallback(DefaultGCActivityCallback::create(this)) , m_sweeper(IncrementalSweeper::create(this)) { m_storageSpace.init(); }
Heap::Heap(VM* vm, HeapType heapType) : m_heapType(heapType) , m_ramSize(Options::forceRAMSize() ? Options::forceRAMSize() : ramSize()) , m_minBytesPerCycle(minHeapSize(m_heapType, m_ramSize)) , m_sizeAfterLastCollect(0) , m_sizeAfterLastFullCollect(0) , m_sizeBeforeLastFullCollect(0) , m_sizeAfterLastEdenCollect(0) , m_sizeBeforeLastEdenCollect(0) , m_bytesAllocatedThisCycle(0) , m_bytesAbandonedSinceLastFullCollect(0) , m_maxEdenSize(m_minBytesPerCycle) , m_maxHeapSize(m_minBytesPerCycle) , m_shouldDoFullCollection(false) , m_totalBytesVisited(0) , m_totalBytesCopied(0) , m_operationInProgress(NoOperation) , m_objectSpace(this) , m_storageSpace(this) , m_extraMemorySize(0) , m_deprecatedExtraMemorySize(0) , m_machineThreads(this) , m_sharedData(vm) , m_slotVisitor(m_sharedData) , m_copyVisitor(m_sharedData) , m_handleSet(vm) , m_isSafeToCollect(false) , m_writeBarrierBuffer(256) , m_vm(vm) // We seed with 10ms so that GCActivityCallback::didAllocate doesn't continuously // schedule the timer if we've never done a collection. , m_lastFullGCLength(0.01) , m_lastEdenGCLength(0.01) , m_fullActivityCallback(GCActivityCallback::createFullTimer(this)) #if ENABLE(GGC) , m_edenActivityCallback(GCActivityCallback::createEdenTimer(this)) #else , m_edenActivityCallback(m_fullActivityCallback) #endif #if USE(CF) , m_sweeper(std::make_unique<IncrementalSweeper>(this, CFRunLoopGetCurrent())) #else , m_sweeper(std::make_unique<IncrementalSweeper>(this->vm())) #endif , m_deferralDepth(0) #if USE(CF) , m_delayedReleaseRecursionCount(0) #endif { m_storageSpace.init(); if (Options::verifyHeap()) m_verifier = std::make_unique<HeapVerifier>(this, Options::numberOfGCCyclesToRecordForVerification()); }
void PDFDocumentImage::updateCachedImageIfNeeded(GraphicsContext& context, const FloatRect& dstRect, const FloatRect& srcRect) { #if PLATFORM(IOS) // On iOS, if the physical memory is less than 1GB, do not allocate more than 16MB for the PDF cachedImage. const size_t memoryThreshold = WTF::GB; const size_t maxArea = 16 * WTF::MB / 4; // 16 MB maximum size, divided by a rough cost of 4 bytes per pixel of area. if (ramSize() <= memoryThreshold && ImageBuffer::compatibleBufferSize(dstRect.size(), context).area() >= maxArea) { m_cachedImageBuffer = nullptr; return; } // On iOS, some clients use low-quality image interpolation always, which throws off this optimization, // as we never get the subsequent high-quality paint. Since live resize is rare on iOS, disable the optimization. // FIXME (136593): It's also possible to do the wrong thing here if CSS specifies low-quality interpolation via the "image-rendering" // property, on all platforms. We should only do this optimization if we're actually in a ImageQualityController live resize, // and are guaranteed to do a high-quality paint later. bool repaintIfNecessary = true; #else // If we have an existing image, reuse it if we're doing a low-quality paint, even if cache parameters don't match; // we'll rerender when we do the subsequent high-quality paint. InterpolationQuality interpolationQuality = context.imageInterpolationQuality(); bool repaintIfNecessary = interpolationQuality != InterpolationNone && interpolationQuality != InterpolationLow; #endif if (m_cachedImageBuffer && (!repaintIfNecessary || cacheParametersMatch(context, dstRect, srcRect))) return; m_cachedImageBuffer = ImageBuffer::createCompatibleBuffer(FloatRect(enclosingIntRect(dstRect)).size(), context); if (!m_cachedImageBuffer) return; auto& bufferContext = m_cachedImageBuffer->context(); transformContextForPainting(bufferContext, dstRect, srcRect); drawPDFPage(bufferContext); m_cachedTransform = context.getCTM(GraphicsContext::DefinitelyIncludeDeviceScale); m_cachedDestinationSize = dstRect.size(); m_cachedSourceRect = srcRect; IntSize internalSize = m_cachedImageBuffer->internalSize(); size_t oldCachedBytes = m_cachedBytes; m_cachedBytes = safeCast<size_t>(internalSize.width()) * internalSize.height() * 4; if (imageObserver()) imageObserver()->decodedSizeChanged(this, safeCast<int>(m_cachedBytes) - safeCast<int>(oldCachedBytes)); }
void MBC3Mapper::writeExRam(quint16 address, quint8 data) { if (m_ramEnable) { if (m_ramBank != -1) { if (ramSize()) writeDirect(address, data); } else { time(&m_lastTime); switch (m_clockRegister) { case 0x08: m_seconds = data; break; case 0x09: m_minutes = data; break; case 0x0a: m_hours = data; break; case 0x0b: m_days = data; break; case 0x0c: m_control = (m_control & 0x80) | data; break; } } } }