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 1101 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
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 #define EAGERLY_SWEEP(TYPE) \ | 1122 // TODO(Oilpan): enable this macro when enabling lazy sweeping, non-Oilpan. |
1123 template<typename T> \ | 1123 #if ENABLE(OILPAN) |
1124 class HeapIndexTrait<T, typename WTF::EnableIf<WTF::IsSubclass<T, TYPE>::value>:
:Type> { \ | 1124 #define EAGERLY_SWEEP() typedef int IsEagerlySweptMarker |
1125 public: \ | 1125 #else |
1126 static int heapIndexForObject(size_t) \ | 1126 #define EAGERLY_SWEEP() |
1127 { \ | 1127 #endif |
1128 return EagerSweepHeapIndex; \ | 1128 |
1129 } \ | 1129 template<typename T> |
1130 } | 1130 struct IsEagerlySweptType { |
| 1131 private: |
| 1132 typedef char YesType; |
| 1133 struct NoType { |
| 1134 char padding[8]; |
| 1135 }; |
| 1136 |
| 1137 template <typename U> static YesType checkMarker(typename U::IsEagerlySweptM
arker*); |
| 1138 template <typename U> static NoType checkMarker(...); |
| 1139 |
| 1140 public: |
| 1141 static const bool value = sizeof(checkMarker<T>(nullptr)) == sizeof(YesType)
; |
| 1142 }; |
| 1143 |
| 1144 template<typename T> |
| 1145 class HeapIndexTrait<T, typename WTF::EnableIf<IsEagerlySweptType<T>::value>::Ty
pe> { |
| 1146 public: |
| 1147 static int heapIndexForObject(size_t) |
| 1148 { |
| 1149 return EagerSweepHeapIndex; |
| 1150 } |
| 1151 }; |
1131 | 1152 |
1132 NO_SANITIZE_ADDRESS inline | 1153 NO_SANITIZE_ADDRESS inline |
1133 size_t HeapObjectHeader::size() const | 1154 size_t HeapObjectHeader::size() const |
1134 { | 1155 { |
1135 size_t result = m_encoded & headerSizeMask; | 1156 size_t result = m_encoded & headerSizeMask; |
1136 // Large objects should not refer to header->size(). | 1157 // Large objects should not refer to header->size(). |
1137 // The actual size of a large object is stored in | 1158 // The actual size of a large object is stored in |
1138 // LargeObjectPage::m_payloadSize. | 1159 // LargeObjectPage::m_payloadSize. |
1139 ASSERT(result != largeObjectSizeInHeader); | 1160 ASSERT(result != largeObjectSizeInHeader); |
1140 ASSERT(!pageFromObject(this)->isLargeObjectPage()); | 1161 ASSERT(!pageFromObject(this)->isLargeObjectPage()); |
(...skipping 132 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1273 size_t copySize = previousHeader->payloadSize(); | 1294 size_t copySize = previousHeader->payloadSize(); |
1274 if (copySize > size) | 1295 if (copySize > size) |
1275 copySize = size; | 1296 copySize = size; |
1276 memcpy(address, previous, copySize); | 1297 memcpy(address, previous, copySize); |
1277 return address; | 1298 return address; |
1278 } | 1299 } |
1279 | 1300 |
1280 } // namespace blink | 1301 } // namespace blink |
1281 | 1302 |
1282 #endif // Heap_h | 1303 #endif // Heap_h |
OLD | NEW |