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 1161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1172 return NormalPage3HeapIndex; | 1172 return NormalPage3HeapIndex; |
1173 return NormalPage4HeapIndex; | 1173 return NormalPage4HeapIndex; |
1174 } | 1174 } |
1175 | 1175 |
1176 inline bool Heap::isNormalHeapIndex(int index) | 1176 inline bool Heap::isNormalHeapIndex(int index) |
1177 { | 1177 { |
1178 return index >= NormalPage1HeapIndex && index <= NormalPage4HeapIndex; | 1178 return index >= NormalPage1HeapIndex && index <= NormalPage4HeapIndex; |
1179 } | 1179 } |
1180 | 1180 |
1181 #if ENABLE(LAZY_SWEEPING) | 1181 #if ENABLE(LAZY_SWEEPING) |
| 1182 #define DECLARE_EAGER_FINALIZATION_OPERATOR_NEW() \ |
| 1183 public: \ |
| 1184 GC_PLUGIN_IGNORE("491488") \ |
| 1185 void* operator new(size_t size) \ |
| 1186 { \ |
| 1187 return allocateObject(size, true); \ |
| 1188 } |
| 1189 #define EAGERLY_FINALIZE_WILL_BE_REMOVED() |
| 1190 #if ENABLE(ASSERT) |
| 1191 class VerifyEagerFinalization { |
| 1192 public: |
| 1193 ~VerifyEagerFinalization() |
| 1194 { |
| 1195 // If this assert triggers, the class annotated as eagerly |
| 1196 // finalized ended up not being allocated on the heap |
| 1197 // set aside for eager finalization. The reason is most |
| 1198 // likely that the effective 'operator new' overload for |
| 1199 // this class' leftmost base is for a class that is not |
| 1200 // eagerly finalized. Declaring and defining an 'operator new' |
| 1201 // for this class is what's required -- consider using |
| 1202 // DECLARE_EAGER_FINALIZATION_OPERATOR_NEW(). |
| 1203 ASSERT(pageFromObject(this)->heap()->heapIndex() == EagerSweepHeapIndex)
; |
| 1204 } |
| 1205 }; |
| 1206 #define EAGERLY_FINALIZE() \ |
| 1207 private: \ |
| 1208 VerifyEagerFinalization m_verifyEagerFinalization; \ |
| 1209 public: \ |
| 1210 typedef int IsEagerlyFinalizedMarker |
| 1211 #else |
1182 #define EAGERLY_FINALIZE() typedef int IsEagerlyFinalizedMarker | 1212 #define EAGERLY_FINALIZE() typedef int IsEagerlyFinalizedMarker |
1183 #define EAGERLY_FINALIZE_WILL_BE_REMOVED() | 1213 #endif |
1184 #else | 1214 #else |
| 1215 #define DECLARE_EAGER_FINALIZATION_OPERATOR_NEW() |
1185 #define EAGERLY_FINALIZE() | 1216 #define EAGERLY_FINALIZE() |
1186 // TODO(Oilpan): define in terms of Oilpan's EAGERLY_FINALIZE() once lazy | 1217 // TODO(Oilpan): define in terms of Oilpan's EAGERLY_FINALIZE() once lazy |
1187 // sweeping is enabled non-Oilpan. | 1218 // sweeping is enabled non-Oilpan. |
1188 #define EAGERLY_FINALIZE_WILL_BE_REMOVED() | 1219 #define EAGERLY_FINALIZE_WILL_BE_REMOVED() |
1189 #endif | 1220 #endif |
1190 | 1221 |
1191 NO_SANITIZE_ADDRESS inline | 1222 NO_SANITIZE_ADDRESS inline |
1192 size_t HeapObjectHeader::size() const | 1223 size_t HeapObjectHeader::size() const |
1193 { | 1224 { |
1194 size_t result = m_encoded & headerSizeMask; | 1225 size_t result = m_encoded & headerSizeMask; |
(...skipping 161 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1356 size_t copySize = previousHeader->payloadSize(); | 1387 size_t copySize = previousHeader->payloadSize(); |
1357 if (copySize > size) | 1388 if (copySize > size) |
1358 copySize = size; | 1389 copySize = size; |
1359 memcpy(address, previous, copySize); | 1390 memcpy(address, previous, copySize); |
1360 return address; | 1391 return address; |
1361 } | 1392 } |
1362 | 1393 |
1363 } // namespace blink | 1394 } // namespace blink |
1364 | 1395 |
1365 #endif // Heap_h | 1396 #endif // Heap_h |
OLD | NEW |