| 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 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 78 // Blink heap. This meta-data consists of a function pointer used to | 78 // Blink heap. This meta-data consists of a function pointer used to |
| 79 // trace the pointers in the object during garbage collection, an | 79 // trace the pointers in the object during garbage collection, an |
| 80 // indication of whether or not the object needs a finalization | 80 // indication of whether or not the object needs a finalization |
| 81 // callback, and a function pointer used to finalize the object when | 81 // callback, and a function pointer used to finalize the object when |
| 82 // the garbage collector determines that the object is no longer | 82 // the garbage collector determines that the object is no longer |
| 83 // reachable. There is a GCInfo struct for each class that directly | 83 // reachable. There is a GCInfo struct for each class that directly |
| 84 // inherits from GarbageCollected or GarbageCollectedFinalized. | 84 // inherits from GarbageCollected or GarbageCollectedFinalized. |
| 85 struct GCInfo { | 85 struct GCInfo { |
| 86 bool hasFinalizer() const { return m_nonTrivialFinalizer; } | 86 bool hasFinalizer() const { return m_nonTrivialFinalizer; } |
| 87 bool hasVTable() const { return m_hasVTable; } | 87 bool hasVTable() const { return m_hasVTable; } |
| 88 int heapIndex() const { return m_heapIndex; } |
| 88 TraceCallback m_trace; | 89 TraceCallback m_trace; |
| 89 FinalizationCallback m_finalize; | 90 FinalizationCallback m_finalize; |
| 90 bool m_nonTrivialFinalizer; | 91 bool m_nonTrivialFinalizer; |
| 91 bool m_hasVTable; | 92 bool m_hasVTable; |
| 93 int m_heapIndex; |
| 92 #if ENABLE(GC_PROFILING) | 94 #if ENABLE(GC_PROFILING) |
| 93 // |m_className| is held as a reference to prevent dtor being called at exit
. | 95 // |m_className| is held as a reference to prevent dtor being called at exit
. |
| 94 const String& m_className; | 96 const String& m_className; |
| 95 #endif | 97 #endif |
| 96 }; | 98 }; |
| 97 | 99 |
| 98 // The FinalizerTraitImpl specifies how to finalize objects. Object | 100 // The FinalizerTraitImpl specifies how to finalize objects. Object |
| 99 // that inherit from GarbageCollectedFinalized are finalized by | 101 // that inherit from GarbageCollectedFinalized are finalized by |
| 100 // calling their 'finalize' method which by default will call the | 102 // calling their 'finalize' method which by default will call the |
| 101 // destructor on the object. | 103 // destructor on the object. |
| (...skipping 521 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 623 | 625 |
| 624 template<typename T> | 626 template<typename T> |
| 625 struct GCInfoAtBase { | 627 struct GCInfoAtBase { |
| 626 static const GCInfo* get() | 628 static const GCInfo* get() |
| 627 { | 629 { |
| 628 static const GCInfo gcInfo = { | 630 static const GCInfo gcInfo = { |
| 629 TraceTrait<T>::trace, | 631 TraceTrait<T>::trace, |
| 630 FinalizerTrait<T>::finalize, | 632 FinalizerTrait<T>::finalize, |
| 631 FinalizerTrait<T>::nonTrivialFinalizer, | 633 FinalizerTrait<T>::nonTrivialFinalizer, |
| 632 WTF::IsPolymorphic<T>::value, | 634 WTF::IsPolymorphic<T>::value, |
| 635 HeapTypeTrait<T>::index(FinalizerTrait<T>::nonTrivialFinalizer ? tru
e : false), |
| 633 #if ENABLE(GC_PROFILING) | 636 #if ENABLE(GC_PROFILING) |
| 634 TypenameStringTrait<T>::get() | 637 TypenameStringTrait<T>::get() |
| 635 #endif | 638 #endif |
| 636 }; | 639 }; |
| 637 return &gcInfo; | 640 return &gcInfo; |
| 638 } | 641 } |
| 639 }; | 642 }; |
| 640 | 643 |
| 641 template<typename T> class GarbageCollected; | 644 template<typename T> class GarbageCollected; |
| 642 template<typename T, bool = WTF::IsSubclassOfTemplate<typename WTF::RemoveConst<
T>::Type, GarbageCollected>::value> struct GetGarbageCollectedBase; | 645 template<typename T, bool = WTF::IsSubclassOfTemplate<typename WTF::RemoveConst<
T>::Type, GarbageCollected>::value> struct GetGarbageCollectedBase; |
| (...skipping 12 matching lines...) Expand all Loading... |
| 655 struct GCInfoTrait { | 658 struct GCInfoTrait { |
| 656 static const GCInfo* get() | 659 static const GCInfo* get() |
| 657 { | 660 { |
| 658 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::get(); | 661 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::get(); |
| 659 } | 662 } |
| 660 }; | 663 }; |
| 661 | 664 |
| 662 } | 665 } |
| 663 | 666 |
| 664 #endif | 667 #endif |
| OLD | NEW |