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

Side by Side Diff: src/d8.h

Issue 2010243003: Move hashmap into base/. (Closed) Base URL: https://chromium.googlesource.com/v8/v8.git@master
Patch Set: Rebase Created 4 years, 6 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
« no previous file with comments | « src/compilation-cache.h ('k') | src/debug/debug.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2012 the V8 project authors. All rights reserved. 1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef V8_D8_H_ 5 #ifndef V8_D8_H_
6 #define V8_D8_H_ 6 #define V8_D8_H_
7 7
8 #ifndef V8_SHARED 8 #ifndef V8_SHARED
9 #include "src/allocation.h" 9 #include "src/allocation.h"
10 #include "src/base/hashmap.h"
10 #include "src/base/platform/time.h" 11 #include "src/base/platform/time.h"
11 #include "src/hashmap.h"
12 #include "src/list.h" 12 #include "src/list.h"
13 #else 13 #else
14 #include "include/v8.h" 14 #include "include/v8.h"
15 #include "src/base/compiler-specific.h" 15 #include "src/base/compiler-specific.h"
16 #endif // !V8_SHARED 16 #endif // !V8_SHARED
17 17
18 #include "src/base/once.h" 18 #include "src/base/once.h"
19 19
20 20
21 namespace v8 { 21 namespace v8 {
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after
54 uint32_t max_name_size_; 54 uint32_t max_name_size_;
55 uint32_t counters_in_use_; 55 uint32_t counters_in_use_;
56 Counter counters_[kMaxCounters]; 56 Counter counters_[kMaxCounters];
57 }; 57 };
58 58
59 59
60 class CounterMap { 60 class CounterMap {
61 public: 61 public:
62 CounterMap(): hash_map_(Match) { } 62 CounterMap(): hash_map_(Match) { }
63 Counter* Lookup(const char* name) { 63 Counter* Lookup(const char* name) {
64 i::HashMap::Entry* answer = 64 base::HashMap::Entry* answer =
65 hash_map_.Lookup(const_cast<char*>(name), Hash(name)); 65 hash_map_.Lookup(const_cast<char*>(name), Hash(name));
66 if (!answer) return NULL; 66 if (!answer) return NULL;
67 return reinterpret_cast<Counter*>(answer->value); 67 return reinterpret_cast<Counter*>(answer->value);
68 } 68 }
69 void Set(const char* name, Counter* value) { 69 void Set(const char* name, Counter* value) {
70 i::HashMap::Entry* answer = 70 base::HashMap::Entry* answer =
71 hash_map_.LookupOrInsert(const_cast<char*>(name), Hash(name)); 71 hash_map_.LookupOrInsert(const_cast<char*>(name), Hash(name));
72 DCHECK(answer != NULL); 72 DCHECK(answer != NULL);
73 answer->value = value; 73 answer->value = value;
74 } 74 }
75 class Iterator { 75 class Iterator {
76 public: 76 public:
77 explicit Iterator(CounterMap* map) 77 explicit Iterator(CounterMap* map)
78 : map_(&map->hash_map_), entry_(map_->Start()) { } 78 : map_(&map->hash_map_), entry_(map_->Start()) { }
79 void Next() { entry_ = map_->Next(entry_); } 79 void Next() { entry_ = map_->Next(entry_); }
80 bool More() { return entry_ != NULL; } 80 bool More() { return entry_ != NULL; }
81 const char* CurrentKey() { return static_cast<const char*>(entry_->key); } 81 const char* CurrentKey() { return static_cast<const char*>(entry_->key); }
82 Counter* CurrentValue() { return static_cast<Counter*>(entry_->value); } 82 Counter* CurrentValue() { return static_cast<Counter*>(entry_->value); }
83 private: 83 private:
84 i::HashMap* map_; 84 base::HashMap* map_;
85 i::HashMap::Entry* entry_; 85 base::HashMap::Entry* entry_;
86 }; 86 };
87 87
88 private: 88 private:
89 static int Hash(const char* name); 89 static int Hash(const char* name);
90 static bool Match(void* key1, void* key2); 90 static bool Match(void* key1, void* key2);
91 i::HashMap hash_map_; 91 base::HashMap hash_map_;
92 }; 92 };
93 #endif // !V8_SHARED 93 #endif // !V8_SHARED
94 94
95 95
96 class SourceGroup { 96 class SourceGroup {
97 public: 97 public:
98 SourceGroup() : 98 SourceGroup() :
99 #ifndef V8_SHARED 99 #ifndef V8_SHARED
100 next_semaphore_(0), 100 next_semaphore_(0),
101 done_semaphore_(0), 101 done_semaphore_(0),
(...skipping 241 matching lines...) Expand 10 before | Expand all | Expand 10 after
343 static Local<Context> CreateEvaluationContext(Isolate* isolate); 343 static Local<Context> CreateEvaluationContext(Isolate* isolate);
344 static int RunMain(Isolate* isolate, int argc, char* argv[], bool last_run); 344 static int RunMain(Isolate* isolate, int argc, char* argv[], bool last_run);
345 static int Main(int argc, char* argv[]); 345 static int Main(int argc, char* argv[]);
346 static void Exit(int exit_code); 346 static void Exit(int exit_code);
347 static void OnExit(Isolate* isolate); 347 static void OnExit(Isolate* isolate);
348 static void CollectGarbage(Isolate* isolate); 348 static void CollectGarbage(Isolate* isolate);
349 static void EmptyMessageQueues(Isolate* isolate); 349 static void EmptyMessageQueues(Isolate* isolate);
350 350
351 #ifndef V8_SHARED 351 #ifndef V8_SHARED
352 // TODO(binji): stupid implementation for now. Is there an easy way to hash an 352 // TODO(binji): stupid implementation for now. Is there an easy way to hash an
353 // object for use in i::HashMap? By pointer? 353 // object for use in base::HashMap? By pointer?
354 typedef i::List<Local<Object>> ObjectList; 354 typedef i::List<Local<Object>> ObjectList;
355 static bool SerializeValue(Isolate* isolate, Local<Value> value, 355 static bool SerializeValue(Isolate* isolate, Local<Value> value,
356 const ObjectList& to_transfer, 356 const ObjectList& to_transfer,
357 ObjectList* seen_objects, 357 ObjectList* seen_objects,
358 SerializationData* out_data); 358 SerializationData* out_data);
359 static MaybeLocal<Value> DeserializeValue(Isolate* isolate, 359 static MaybeLocal<Value> DeserializeValue(Isolate* isolate,
360 const SerializationData& data, 360 const SerializationData& data,
361 int* offset); 361 int* offset);
362 static void CleanupWorkers(); 362 static void CleanupWorkers();
363 static int* LookupCounter(const char* name); 363 static int* LookupCounter(const char* name);
(...skipping 109 matching lines...) Expand 10 before | Expand all | Expand 10 after
473 static Local<ObjectTemplate> CreateGlobalTemplate(Isolate* isolate); 473 static Local<ObjectTemplate> CreateGlobalTemplate(Isolate* isolate);
474 static MaybeLocal<Context> CreateRealm( 474 static MaybeLocal<Context> CreateRealm(
475 const v8::FunctionCallbackInfo<v8::Value>& args); 475 const v8::FunctionCallbackInfo<v8::Value>& args);
476 }; 476 };
477 477
478 478
479 } // namespace v8 479 } // namespace v8
480 480
481 481
482 #endif // V8_D8_H_ 482 #endif // V8_D8_H_
OLDNEW
« no previous file with comments | « src/compilation-cache.h ('k') | src/debug/debug.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698