@@ -566,32 +566,17 @@ static bool IsValidMmapRange(uptr addr, uptr size) {
566566 return false ;
567567}
568568
569- void UnmapShadow (ThreadState* thr, uptr addr, uptr size) {
569+ void UnmapShadow (ThreadState * thr, uptr addr, uptr size) {
570570 if (size == 0 || !IsValidMmapRange (addr, size))
571571 return ;
572- // unmap shadow is related to semantic of mmap/munmap, so we
573- // should clear the whole shadow range, including the tail shadow
574- // while addr + size % kShadowCell != 0.
575- uptr rounded_size_shadow = RoundUp (addr + size, kShadowCell ) - addr;
576- DontNeedShadowFor (addr, rounded_size_shadow);
572+ DontNeedShadowFor (addr, size);
577573 ScopedGlobalProcessor sgp;
578574 SlotLocker locker (thr, true );
579- uptr rounded_size_meta = RoundUp (addr + size, kMetaShadowCell ) - addr;
580- ctx->metamap .ResetRange (thr->proc (), addr, rounded_size_meta, true );
575+ ctx->metamap .ResetRange (thr->proc (), addr, size, true );
581576}
582577#endif
583578
584579void MapShadow (uptr addr, uptr size) {
585- // Although named MapShadow, this function's semantic is unrelated to
586- // UnmapShadow. This function currently only used for Go's lazy allocation
587- // of shadow, whose targets are program section (e.g., bss, data, etc.).
588- // Therefore, we can guarantee that the addr and size align to kShadowCell
589- // and kMetaShadowCell by the following assertions.
590- DCHECK_EQ (addr % kShadowCell , 0 );
591- DCHECK_EQ (size % kShadowCell , 0 );
592- DCHECK_EQ (addr % kMetaShadowCell , 0 );
593- DCHECK_EQ (size % kMetaShadowCell , 0 );
594-
595580 // Ensure thead registry lock held, so as to synchronize
596581 // with DoReset, which also access the mapped_shadow_* ctxt fields.
597582 ThreadRegistryLock lock0 (&ctx->thread_registry );
0 commit comments