Lines Matching +full:page +full:- +full:offset
1 //===-- release.h -----------------------------------------------*- C++ -*-===//
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 //===----------------------------------------------------------------------===//
22 RegionReleaseRecorder(MemMapT *RegionMemMap, uptr Base, uptr Offset = 0)
23 : RegionMemMap(RegionMemMap), Base(Base), Offset(Offset) {}
32 // are offseted from `Base` + Offset.
34 const uptr Size = To - From;
35 RegionMemMap->releasePagesToOS(getBase() + Offset + From, Size);
45 // The release offset from Base. This is used when we know a given range after
47 uptr Offset = 0;
52 ReleaseRecorder(uptr Base, uptr Offset = 0, MapPlatformData *Data = nullptr)
53 : Base(Base), Offset(Offset), Data(Data) {}
63 const uptr Size = To - From;
64 releasePagesToOS(Base, From + Offset, Size, Data);
73 // Offset) as a new Base. However, the Base is retrieved from
74 // `MapPlatformData` on Fuchsia, which means the offset won't be aware.
77 // The release offset from Base. This is used when we know a given range after
79 uptr Offset = 0;
90 DCHECK_EQ((To - From) % getPageSizeCached(), 0U);
91 ReleasedPagesCount += (To - From) / getPageSizeCached();
105 // Preserve 1 bit in the `Mask` so that we don't need to do zero-check while
125 // Return a zero-initialized buffer which can contain at least the given
135 // the busy-waiting but we may want to review the performance and see if
173 // When using a heap-based buffer, precommit the pages backing the
175 // where page fault exceptions are skipped as the allocated memory
195 // A Region page map is used to record the usage of pages in the regions. It
221 // specify the thread-safety attribute properly in current code structure.
223 // it's fine to bypass the thread-safety analysis now.
234 // bit shifts calculating particular counter's Index and offset.
239 CounterMask = ~(static_cast<uptr>(0)) >> (MaxCounterBits - CounterSizeBits);
244 BitOffsetMask = PackingRatio - 1;
279 DCHECK_LE(get(Region, I), CounterMask - N);
295 // page may vary. To provide an easier way to tell if all the blocks are
297 // all-counted status.
395 // Same number of chunks per page, no cross overs.
399 // Some chunks are crossing page boundaries, which means that the page
405 // Some chunks are crossing page boundaries, which means that the page
416 // One chunk covers multiple pages, Some chunks are crossing page
449 // the blocks, we will just mark the page as all counted. Note the `From` and
450 // `To` has to be page aligned but with one exception, if `To` is equal to the
451 // RegionSize, it's not necessary to be aligned with page size.
457 DCHECK_LE(To - From, RegionSize);
462 uptr FromInRegion = From - Base;
463 uptr ToInRegion = To - Base;
471 // `FromInRegion` to the first block page.
479 // +-----------------------------------------------+
480 // +-----+-----+-----+-----+
482 // +-----+-----+-----+-----+
483 // |- first page -||- second page -||- ...
485 // Therefore, we can't just mark the first page as all counted. Instead, we
486 // increment the number of blocks in the first page in the page map and
487 // then round up the `From` to the next page.
491 (FromInRegion + PageSize - FirstBlockInRange + BlockSize - 1) /
498 uptr LastBlockInRange = roundDownSlow(ToInRegion - 1, BlockSize);
513 // +----------------------------------------+
514 // +-----+-----+-----+-----+
516 // +-----+-----+-----+-----+
517 // ... -||- last page -||- next page -|
520 // counter of `next page` by 1.
523 getPageIndex(LastBlockInRange + BlockSize - 1));
529 // After handling the first page and the last block, it's safe to mark any
530 // page in between the range [From, To).
533 getPageIndex(ToInRegion - 1));
549 ((RegionSize / BlockSize) - 1U) * BlockSize;
550 // The last block in a region may not use the entire page, we mark the
555 // -----+-----------------------+
556 // | Last Page | <- Rounded Region Boundary
557 // -----+-----------------------+
558 // |-----||- trailing blocks -|
564 // `TrailingBlockBase` is larger than a page, that implies the reported
566 DCHECK_LT(RoundedRegionSize - TrailingBlockBase, PageSize);
568 // Only the last page touched by the last block needs to mark the trailing
571 // of blocks on a page is consistent.
573 (roundUpSlow(RoundedRegionSize - TrailingBlockBase, BlockSize) +
574 BlockSize - 1) /
583 // allocated page.
585 // Each chunk affects one page only.
588 const uptr PInRegion = DecompactPtr(It.get(I)) - Base;
594 // In all other cases chunks might affect more than one page.
598 const uptr PInRegion = DecompactPtr(It.get(I)) - Base;
600 getPageIndex(PInRegion + BlockSize - 1));
608 uptr getPageIndex(uptr P) { return (P >> PageSizeLog) - ReleasePageOffset; }
624 // Try to release the page which doesn't have any in-used block, i.e., they are
626 // page.
641 // to the expected number of chunks for the particular page.
644 // Fast path, every page has the same number of chunks affecting it.
658 // each page.
661 // The idea is to increment the current page pointer by the first chunk
662 // size, middle portion size (the portion of the page covered by chunks
664 // up the number of chunks on the current page and checking on every step
665 // whether the page boundary was crossed.