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 // The reason we write our own hash map instead of using unordered_map in STL, | 5 // The reason we write our own hash map instead of using unordered_map in STL, |
6 // is that STL containers use a mutex pool on debug build, which will lead to | 6 // is that STL containers use a mutex pool on debug build, which will lead to |
7 // deadlock when we are using async signal handler. | 7 // deadlock when we are using async signal handler. |
8 | 8 |
9 #ifndef V8_BASE_HASHMAP_H_ | 9 #ifndef V8_BASE_HASHMAP_H_ |
10 #define V8_BASE_HASHMAP_H_ | 10 #define V8_BASE_HASHMAP_H_ |
11 | 11 |
| 12 #include <stdlib.h> |
| 13 |
12 #include "src/base/bits.h" | 14 #include "src/base/bits.h" |
13 #include "src/base/logging.h" | 15 #include "src/base/logging.h" |
14 | 16 |
15 namespace v8 { | 17 namespace v8 { |
16 namespace base { | 18 namespace base { |
17 | 19 |
18 class DefaultAllocationPolicy { | 20 class DefaultAllocationPolicy { |
19 public: | 21 public: |
20 V8_INLINE void* New(size_t size) { return malloc(size); } | 22 V8_INLINE void* New(size_t size) { return malloc(size); } |
21 V8_INLINE static void Delete(void* p) { free(p); } | 23 V8_INLINE static void Delete(void* p) { free(p); } |
(...skipping 319 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
341 return Iterator(this, this->LookupOrInsert(key, key->Hash(), allocator)); | 343 return Iterator(this, this->LookupOrInsert(key, key->Hash(), allocator)); |
342 } | 344 } |
343 return Iterator(this, this->Lookup(key, key->Hash())); | 345 return Iterator(this, this->Lookup(key, key->Hash())); |
344 } | 346 } |
345 }; | 347 }; |
346 | 348 |
347 } // namespace base | 349 } // namespace base |
348 } // namespace v8 | 350 } // namespace v8 |
349 | 351 |
350 #endif // V8_BASE_HASHMAP_H_ | 352 #endif // V8_BASE_HASHMAP_H_ |
OLD | NEW |