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 | 25 |
26 #ifdef DEBUG | |
27 void increment_count(uint32_t i) { refs_[i].count++; } | |
28 int count(uint32_t i) { return refs_[i].count; } | |
29 void ResetCount(); | |
30 void PrintCount(); | |
31 #endif // DEBUG | |
32 | |
33 static const char* ResolveSymbol(void* address); | |
34 | |
35 static const int kDeoptTableSerializeEntryCount = 64; | 26 static const int kDeoptTableSerializeEntryCount = 64; |
36 | 27 |
37 private: | 28 private: |
38 struct ExternalReferenceEntry { | 29 struct ExternalReferenceEntry { |
39 Address address; | 30 Address address; |
40 const char* name; | 31 const char* name; |
41 #ifdef DEBUG | |
42 int count; | |
43 #endif // DEBUG | |
44 }; | 32 }; |
45 | 33 |
46 explicit ExternalReferenceTable(Isolate* isolate); | 34 explicit ExternalReferenceTable(Isolate* isolate); |
47 | 35 |
48 void Add(Address address, const char* name) { | 36 void Add(Address address, const char* name) { |
49 ExternalReferenceEntry entry = {address, name}; | 37 ExternalReferenceEntry entry = {address, name}; |
50 refs_.Add(entry); | 38 refs_.Add(entry); |
51 } | 39 } |
52 | 40 |
53 void AddReferences(Isolate* isolate); | 41 void AddReferences(Isolate* isolate); |
54 void AddBuiltins(Isolate* isolate); | 42 void AddBuiltins(Isolate* isolate); |
55 void AddRuntimeFunctions(Isolate* isolate); | 43 void AddRuntimeFunctions(Isolate* isolate); |
56 void AddIsolateAddresses(Isolate* isolate); | 44 void AddIsolateAddresses(Isolate* isolate); |
57 void AddAccessors(Isolate* isolate); | 45 void AddAccessors(Isolate* isolate); |
58 void AddStubCache(Isolate* isolate); | 46 void AddStubCache(Isolate* isolate); |
59 void AddDeoptEntries(Isolate* isolate); | 47 void AddDeoptEntries(Isolate* isolate); |
60 void AddApiReferences(Isolate* isolate); | 48 void AddApiReferences(Isolate* isolate); |
61 | 49 |
62 List<ExternalReferenceEntry> refs_; | 50 List<ExternalReferenceEntry> refs_; |
63 | 51 |
64 DISALLOW_COPY_AND_ASSIGN(ExternalReferenceTable); | 52 DISALLOW_COPY_AND_ASSIGN(ExternalReferenceTable); |
65 }; | 53 }; |
66 | 54 |
67 } // namespace internal | 55 } // namespace internal |
68 } // namespace v8 | 56 } // namespace v8 |
69 #endif // V8_EXTERNAL_REFERENCE_TABLE_H_ | 57 #endif // V8_EXTERNAL_REFERENCE_TABLE_H_ |
OLD | NEW |