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 367 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
378 #if ENABLE(ASSERT) | 378 #if ENABLE(ASSERT) |
379 virtual bool weakTableRegistered(const void*) = 0; | 379 virtual bool weakTableRegistered(const void*) = 0; |
380 #endif | 380 #endif |
381 | 381 |
382 virtual bool isMarked(const void*) = 0; | 382 virtual bool isMarked(const void*) = 0; |
383 | 383 |
384 template<typename T> inline bool isAlive(T* obj) | 384 template<typename T> inline bool isAlive(T* obj) |
385 { | 385 { |
386 // Check that we actually know the definition of T when tracing. | 386 // Check that we actually know the definition of T when tracing. |
387 COMPILE_ASSERT(sizeof(T), WeNeedToKnowTheDefinitionOfTheTypeWeAreTracing
); | 387 COMPILE_ASSERT(sizeof(T), WeNeedToKnowTheDefinitionOfTheTypeWeAreTracing
); |
388 return !!obj && ObjectAliveTrait<T>::isAlive(this, obj); | 388 // The strongification of collections relies on the fact that once a |
| 389 // collection has been strongified, there is no way that it can contain |
| 390 // non-live entries, so no entries will be removed. Since you can't set |
| 391 // the mark bit on a null pointer, that means that null pointers are |
| 392 // always 'alive'. |
| 393 if (!obj) |
| 394 return true; |
| 395 return ObjectAliveTrait<T>::isAlive(this, obj); |
389 } | 396 } |
390 template<typename T> inline bool isAlive(const Member<T>& member) | 397 template<typename T> inline bool isAlive(const Member<T>& member) |
391 { | 398 { |
392 return isAlive(member.get()); | 399 return isAlive(member.get()); |
393 } | 400 } |
394 template<typename T> inline bool isAlive(RawPtr<T> ptr) | 401 template<typename T> inline bool isAlive(RawPtr<T> ptr) |
395 { | 402 { |
396 return isAlive(ptr.get()); | 403 return isAlive(ptr.get()); |
397 } | 404 } |
398 | 405 |
(...skipping 235 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
634 struct GCInfoTrait { | 641 struct GCInfoTrait { |
635 static const GCInfo* get() | 642 static const GCInfo* get() |
636 { | 643 { |
637 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::get(); | 644 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::get(); |
638 } | 645 } |
639 }; | 646 }; |
640 | 647 |
641 } | 648 } |
642 | 649 |
643 #endif | 650 #endif |
OLD | NEW |