diff --git a/common_components/heap/allocator/region_desc.h b/common_components/heap/allocator/region_desc.h index 210dd11c57604bf8b3d9c7860d7a415a9a354166..6c4e9ab5b5fa02a0fd6e311237c25b33ac8ebe73 100755 --- a/common_components/heap/allocator/region_desc.h +++ b/common_components/heap/allocator/region_desc.h @@ -853,7 +853,7 @@ public: return (GetRegionType() == RegionType::FIXED_PINNED_REGION) || (GetRegionType() == RegionType::FULL_FIXED_PINNED_REGION); } - + bool IsThreadLocalRegion() const { return GetRegionType() == RegionType::THREAD_LOCAL_REGION || @@ -1267,7 +1267,7 @@ public: DCHECK_CC(RegionDesc::IsAliveRegionType(regionType_)); return regionType_; } - + bool IsInRecentSpace() const { RegionType type = GetRegionType(); @@ -1369,12 +1369,10 @@ private: SetResurrectedRegionFlag(0); __atomic_store_n(&metadata.rawPointerObjectCount, 0, __ATOMIC_SEQ_CST); #ifdef USE_HWASAN - ASAN_UNPOISON_MEMORY_REGION(reinterpret_cast(metadata.allocPtr), - nUnit * RegionDesc::UNIT_SIZE); - uintptr_t pAddr = metadata.allocPtr; + uintptr_t pAddr = metadata.regionBase; uintptr_t pSize = nUnit * RegionDesc::UNIT_SIZE; - LOG_COMMON(DEBUG) << std::hex << "set [" << pAddr << - std::hex << ", " << (pAddr + pSize) << ") unpoisoned\n"; + ASAN_UNPOISON_MEMORY_REGION(reinterpret_cast(pAddr), pSize); + LOG_COMMON(DEBUG) << std::hex << "set [" << pAddr << std::hex << ", " << (pAddr + pSize) << ") unpoisoned\n"; #endif } diff --git a/common_components/heap/allocator/region_manager.cpp b/common_components/heap/allocator/region_manager.cpp index 4f5bdc9c4d1ddf39d8f5ee6c84987b4c3c45c24d..e395d58370dbe33f9235e8e6490a4e9745c43cdd 100755 --- a/common_components/heap/allocator/region_manager.cpp +++ b/common_components/heap/allocator/region_manager.cpp @@ -443,12 +443,10 @@ void RegionManager::Initialize(size_t nRegion, uintptr_t regionInfoAddr) DLOG(REPORT, "region info @0x%zx+%zu, heap [0x%zx, 0x%zx), unit count %zu", regionInfoAddr, metadataSize, regionHeapStart_, regionHeapEnd_, nRegion); #ifdef USE_HWASAN - ASAN_UNPOISON_MEMORY_REGION(reinterpret_cast(regionInfoAddr), - metadataSize + nRegion * RegionDesc::UNIT_SIZE); const uintptr_t p_addr = regionInfoAddr; const uintptr_t p_size = metadataSize + nRegion * RegionDesc::UNIT_SIZE; - LOG_COMMON(DEBUG) << std::hex << "set [" << p_addr << - std::hex << ", " << p_addr + p_size << ") unpoisoned\n"; + ASAN_UNPOISON_MEMORY_REGION(reinterpret_cast(p_addr), p_size); + LOG_COMMON(DEBUG) << std::hex << "set [" << p_addr << std::hex << ", " << p_addr + p_size << ") unpoisoned\n"; #endif } @@ -593,12 +591,11 @@ RegionDesc *RegionManager::TakeRegion(size_t num, RegionDesc::UnitRole type, boo if (num <= GetInactiveUnitCount()) { uintptr_t addr = inactiveZone_.fetch_add(size); if (addr < regionHeapEnd_ - size) { - region = RegionDesc::InitRegionAt(addr, num, type); - size_t idx = region->GetUnitIdx(); #ifdef _WIN64 - MemoryMap::CommitMemory( - reinterpret_cast(RegionDesc::GetUnitAddress(idx)), num * RegionDesc::UNIT_SIZE); + MemoryMap::CommitMemory(reinterpret_cast(addr), num * RegionDesc::UNIT_SIZE); #endif + region = RegionDesc::InitRegionAt(addr, num, type); + size_t idx = region->GetUnitIdx(); (void)idx; // eliminate compilation warning DLOG(REGION, "take inactive units [%zu+%zu, %zu) at [0x%zx, 0x%zx)", idx, num, idx + num, RegionDesc::GetUnitAddress(idx), RegionDesc::GetUnitAddress(idx + num)); diff --git a/common_components/heap/collector/region_rset.h b/common_components/heap/collector/region_rset.h index 80131677162ee83b47e6e52a490b99c2df8d8cac..dc03f3074129685ea03fe3818a917c1f2caca3c4 100644 --- a/common_components/heap/collector/region_rset.h +++ b/common_components/heap/collector/region_rset.h @@ -25,7 +25,7 @@ public: { CHECK_CC(regionSize % CARD_SIZE == 0); #ifdef _WIN64 - void* startAddress = VirtualAlloc(NULL, cardCnt * sizeof(uint64_t), MEM_RESERVE, PAGE_READWRITE); + void* startAddress = VirtualAlloc(NULL, cardCnt * sizeof(uint64_t), MEM_RESERVE | MEM_COMMIT, PAGE_READWRITE); if (startAddress == NULL) { LOG_COMMON(FATAL) << "failed to initialize HeapBitmapManager"; UNREACHABLE_CC();