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 } | 1172 } |
1173 | 1173 |
1174 virtual void mark(const void* objectPointer, TraceCallback callback) OVERRID
E | 1174 virtual void mark(const void* objectPointer, TraceCallback callback) OVERRID
E |
1175 { | 1175 { |
1176 if (!objectPointer) | 1176 if (!objectPointer) |
1177 return; | 1177 return; |
1178 FinalizedHeapObjectHeader* header = FinalizedHeapObjectHeader::fromPaylo
ad(objectPointer); | 1178 FinalizedHeapObjectHeader* header = FinalizedHeapObjectHeader::fromPaylo
ad(objectPointer); |
1179 visitHeader(header, header->payload(), callback); | 1179 visitHeader(header, header->payload(), callback); |
1180 } | 1180 } |
1181 | 1181 |
1182 virtual void registerWeakMembers(const void* containingObject, WeakPointerCa
llback callback) OVERRIDE | 1182 virtual void registerWeakMembers(const void* closure, const void* containing
Object, WeakPointerCallback callback) OVERRIDE |
1183 { | 1183 { |
1184 Heap::pushWeakObjectPointerCallback(const_cast<void*>(containingObject),
callback); | 1184 Heap::pushWeakObjectPointerCallback(const_cast<void*>(closure), const_ca
st<void*>(containingObject), callback); |
1185 } | 1185 } |
1186 | 1186 |
1187 virtual bool isMarked(const void* objectPointer) OVERRIDE | 1187 virtual bool isMarked(const void* objectPointer) OVERRIDE |
1188 { | 1188 { |
1189 return FinalizedHeapObjectHeader::fromPayload(objectPointer)->isMarked()
; | 1189 return FinalizedHeapObjectHeader::fromPayload(objectPointer)->isMarked()
; |
1190 } | 1190 } |
1191 | 1191 |
1192 // This macro defines the necessary visitor methods for typed heaps | 1192 // This macro defines the necessary visitor methods for typed heaps |
1193 #define DEFINE_VISITOR_METHODS(Type)
\ | 1193 #define DEFINE_VISITOR_METHODS(Type)
\ |
1194 virtual void mark(const Type* objectPointer, TraceCallback callback) OVERRID
E \ | 1194 virtual void mark(const Type* objectPointer, TraceCallback callback) OVERRID
E \ |
(...skipping 72 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1267 return s_markingStack->popAndInvokeCallback(&s_markingStack, visitor); | 1267 return s_markingStack->popAndInvokeCallback(&s_markingStack, visitor); |
1268 } | 1268 } |
1269 | 1269 |
1270 void Heap::pushWeakCellPointerCallback(void** cell, WeakPointerCallback callback
) | 1270 void Heap::pushWeakCellPointerCallback(void** cell, WeakPointerCallback callback
) |
1271 { | 1271 { |
1272 ASSERT(Heap::contains(cell)); | 1272 ASSERT(Heap::contains(cell)); |
1273 CallbackStack::Item* slot = s_weakCallbackStack->allocateEntry(&s_weakCallba
ckStack); | 1273 CallbackStack::Item* slot = s_weakCallbackStack->allocateEntry(&s_weakCallba
ckStack); |
1274 *slot = CallbackStack::Item(cell, callback); | 1274 *slot = CallbackStack::Item(cell, callback); |
1275 } | 1275 } |
1276 | 1276 |
1277 void Heap::pushWeakObjectPointerCallback(void* object, WeakPointerCallback callb
ack) | 1277 void Heap::pushWeakObjectPointerCallback(void* closure, void* object, WeakPointe
rCallback callback) |
1278 { | 1278 { |
1279 ASSERT(Heap::contains(object)); | 1279 ASSERT(Heap::contains(object)); |
1280 BaseHeapPage* heapPageForObject = reinterpret_cast<BaseHeapPage*>(pageHeader
Address(reinterpret_cast<Address>(object))); | 1280 BaseHeapPage* heapPageForObject = reinterpret_cast<BaseHeapPage*>(pageHeader
Address(reinterpret_cast<Address>(object))); |
1281 ASSERT(Heap::contains(object) == heapPageForObject); | 1281 ASSERT(Heap::contains(object) == heapPageForObject); |
1282 ThreadState* state = heapPageForObject->threadState(); | 1282 ThreadState* state = heapPageForObject->threadState(); |
1283 state->pushWeakObjectPointerCallback(object, callback); | 1283 state->pushWeakObjectPointerCallback(closure, callback); |
1284 } | 1284 } |
1285 | 1285 |
1286 bool Heap::popAndInvokeWeakPointerCallback(Visitor* visitor) | 1286 bool Heap::popAndInvokeWeakPointerCallback(Visitor* visitor) |
1287 { | 1287 { |
1288 return s_weakCallbackStack->popAndInvokeCallback(&s_weakCallbackStack, visit
or); | 1288 return s_weakCallbackStack->popAndInvokeCallback(&s_weakCallbackStack, visit
or); |
1289 } | 1289 } |
1290 | 1290 |
1291 void Heap::prepareForGC() | 1291 void Heap::prepareForGC() |
1292 { | 1292 { |
1293 ASSERT(ThreadState::isAnyThreadInGC()); | 1293 ASSERT(ThreadState::isAnyThreadInGC()); |
(...skipping 68 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1362 // Force template instantiations for the types that we need. | 1362 // Force template instantiations for the types that we need. |
1363 template class HeapPage<FinalizedHeapObjectHeader>; | 1363 template class HeapPage<FinalizedHeapObjectHeader>; |
1364 template class HeapPage<HeapObjectHeader>; | 1364 template class HeapPage<HeapObjectHeader>; |
1365 template class ThreadHeap<FinalizedHeapObjectHeader>; | 1365 template class ThreadHeap<FinalizedHeapObjectHeader>; |
1366 template class ThreadHeap<HeapObjectHeader>; | 1366 template class ThreadHeap<HeapObjectHeader>; |
1367 | 1367 |
1368 Visitor* Heap::s_markingVisitor; | 1368 Visitor* Heap::s_markingVisitor; |
1369 CallbackStack* Heap::s_markingStack; | 1369 CallbackStack* Heap::s_markingStack; |
1370 CallbackStack* Heap::s_weakCallbackStack; | 1370 CallbackStack* Heap::s_weakCallbackStack; |
1371 } | 1371 } |
OLD | NEW |