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_SNAPSHOT_SERIALIZER_COMMON_H_ | 5 #ifndef V8_SNAPSHOT_SERIALIZER_COMMON_H_ |
6 #define V8_SNAPSHOT_SERIALIZER_COMMON_H_ | 6 #define V8_SNAPSHOT_SERIALIZER_COMMON_H_ |
7 | 7 |
8 #include "src/address-map.h" | 8 #include "src/address-map.h" |
| 9 #include "src/external-reference-table.h" |
9 #include "src/globals.h" | 10 #include "src/globals.h" |
10 | 11 |
11 namespace v8 { | 12 namespace v8 { |
12 namespace internal { | 13 namespace internal { |
13 | 14 |
14 class Isolate; | 15 class Isolate; |
15 | 16 |
16 // ExternalReferenceTable is a helper class that defines the relationship | |
17 // between external references and their encodings. It is used to build | |
18 // hashmaps in ExternalReferenceEncoder and ExternalReferenceDecoder. | |
19 class ExternalReferenceTable { | |
20 public: | |
21 static ExternalReferenceTable* instance(Isolate* isolate); | |
22 | |
23 int size() const { return refs_.length(); } | |
24 Address address(int i) { return refs_[i].address; } | |
25 const char* name(int i) { return refs_[i].name; } | |
26 | |
27 inline static Address NotAvailable() { return NULL; } | |
28 | |
29 static const int kDeoptTableSerializeEntryCount = 64; | |
30 | |
31 private: | |
32 struct ExternalReferenceEntry { | |
33 Address address; | |
34 const char* name; | |
35 }; | |
36 | |
37 explicit ExternalReferenceTable(Isolate* isolate); | |
38 | |
39 void Add(Address address, const char* name) { | |
40 ExternalReferenceEntry entry = {address, name}; | |
41 refs_.Add(entry); | |
42 } | |
43 | |
44 List<ExternalReferenceEntry> refs_; | |
45 | |
46 DISALLOW_COPY_AND_ASSIGN(ExternalReferenceTable); | |
47 }; | |
48 | |
49 class ExternalReferenceEncoder { | 17 class ExternalReferenceEncoder { |
50 public: | 18 public: |
51 explicit ExternalReferenceEncoder(Isolate* isolate); | 19 explicit ExternalReferenceEncoder(Isolate* isolate); |
52 | 20 |
53 uint32_t Encode(Address key) const; | 21 uint32_t Encode(Address key) const; |
54 | 22 |
55 const char* NameOfAddress(Isolate* isolate, Address address) const; | 23 const char* NameOfAddress(Isolate* isolate, Address address) const; |
56 | 24 |
57 private: | 25 private: |
58 static uint32_t Hash(Address key) { | 26 static uint32_t Hash(Address key) { |
(...skipping 254 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
313 | 281 |
314 byte* data_; | 282 byte* data_; |
315 int size_; | 283 int size_; |
316 bool owns_data_; | 284 bool owns_data_; |
317 }; | 285 }; |
318 | 286 |
319 } // namespace internal | 287 } // namespace internal |
320 } // namespace v8 | 288 } // namespace v8 |
321 | 289 |
322 #endif // V8_SNAPSHOT_SERIALIZER_COMMON_H_ | 290 #endif // V8_SNAPSHOT_SERIALIZER_COMMON_H_ |
OLD | NEW |