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

Unified Diff: src/global-handles.h

Issue 21133006: introduce eternal handles (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: returns handles, added tests Created 7 years, 4 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « src/extensions/i18n/i18n-utils.cc ('k') | src/global-handles.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/global-handles.h
diff --git a/src/global-handles.h b/src/global-handles.h
index cd75133a24367092ec07e87bd9fc451a8a9e9d64..5a4ad13e2f59c3b8342a6b03328f2336f4bcb06f 100644
--- a/src/global-handles.h
+++ b/src/global-handles.h
@@ -31,6 +31,7 @@
#include "../include/v8.h"
#include "../include/v8-profiler.h"
+#include "handles.h"
#include "list.h"
#include "v8utils.h"
@@ -331,6 +332,76 @@ class GlobalHandles {
};
+class EternalHandles {
+ public:
+ enum SingletonHandle {
+ I18N_TEMPLATE_ONE,
+ I18N_TEMPLATE_TWO,
+
+ NUMBER_OF_SINGLETON_HANDLES
+ };
+
+ EternalHandles();
+ ~EternalHandles();
+
+ int NumberOfHandles() { return size_; }
+
+ // Create an EternalHandle, returning the index.
+ int Create(Isolate* isolate, Object* object);
+
+ // Grab the handle for an existing EternalHandle.
+ inline Handle<Object> Get(int index) {
+ return Handle<Object>(GetLocation(index));
+ }
+
+ // Grab the handle for an existing SingletonHandle.
+ inline Handle<Object> GetSingleton(SingletonHandle singleton) {
+ ASSERT(Exists(singleton));
+ return Get(singleton_handles_[singleton]);
+ }
+
+ // Checks whether a SingletonHandle has been assigned.
+ inline bool Exists(SingletonHandle singleton) {
+ return singleton_handles_[singleton] != kInvalidIndex;
+ }
+
+ // Assign a SingletonHandle to an empty slot and returns the handle.
+ Handle<Object> CreateSingleton(Isolate* isolate,
+ Object* object,
+ SingletonHandle singleton) {
+ ASSERT(singleton_handles_[singleton] == kInvalidIndex);
+ singleton_handles_[singleton] = Create(isolate, object);
+ return Get(singleton_handles_[singleton]);
+ }
+
+ // Iterates over all handles.
+ void IterateAllRoots(ObjectVisitor* visitor);
+ // Iterates over all handles which might be in new space.
+ void IterateNewSpaceRoots(ObjectVisitor* visitor);
+ // Rebuilds new space list.
+ void PostGarbageCollectionProcessing(Heap* heap);
+
+ private:
+ static const int kInvalidIndex = -1;
+ static const int kShift = 8;
+ static const int kSize = 1 << kShift;
+ static const int kMask = 0xff;
+
+ // Gets the slot for an index
+ inline Object** GetLocation(int index) {
+ ASSERT(index >= 0 && index < size_);
+ return &blocks_[index >> kShift][index & kMask];
+ }
+
+ int size_;
+ List<Object**> blocks_;
+ List<int> new_space_indices_;
+ int singleton_handles_[NUMBER_OF_SINGLETON_HANDLES];
+
+ DISALLOW_COPY_AND_ASSIGN(EternalHandles);
+};
+
+
} } // namespace v8::internal
#endif // V8_GLOBAL_HANDLES_H_
« no previous file with comments | « src/extensions/i18n/i18n-utils.cc ('k') | src/global-handles.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698