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

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

Issue 834673008: Extend locking of GCInfo table to include slot allocation. (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: 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
« no previous file with comments | « no previous file | Source/platform/heap/Visitor.cpp » ('j') | Source/platform/heap/Visitor.cpp » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 845 matching lines...) Expand 10 before | Expand all | Expand 10 after
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 bool allocateGCInfoSlot(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 && GCInfoTable::allocateGCInfoSlot(gcInfoIndex)) \
887 ASSERT(s_gcInfoTable); \ 887 s_gcInfoTable[gcInfoIndex] = &gcInfo; \
haraken 2015/01/10 08:37:24 Can we do this assignment in allocateGCInfoSlot? P
sof 2015/01/10 08:42:46 I suppose, but I don't see the overall benefit.
haraken 2015/01/10 08:48:45 up to you :)
sof 2015/01/10 08:54:23 Done.
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
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
OLDNEW
« no previous file with comments | « no previous file | Source/platform/heap/Visitor.cpp » ('j') | Source/platform/heap/Visitor.cpp » ('J')

Powered by Google App Engine
This is Rietveld 408576698