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

Side by Side 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 unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « no previous file | src/d8.cc » ('j') | src/d8.cc » ('J')
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2008 the V8 project authors. All rights reserved. 1 // Copyright 2008 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 10 matching lines...) Expand all
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #ifndef V8_D8_H_ 28 #ifndef V8_D8_H_
29 #define V8_D8_H_ 29 #define V8_D8_H_
30 30
31
32 // Disable exceptions on windows to not generate warnings from <map>.
33 #define _HAS_EXCEPTIONS 0
34 #include <map>
35
36 #include "v8.h" 31 #include "v8.h"
32 #include "hashmap.h"
37 33
38 34
39 namespace v8 { 35 namespace v8 {
40 36
41 37
42 namespace i = v8::internal; 38 namespace i = v8::internal;
43 39
44 40
45 // A single counter in a counter collection. 41 // A single counter in a counter collection.
46 class Counter { 42 class Counter {
(...skipping 18 matching lines...) Expand all
65 private: 61 private:
66 static const unsigned kMaxCounters = 256; 62 static const unsigned kMaxCounters = 256;
67 uint32_t magic_number_; 63 uint32_t magic_number_;
68 uint32_t max_counters_; 64 uint32_t max_counters_;
69 uint32_t max_name_size_; 65 uint32_t max_name_size_;
70 uint32_t counters_in_use_; 66 uint32_t counters_in_use_;
71 Counter counters_[kMaxCounters]; 67 Counter counters_[kMaxCounters];
72 }; 68 };
73 69
74 70
71 class CounterMap {
72 public:
73 CounterMap(): hash_map_(Match) { }
74 Counter* Lookup(const char* name) {
75 i::HashMap::Entry* answer = hash_map_.Lookup(
76 const_cast<char*>(name),
77 Hash(name),
78 false);
79 if (!answer) return NULL;
80 return reinterpret_cast<Counter*>(answer->value);
81 }
82 void Set(const char* name, Counter* value) {
83 i::HashMap::Entry* answer = hash_map_.Lookup(
84 const_cast<char*>(name),
85 Hash(name),
86 true);
87 ASSERT(answer != NULL);
88 answer->value = value;
89 }
90 class Iterator {
91 public:
92 Iterator(CounterMap* map): map_(&map->hash_map_), entry_(map_->Start()) { }
93 void Next() { entry_ = map_->Next(entry_); }
94 bool More() { return entry_ != NULL; }
95 const char* CurrentKey() { return static_cast<const char*>(entry_->key); }
96 Counter* CurrentValue() { return static_cast<Counter*>(entry_->value); }
97 private:
98 i::HashMap* map_;
99 i::HashMap::Entry* entry_;
100 };
101 private:
102 static int Hash(const char* name);
103 static bool Match(void* key1, void* key2);
104 i::HashMap hash_map_;
105 };
106
107
75 class Shell: public i::AllStatic { 108 class Shell: public i::AllStatic {
76 public: 109 public:
77 static bool ExecuteString(Handle<String> source, 110 static bool ExecuteString(Handle<String> source,
78 Handle<Value> name, 111 Handle<Value> name,
79 bool print_result, 112 bool print_result,
80 bool report_exceptions); 113 bool report_exceptions);
81 static void ReportException(TryCatch* try_catch); 114 static void ReportException(TryCatch* try_catch);
82 static void Initialize(); 115 static void Initialize();
83 static void OnExit(); 116 static void OnExit();
84 static int* LookupCounter(const char* name); 117 static int* LookupCounter(const char* name);
(...skipping 12 matching lines...) Expand all
97 static Handle<Value> Version(const Arguments& args); 130 static Handle<Value> Version(const Arguments& args);
98 static Handle<Value> Load(const Arguments& args); 131 static Handle<Value> Load(const Arguments& args);
99 132
100 static Handle<Context> utility_context() { return utility_context_; } 133 static Handle<Context> utility_context() { return utility_context_; }
101 134
102 static const char* kHistoryFileName; 135 static const char* kHistoryFileName;
103 static const char* kPrompt; 136 static const char* kPrompt;
104 private: 137 private:
105 static Persistent<Context> utility_context_; 138 static Persistent<Context> utility_context_;
106 static Persistent<Context> evaluation_context_; 139 static Persistent<Context> evaluation_context_;
107 typedef std::map<const char*, Counter*> CounterMap; 140 static CounterMap* counter_map_;
108 static CounterMap counter_map_;
109 // We statically allocate a set of local counters to be used if we 141 // We statically allocate a set of local counters to be used if we
110 // don't want to store the stats in a memory-mapped file 142 // don't want to store the stats in a memory-mapped file
111 static CounterCollection local_counters_; 143 static CounterCollection local_counters_;
112 static CounterCollection* counters_; 144 static CounterCollection* counters_;
113 static i::OS::MemoryMappedFile* counters_file_; 145 static i::OS::MemoryMappedFile* counters_file_;
114 }; 146 };
115 147
116 148
117 class LineEditor { 149 class LineEditor {
118 public: 150 public:
(...skipping 13 matching lines...) Expand all
132 const char* name_; 164 const char* name_;
133 LineEditor* next_; 165 LineEditor* next_;
134 static LineEditor* first_; 166 static LineEditor* first_;
135 }; 167 };
136 168
137 169
138 } // namespace v8 170 } // namespace v8
139 171
140 172
141 #endif // V8_D8_H_ 173 #endif // V8_D8_H_
OLDNEW
« 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