Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(2272)

Unified Diff: Source/platform/heap/Heap.cpp

Issue 827423002: For large object allocations, do not clear already zeroed memory. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 12 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: Source/platform/heap/Heap.cpp
diff --git a/Source/platform/heap/Heap.cpp b/Source/platform/heap/Heap.cpp
index 779a9be65f7fce0658dea8eca219c35a76e7124f..b197c3d0a198d0b8c8d0e59d05e7e811cad24dc2 100644
--- a/Source/platform/heap/Heap.cpp
+++ b/Source/platform/heap/Heap.cpp
@@ -373,6 +373,8 @@ public:
// [ guard os page | ... payload ... | guard os page ]
// ^---{ aligned to blink page size }
//
+ // The returned page memory region will be zeroed.
+ //
static PageMemory* allocate(size_t payloadSize)
{
ASSERT(payloadSize > 0);
@@ -1042,7 +1044,11 @@ Address ThreadHeap<Header>::allocateLargeObject(size_t size, const GCInfo* gcInf
m_threadState->allocatedRegionsSinceLastGC().append(pageMemory->region());
Address largeObjectAddress = pageMemory->writableStart();
Address headerAddress = largeObjectAddress + sizeof(LargeObject<Header>) + headerPadding<Header>();
- memset(headerAddress, 0, size);
+#if ENABLE(ASSERT)
+ // Verify that the allocated PageMemory is expectedly zeroed.
+ for (size_t i = 0; i < size; ++i)
+ ASSERT(!headerAddress[i]);
+#endif
Header* header = new (NotNull, headerAddress) Header(size, gcInfo);
Address result = headerAddress + sizeof(*header);
ASSERT(!(reinterpret_cast<uintptr_t>(result) & allocationMask));
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698