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 1172 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1183 { | 1183 { |
1184 ASSERT(header); | 1184 ASSERT(header); |
1185 ASSERT(objectPointer); | 1185 ASSERT(objectPointer); |
1186 if (header->isMarked()) | 1186 if (header->isMarked()) |
1187 return; | 1187 return; |
1188 header->mark(); | 1188 header->mark(); |
1189 if (callback) | 1189 if (callback) |
1190 Heap::pushTraceCallback(const_cast<void*>(objectPointer), callback); | 1190 Heap::pushTraceCallback(const_cast<void*>(objectPointer), callback); |
1191 } | 1191 } |
1192 | 1192 |
1193 virtual void mark(HeapObjectHeader* header, TraceCallback callback) | 1193 virtual void mark(HeapObjectHeader* header, TraceCallback callback) OVERRIDE |
1194 { | 1194 { |
1195 // We need both the HeapObjectHeader and FinalizedHeapObjectHeader | 1195 // We need both the HeapObjectHeader and FinalizedHeapObjectHeader |
1196 // version to correctly find the payload. | 1196 // version to correctly find the payload. |
1197 visitHeader(header, header->payload(), callback); | 1197 visitHeader(header, header->payload(), callback); |
1198 } | 1198 } |
1199 | 1199 |
1200 virtual void mark(FinalizedHeapObjectHeader* header, TraceCallback callback) | 1200 virtual void mark(FinalizedHeapObjectHeader* header, TraceCallback callback)
OVERRIDE |
1201 { | 1201 { |
1202 // We need both the HeapObjectHeader and FinalizedHeapObjectHeader | 1202 // We need both the HeapObjectHeader and FinalizedHeapObjectHeader |
1203 // version to correctly find the payload. | 1203 // version to correctly find the payload. |
1204 visitHeader(header, header->payload(), callback); | 1204 visitHeader(header, header->payload(), callback); |
1205 } | 1205 } |
1206 | 1206 |
1207 virtual void mark(const void* objectPointer, TraceCallback callback) | 1207 virtual void mark(const void* objectPointer, TraceCallback callback) OVERRID
E |
1208 { | 1208 { |
1209 if (!objectPointer) | 1209 if (!objectPointer) |
1210 return; | 1210 return; |
1211 FinalizedHeapObjectHeader* header = FinalizedHeapObjectHeader::fromPaylo
ad(objectPointer); | 1211 FinalizedHeapObjectHeader* header = FinalizedHeapObjectHeader::fromPaylo
ad(objectPointer); |
1212 visitHeader(header, header->payload(), callback); | 1212 visitHeader(header, header->payload(), callback); |
1213 } | 1213 } |
1214 | 1214 |
1215 virtual void registerWeakMembers(const void* containingObject, WeakPointerCa
llback callback) | 1215 virtual void registerWeakMembers(const void* containingObject, WeakPointerCa
llback callback) OVERRIDE |
1216 { | 1216 { |
1217 Heap::pushWeakPointerCallback(const_cast<void*>(containingObject), callb
ack); | 1217 Heap::pushWeakPointerCallback(const_cast<void*>(containingObject), callb
ack); |
1218 } | 1218 } |
1219 | 1219 |
1220 virtual bool isMarked(const void* objectPointer) | 1220 virtual bool isMarked(const void* objectPointer) OVERRIDE |
1221 { | 1221 { |
1222 return FinalizedHeapObjectHeader::fromPayload(objectPointer)->isMarked()
; | 1222 return FinalizedHeapObjectHeader::fromPayload(objectPointer)->isMarked()
; |
1223 } | 1223 } |
1224 | 1224 |
1225 // This macro defines the necessary visitor methods for typed heaps | 1225 // This macro defines the necessary visitor methods for typed heaps |
1226 #define DEFINE_VISITOR_METHODS(Type) \ | 1226 #define DEFINE_VISITOR_METHODS(Type)
\ |
1227 virtual void mark(const Type* objectPointer, TraceCallback callback) \ | 1227 virtual void mark(const Type* objectPointer, TraceCallback callback) OVERRID
E \ |
1228 { \ | 1228 {
\ |
1229 if (!objectPointer) \ | 1229 if (!objectPointer)
\ |
1230 return; \ | 1230 return;
\ |
1231 HeapObjectHeader* header = \ | 1231 HeapObjectHeader* header =
\ |
1232 HeapObjectHeader::fromPayload(objectPointer); \ | 1232 HeapObjectHeader::fromPayload(objectPointer);
\ |
1233 visitHeader(header, header->payload(), callback); \ | 1233 visitHeader(header, header->payload(), callback);
\ |
1234 } \ | 1234 }
\ |
1235 virtual bool isMarked(const Type* objectPointer) \ | 1235 virtual bool isMarked(const Type* objectPointer) OVERRIDE
\ |
1236 { \ | 1236 {
\ |
1237 return HeapObjectHeader::fromPayload(objectPointer)->isMarked(); \ | 1237 return HeapObjectHeader::fromPayload(objectPointer)->isMarked();
\ |
1238 } | 1238 } |
1239 | 1239 |
1240 FOR_EACH_TYPED_HEAP(DEFINE_VISITOR_METHODS) | 1240 FOR_EACH_TYPED_HEAP(DEFINE_VISITOR_METHODS) |
1241 #undef DEFINE_VISITOR_METHODS | 1241 #undef DEFINE_VISITOR_METHODS |
1242 }; | 1242 }; |
1243 | 1243 |
1244 void Heap::init() | 1244 void Heap::init() |
1245 { | 1245 { |
1246 ThreadState::init(); | 1246 ThreadState::init(); |
1247 CallbackStack::init(&s_markingStack); | 1247 CallbackStack::init(&s_markingStack); |
(...skipping 118 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1366 | 1366 |
1367 // Force template instantiations for the types that we need. | 1367 // Force template instantiations for the types that we need. |
1368 template class HeapPage<FinalizedHeapObjectHeader>; | 1368 template class HeapPage<FinalizedHeapObjectHeader>; |
1369 template class HeapPage<HeapObjectHeader>; | 1369 template class HeapPage<HeapObjectHeader>; |
1370 template class ThreadHeap<FinalizedHeapObjectHeader>; | 1370 template class ThreadHeap<FinalizedHeapObjectHeader>; |
1371 template class ThreadHeap<HeapObjectHeader>; | 1371 template class ThreadHeap<HeapObjectHeader>; |
1372 | 1372 |
1373 CallbackStack* Heap::s_markingStack; | 1373 CallbackStack* Heap::s_markingStack; |
1374 CallbackStack* Heap::s_weakCallbackStack; | 1374 CallbackStack* Heap::s_weakCallbackStack; |
1375 } | 1375 } |
OLD | NEW |