OLD | NEW |
1 // Copyright 2015 the V8 project authors. All rights reserved. | 1 // Copyright 2015 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_ADDRESS_MAP_H_ | 5 #ifndef V8_ADDRESS_MAP_H_ |
6 #define V8_ADDRESS_MAP_H_ | 6 #define V8_ADDRESS_MAP_H_ |
7 | 7 |
8 #include "src/assert-scope.h" | 8 #include "src/assert-scope.h" |
9 #include "src/base/hashmap.h" | 9 #include "src/base/hashmap.h" |
10 #include "src/objects.h" | 10 #include "src/objects.h" |
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
70 static SerializerReference BackReference(AllocationSpace space, | 70 static SerializerReference BackReference(AllocationSpace space, |
71 uint32_t chunk_index, | 71 uint32_t chunk_index, |
72 uint32_t chunk_offset) { | 72 uint32_t chunk_offset) { |
73 DCHECK(IsAligned(chunk_offset, kObjectAlignment)); | 73 DCHECK(IsAligned(chunk_offset, kObjectAlignment)); |
74 DCHECK_NE(LO_SPACE, space); | 74 DCHECK_NE(LO_SPACE, space); |
75 return SerializerReference( | 75 return SerializerReference( |
76 SpaceBits::encode(space) | ChunkIndexBits::encode(chunk_index) | | 76 SpaceBits::encode(space) | ChunkIndexBits::encode(chunk_index) | |
77 ChunkOffsetBits::encode(chunk_offset >> kObjectAlignmentBits)); | 77 ChunkOffsetBits::encode(chunk_offset >> kObjectAlignmentBits)); |
78 } | 78 } |
79 | 79 |
| 80 static SerializerReference MapReference(uint32_t index) { |
| 81 return SerializerReference(SpaceBits::encode(MAP_SPACE) | |
| 82 ValueIndexBits::encode(index)); |
| 83 } |
| 84 |
80 static SerializerReference LargeObjectReference(uint32_t index) { | 85 static SerializerReference LargeObjectReference(uint32_t index) { |
81 return SerializerReference(SpaceBits::encode(LO_SPACE) | | 86 return SerializerReference(SpaceBits::encode(LO_SPACE) | |
82 ValueIndexBits::encode(index)); | 87 ValueIndexBits::encode(index)); |
83 } | 88 } |
84 | 89 |
85 static SerializerReference AttachedReference(uint32_t index) { | 90 static SerializerReference AttachedReference(uint32_t index) { |
86 return SerializerReference(SpaceBits::encode(kAttachedReferenceSpace) | | 91 return SerializerReference(SpaceBits::encode(kAttachedReferenceSpace) | |
87 ValueIndexBits::encode(index)); | 92 ValueIndexBits::encode(index)); |
88 } | 93 } |
89 | 94 |
(...skipping 10 matching lines...) Expand all Loading... |
100 AllocationSpace space() const { | 105 AllocationSpace space() const { |
101 DCHECK(is_back_reference()); | 106 DCHECK(is_back_reference()); |
102 return static_cast<AllocationSpace>(SpaceBits::decode(bitfield_)); | 107 return static_cast<AllocationSpace>(SpaceBits::decode(bitfield_)); |
103 } | 108 } |
104 | 109 |
105 uint32_t chunk_offset() const { | 110 uint32_t chunk_offset() const { |
106 DCHECK(is_back_reference()); | 111 DCHECK(is_back_reference()); |
107 return ChunkOffsetBits::decode(bitfield_) << kObjectAlignmentBits; | 112 return ChunkOffsetBits::decode(bitfield_) << kObjectAlignmentBits; |
108 } | 113 } |
109 | 114 |
| 115 uint32_t map_index() const { |
| 116 DCHECK(is_back_reference()); |
| 117 return ValueIndexBits::decode(bitfield_); |
| 118 } |
| 119 |
110 uint32_t large_object_index() const { | 120 uint32_t large_object_index() const { |
111 DCHECK(is_back_reference()); | 121 DCHECK(is_back_reference()); |
112 DCHECK(chunk_index() == 0); | 122 return ValueIndexBits::decode(bitfield_); |
113 return ChunkOffsetBits::decode(bitfield_); | |
114 } | 123 } |
115 | 124 |
116 uint32_t chunk_index() const { | 125 uint32_t chunk_index() const { |
117 DCHECK(is_back_reference()); | 126 DCHECK(is_back_reference()); |
118 return ChunkIndexBits::decode(bitfield_); | 127 return ChunkIndexBits::decode(bitfield_); |
119 } | 128 } |
120 | 129 |
121 uint32_t back_reference() const { | 130 uint32_t back_reference() const { |
122 DCHECK(is_back_reference()); | 131 DCHECK(is_back_reference()); |
123 return bitfield_ & (ChunkOffsetBits::kMask | ChunkIndexBits::kMask); | 132 return bitfield_ & (ChunkOffsetBits::kMask | ChunkIndexBits::kMask); |
(...skipping 83 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
207 DisallowHeapAllocation no_allocation_; | 216 DisallowHeapAllocation no_allocation_; |
208 base::HashMap map_; | 217 base::HashMap map_; |
209 int attached_reference_index_; | 218 int attached_reference_index_; |
210 DISALLOW_COPY_AND_ASSIGN(SerializerReferenceMap); | 219 DISALLOW_COPY_AND_ASSIGN(SerializerReferenceMap); |
211 }; | 220 }; |
212 | 221 |
213 } // namespace internal | 222 } // namespace internal |
214 } // namespace v8 | 223 } // namespace v8 |
215 | 224 |
216 #endif // V8_ADDRESS_MAP_H_ | 225 #endif // V8_ADDRESS_MAP_H_ |
OLD | NEW |