OLD | NEW |
1 /* | 1 /* |
2 * Copyright (C) 2013 Google Inc. All rights reserved. | 2 * Copyright (C) 2013 Google Inc. All rights reserved. |
3 * | 3 * |
4 * Redistribution and use in source and binary forms, with or without | 4 * Redistribution and use in source and binary forms, with or without |
5 * modification, are permitted provided that the following conditions are | 5 * modification, are permitted provided that the following conditions are |
6 * met: | 6 * met: |
7 * | 7 * |
8 * * Redistributions of source code must retain the above copyright | 8 * * Redistributions of source code must retain the above copyright |
9 * notice, this list of conditions and the following disclaimer. | 9 * notice, this list of conditions and the following disclaimer. |
10 * * Redistributions in binary form must reproduce the above | 10 * * Redistributions in binary form must reproduce the above |
(...skipping 355 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
366 Address payloadAddress = region->base() + pageOffset + WTF::kSystemPageS
ize; | 366 Address payloadAddress = region->base() + pageOffset + WTF::kSystemPageS
ize; |
367 return new PageMemory(region, MemoryRegion(payloadAddress, payloadSize))
; | 367 return new PageMemory(region, MemoryRegion(payloadAddress, payloadSize))
; |
368 } | 368 } |
369 | 369 |
370 // Allocate a virtual address space for one blink page with the | 370 // Allocate a virtual address space for one blink page with the |
371 // following layout: | 371 // following layout: |
372 // | 372 // |
373 // [ guard os page | ... payload ... | guard os page ] | 373 // [ guard os page | ... payload ... | guard os page ] |
374 // ^---{ aligned to blink page size } | 374 // ^---{ aligned to blink page size } |
375 // | 375 // |
| 376 // The returned page memory region will be zeroed. |
| 377 // |
376 static PageMemory* allocate(size_t payloadSize) | 378 static PageMemory* allocate(size_t payloadSize) |
377 { | 379 { |
378 ASSERT(payloadSize > 0); | 380 ASSERT(payloadSize > 0); |
379 | 381 |
380 // Virtual memory allocation routines operate in OS page sizes. | 382 // Virtual memory allocation routines operate in OS page sizes. |
381 // Round up the requested size to nearest os page size. | 383 // Round up the requested size to nearest os page size. |
382 payloadSize = roundToOsPageSize(payloadSize); | 384 payloadSize = roundToOsPageSize(payloadSize); |
383 | 385 |
384 // Overallocate by 2 times OS page size to have space for a | 386 // Overallocate by 2 times OS page size to have space for a |
385 // guard page at the beginning and end of blink heap page. | 387 // guard page at the beginning and end of blink heap page. |
(...skipping 649 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1035 #endif | 1037 #endif |
1036 | 1038 |
1037 updateRemainingAllocationSize(); | 1039 updateRemainingAllocationSize(); |
1038 m_threadState->scheduleGCOrForceConservativeGCIfNeeded(); | 1040 m_threadState->scheduleGCOrForceConservativeGCIfNeeded(); |
1039 | 1041 |
1040 m_threadState->shouldFlushHeapDoesNotContainCache(); | 1042 m_threadState->shouldFlushHeapDoesNotContainCache(); |
1041 PageMemory* pageMemory = PageMemory::allocate(allocationSize); | 1043 PageMemory* pageMemory = PageMemory::allocate(allocationSize); |
1042 m_threadState->allocatedRegionsSinceLastGC().append(pageMemory->region()); | 1044 m_threadState->allocatedRegionsSinceLastGC().append(pageMemory->region()); |
1043 Address largeObjectAddress = pageMemory->writableStart(); | 1045 Address largeObjectAddress = pageMemory->writableStart(); |
1044 Address headerAddress = largeObjectAddress + sizeof(LargeObject<Header>) + h
eaderPadding<Header>(); | 1046 Address headerAddress = largeObjectAddress + sizeof(LargeObject<Header>) + h
eaderPadding<Header>(); |
1045 memset(headerAddress, 0, size); | 1047 #if ENABLE(ASSERT) |
| 1048 // Verify that the allocated PageMemory is expectedly zeroed. |
| 1049 for (size_t i = 0; i < size; ++i) |
| 1050 ASSERT(!headerAddress[i]); |
| 1051 #endif |
1046 Header* header = new (NotNull, headerAddress) Header(size, gcInfo); | 1052 Header* header = new (NotNull, headerAddress) Header(size, gcInfo); |
1047 Address result = headerAddress + sizeof(*header); | 1053 Address result = headerAddress + sizeof(*header); |
1048 ASSERT(!(reinterpret_cast<uintptr_t>(result) & allocationMask)); | 1054 ASSERT(!(reinterpret_cast<uintptr_t>(result) & allocationMask)); |
1049 LargeObject<Header>* largeObject = new (largeObjectAddress) LargeObject<Head
er>(pageMemory, gcInfo, threadState()); | 1055 LargeObject<Header>* largeObject = new (largeObjectAddress) LargeObject<Head
er>(pageMemory, gcInfo, threadState()); |
1050 header->checkHeader(); | 1056 header->checkHeader(); |
1051 | 1057 |
1052 // Poison the object header and allocationGranularity bytes after the object | 1058 // Poison the object header and allocationGranularity bytes after the object |
1053 ASAN_POISON_MEMORY_REGION(header, sizeof(*header)); | 1059 ASAN_POISON_MEMORY_REGION(header, sizeof(*header)); |
1054 ASAN_POISON_MEMORY_REGION(largeObject->address() + largeObject->size(), allo
cationGranularity); | 1060 ASAN_POISON_MEMORY_REGION(largeObject->address() + largeObject->size(), allo
cationGranularity); |
1055 | 1061 |
(...skipping 1761 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2817 bool Heap::s_shutdownCalled = false; | 2823 bool Heap::s_shutdownCalled = false; |
2818 bool Heap::s_lastGCWasConservative = false; | 2824 bool Heap::s_lastGCWasConservative = false; |
2819 FreePagePool* Heap::s_freePagePool; | 2825 FreePagePool* Heap::s_freePagePool; |
2820 OrphanedPagePool* Heap::s_orphanedPagePool; | 2826 OrphanedPagePool* Heap::s_orphanedPagePool; |
2821 Heap::RegionTree* Heap::s_regionTree = nullptr; | 2827 Heap::RegionTree* Heap::s_regionTree = nullptr; |
2822 size_t Heap::s_allocatedObjectSize = 0; | 2828 size_t Heap::s_allocatedObjectSize = 0; |
2823 size_t Heap::s_allocatedSpace = 0; | 2829 size_t Heap::s_allocatedSpace = 0; |
2824 size_t Heap::s_markedObjectSize = 0; | 2830 size_t Heap::s_markedObjectSize = 0; |
2825 | 2831 |
2826 } // namespace blink | 2832 } // namespace blink |
OLD | NEW |