| 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 845 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 856     } | 856     } | 
| 857 }; | 857 }; | 
| 858 #endif | 858 #endif | 
| 859 | 859 | 
| 860 // s_gcInfoTable holds the per-class GCInfo descriptors; each heap | 860 // s_gcInfoTable holds the per-class GCInfo descriptors; each heap | 
| 861 // object header keeps its index into this table. | 861 // object header keeps its index into this table. | 
| 862 extern PLATFORM_EXPORT GCInfo const** s_gcInfoTable; | 862 extern PLATFORM_EXPORT GCInfo const** s_gcInfoTable; | 
| 863 | 863 | 
| 864 class GCInfoTable { | 864 class GCInfoTable { | 
| 865 public: | 865 public: | 
| 866     PLATFORM_EXPORT static size_t allocateGCInfoSlot(); | 866     PLATFORM_EXPORT static void ensureGCInfoIndex(const GCInfo*, size_t*); | 
| 867 | 867 | 
| 868     static void init(); | 868     static void init(); | 
| 869     static void shutdown(); | 869     static void shutdown(); | 
| 870 | 870 | 
| 871     // The (max + 1) GCInfo index supported. | 871     // The (max + 1) GCInfo index supported. | 
| 872     static const size_t maxIndex = 1 << 15; | 872     static const size_t maxIndex = 1 << 15; | 
| 873 | 873 | 
| 874 private: | 874 private: | 
| 875     static void resize(size_t); | 875     static void resize(); | 
| 876 | 876 | 
| 877     static int s_gcInfoIndex; | 877     static int s_gcInfoIndex; | 
| 878     static size_t s_gcInfoTableSize; | 878     static size_t s_gcInfoTableSize; | 
| 879 }; | 879 }; | 
| 880 | 880 | 
| 881 // This macro should be used when returning a unique 15 bit integer | 881 // This macro should be used when returning a unique 15 bit integer | 
| 882 // for a given gcInfo. | 882 // for a given gcInfo. | 
| 883 #define RETURN_GCINFO_INDEX() \ | 883 #define RETURN_GCINFO_INDEX()                                  \ | 
| 884     static const size_t gcInfoIndex = GCInfoTable::allocateGCInfoSlot(); \ | 884     static size_t gcInfoIndex = 0;                             \ | 
| 885     ASSERT(gcInfoIndex >= 1); \ | 885     ASSERT(s_gcInfoTable);                                     \ | 
| 886     ASSERT(gcInfoIndex < GCInfoTable::maxIndex);  \ | 886     if (!gcInfoIndex)                                          \ | 
| 887     ASSERT(s_gcInfoTable); \ | 887         GCInfoTable::ensureGCInfoIndex(&gcInfo, &gcInfoIndex); \ | 
| 888     s_gcInfoTable[gcInfoIndex] = &gcInfo; \ | 888     ASSERT(gcInfoIndex >= 1);                                  \ | 
|  | 889     ASSERT(gcInfoIndex < GCInfoTable::maxIndex);               \ | 
| 889     return gcInfoIndex; | 890     return gcInfoIndex; | 
| 890 | 891 | 
| 891 template<typename T> | 892 template<typename T> | 
| 892 struct GCInfoAtBase { | 893 struct GCInfoAtBase { | 
| 893     static size_t index() | 894     static size_t index() | 
| 894     { | 895     { | 
| 895         static const GCInfo gcInfo = { | 896         static const GCInfo gcInfo = { | 
| 896             TraceTrait<T>::trace, | 897             TraceTrait<T>::trace, | 
| 897             FinalizerTrait<T>::finalize, | 898             FinalizerTrait<T>::finalize, | 
| 898             FinalizerTrait<T>::nonTrivialFinalizer, | 899             FinalizerTrait<T>::nonTrivialFinalizer, | 
| (...skipping 22 matching lines...) Expand all  Loading... | 
| 921 struct GCInfoTrait { | 922 struct GCInfoTrait { | 
| 922     static size_t index() | 923     static size_t index() | 
| 923     { | 924     { | 
| 924         return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::index(); | 925         return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::index(); | 
| 925     } | 926     } | 
| 926 }; | 927 }; | 
| 927 | 928 | 
| 928 } | 929 } | 
| 929 | 930 | 
| 930 #endif | 931 #endif | 
| OLD | NEW | 
|---|