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 217 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
228 #ifndef NDEBUG | 228 #ifndef NDEBUG |
229 TraceTrait<T>::checkTypeMarker(this, t); | 229 TraceTrait<T>::checkTypeMarker(this, t); |
230 #endif | 230 #endif |
231 TraceTrait<T>::mark(this, t); | 231 TraceTrait<T>::mark(this, t); |
232 } | 232 } |
233 | 233 |
234 // Member version of the one-argument templated trace method. | 234 // Member version of the one-argument templated trace method. |
235 template<typename T> | 235 template<typename T> |
236 void trace(const Member<T>& t) | 236 void trace(const Member<T>& t) |
237 { | 237 { |
238 mark(t.raw()); | 238 mark(t.get()); |
239 } | 239 } |
240 | 240 |
241 // WeakMember version of the templated trace method. It doesn't keep | 241 // WeakMember version of the templated trace method. It doesn't keep |
242 // the traced thing alive, but will write null to the WeakMember later | 242 // the traced thing alive, but will write null to the WeakMember later |
243 // if the pointed-to object is dead. | 243 // if the pointed-to object is dead. |
244 template<typename T> | 244 template<typename T> |
245 void trace(const WeakMember<T>& t) | 245 void trace(const WeakMember<T>& t) |
246 { | 246 { |
247 registerWeakCell(t.cell()); | 247 registerWeakCell(t.cell()); |
248 } | 248 } |
(...skipping 54 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
303 void registerWeakCell(T** cell) | 303 void registerWeakCell(T** cell) |
304 { | 304 { |
305 registerWeakMembers(reinterpret_cast<const void*>(cell), &handleWeakCell
<T>); | 305 registerWeakMembers(reinterpret_cast<const void*>(cell), &handleWeakCell
<T>); |
306 } | 306 } |
307 | 307 |
308 virtual bool isMarked(const void*) = 0; | 308 virtual bool isMarked(const void*) = 0; |
309 | 309 |
310 template<typename T> inline bool isAlive(T obj) { return ObjectAliveTrait<T>
::isAlive(this, obj); } | 310 template<typename T> inline bool isAlive(T obj) { return ObjectAliveTrait<T>
::isAlive(this, obj); } |
311 template<typename T> inline bool isAlive(const Member<T>& member) | 311 template<typename T> inline bool isAlive(const Member<T>& member) |
312 { | 312 { |
313 return isAlive(member.raw()); | 313 return isAlive(member.get()); |
314 } | 314 } |
315 | 315 |
316 #ifndef NDEBUG | 316 #ifndef NDEBUG |
317 void checkTypeMarker(const void*, const char* marker); | 317 void checkTypeMarker(const void*, const char* marker); |
318 #endif | 318 #endif |
319 | 319 |
320 // Macro to declare methods needed for each typed heap. | 320 // Macro to declare methods needed for each typed heap. |
321 #define DECLARE_VISITOR_METHODS(Type) \ | 321 #define DECLARE_VISITOR_METHODS(Type) \ |
322 DEBUG_ONLY(void checkTypeMarker(const Type*, const char* marker);) \ | 322 DEBUG_ONLY(void checkTypeMarker(const Type*, const char* marker);) \ |
323 virtual void mark(const Type*, TraceCallback) = 0; \ | 323 virtual void mark(const Type*, TraceCallback) = 0; \ |
(...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
391 // trace(Visitor*) on the object. | 391 // trace(Visitor*) on the object. |
392 visitor->mark(const_cast<T*>(t), &trace); | 392 visitor->mark(const_cast<T*>(t), &trace); |
393 } | 393 } |
394 | 394 |
395 template<typename T> bool ObjectAliveTrait<T>::isAlive(Visitor* visitor, T obj) | 395 template<typename T> bool ObjectAliveTrait<T>::isAlive(Visitor* visitor, T obj) |
396 { | 396 { |
397 return visitor->isMarked(obj); | 397 return visitor->isMarked(obj); |
398 } | 398 } |
399 template<typename T> bool ObjectAliveTrait<Member<T> >::isAlive(Visitor* visitor
, const Member<T>& obj) | 399 template<typename T> bool ObjectAliveTrait<Member<T> >::isAlive(Visitor* visitor
, const Member<T>& obj) |
400 { | 400 { |
401 return visitor->isMarked(obj.raw()); | 401 return visitor->isMarked(obj.get()); |
402 } | 402 } |
403 | 403 |
404 } | 404 } |
405 | 405 |
406 #endif | 406 #endif |
OLD | NEW |