Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(332)

Side by Side Diff: Source/platform/heap/Visitor.h

Issue 820693006: Incremental GCInfo descriptor table expansion. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: add missing PLATFORM_EXPORT Created 5 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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 824 matching lines...) Expand 10 before | Expand all | Expand 10 after
835 template<typename T> 835 template<typename T>
836 struct TypenameStringTrait { 836 struct TypenameStringTrait {
837 static const String& get() 837 static const String& get()
838 { 838 {
839 DEFINE_STATIC_LOCAL(String, typenameString, (WTF::extractTypeNameFromFun ctionName(WTF::extractNameFunction<T>()))); 839 DEFINE_STATIC_LOCAL(String, typenameString, (WTF::extractTypeNameFromFun ctionName(WTF::extractNameFunction<T>())));
840 return typenameString; 840 return typenameString;
841 } 841 }
842 }; 842 };
843 #endif 843 #endif
844 844
845 // s_gcInfoTable is a map used to encode a GCInfo* into a 15 bit integer. 845 // s_gcInfoTable holds the per-class GCInfo descriptors; each heap
846 const size_t gcInfoIndexMax = 1 << 15; 846 // object header keeps its index into this table.
847 extern PLATFORM_EXPORT int s_gcInfoIndex;
848 extern PLATFORM_EXPORT GCInfo const** s_gcInfoTable; 847 extern PLATFORM_EXPORT GCInfo const** s_gcInfoTable;
849 848
849 class GCInfoTable {
850 public:
851 PLATFORM_EXPORT static size_t allocateGCInfoSlot();
852
853 static void init();
854 static void shutdown();
855
856 // The (max + 1) GCInfo index supported.
857 static const size_t maxIndex = 1 << 15;
858
859 private:
860 static void resize(size_t);
861
862 static int s_gcInfoIndex;
863 static size_t s_gcInfoTableSize;
864 };
865
850 // This macro should be used when returning a unique 15 bit integer 866 // This macro should be used when returning a unique 15 bit integer
851 // for a given gcInfo. 867 // for a given gcInfo.
852 #define RETURN_GCINFO_INDEX() \ 868 #define RETURN_GCINFO_INDEX() \
853 static const size_t gcInfoIndex = atomicIncrement(&s_gcInfoIndex); \ 869 static const size_t gcInfoIndex = GCInfoTable::allocateGCInfoSlot(); \
854 ASSERT(gcInfoIndex >= 1); \ 870 ASSERT(gcInfoIndex >= 1); \
855 ASSERT(gcInfoIndex < gcInfoIndexMax); \ 871 ASSERT(gcInfoIndex < GCInfoTable::maxIndex); \
856 ASSERT(s_gcInfoTable); \ 872 ASSERT(s_gcInfoTable); \
857 s_gcInfoTable[gcInfoIndex] = &gcInfo; \ 873 s_gcInfoTable[gcInfoIndex] = &gcInfo; \
858 return gcInfoIndex; 874 return gcInfoIndex;
859 875
860 template<typename T> 876 template<typename T>
861 struct GCInfoAtBase { 877 struct GCInfoAtBase {
862 static size_t index() 878 static size_t index()
863 { 879 {
864 static const GCInfo gcInfo = { 880 static const GCInfo gcInfo = {
865 TraceTrait<T>::trace, 881 TraceTrait<T>::trace,
(...skipping 24 matching lines...) Expand all
890 struct GCInfoTrait { 906 struct GCInfoTrait {
891 static size_t index() 907 static size_t index()
892 { 908 {
893 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::index(); 909 return GCInfoAtBase<typename GetGarbageCollectedBase<T>::type>::index();
894 } 910 }
895 }; 911 };
896 912
897 } 913 }
898 914
899 #endif 915 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698