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

Unified Diff: src/d8.h

Issue 42559: Remove stl dependencies from d8. (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: Created 11 years, 9 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 | « no previous file | src/d8.cc » ('j') | src/d8.cc » ('J')
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: src/d8.h
===================================================================
--- src/d8.h (revision 1587)
+++ src/d8.h (working copy)
@@ -28,12 +28,8 @@
#ifndef V8_D8_H_
#define V8_D8_H_
-
-// Disable exceptions on windows to not generate warnings from <map>.
-#define _HAS_EXCEPTIONS 0
-#include <map>
-
#include "v8.h"
+#include "hashmap.h"
namespace v8 {
@@ -72,6 +68,43 @@
};
+class CounterMap {
+ public:
+ CounterMap(): hash_map_(Match) { }
+ Counter* Lookup(const char* name) {
+ i::HashMap::Entry* answer = hash_map_.Lookup(
+ const_cast<char*>(name),
+ Hash(name),
+ false);
+ if (!answer) return NULL;
+ return reinterpret_cast<Counter*>(answer->value);
+ }
+ void Set(const char* name, Counter* value) {
+ i::HashMap::Entry* answer = hash_map_.Lookup(
+ const_cast<char*>(name),
+ Hash(name),
+ true);
+ ASSERT(answer != NULL);
+ answer->value = value;
+ }
+ class Iterator {
+ public:
+ Iterator(CounterMap* map): map_(&map->hash_map_), entry_(map_->Start()) { }
+ void Next() { entry_ = map_->Next(entry_); }
+ bool More() { return entry_ != NULL; }
+ const char* CurrentKey() { return static_cast<const char*>(entry_->key); }
+ Counter* CurrentValue() { return static_cast<Counter*>(entry_->value); }
+ private:
+ i::HashMap* map_;
+ i::HashMap::Entry* entry_;
+ };
+ private:
+ static int Hash(const char* name);
+ static bool Match(void* key1, void* key2);
+ i::HashMap hash_map_;
+};
+
+
class Shell: public i::AllStatic {
public:
static bool ExecuteString(Handle<String> source,
@@ -104,8 +137,7 @@
private:
static Persistent<Context> utility_context_;
static Persistent<Context> evaluation_context_;
- typedef std::map<const char*, Counter*> CounterMap;
- static CounterMap counter_map_;
+ static CounterMap* counter_map_;
// We statically allocate a set of local counters to be used if we
// don't want to store the stats in a memory-mapped file
static CounterCollection local_counters_;
« no previous file with comments | « no previous file | src/d8.cc » ('j') | src/d8.cc » ('J')

Powered by Google App Engine
This is Rietveld 408576698