Changeset 240193 in webkit
- Timestamp:
- Jan 18, 2019 7:27:29 PM (5 years ago)
- Location:
- trunk/Source/bmalloc
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/bmalloc/ChangeLog
r240176 r240193 1 2019-01-18 Keith Miller <keith_miller@apple.com> 2 3 gigacage slide should randomize both start and end 4 https://bugs.webkit.org/show_bug.cgi?id=193601 5 6 Reviewed by Yusuke Suzuki. 7 8 This patch makes it so that the gigacade slide has an arbitrary 9 distance from the end as well as the start. This is done by 10 picking a random size then based on that size picking an random 11 starting offset. 12 13 * bmalloc/Gigacage.h: 14 * bmalloc/Heap.cpp: 15 (bmalloc::Heap::Heap): 16 1 17 2019-01-18 Jer Noble <jer.noble@apple.com> 2 18 -
trunk/Source/bmalloc/bmalloc/Algorithm.h
r237429 r240193 100 100 { 101 101 BASSERT(isPowerOfTwo(divisor)); 102 return reinterpret_cast<T>(mask(reinterpret_cast<uintptr_t>(x), ~(divisor - 1ul))); 102 static_assert(sizeof(T) == sizeof(uintptr_t), "sizeof(T) must be equal to sizeof(uintptr_t)."); 103 return static_cast<T>(mask(static_cast<uintptr_t>(x), ~(divisor - 1ul))); 104 } 105 106 template<typename T> inline T* roundDownToMultipleOf(size_t divisor, T* x) 107 { 108 BASSERT(isPowerOfTwo(divisor)); 109 return reinterpret_cast<T*>(mask(reinterpret_cast<uintptr_t>(x), ~(divisor - 1ul))); 103 110 } 104 111 -
trunk/Source/bmalloc/bmalloc/Gigacage.h
r240175 r240193 71 71 constexpr size_t jsValueGigacageSize = 1 * bmalloc::Sizes::GB; 72 72 constexpr size_t gigacageBasePtrsSize = 16 * bmalloc::Sizes::kB; 73 constexpr size_t m inimumCageSizeAfterSlide = bmalloc::Sizes::GB / 2;73 constexpr size_t maximumCageSizeReductionForSlide = bmalloc::Sizes::GB / 2; 74 74 #define GIGACAGE_ALLOCATION_CAN_FAIL 1 75 75 #else … … 77 77 constexpr size_t jsValueGigacageSize = 16 * bmalloc::Sizes::GB; 78 78 constexpr size_t gigacageBasePtrsSize = 4 * bmalloc::Sizes::kB; 79 constexpr size_t m inimumCageSizeAfterSlide = 4 * bmalloc::Sizes::GB;79 constexpr size_t maximumCageSizeReductionForSlide = 4 * bmalloc::Sizes::GB; 80 80 #define GIGACAGE_ALLOCATION_CAN_FAIL 0 81 81 #endif … … 91 91 static_assert(bmalloc::isPowerOfTwo(primitiveGigacageSize), ""); 92 92 static_assert(bmalloc::isPowerOfTwo(jsValueGigacageSize), ""); 93 static_assert(primitiveGigacageSize > m inimumCageSizeAfterSlide, "");94 static_assert(jsValueGigacageSize > m inimumCageSizeAfterSlide, "");93 static_assert(primitiveGigacageSize > maximumCageSizeReductionForSlide, ""); 94 static_assert(jsValueGigacageSize > maximumCageSizeReductionForSlide, ""); 95 95 96 96 constexpr size_t gigacageSizeToMask(size_t size) { return size - 1; } -
trunk/Source/bmalloc/bmalloc/Heap.cpp
r240175 r240193 63 63 if (usingGigacage()) { 64 64 RELEASE_BASSERT(gigacageBasePtr()); 65 uint64_t random ;66 cryptoRandom(reinterpret_cast<unsigned char*>( &random), sizeof(random));67 ptrdiff_t offset = random % (gigacageSize() - Gigacage::minimumCageSizeAfterSlide);68 offset = reinterpret_cast<ptrdiff_t>(roundDownToMultipleOf(vmPageSize(), reinterpret_cast<void*>(offset)));65 uint64_t random[2]; 66 cryptoRandom(reinterpret_cast<unsigned char*>(random), sizeof(random)); 67 size_t size = roundDownToMultipleOf(vmPageSize(), gigacageSize() - (random[0] % Gigacage::maximumCageSizeReductionForSlide)); 68 ptrdiff_t offset = roundDownToMultipleOf(vmPageSize(), random[1] % (gigacageSize() - size)); 69 69 void* base = reinterpret_cast<unsigned char*>(gigacageBasePtr()) + offset; 70 m_largeFree.add(LargeRange(base, gigacageSize() - offset, 0, 0));70 m_largeFree.add(LargeRange(base, size, 0, 0)); 71 71 } 72 72 #endif
Note: See TracChangeset
for help on using the changeset viewer.