| 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 1246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1257 header->markDead(); | 1257 header->markDead(); |
| 1258 } | 1258 } |
| 1259 headerAddress += header->size(); | 1259 headerAddress += header->size(); |
| 1260 } | 1260 } |
| 1261 if (markedObjectSize) | 1261 if (markedObjectSize) |
| 1262 Heap::increaseMarkedObjectSize(markedObjectSize); | 1262 Heap::increaseMarkedObjectSize(markedObjectSize); |
| 1263 } | 1263 } |
| 1264 | 1264 |
| 1265 void NormalPage::makeConsistentForMutator() | 1265 void NormalPage::makeConsistentForMutator() |
| 1266 { | 1266 { |
| 1267 size_t markedObjectSize = 0; | |
| 1268 Address startOfGap = payload(); | 1267 Address startOfGap = payload(); |
| 1269 for (Address headerAddress = payload(); headerAddress < payloadEnd();) { | 1268 for (Address headerAddress = payload(); headerAddress < payloadEnd();) { |
| 1270 HeapObjectHeader* header = reinterpret_cast<HeapObjectHeader*>(headerAdd
ress); | 1269 HeapObjectHeader* header = reinterpret_cast<HeapObjectHeader*>(headerAdd
ress); |
| 1271 ASSERT(header->size() < blinkPagePayloadSize()); | 1270 ASSERT(header->size() < blinkPagePayloadSize()); |
| 1272 // Check if a free list entry first since we cannot call | 1271 // Check if a free list entry first since we cannot call |
| 1273 // isMarked on a free list entry. | 1272 // isMarked on a free list entry. |
| 1274 if (header->isFree()) { | 1273 if (header->isFree()) { |
| 1275 headerAddress += header->size(); | 1274 headerAddress += header->size(); |
| 1276 continue; | 1275 continue; |
| 1277 } | 1276 } |
| 1278 header->checkHeader(); | 1277 header->checkHeader(); |
| 1279 | 1278 |
| 1280 if (startOfGap != headerAddress) | 1279 if (startOfGap != headerAddress) |
| 1281 heapForNormalPage()->addToFreeList(startOfGap, headerAddress - start
OfGap); | 1280 heapForNormalPage()->addToFreeList(startOfGap, headerAddress - start
OfGap); |
| 1282 if (header->isMarked()) { | 1281 if (header->isMarked()) { |
| 1283 header->unmark(); | 1282 header->unmark(); |
| 1284 markedObjectSize += header->size(); | |
| 1285 } | 1283 } |
| 1286 headerAddress += header->size(); | 1284 headerAddress += header->size(); |
| 1287 startOfGap = headerAddress; | 1285 startOfGap = headerAddress; |
| 1288 } | 1286 } |
| 1289 if (startOfGap != payloadEnd()) | 1287 if (startOfGap != payloadEnd()) |
| 1290 heapForNormalPage()->addToFreeList(startOfGap, payloadEnd() - startOfGap
); | 1288 heapForNormalPage()->addToFreeList(startOfGap, payloadEnd() - startOfGap
); |
| 1291 | |
| 1292 if (markedObjectSize) | |
| 1293 Heap::increaseMarkedObjectSize(markedObjectSize); | |
| 1294 } | 1289 } |
| 1295 | 1290 |
| 1296 #if defined(ADDRESS_SANITIZER) | 1291 #if defined(ADDRESS_SANITIZER) |
| 1297 void NormalPage::poisonObjects(ObjectsToPoison objectsToPoison, Poisoning poison
ing) | 1292 void NormalPage::poisonObjects(ObjectsToPoison objectsToPoison, Poisoning poison
ing) |
| 1298 { | 1293 { |
| 1299 for (Address headerAddress = payload(); headerAddress < payloadEnd();) { | 1294 for (Address headerAddress = payload(); headerAddress < payloadEnd();) { |
| 1300 HeapObjectHeader* header = reinterpret_cast<HeapObjectHeader*>(headerAdd
ress); | 1295 HeapObjectHeader* header = reinterpret_cast<HeapObjectHeader*>(headerAdd
ress); |
| 1301 ASSERT(header->size() < blinkPagePayloadSize()); | 1296 ASSERT(header->size() < blinkPagePayloadSize()); |
| 1302 // Check if a free list entry first since we cannot call | 1297 // Check if a free list entry first since we cannot call |
| 1303 // isMarked on a free list entry. | 1298 // isMarked on a free list entry. |
| (...skipping 274 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1578 header->unmark(); | 1573 header->unmark(); |
| 1579 Heap::increaseMarkedObjectSize(size()); | 1574 Heap::increaseMarkedObjectSize(size()); |
| 1580 } else { | 1575 } else { |
| 1581 header->markDead(); | 1576 header->markDead(); |
| 1582 } | 1577 } |
| 1583 } | 1578 } |
| 1584 | 1579 |
| 1585 void LargeObjectPage::makeConsistentForMutator() | 1580 void LargeObjectPage::makeConsistentForMutator() |
| 1586 { | 1581 { |
| 1587 HeapObjectHeader* header = heapObjectHeader(); | 1582 HeapObjectHeader* header = heapObjectHeader(); |
| 1588 if (header->isMarked()) { | 1583 if (header->isMarked()) |
| 1589 header->unmark(); | 1584 header->unmark(); |
| 1590 Heap::increaseMarkedObjectSize(size()); | |
| 1591 } | |
| 1592 } | 1585 } |
| 1593 | 1586 |
| 1594 #if defined(ADDRESS_SANITIZER) | 1587 #if defined(ADDRESS_SANITIZER) |
| 1595 void LargeObjectPage::poisonObjects(ObjectsToPoison objectsToPoison, Poisoning p
oisoning) | 1588 void LargeObjectPage::poisonObjects(ObjectsToPoison objectsToPoison, Poisoning p
oisoning) |
| 1596 { | 1589 { |
| 1597 HeapObjectHeader* header = heapObjectHeader(); | 1590 HeapObjectHeader* header = heapObjectHeader(); |
| 1598 if (objectsToPoison == MarkedAndUnmarked || !header->isMarked()) { | 1591 if (objectsToPoison == MarkedAndUnmarked || !header->isMarked()) { |
| 1599 if (poisoning == SetPoison) | 1592 if (poisoning == SetPoison) |
| 1600 ASAN_POISON_MEMORY_REGION(header->payload(), header->payloadSize()); | 1593 ASAN_POISON_MEMORY_REGION(header->payload(), header->payloadSize()); |
| 1601 else | 1594 else |
| (...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2012 | 2005 |
| 2013 // Disallow allocation during garbage collection (but not during the | 2006 // Disallow allocation during garbage collection (but not during the |
| 2014 // finalization that happens when the gcScope is torn down). | 2007 // finalization that happens when the gcScope is torn down). |
| 2015 ThreadState::NoAllocationScope noAllocationScope(state); | 2008 ThreadState::NoAllocationScope noAllocationScope(state); |
| 2016 | 2009 |
| 2017 preGC(); | 2010 preGC(); |
| 2018 | 2011 |
| 2019 StackFrameDepthScope stackDepthScope; | 2012 StackFrameDepthScope stackDepthScope; |
| 2020 | 2013 |
| 2021 size_t totalObjectSize = Heap::allocatedObjectSize() + Heap::markedObjectSiz
e(); | 2014 size_t totalObjectSize = Heap::allocatedObjectSize() + Heap::markedObjectSiz
e(); |
| 2022 Heap::resetHeapCounters(); | 2015 if (gcType != ThreadState::TakeSnapshot) |
| 2016 Heap::resetHeapCounters(); |
| 2023 | 2017 |
| 2024 // 1. Trace persistent roots. | 2018 // 1. Trace persistent roots. |
| 2025 ThreadState::visitPersistentRoots(gcScope.visitor()); | 2019 ThreadState::visitPersistentRoots(gcScope.visitor()); |
| 2026 | 2020 |
| 2027 // 2. Trace objects reachable from the stack. We do this independent of the | 2021 // 2. Trace objects reachable from the stack. We do this independent of the |
| 2028 // given stackState since other threads might have a different stack state. | 2022 // given stackState since other threads might have a different stack state. |
| 2029 ThreadState::visitStackRoots(gcScope.visitor()); | 2023 ThreadState::visitStackRoots(gcScope.visitor()); |
| 2030 | 2024 |
| 2031 // 3. Transitive closure to trace objects including ephemerons. | 2025 // 3. Transitive closure to trace objects including ephemerons. |
| 2032 processMarkingStack(gcScope.visitor()); | 2026 processMarkingStack(gcScope.visitor()); |
| (...skipping 289 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2322 size_t Heap::s_allocatedObjectSize = 0; | 2316 size_t Heap::s_allocatedObjectSize = 0; |
| 2323 size_t Heap::s_allocatedSpace = 0; | 2317 size_t Heap::s_allocatedSpace = 0; |
| 2324 size_t Heap::s_markedObjectSize = 0; | 2318 size_t Heap::s_markedObjectSize = 0; |
| 2325 // We don't want to use 0 KB for the initial value because it may end up | 2319 // We don't want to use 0 KB for the initial value because it may end up |
| 2326 // triggering the first GC of some thread too prematurely. | 2320 // triggering the first GC of some thread too prematurely. |
| 2327 size_t Heap::s_estimatedLiveObjectSize = 512 * 1024; | 2321 size_t Heap::s_estimatedLiveObjectSize = 512 * 1024; |
| 2328 size_t Heap::s_externalObjectSizeAtLastGC = 0; | 2322 size_t Heap::s_externalObjectSizeAtLastGC = 0; |
| 2329 double Heap::s_estimatedMarkingTimePerByte = 0.0; | 2323 double Heap::s_estimatedMarkingTimePerByte = 0.0; |
| 2330 | 2324 |
| 2331 } // namespace blink | 2325 } // namespace blink |
| OLD | NEW |