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

Side by Side Diff: third_party/WebKit/Source/platform/heap/HeapPage.cpp

Issue 1676973002: Introduce HeapAllocHooks (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: WTF_EXPORT -> PLATFORM_EXPORT Created 4 years, 10 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 unified diff | Download patch
OLDNEW
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 1115 matching lines...) Expand 10 before | Expand all | Expand 10 after
1126 headerAddress += size; 1126 headerAddress += size;
1127 continue; 1127 continue;
1128 } 1128 }
1129 ASSERT(header->checkHeader()); 1129 ASSERT(header->checkHeader());
1130 1130
1131 if (!header->isMarked()) { 1131 if (!header->isMarked()) {
1132 size_t size = header->size(); 1132 size_t size = header->size();
1133 // This is a fast version of header->payloadSize(). 1133 // This is a fast version of header->payloadSize().
1134 size_t payloadSize = size - sizeof(HeapObjectHeader); 1134 size_t payloadSize = size - sizeof(HeapObjectHeader);
1135 Address payload = header->payload(); 1135 Address payload = header->payload();
1136 HeapAllocHooks::freeHookIfEnabled(payload);
haraken 2016/02/12 10:29:19 Can we move this into header->finalize()?
hajimehoshi 2016/02/15 07:14:46 Done.
1136 // For ASan, unpoison the object before calling the finalizer. The 1137 // For ASan, unpoison the object before calling the finalizer. The
1137 // finalized object will be zero-filled and poison'ed afterwards. 1138 // finalized object will be zero-filled and poison'ed afterwards.
1138 // Given all other unmarked objects are poisoned, ASan will detect 1139 // Given all other unmarked objects are poisoned, ASan will detect
1139 // an error if the finalizer touches any other on-heap object that 1140 // an error if the finalizer touches any other on-heap object that
1140 // die at the same GC cycle. 1141 // die at the same GC cycle.
1141 ASAN_UNPOISON_MEMORY_REGION(payload, payloadSize); 1142 ASAN_UNPOISON_MEMORY_REGION(payload, payloadSize);
1142 header->finalize(payload, payloadSize); 1143 header->finalize(payload, payloadSize);
1143 // This memory will be added to the freelist. Maintain the invariant 1144 // This memory will be added to the freelist. Maintain the invariant
1144 // that memory on the freelist is zero filled. 1145 // that memory on the freelist is zero filled.
1145 SET_MEMORY_INACCESSIBLE(headerAddress, size); 1146 SET_MEMORY_INACCESSIBLE(headerAddress, size);
(...skipping 295 matching lines...) Expand 10 before | Expand all | Expand 10 after
1441 return !heapObjectHeader()->isMarked(); 1442 return !heapObjectHeader()->isMarked();
1442 } 1443 }
1443 1444
1444 void LargeObjectPage::removeFromHeap() 1445 void LargeObjectPage::removeFromHeap()
1445 { 1446 {
1446 static_cast<LargeObjectHeap*>(heap())->freeLargeObjectPage(this); 1447 static_cast<LargeObjectHeap*>(heap())->freeLargeObjectPage(this);
1447 } 1448 }
1448 1449
1449 void LargeObjectPage::sweep() 1450 void LargeObjectPage::sweep()
1450 { 1451 {
1452 HeapAllocHooks::freeHookIfEnabled(payload());
haraken 2016/02/12 10:29:19 Then you can remove this.
hajimehoshi 2016/02/15 07:14:46 Done.
1451 heapObjectHeader()->unmark(); 1453 heapObjectHeader()->unmark();
1452 Heap::increaseMarkedObjectSize(size()); 1454 Heap::increaseMarkedObjectSize(size());
1453 } 1455 }
1454 1456
1455 void LargeObjectPage::makeConsistentForGC() 1457 void LargeObjectPage::makeConsistentForGC()
1456 { 1458 {
1457 HeapObjectHeader* header = heapObjectHeader(); 1459 HeapObjectHeader* header = heapObjectHeader();
1458 if (header->isMarked()) { 1460 if (header->isMarked()) {
1459 header->unmark(); 1461 header->unmark();
1460 Heap::increaseMarkedObjectSize(size()); 1462 Heap::increaseMarkedObjectSize(size());
(...skipping 113 matching lines...) Expand 10 before | Expand all | Expand 10 after
1574 1576
1575 m_hasEntries = true; 1577 m_hasEntries = true;
1576 size_t index = hash(address); 1578 size_t index = hash(address);
1577 ASSERT(!(index & 1)); 1579 ASSERT(!(index & 1));
1578 Address cachePage = roundToBlinkPageStart(address); 1580 Address cachePage = roundToBlinkPageStart(address);
1579 m_entries[index + 1] = m_entries[index]; 1581 m_entries[index + 1] = m_entries[index];
1580 m_entries[index] = cachePage; 1582 m_entries[index] = cachePage;
1581 } 1583 }
1582 1584
1583 } // namespace blink 1585 } // namespace blink
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698