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

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

Issue 1166793002: Oilpan: add assert to verify eager finalization. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 5 years, 6 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 | « no previous file | Source/platform/heap/Heap.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 1110 matching lines...) Expand 10 before | Expand all | Expand 10 after
1121 return NormalPage3HeapIndex; 1121 return NormalPage3HeapIndex;
1122 return NormalPage4HeapIndex; 1122 return NormalPage4HeapIndex;
1123 } 1123 }
1124 1124
1125 inline bool Heap::isNormalHeapIndex(int index) 1125 inline bool Heap::isNormalHeapIndex(int index)
1126 { 1126 {
1127 return index >= NormalPage1HeapIndex && index <= NormalPage4HeapIndex; 1127 return index >= NormalPage1HeapIndex && index <= NormalPage4HeapIndex;
1128 } 1128 }
1129 1129
1130 #if ENABLE_LAZY_SWEEPING 1130 #if ENABLE_LAZY_SWEEPING
1131 #define DECLARE_EAGER_FINALIZATION_OPERATOR_NEW() \
1132 public: \
1133 GC_PLUGIN_IGNORE("491488") \
1134 void* operator new(size_t size) \
1135 { \
1136 return allocateObject(size, true); \
1137 }
1138 #define EAGERLY_FINALIZE_WILL_BE_REMOVED()
1139 #if ENABLE(ASSERT)
1140 class VerifyEagerFinalization {
1141 public:
1142 ~VerifyEagerFinalization()
1143 {
1144 // If this assert triggers, the class annotated as eagerly
1145 // finalized ended up not being allocated on the heap
1146 // set aside for eager finalization. The reason is most
1147 // likely that the effective 'operator new' overload for
1148 // this class' leftmost base is for a class that is not
1149 // eagerly finalized. Declaring and defining an 'operator new'
1150 // for this class is what's required -- consider using
1151 // DECLARE_EAGER_FINALIZATION_OPERATOR_NEW().
1152 ASSERT(ThreadState::current()->isEagerlySweeping());
haraken 2015/06/03 03:52:35 Instead of introducing isEagerlySweeping(), you mi
sof 2015/06/03 11:35:16 That gets us there also and with less noise; done.
1153 }
1154 };
1155 #define EAGERLY_FINALIZE() \
1156 private: \
1157 VerifyEagerFinalization m_verifyEagerFinalization; \
1158 public: \
1159 typedef int IsEagerlyFinalizedMarker
1160 #else
1131 #define EAGERLY_FINALIZE() typedef int IsEagerlyFinalizedMarker 1161 #define EAGERLY_FINALIZE() typedef int IsEagerlyFinalizedMarker
1132 #define EAGERLY_FINALIZE_WILL_BE_REMOVED() 1162 #endif
1133 #else 1163 #else
1164 #define DECLARE_EAGER_FINALIZATION_OPERATOR_NEW()
1134 #define EAGERLY_FINALIZE() 1165 #define EAGERLY_FINALIZE()
1135 // TODO(Oilpan): define in terms of Oilpan's EAGERLY_FINALIZE() once lazy 1166 // TODO(Oilpan): define in terms of Oilpan's EAGERLY_FINALIZE() once lazy
1136 // sweeping is enabled non-Oilpan. 1167 // sweeping is enabled non-Oilpan.
1137 #define EAGERLY_FINALIZE_WILL_BE_REMOVED() 1168 #define EAGERLY_FINALIZE_WILL_BE_REMOVED()
1138 #endif 1169 #endif
1139 1170
1140 NO_SANITIZE_ADDRESS inline 1171 NO_SANITIZE_ADDRESS inline
1141 size_t HeapObjectHeader::size() const 1172 size_t HeapObjectHeader::size() const
1142 { 1173 {
1143 size_t result = m_encoded & headerSizeMask; 1174 size_t result = m_encoded & headerSizeMask;
(...skipping 152 matching lines...) Expand 10 before | Expand all | Expand 10 after
1296 size_t copySize = previousHeader->payloadSize(); 1327 size_t copySize = previousHeader->payloadSize();
1297 if (copySize > size) 1328 if (copySize > size)
1298 copySize = size; 1329 copySize = size;
1299 memcpy(address, previous, copySize); 1330 memcpy(address, previous, copySize);
1300 return address; 1331 return address;
1301 } 1332 }
1302 1333
1303 } // namespace blink 1334 } // namespace blink
1304 1335
1305 #endif // Heap_h 1336 #endif // Heap_h
OLDNEW
« no previous file with comments | « no previous file | Source/platform/heap/Heap.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698