| OLD | NEW |
| 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/hashmap.h" | 10 #include "src/hashmap.h" |
| (...skipping 40 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 51 uint32_t max_name_size_; | 51 uint32_t max_name_size_; |
| 52 uint32_t counters_in_use_; | 52 uint32_t counters_in_use_; |
| 53 Counter counters_[kMaxCounters]; | 53 Counter counters_[kMaxCounters]; |
| 54 }; | 54 }; |
| 55 | 55 |
| 56 | 56 |
| 57 class CounterMap { | 57 class CounterMap { |
| 58 public: | 58 public: |
| 59 CounterMap(): hash_map_(Match) { } | 59 CounterMap(): hash_map_(Match) { } |
| 60 Counter* Lookup(const char* name) { | 60 Counter* Lookup(const char* name) { |
| 61 i::HashMap::Entry* answer = hash_map_.Lookup( | 61 i::HashMap::Entry* answer = |
| 62 const_cast<char*>(name), | 62 hash_map_.Lookup(const_cast<char*>(name), Hash(name)); |
| 63 Hash(name), | |
| 64 false); | |
| 65 if (!answer) return NULL; | 63 if (!answer) return NULL; |
| 66 return reinterpret_cast<Counter*>(answer->value); | 64 return reinterpret_cast<Counter*>(answer->value); |
| 67 } | 65 } |
| 68 void Set(const char* name, Counter* value) { | 66 void Set(const char* name, Counter* value) { |
| 69 i::HashMap::Entry* answer = hash_map_.Lookup( | 67 i::HashMap::Entry* answer = |
| 70 const_cast<char*>(name), | 68 hash_map_.LookupOrInsert(const_cast<char*>(name), Hash(name)); |
| 71 Hash(name), | |
| 72 true); | |
| 73 DCHECK(answer != NULL); | 69 DCHECK(answer != NULL); |
| 74 answer->value = value; | 70 answer->value = value; |
| 75 } | 71 } |
| 76 class Iterator { | 72 class Iterator { |
| 77 public: | 73 public: |
| 78 explicit Iterator(CounterMap* map) | 74 explicit Iterator(CounterMap* map) |
| 79 : map_(&map->hash_map_), entry_(map_->Start()) { } | 75 : map_(&map->hash_map_), entry_(map_->Start()) { } |
| 80 void Next() { entry_ = map_->Next(entry_); } | 76 void Next() { entry_ = map_->Next(entry_); } |
| 81 bool More() { return entry_ != NULL; } | 77 bool More() { return entry_ != NULL; } |
| 82 const char* CurrentKey() { return static_cast<const char*>(entry_->key); } | 78 const char* CurrentKey() { return static_cast<const char*>(entry_->key); } |
| (...skipping 324 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 407 static void ExternalArrayWeakCallback(Isolate* isolate, | 403 static void ExternalArrayWeakCallback(Isolate* isolate, |
| 408 Persistent<Object>* object, | 404 Persistent<Object>* object, |
| 409 uint8_t* data); | 405 uint8_t* data); |
| 410 }; | 406 }; |
| 411 | 407 |
| 412 | 408 |
| 413 } // namespace v8 | 409 } // namespace v8 |
| 414 | 410 |
| 415 | 411 |
| 416 #endif // V8_D8_H_ | 412 #endif // V8_D8_H_ |
| OLD | NEW |