Index: src/global-handles.h |
diff --git a/src/global-handles.h b/src/global-handles.h |
index cd75133a24367092ec07e87bd9fc451a8a9e9d64..cff6f933577a54de807c7676d7981f1d4536741e 100644 |
--- a/src/global-handles.h |
+++ b/src/global-handles.h |
@@ -331,6 +331,55 @@ class GlobalHandles { |
}; |
+class EternalHandles { |
+ public: |
+ static const int kInvalidIndex = -1; |
Michael Starzinger
2013/08/01 13:26:11
Instead of exposing the kInvalidIndex constant, ca
|
+ enum IndexedHandle { |
Michael Starzinger
2013/08/01 13:26:11
There is a slight name collision going on here I t
|
+ I18N_TEMPLATE_ONE, |
+ I18N_TEMPLATE_TWO, |
+ |
+ LAST_INDEX = I18N_TEMPLATE_TWO |
Michael Starzinger
2013/08/01 13:26:11
nit: Let's call this NUMBER_OF_SINGLETON_HANDLES i
|
+ }; |
+ |
+ EternalHandles(); |
+ ~EternalHandles(); |
+ |
+ int NumberOfHandles() { return size_; } |
+ |
+ int Create(Isolate* isolate, Object* object); |
+ |
+ inline Object** Get(int index) { |
Michael Starzinger
2013/08/01 13:26:11
The publicly visible Get() method should return Ha
|
+ ASSERT(index >= 0 && index < size_); |
+ return &blocks_[index >> kShift][index & kMask]; |
+ } |
+ |
+ inline int GetIndex(IndexedHandle i) { |
+ return indexed_handles_[i]; |
+ } |
+ |
+ int CreateIndexed(Isolate* isolate, Object* object, IndexedHandle i) { |
+ ASSERT(GetIndex(i) == kInvalidIndex); |
+ indexed_handles_[i] = Create(isolate, object); |
+ return indexed_handles_[i]; |
+ } |
+ |
+ void IterateAllRoots(ObjectVisitor* visitor); |
+ void IterateNewSpaceRoots(ObjectVisitor* visitor); |
+ void PostGarbageCollectionProcessing(Heap* heap); |
+ |
+ private: |
+ static const int kShift = 8; |
+ static const int kSize = 1 << kShift; |
+ static const int kMask = 0xff; |
+ int size_; |
Michael Starzinger
2013/08/01 13:26:11
nit: Let's add an empty newline after the constant
|
+ List<Object**> blocks_; |
+ List<int> new_space_indices_; |
+ int indexed_handles_[LAST_INDEX+1]; |
+ |
+ DISALLOW_COPY_AND_ASSIGN(EternalHandles); |
+}; |
+ |
+ |
} } // namespace v8::internal |
#endif // V8_GLOBAL_HANDLES_H_ |