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

Unified Diff: src/api.cc

Issue 8536042: Extension state made per-siolate in genesis (Closed) Base URL: https://v8.googlecode.com/svn/branches/bleeding_edge
Patch Set: Created 9 years, 1 month 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
Index: src/api.cc
diff --git a/src/api.cc b/src/api.cc
index 1ad70e8dbcba5c6943118a72807d52bc875660e6..91f8ad867e86aa675439496ee95ac87319b734c6 100644
--- a/src/api.cc
+++ b/src/api.cc
@@ -304,7 +304,7 @@ static inline i::Isolate* EnterIsolateIfNeeded() {
i::Isolate::EnterDefaultIsolate();
isolate = i::Isolate::Current();
- return isolate;
+return isolate;
danno 2011/11/15 09:46:47 nit: indent
}
@@ -486,7 +486,7 @@ RegisteredExtension* RegisteredExtension::first_extension_ = NULL;
RegisteredExtension::RegisteredExtension(Extension* extension)
- : extension_(extension), state_(UNVISITED) { }
+ : extension_(extension) { }
void RegisteredExtension::Register(RegisteredExtension* that) {
@@ -501,6 +501,46 @@ void RegisterExtension(Extension* that) {
}
+namespace internal {
+
Vitaly Repeshko 2011/11/15 18:14:17 nit: Remove one blank line.
+
+static uint32_t Hash(RegisteredExtension* extension) {
+ return v8::internal::ComputeIntegerHash(
+ reinterpret_cast<uint32_t>(extension));
Vitaly Repeshko 2011/11/15 18:14:17 I'm not sure it'll work with 64 bit pointers. I th
+}
+
+static bool MatchRegisteredExtensions(void* key1, void* key2) {
+ return key1 == key2;
+}
+
+static Allocator* ExtensionStatesAllocator() {
+ static Allocator default_allocator;
Vitaly Repeshko 2011/11/15 18:14:17 Allocate the allocator with "new" to avoid issues
+ return &default_allocator;
+}
+
+ExtensionStates::ExtensionStates()
+ : HashMap(MatchRegisteredExtensions, ExtensionStatesAllocator(), 8)
+ {}
+
+ExtensionTraversalState ExtensionStates::get_state(
+ RegisteredExtension* extension) {
+ i::HashMap::Entry* entry = Lookup(extension, Hash(extension), false);
+ if (entry == NULL) {
+ entry = Lookup(extension, Hash(extension), true);
Vitaly Repeshko 2011/11/15 18:14:17 Can't you simply return UNVISITED?
+ entry->value = reinterpret_cast<void*>(
+ static_cast<int>(UNVISITED));
+ }
+ return static_cast<ExtensionTraversalState>(
+ reinterpret_cast<int>(entry->value));
Vitaly Repeshko 2011/11/15 18:14:17 Again, I think it has to be something like static_
+}
+
+void ExtensionStates::set_state(RegisteredExtension* extension,
+ ExtensionTraversalState state) {
+ Lookup(extension, Hash(extension), true)->value =
+ reinterpret_cast<void*>(static_cast<int>(state));
+}
+}
Vitaly Repeshko 2011/11/15 18:14:17 nit: // namespace internal
+
Extension::Extension(const char* name,
const char* source,
int dep_count,

Powered by Google App Engine
This is Rietveld 408576698