Changeset 227721 in webkit
- Timestamp:
- Jan 28, 2018 9:08:13 PM (6 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r227718 r227721 1 2018-01-28 Filip Pizlo <fpizlo@apple.com> 2 3 LargeAllocation should do the same distancing as MarkedBlock 4 https://bugs.webkit.org/show_bug.cgi?id=182226 5 6 Reviewed by Saam Barati. 7 8 This makes LargeAllocation do the same exact distancing that MarkedBlock promises to do. 9 10 To make that possible, this patch first makes MarkedBlock know exactly how much distancing it 11 is doing: 12 13 - I've rationalized the payloadSize calculation. In particular, I made MarkedSpace use the 14 calculation done in MarkedBlock. MarkedSpace used to do the math a different way. This 15 keeps the old way just for a static_assert. 16 17 - The promised amount of distancing is now codified in HeapCell.h as 18 minimumDistanceBetweenCellsFromDifferentOrigins. We assert that the footer size is at least 19 as big as this. I didn't want to just use footer size for this constant because then, if 20 you increased the size of the footer, you'd also add padding to every large allocation. 21 22 Then this patch just adds minimumDistanceBetweenCellsFromDifferentOrigins to each large 23 allocation. It also zeroes that slice of memory to prevent any information leaks that way. 24 25 This is perf neutral. Large allocations start out at ~8000 bytes. The amount of padding is 26 ~300 bytes. That's 3.75% space overhead for objects that are ~8000 bytes, zero overhead for 27 smaller objects, and diminishing overhead for larger objects. We allocate very few large 28 objects, so we shouldn't have any real space overhead from this. 29 30 * heap/HeapCell.h: 31 * heap/LargeAllocation.cpp: 32 (JSC::LargeAllocation::tryCreate): 33 * heap/MarkedBlock.h: 34 * heap/MarkedSpace.h: 35 1 36 2018-01-27 Filip Pizlo <fpizlo@apple.com> 2 37 -
trunk/Source/JavaScriptCore/heap/HeapCell.h
r226822 r227721 1 1 /* 2 * Copyright (C) 2016-201 7Apple Inc. All rights reserved.2 * Copyright (C) 2016-2018 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 37 37 class VM; 38 38 struct CellAttributes; 39 40 static constexpr unsigned minimumDistanceBetweenCellsFromDifferentOrigins = sizeof(void*) == 8 ? 304 : 288; 39 41 40 42 class HeapCell { -
trunk/Source/JavaScriptCore/heap/LargeAllocation.cpp
r220291 r227721 1 1 /* 2 * Copyright (C) 2016-201 7Apple Inc. All rights reserved.2 * Copyright (C) 2016-2018 Apple Inc. All rights reserved. 3 3 * 4 4 * Redistribution and use in source and binary forms, with or without … … 36 36 LargeAllocation* LargeAllocation::tryCreate(Heap& heap, size_t size, Subspace* subspace) 37 37 { 38 void* space = subspace->alignedMemoryAllocator()->tryAllocateAlignedMemory(alignment, headerSize() + size); 38 // This includes padding at the end of the allocation to maintain the distancing constraint. 39 constexpr size_t distancing = minimumDistanceBetweenCellsFromDifferentOrigins; 40 size_t sizeBeforeDistancing = headerSize() + size; 41 size_t sizeIncludingDistancing = sizeBeforeDistancing + distancing; 42 43 void* space = subspace->alignedMemoryAllocator()->tryAllocateAlignedMemory(alignment, sizeIncludingDistancing); 39 44 if (!space) 40 45 return nullptr; 46 47 // Make sure that the padding does not contain useful things. 48 memset(static_cast<char*>(space) + sizeBeforeDistancing, 0, distancing); 49 41 50 if (scribbleFreeCells()) 42 51 scribble(space, size); -
trunk/Source/JavaScriptCore/heap/MarkedBlock.h
r227718 r227721 286 286 Bitmap<atomsPerBlock> m_newlyAllocated; 287 287 }; 288 288 289 289 private: 290 290 Footer& footer(); … … 293 293 public: 294 294 static constexpr size_t endAtom = (blockSize - sizeof(Footer)) / atomSize; 295 295 static constexpr size_t payloadSize = endAtom * atomSize; 296 static constexpr size_t footerSize = blockSize - payloadSize; 297 298 static_assert(payloadSize == ((blockSize - sizeof(MarkedBlock::Footer)) & ~(atomSize - 1)), "Payload size computed the alternate way should give the same result"); 299 static_assert(footerSize >= minimumDistanceBetweenCellsFromDifferentOrigins, "Footer is not big enough to create the necessary distance between objects from different origins"); 300 296 301 static MarkedBlock::Handle* tryCreate(Heap&, AlignedMemoryAllocator*); 297 302 -
trunk/Source/JavaScriptCore/heap/MarkedSpace.h
r227717 r227721 56 56 static constexpr size_t preciseCutoff = 80; 57 57 58 // The amount of available payload in a block is the block's size minus the footer. But the 59 // header size might not be atom size aligned, so we round down the result accordingly. 60 static constexpr size_t blockPayload = (MarkedBlock::blockSize - sizeof(MarkedBlock::Footer)) & ~(MarkedBlock::atomSize - 1); 58 // The amount of available payload in a block is the block's size minus the footer. 59 static constexpr size_t blockPayload = MarkedBlock::payloadSize; 61 60 62 61 // The largest cell we're willing to allocate in a MarkedBlock the "normal way" (i.e. using size
Note: See TracChangeset
for help on using the changeset viewer.