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_SERIALIZE_H_ | 5 #ifndef V8_SERIALIZE_H_ |
6 #define V8_SERIALIZE_H_ | 6 #define V8_SERIALIZE_H_ |
7 | 7 |
8 #include "src/compiler.h" | 8 #include "src/compiler.h" |
9 #include "src/hashmap.h" | 9 #include "src/hashmap.h" |
10 #include "src/heap-profiler.h" | 10 #include "src/heap-profiler.h" |
11 #include "src/isolate.h" | 11 #include "src/isolate.h" |
12 #include "src/snapshot-source-sink.h" | 12 #include "src/snapshot-source-sink.h" |
13 | 13 |
14 namespace v8 { | 14 namespace v8 { |
15 namespace internal { | 15 namespace internal { |
16 | 16 |
17 // A TypeCode is used to distinguish different kinds of external reference. | 17 // A TypeCode is used to distinguish different kinds of external reference. |
18 // It is a single bit to make testing for types easy. | 18 // It is a single bit to make testing for types easy. |
19 enum TypeCode { | 19 enum TypeCode { |
20 UNCLASSIFIED, // One-of-a-kind references. | 20 UNCLASSIFIED, // One-of-a-kind references. |
| 21 C_BUILTIN, |
21 BUILTIN, | 22 BUILTIN, |
22 RUNTIME_FUNCTION, | 23 RUNTIME_FUNCTION, |
23 IC_UTILITY, | 24 IC_UTILITY, |
24 STATS_COUNTER, | 25 STATS_COUNTER, |
25 TOP_ADDRESS, | 26 TOP_ADDRESS, |
26 C_BUILTIN, | |
27 EXTENSION, | |
28 ACCESSOR, | 27 ACCESSOR, |
| 28 STUB_CACHE_TABLE, |
29 RUNTIME_ENTRY, | 29 RUNTIME_ENTRY, |
30 STUB_CACHE_TABLE, | |
31 LAZY_DEOPTIMIZATION | 30 LAZY_DEOPTIMIZATION |
32 }; | 31 }; |
33 | 32 |
34 const int kTypeCodeCount = LAZY_DEOPTIMIZATION + 1; | 33 const int kTypeCodeCount = LAZY_DEOPTIMIZATION + 1; |
35 const int kFirstTypeCode = UNCLASSIFIED; | 34 const int kFirstTypeCode = UNCLASSIFIED; |
36 | 35 |
37 const int kReferenceIdBits = 16; | 36 const int kReferenceIdBits = 16; |
38 const int kReferenceIdMask = (1 << kReferenceIdBits) - 1; | 37 const int kReferenceIdMask = (1 << kReferenceIdBits) - 1; |
39 const int kReferenceTypeShift = kReferenceIdBits; | 38 const int kReferenceTypeShift = kReferenceIdBits; |
40 | 39 |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
74 | 73 |
75 // For a few types of references, we can get their address from their id. | 74 // For a few types of references, we can get their address from their id. |
76 void AddFromId(TypeCode type, | 75 void AddFromId(TypeCode type, |
77 uint16_t id, | 76 uint16_t id, |
78 const char* name, | 77 const char* name, |
79 Isolate* isolate); | 78 Isolate* isolate); |
80 | 79 |
81 // For other types of references, the caller will figure out the address. | 80 // For other types of references, the caller will figure out the address. |
82 void Add(Address address, TypeCode type, uint16_t id, const char* name); | 81 void Add(Address address, TypeCode type, uint16_t id, const char* name); |
83 | 82 |
| 83 void Add(Address address, const char* name) { |
| 84 Add(address, UNCLASSIFIED, ++max_id_[UNCLASSIFIED], name); |
| 85 } |
| 86 |
84 List<ExternalReferenceEntry> refs_; | 87 List<ExternalReferenceEntry> refs_; |
85 int max_id_[kTypeCodeCount]; | 88 uint16_t max_id_[kTypeCodeCount]; |
86 }; | 89 }; |
87 | 90 |
88 | 91 |
89 class ExternalReferenceEncoder { | 92 class ExternalReferenceEncoder { |
90 public: | 93 public: |
91 explicit ExternalReferenceEncoder(Isolate* isolate); | 94 explicit ExternalReferenceEncoder(Isolate* isolate); |
92 | 95 |
93 uint32_t Encode(Address key) const; | 96 uint32_t Encode(Address key) const; |
94 | 97 |
95 const char* NameOfAddress(Address key) const; | 98 const char* NameOfAddress(Address key) const; |
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
667 static const int kCheckSumOffset = 0; | 670 static const int kCheckSumOffset = 0; |
668 static const int kReservationsOffset = 1; | 671 static const int kReservationsOffset = 1; |
669 static const int kHeaderEntries = 8; | 672 static const int kHeaderEntries = 8; |
670 | 673 |
671 ScriptData* script_data_; | 674 ScriptData* script_data_; |
672 bool owns_script_data_; | 675 bool owns_script_data_; |
673 }; | 676 }; |
674 } } // namespace v8::internal | 677 } } // namespace v8::internal |
675 | 678 |
676 #endif // V8_SERIALIZE_H_ | 679 #endif // V8_SERIALIZE_H_ |
OLD | NEW |