OLD | NEW |
1 // Copyright 2016 the V8 project authors. All rights reserved. | 1 // Copyright 2016 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_EXTERNAL_REFERENCE_TABLE_H_ | 5 #ifndef V8_EXTERNAL_REFERENCE_TABLE_H_ |
6 #define V8_EXTERNAL_REFERENCE_TABLE_H_ | 6 #define V8_EXTERNAL_REFERENCE_TABLE_H_ |
7 | 7 |
8 #include "src/address-map.h" | 8 #include "src/address-map.h" |
9 | 9 |
10 namespace v8 { | 10 namespace v8 { |
11 namespace internal { | 11 namespace internal { |
12 | 12 |
13 class Isolate; | 13 class Isolate; |
14 | 14 |
15 // ExternalReferenceTable is a helper class that defines the relationship | 15 // ExternalReferenceTable is a helper class that defines the relationship |
16 // between external references and their encodings. It is used to build | 16 // between external references and their encodings. It is used to build |
17 // hashmaps in ExternalReferenceEncoder and ExternalReferenceDecoder. | 17 // hashmaps in ExternalReferenceEncoder and ExternalReferenceDecoder. |
18 class ExternalReferenceTable { | 18 class ExternalReferenceTable { |
19 public: | 19 public: |
20 static ExternalReferenceTable* instance(Isolate* isolate); | 20 static ExternalReferenceTable* instance(Isolate* isolate); |
21 | 21 |
22 uint32_t size() const { return static_cast<uint32_t>(refs_.length()); } | 22 uint32_t size() const { return static_cast<uint32_t>(refs_.length()); } |
23 Address address(uint32_t i) { return refs_[i].address; } | 23 Address address(uint32_t i) { return refs_[i].address; } |
24 const char* name(uint32_t i) { return refs_[i].name; } | 24 const char* name(uint32_t i) { return refs_[i].name; } |
25 bool is_api_reference(uint32_t i) { return i >= api_refs_start_; } | 25 bool is_api_reference(uint32_t i) { return i >= api_refs_start_; } |
| 26 uint32_t num_api_references() { return size() - api_refs_start_; } |
26 | 27 |
27 #ifdef DEBUG | 28 #ifdef DEBUG |
28 void increment_count(uint32_t i) { refs_[i].count++; } | 29 void increment_count(uint32_t i) { refs_[i].count++; } |
29 int count(uint32_t i) { return refs_[i].count; } | 30 int count(uint32_t i) { return refs_[i].count; } |
30 void ResetCount(); | 31 void ResetCount(); |
31 void PrintCount(); | 32 void PrintCount(); |
32 #endif // DEBUG | 33 #endif // DEBUG |
33 | 34 |
34 static const char* ResolveSymbol(void* address); | 35 static const char* ResolveSymbol(void* address); |
35 | 36 |
(...skipping 30 matching lines...) Expand all Loading... |
66 | 67 |
67 List<ExternalReferenceEntry> refs_; | 68 List<ExternalReferenceEntry> refs_; |
68 uint32_t api_refs_start_; | 69 uint32_t api_refs_start_; |
69 | 70 |
70 DISALLOW_COPY_AND_ASSIGN(ExternalReferenceTable); | 71 DISALLOW_COPY_AND_ASSIGN(ExternalReferenceTable); |
71 }; | 72 }; |
72 | 73 |
73 } // namespace internal | 74 } // namespace internal |
74 } // namespace v8 | 75 } // namespace v8 |
75 #endif // V8_EXTERNAL_REFERENCE_TABLE_H_ | 76 #endif // V8_EXTERNAL_REFERENCE_TABLE_H_ |
OLD | NEW |