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, |