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

Side by Side Diff: Source/platform/heap/Heap.h

Issue 1146353002: Oilpan: insist on eager sweeping for some objects. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 7 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 | Annotate | Revision Log
« no previous file with comments | « Source/platform/LifecycleObserver.h ('k') | Source/platform/heap/HeapTest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after
1112 if (size < 32) 1112 if (size < 32)
1113 return NormalPage1HeapIndex; 1113 return NormalPage1HeapIndex;
1114 return NormalPage2HeapIndex; 1114 return NormalPage2HeapIndex;
1115 } 1115 }
1116 if (size < 128) 1116 if (size < 128)
1117 return NormalPage3HeapIndex; 1117 return NormalPage3HeapIndex;
1118 return NormalPage4HeapIndex; 1118 return NormalPage4HeapIndex;
1119 } 1119 }
1120 }; 1120 };
1121 1121
1122 // TODO(Oilpan): enable these macros when enabling lazy sweeping, non-Oilpan.
1123 #if ENABLE(OILPAN)
1122 #define EAGERLY_SWEEP(TYPE) \ 1124 #define EAGERLY_SWEEP(TYPE) \
1123 template<typename T> \ 1125 template<typename T> \
1124 class HeapIndexTrait<T, typename WTF::EnableIf<WTF::IsSubclass<T, TYPE>::value>: :Type> { \ 1126 class HeapIndexTrait<T, typename WTF::EnableIf<WTF::IsSubclass<T, TYPE>::value>: :Type> { \
1125 public: \ 1127 public: \
1126 static int heapIndexForObject(size_t) \ 1128 static int heapIndexForObject(size_t) \
1127 { \ 1129 { \
1128 return EagerSweepHeapIndex; \ 1130 return EagerSweepHeapIndex; \
1129 } \ 1131 } \
1130 } 1132 }
1131 1133
1134 #define EAGERLY_SWEEP_TEMPLATE(TYPE) \
1135 template<typename T> \
1136 class HeapIndexTrait<T, typename WTF::EnableIf<WTF::IsSubclassOfTemplate<T, TYPE >::value>::Type> { \
1137 public: \
1138 static int heapIndexForObject(size_t) \
1139 { \
1140 return EagerSweepHeapIndex; \
1141 } \
1142 }
1143
1144 // Overlapping and ambiguous specializations may happen
1145 // for Blink's DOMWindowProperty -- provide a convenience
haraken 2015/05/21 11:45:39 Just to confirm: If we write: EAGERLY_SWEEP_TEM
sof 2015/05/21 11:47:50 Correct.
haraken 2015/05/21 13:23:24 Makes sense. I'm OK with this but would slightly
1146 // macro which lifts the disambiguation to the EnableIf<>
1147 // predicate.
1148 #define EAGERLY_SWEEP_IF_NOT(TYPE, INSTANCE_OF) \
1149 template<typename T> \
1150 class HeapIndexTrait<T, typename WTF::EnableIf<!WTF::IsSubclassOfTemplate<T, INS TANCE_OF>::value && WTF::IsSubclass<T, TYPE>::value>::Type> { \
1151 public: \
1152 static int heapIndexForObject(size_t) \
1153 { \
1154 return EagerSweepHeapIndex; \
1155 } \
1156 }
1157 #else
1158 #define EAGERLY_SWEEP(TYPE)
1159 #define EAGERLY_SWEEP_TEMPLATE(TYPE)
1160 #define EAGERLY_SWEEP_IF_NOT(TYPE, COND)
1161 #endif
1162
1132 NO_SANITIZE_ADDRESS inline 1163 NO_SANITIZE_ADDRESS inline
1133 size_t HeapObjectHeader::size() const 1164 size_t HeapObjectHeader::size() const
1134 { 1165 {
1135 size_t result = m_encoded & headerSizeMask; 1166 size_t result = m_encoded & headerSizeMask;
1136 // Large objects should not refer to header->size(). 1167 // Large objects should not refer to header->size().
1137 // The actual size of a large object is stored in 1168 // The actual size of a large object is stored in
1138 // LargeObjectPage::m_payloadSize. 1169 // LargeObjectPage::m_payloadSize.
1139 ASSERT(result != largeObjectSizeInHeader); 1170 ASSERT(result != largeObjectSizeInHeader);
1140 ASSERT(!pageFromObject(this)->isLargeObjectPage()); 1171 ASSERT(!pageFromObject(this)->isLargeObjectPage());
1141 return result; 1172 return result;
(...skipping 131 matching lines...) Expand 10 before | Expand all | Expand 10 after
1273 size_t copySize = previousHeader->payloadSize(); 1304 size_t copySize = previousHeader->payloadSize();
1274 if (copySize > size) 1305 if (copySize > size)
1275 copySize = size; 1306 copySize = size;
1276 memcpy(address, previous, copySize); 1307 memcpy(address, previous, copySize);
1277 return address; 1308 return address;
1278 } 1309 }
1279 1310
1280 } // namespace blink 1311 } // namespace blink
1281 1312
1282 #endif // Heap_h 1313 #endif // Heap_h
OLDNEW
« no previous file with comments | « Source/platform/LifecycleObserver.h ('k') | Source/platform/heap/HeapTest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698