| 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_OBJECTS_BODY_DESCRIPTORS_INL_H_ | 5 #ifndef V8_OBJECTS_BODY_DESCRIPTORS_INL_H_ |
| 6 #define V8_OBJECTS_BODY_DESCRIPTORS_INL_H_ | 6 #define V8_OBJECTS_BODY_DESCRIPTORS_INL_H_ |
| 7 | 7 |
| 8 #include "src/assembler-inl.h" | 8 #include "src/assembler-inl.h" |
| 9 #include "src/objects-body-descriptors.h" | 9 #include "src/objects-body-descriptors.h" |
| 10 #include "src/transitions.h" | 10 #include "src/transitions.h" |
| 11 | 11 |
| 12 namespace v8 { | 12 namespace v8 { |
| 13 namespace internal { | 13 namespace internal { |
| 14 | 14 |
| 15 template <int start_offset> | 15 template <int start_offset> |
| 16 int FlexibleBodyDescriptor<start_offset>::SizeOf(Map* map, HeapObject* object) { | 16 int FlexibleBodyDescriptor<start_offset>::SizeOf(Map* map, HeapObject* object) { |
| 17 return object->SizeFromMap(map); | 17 return object->SizeFromMap(map); |
| 18 } | 18 } |
| 19 | 19 |
| 20 | |
| 21 bool BodyDescriptorBase::IsValidSlotImpl(HeapObject* obj, int offset) { | 20 bool BodyDescriptorBase::IsValidSlotImpl(HeapObject* obj, int offset) { |
| 22 if (!FLAG_unbox_double_fields || obj->map()->HasFastPointerLayout()) { | 21 if (!FLAG_unbox_double_fields || obj->map()->HasFastPointerLayout()) { |
| 23 return true; | 22 return true; |
| 24 } else { | 23 } else { |
| 25 DCHECK(FLAG_unbox_double_fields); | 24 DCHECK(FLAG_unbox_double_fields); |
| 26 DCHECK(IsAligned(offset, kPointerSize)); | 25 DCHECK(IsAligned(offset, kPointerSize)); |
| 27 | 26 |
| 28 LayoutDescriptorHelper helper(obj->map()); | 27 LayoutDescriptorHelper helper(obj->map()); |
| 29 DCHECK(!helper.all_fields_tagged()); | 28 DCHECK(!helper.all_fields_tagged()); |
| 30 return helper.IsTagged(offset); | 29 return helper.IsTagged(offset); |
| (...skipping 15 matching lines...) Expand all Loading... |
| 46 for (int offset = start_offset; offset < end_offset;) { | 45 for (int offset = start_offset; offset < end_offset;) { |
| 47 int end_of_region_offset; | 46 int end_of_region_offset; |
| 48 if (helper.IsTagged(offset, end_offset, &end_of_region_offset)) { | 47 if (helper.IsTagged(offset, end_offset, &end_of_region_offset)) { |
| 49 IteratePointers(obj, offset, end_of_region_offset, v); | 48 IteratePointers(obj, offset, end_of_region_offset, v); |
| 50 } | 49 } |
| 51 offset = end_of_region_offset; | 50 offset = end_of_region_offset; |
| 52 } | 51 } |
| 53 } | 52 } |
| 54 } | 53 } |
| 55 | 54 |
| 56 | |
| 57 template <typename StaticVisitor> | 55 template <typename StaticVisitor> |
| 58 void BodyDescriptorBase::IterateBodyImpl(Heap* heap, HeapObject* obj, | 56 void BodyDescriptorBase::IterateBodyImpl(Heap* heap, HeapObject* obj, |
| 59 int start_offset, int end_offset) { | 57 int start_offset, int end_offset) { |
| 60 if (!FLAG_unbox_double_fields || obj->map()->HasFastPointerLayout()) { | 58 if (!FLAG_unbox_double_fields || obj->map()->HasFastPointerLayout()) { |
| 61 IteratePointers<StaticVisitor>(heap, obj, start_offset, end_offset); | 59 IteratePointers<StaticVisitor>(heap, obj, start_offset, end_offset); |
| 62 } else { | 60 } else { |
| 63 DCHECK(FLAG_unbox_double_fields); | 61 DCHECK(FLAG_unbox_double_fields); |
| 64 DCHECK(IsAligned(start_offset, kPointerSize) && | 62 DCHECK(IsAligned(start_offset, kPointerSize) && |
| 65 IsAligned(end_offset, kPointerSize)); | 63 IsAligned(end_offset, kPointerSize)); |
| 66 | 64 |
| 67 LayoutDescriptorHelper helper(obj->map()); | 65 LayoutDescriptorHelper helper(obj->map()); |
| 68 DCHECK(!helper.all_fields_tagged()); | 66 DCHECK(!helper.all_fields_tagged()); |
| 69 for (int offset = start_offset; offset < end_offset;) { | 67 for (int offset = start_offset; offset < end_offset;) { |
| 70 int end_of_region_offset; | 68 int end_of_region_offset; |
| 71 if (helper.IsTagged(offset, end_offset, &end_of_region_offset)) { | 69 if (helper.IsTagged(offset, end_offset, &end_of_region_offset)) { |
| 72 IteratePointers<StaticVisitor>(heap, obj, offset, end_of_region_offset); | 70 IteratePointers<StaticVisitor>(heap, obj, offset, end_of_region_offset); |
| 73 } | 71 } |
| 74 offset = end_of_region_offset; | 72 offset = end_of_region_offset; |
| 75 } | 73 } |
| 76 } | 74 } |
| 77 } | 75 } |
| 78 | 76 |
| 79 | |
| 80 template <typename ObjectVisitor> | 77 template <typename ObjectVisitor> |
| 81 DISABLE_CFI_PERF | 78 DISABLE_CFI_PERF void BodyDescriptorBase::IteratePointers(HeapObject* obj, |
| 82 void BodyDescriptorBase::IteratePointers(HeapObject* obj, int start_offset, | 79 int start_offset, |
| 83 int end_offset, ObjectVisitor* v) { | 80 int end_offset, |
| 81 ObjectVisitor* v) { |
| 84 v->VisitPointers(HeapObject::RawField(obj, start_offset), | 82 v->VisitPointers(HeapObject::RawField(obj, start_offset), |
| 85 HeapObject::RawField(obj, end_offset)); | 83 HeapObject::RawField(obj, end_offset)); |
| 86 } | 84 } |
| 87 | 85 |
| 88 | |
| 89 template <typename StaticVisitor> | 86 template <typename StaticVisitor> |
| 90 DISABLE_CFI_PERF | 87 DISABLE_CFI_PERF void BodyDescriptorBase::IteratePointers(Heap* heap, |
| 91 void BodyDescriptorBase::IteratePointers(Heap* heap, HeapObject* obj, | 88 HeapObject* obj, |
| 92 int start_offset, int end_offset) { | 89 int start_offset, |
| 90 int end_offset) { |
| 93 StaticVisitor::VisitPointers(heap, obj, | 91 StaticVisitor::VisitPointers(heap, obj, |
| 94 HeapObject::RawField(obj, start_offset), | 92 HeapObject::RawField(obj, start_offset), |
| 95 HeapObject::RawField(obj, end_offset)); | 93 HeapObject::RawField(obj, end_offset)); |
| 96 } | 94 } |
| 97 | 95 |
| 98 | |
| 99 template <typename ObjectVisitor> | 96 template <typename ObjectVisitor> |
| 100 void BodyDescriptorBase::IteratePointer(HeapObject* obj, int offset, | 97 void BodyDescriptorBase::IteratePointer(HeapObject* obj, int offset, |
| 101 ObjectVisitor* v) { | 98 ObjectVisitor* v) { |
| 102 v->VisitPointer(HeapObject::RawField(obj, offset)); | 99 v->VisitPointer(HeapObject::RawField(obj, offset)); |
| 103 } | 100 } |
| 104 | 101 |
| 105 | |
| 106 template <typename StaticVisitor> | 102 template <typename StaticVisitor> |
| 107 void BodyDescriptorBase::IteratePointer(Heap* heap, HeapObject* obj, | 103 void BodyDescriptorBase::IteratePointer(Heap* heap, HeapObject* obj, |
| 108 int offset) { | 104 int offset) { |
| 109 StaticVisitor::VisitPointer(heap, obj, HeapObject::RawField(obj, offset)); | 105 StaticVisitor::VisitPointer(heap, obj, HeapObject::RawField(obj, offset)); |
| 110 } | 106 } |
| 111 | 107 |
| 108 class JSObject::BodyDescriptor final : public BodyDescriptorBase { |
| 109 public: |
| 110 static const int kStartOffset = JSReceiver::kPropertiesOffset; |
| 111 |
| 112 static bool IsValidSlot(HeapObject* obj, int offset) { |
| 113 if (offset < kStartOffset) return false; |
| 114 return IsValidSlotImpl(obj, offset); |
| 115 } |
| 116 |
| 117 template <typename ObjectVisitor> |
| 118 static inline void IterateBody(HeapObject* obj, int object_size, |
| 119 ObjectVisitor* v) { |
| 120 IterateBodyImpl(obj, kStartOffset, object_size, v); |
| 121 } |
| 122 |
| 123 template <typename StaticVisitor> |
| 124 static inline void IterateBody(HeapObject* obj, int object_size) { |
| 125 Heap* heap = obj->GetHeap(); |
| 126 IterateBodyImpl<StaticVisitor>(heap, obj, kStartOffset, object_size); |
| 127 } |
| 128 |
| 129 static inline int SizeOf(Map* map, HeapObject* object) { |
| 130 return map->instance_size(); |
| 131 } |
| 132 }; |
| 112 | 133 |
| 113 // Iterates the function object according to the visiting policy. | 134 // Iterates the function object according to the visiting policy. |
| 114 template <JSFunction::BodyVisitingPolicy body_visiting_policy> | 135 template <JSFunction::BodyVisitingPolicy body_visiting_policy> |
| 115 class JSFunction::BodyDescriptorImpl final : public BodyDescriptorBase { | 136 class JSFunction::BodyDescriptorImpl final : public BodyDescriptorBase { |
| 116 public: | 137 public: |
| 117 STATIC_ASSERT(kNonWeakFieldsEndOffset == kCodeEntryOffset); | 138 STATIC_ASSERT(kNonWeakFieldsEndOffset == kCodeEntryOffset); |
| 118 STATIC_ASSERT(kCodeEntryOffset + kPointerSize == kNextFunctionLinkOffset); | 139 STATIC_ASSERT(kCodeEntryOffset + kPointerSize == kNextFunctionLinkOffset); |
| 119 STATIC_ASSERT(kNextFunctionLinkOffset + kPointerSize == kSize); | 140 STATIC_ASSERT(kNextFunctionLinkOffset + kPointerSize == kSize); |
| 120 | 141 |
| 121 static bool IsValidSlot(HeapObject* obj, int offset) { | 142 static bool IsValidSlot(HeapObject* obj, int offset) { |
| (...skipping 31 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 153 IteratePointers<StaticVisitor>(heap, obj, kNextFunctionLinkOffset, kSize); | 174 IteratePointers<StaticVisitor>(heap, obj, kNextFunctionLinkOffset, kSize); |
| 154 } | 175 } |
| 155 IterateBodyImpl<StaticVisitor>(heap, obj, kSize, object_size); | 176 IterateBodyImpl<StaticVisitor>(heap, obj, kSize, object_size); |
| 156 } | 177 } |
| 157 | 178 |
| 158 static inline int SizeOf(Map* map, HeapObject* object) { | 179 static inline int SizeOf(Map* map, HeapObject* object) { |
| 159 return map->instance_size(); | 180 return map->instance_size(); |
| 160 } | 181 } |
| 161 }; | 182 }; |
| 162 | 183 |
| 163 | |
| 164 class JSArrayBuffer::BodyDescriptor final : public BodyDescriptorBase { | 184 class JSArrayBuffer::BodyDescriptor final : public BodyDescriptorBase { |
| 165 public: | 185 public: |
| 166 STATIC_ASSERT(kByteLengthOffset + kPointerSize == kBackingStoreOffset); | 186 STATIC_ASSERT(kByteLengthOffset + kPointerSize == kBackingStoreOffset); |
| 167 STATIC_ASSERT(kBackingStoreOffset + kPointerSize == kBitFieldSlot); | 187 STATIC_ASSERT(kBackingStoreOffset + kPointerSize == kBitFieldSlot); |
| 168 STATIC_ASSERT(kBitFieldSlot + kPointerSize == kSize); | 188 STATIC_ASSERT(kBitFieldSlot + kPointerSize == kSize); |
| 169 | 189 |
| 170 static bool IsValidSlot(HeapObject* obj, int offset) { | 190 static bool IsValidSlot(HeapObject* obj, int offset) { |
| 171 if (offset < kBackingStoreOffset) return true; | 191 if (offset < kBackingStoreOffset) return true; |
| 172 if (offset < kSize) return false; | 192 if (offset < kSize) return false; |
| 173 return IsValidSlotImpl(obj, offset); | 193 return IsValidSlotImpl(obj, offset); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 186 IteratePointers<StaticVisitor>(heap, obj, kPropertiesOffset, | 206 IteratePointers<StaticVisitor>(heap, obj, kPropertiesOffset, |
| 187 kBackingStoreOffset); | 207 kBackingStoreOffset); |
| 188 IterateBodyImpl<StaticVisitor>(heap, obj, kSize, object_size); | 208 IterateBodyImpl<StaticVisitor>(heap, obj, kSize, object_size); |
| 189 } | 209 } |
| 190 | 210 |
| 191 static inline int SizeOf(Map* map, HeapObject* object) { | 211 static inline int SizeOf(Map* map, HeapObject* object) { |
| 192 return map->instance_size(); | 212 return map->instance_size(); |
| 193 } | 213 } |
| 194 }; | 214 }; |
| 195 | 215 |
| 196 | |
| 197 class BytecodeArray::BodyDescriptor final : public BodyDescriptorBase { | 216 class BytecodeArray::BodyDescriptor final : public BodyDescriptorBase { |
| 198 public: | 217 public: |
| 199 static bool IsValidSlot(HeapObject* obj, int offset) { | 218 static bool IsValidSlot(HeapObject* obj, int offset) { |
| 200 return offset >= kConstantPoolOffset && | 219 return offset >= kConstantPoolOffset && |
| 201 offset <= kSourcePositionTableOffset; | 220 offset <= kSourcePositionTableOffset; |
| 202 } | 221 } |
| 203 | 222 |
| 204 template <typename ObjectVisitor> | 223 template <typename ObjectVisitor> |
| 205 static inline void IterateBody(HeapObject* obj, int object_size, | 224 static inline void IterateBody(HeapObject* obj, int object_size, |
| 206 ObjectVisitor* v) { | 225 ObjectVisitor* v) { |
| 207 IteratePointer(obj, kConstantPoolOffset, v); | 226 IteratePointer(obj, kConstantPoolOffset, v); |
| 208 IteratePointer(obj, kHandlerTableOffset, v); | 227 IteratePointer(obj, kHandlerTableOffset, v); |
| 209 IteratePointer(obj, kSourcePositionTableOffset, v); | 228 IteratePointer(obj, kSourcePositionTableOffset, v); |
| 210 } | 229 } |
| 211 | 230 |
| 212 template <typename StaticVisitor> | 231 template <typename StaticVisitor> |
| 213 static inline void IterateBody(HeapObject* obj, int object_size) { | 232 static inline void IterateBody(HeapObject* obj, int object_size) { |
| 214 Heap* heap = obj->GetHeap(); | 233 Heap* heap = obj->GetHeap(); |
| 215 IteratePointer<StaticVisitor>(heap, obj, kConstantPoolOffset); | 234 IteratePointer<StaticVisitor>(heap, obj, kConstantPoolOffset); |
| 216 IteratePointer<StaticVisitor>(heap, obj, kHandlerTableOffset); | 235 IteratePointer<StaticVisitor>(heap, obj, kHandlerTableOffset); |
| 217 IteratePointer<StaticVisitor>(heap, obj, kSourcePositionTableOffset); | 236 IteratePointer<StaticVisitor>(heap, obj, kSourcePositionTableOffset); |
| 218 } | 237 } |
| 219 | 238 |
| 220 static inline int SizeOf(Map* map, HeapObject* obj) { | 239 static inline int SizeOf(Map* map, HeapObject* obj) { |
| 221 return reinterpret_cast<BytecodeArray*>(obj)->BytecodeArraySize(); | 240 return reinterpret_cast<BytecodeArray*>(obj)->BytecodeArraySize(); |
| 222 } | 241 } |
| 223 }; | 242 }; |
| 224 | 243 |
| 225 | |
| 226 class FixedTypedArrayBase::BodyDescriptor final : public BodyDescriptorBase { | 244 class FixedTypedArrayBase::BodyDescriptor final : public BodyDescriptorBase { |
| 227 public: | 245 public: |
| 228 static bool IsValidSlot(HeapObject* obj, int offset) { | 246 static bool IsValidSlot(HeapObject* obj, int offset) { |
| 229 return offset == kBasePointerOffset; | 247 return offset == kBasePointerOffset; |
| 230 } | 248 } |
| 231 | 249 |
| 232 template <typename ObjectVisitor> | 250 template <typename ObjectVisitor> |
| 233 static inline void IterateBody(HeapObject* obj, int object_size, | 251 static inline void IterateBody(HeapObject* obj, int object_size, |
| 234 ObjectVisitor* v) { | 252 ObjectVisitor* v) { |
| 235 IteratePointer(obj, kBasePointerOffset, v); | 253 IteratePointer(obj, kBasePointerOffset, v); |
| 236 } | 254 } |
| 237 | 255 |
| 238 template <typename StaticVisitor> | 256 template <typename StaticVisitor> |
| 239 static inline void IterateBody(HeapObject* obj, int object_size) { | 257 static inline void IterateBody(HeapObject* obj, int object_size) { |
| 240 Heap* heap = obj->GetHeap(); | 258 Heap* heap = obj->GetHeap(); |
| 241 IteratePointer<StaticVisitor>(heap, obj, kBasePointerOffset); | 259 IteratePointer<StaticVisitor>(heap, obj, kBasePointerOffset); |
| 242 } | 260 } |
| 243 | 261 |
| 244 static inline int SizeOf(Map* map, HeapObject* object) { | 262 static inline int SizeOf(Map* map, HeapObject* object) { |
| 245 return reinterpret_cast<FixedTypedArrayBase*>(object)->size(); | 263 return reinterpret_cast<FixedTypedArrayBase*>(object)->size(); |
| 246 } | 264 } |
| 247 }; | 265 }; |
| 248 | 266 |
| 249 | |
| 250 template <JSWeakCollection::BodyVisitingPolicy body_visiting_policy> | 267 template <JSWeakCollection::BodyVisitingPolicy body_visiting_policy> |
| 251 class JSWeakCollection::BodyDescriptorImpl final : public BodyDescriptorBase { | 268 class JSWeakCollection::BodyDescriptorImpl final : public BodyDescriptorBase { |
| 252 public: | 269 public: |
| 253 STATIC_ASSERT(kTableOffset + kPointerSize == kNextOffset); | 270 STATIC_ASSERT(kTableOffset + kPointerSize == kNextOffset); |
| 254 STATIC_ASSERT(kNextOffset + kPointerSize == kSize); | 271 STATIC_ASSERT(kNextOffset + kPointerSize == kSize); |
| 255 | 272 |
| 256 static bool IsValidSlot(HeapObject* obj, int offset) { | 273 static bool IsValidSlot(HeapObject* obj, int offset) { |
| 257 return IsValidSlotImpl(obj, offset); | 274 return IsValidSlotImpl(obj, offset); |
| 258 } | 275 } |
| 259 | 276 |
| (...skipping 18 matching lines...) Expand all Loading... |
| 278 kTableOffset); | 295 kTableOffset); |
| 279 IterateBodyImpl<StaticVisitor>(heap, obj, kSize, object_size); | 296 IterateBodyImpl<StaticVisitor>(heap, obj, kSize, object_size); |
| 280 } | 297 } |
| 281 } | 298 } |
| 282 | 299 |
| 283 static inline int SizeOf(Map* map, HeapObject* object) { | 300 static inline int SizeOf(Map* map, HeapObject* object) { |
| 284 return map->instance_size(); | 301 return map->instance_size(); |
| 285 } | 302 } |
| 286 }; | 303 }; |
| 287 | 304 |
| 288 | |
| 289 class Foreign::BodyDescriptor final : public BodyDescriptorBase { | 305 class Foreign::BodyDescriptor final : public BodyDescriptorBase { |
| 290 public: | 306 public: |
| 291 static bool IsValidSlot(HeapObject* obj, int offset) { return false; } | 307 static bool IsValidSlot(HeapObject* obj, int offset) { return false; } |
| 292 | 308 |
| 293 template <typename ObjectVisitor> | 309 template <typename ObjectVisitor> |
| 294 static inline void IterateBody(HeapObject* obj, int object_size, | 310 static inline void IterateBody(HeapObject* obj, int object_size, |
| 295 ObjectVisitor* v) { | 311 ObjectVisitor* v) { |
| 296 v->VisitExternalReference(reinterpret_cast<Address*>( | 312 v->VisitExternalReference(reinterpret_cast<Address*>( |
| 297 HeapObject::RawField(obj, kForeignAddressOffset))); | 313 HeapObject::RawField(obj, kForeignAddressOffset))); |
| 298 } | 314 } |
| 299 | 315 |
| 300 template <typename StaticVisitor> | 316 template <typename StaticVisitor> |
| 301 static inline void IterateBody(HeapObject* obj, int object_size) { | 317 static inline void IterateBody(HeapObject* obj, int object_size) { |
| 302 StaticVisitor::VisitExternalReference(reinterpret_cast<Address*>( | 318 StaticVisitor::VisitExternalReference(reinterpret_cast<Address*>( |
| 303 HeapObject::RawField(obj, kForeignAddressOffset))); | 319 HeapObject::RawField(obj, kForeignAddressOffset))); |
| 304 } | 320 } |
| 305 | 321 |
| 306 static inline int SizeOf(Map* map, HeapObject* object) { return kSize; } | 322 static inline int SizeOf(Map* map, HeapObject* object) { return kSize; } |
| 307 }; | 323 }; |
| 308 | 324 |
| 309 | |
| 310 class ExternalOneByteString::BodyDescriptor final : public BodyDescriptorBase { | 325 class ExternalOneByteString::BodyDescriptor final : public BodyDescriptorBase { |
| 311 public: | 326 public: |
| 312 static bool IsValidSlot(HeapObject* obj, int offset) { return false; } | 327 static bool IsValidSlot(HeapObject* obj, int offset) { return false; } |
| 313 | 328 |
| 314 template <typename ObjectVisitor> | 329 template <typename ObjectVisitor> |
| 315 static inline void IterateBody(HeapObject* obj, int object_size, | 330 static inline void IterateBody(HeapObject* obj, int object_size, |
| 316 ObjectVisitor* v) { | 331 ObjectVisitor* v) { |
| 317 typedef v8::String::ExternalOneByteStringResource Resource; | 332 typedef v8::String::ExternalOneByteStringResource Resource; |
| 318 v->VisitExternalOneByteString(reinterpret_cast<Resource**>( | 333 v->VisitExternalOneByteString(reinterpret_cast<Resource**>( |
| 319 HeapObject::RawField(obj, kResourceOffset))); | 334 HeapObject::RawField(obj, kResourceOffset))); |
| 320 } | 335 } |
| 321 | 336 |
| 322 template <typename StaticVisitor> | 337 template <typename StaticVisitor> |
| 323 static inline void IterateBody(HeapObject* obj, int object_size) { | 338 static inline void IterateBody(HeapObject* obj, int object_size) { |
| 324 typedef v8::String::ExternalOneByteStringResource Resource; | 339 typedef v8::String::ExternalOneByteStringResource Resource; |
| 325 StaticVisitor::VisitExternalOneByteString(reinterpret_cast<Resource**>( | 340 StaticVisitor::VisitExternalOneByteString(reinterpret_cast<Resource**>( |
| 326 HeapObject::RawField(obj, kResourceOffset))); | 341 HeapObject::RawField(obj, kResourceOffset))); |
| 327 } | 342 } |
| 328 | 343 |
| 329 static inline int SizeOf(Map* map, HeapObject* object) { return kSize; } | 344 static inline int SizeOf(Map* map, HeapObject* object) { return kSize; } |
| 330 }; | 345 }; |
| 331 | 346 |
| 332 | |
| 333 class ExternalTwoByteString::BodyDescriptor final : public BodyDescriptorBase { | 347 class ExternalTwoByteString::BodyDescriptor final : public BodyDescriptorBase { |
| 334 public: | 348 public: |
| 335 static bool IsValidSlot(HeapObject* obj, int offset) { return false; } | 349 static bool IsValidSlot(HeapObject* obj, int offset) { return false; } |
| 336 | 350 |
| 337 template <typename ObjectVisitor> | 351 template <typename ObjectVisitor> |
| 338 static inline void IterateBody(HeapObject* obj, int object_size, | 352 static inline void IterateBody(HeapObject* obj, int object_size, |
| 339 ObjectVisitor* v) { | 353 ObjectVisitor* v) { |
| 340 typedef v8::String::ExternalStringResource Resource; | 354 typedef v8::String::ExternalStringResource Resource; |
| 341 v->VisitExternalTwoByteString(reinterpret_cast<Resource**>( | 355 v->VisitExternalTwoByteString(reinterpret_cast<Resource**>( |
| 342 HeapObject::RawField(obj, kResourceOffset))); | 356 HeapObject::RawField(obj, kResourceOffset))); |
| 343 } | 357 } |
| 344 | 358 |
| 345 template <typename StaticVisitor> | 359 template <typename StaticVisitor> |
| 346 static inline void IterateBody(HeapObject* obj, int object_size) { | 360 static inline void IterateBody(HeapObject* obj, int object_size) { |
| 347 typedef v8::String::ExternalStringResource Resource; | 361 typedef v8::String::ExternalStringResource Resource; |
| 348 StaticVisitor::VisitExternalTwoByteString(reinterpret_cast<Resource**>( | 362 StaticVisitor::VisitExternalTwoByteString(reinterpret_cast<Resource**>( |
| 349 HeapObject::RawField(obj, kResourceOffset))); | 363 HeapObject::RawField(obj, kResourceOffset))); |
| 350 } | 364 } |
| 351 | 365 |
| 352 static inline int SizeOf(Map* map, HeapObject* object) { return kSize; } | 366 static inline int SizeOf(Map* map, HeapObject* object) { return kSize; } |
| 353 }; | 367 }; |
| 354 | 368 |
| 355 | |
| 356 class Code::BodyDescriptor final : public BodyDescriptorBase { | 369 class Code::BodyDescriptor final : public BodyDescriptorBase { |
| 357 public: | 370 public: |
| 358 STATIC_ASSERT(kRelocationInfoOffset + kPointerSize == kHandlerTableOffset); | 371 STATIC_ASSERT(kRelocationInfoOffset + kPointerSize == kHandlerTableOffset); |
| 359 STATIC_ASSERT(kHandlerTableOffset + kPointerSize == | 372 STATIC_ASSERT(kHandlerTableOffset + kPointerSize == |
| 360 kDeoptimizationDataOffset); | 373 kDeoptimizationDataOffset); |
| 361 STATIC_ASSERT(kDeoptimizationDataOffset + kPointerSize == | 374 STATIC_ASSERT(kDeoptimizationDataOffset + kPointerSize == |
| 362 kSourcePositionTableOffset); | 375 kSourcePositionTableOffset); |
| 363 STATIC_ASSERT(kSourcePositionTableOffset + kPointerSize == | 376 STATIC_ASSERT(kSourcePositionTableOffset + kPointerSize == |
| 364 kTypeFeedbackInfoOffset); | 377 kTypeFeedbackInfoOffset); |
| 365 STATIC_ASSERT(kTypeFeedbackInfoOffset + kPointerSize == | 378 STATIC_ASSERT(kTypeFeedbackInfoOffset + kPointerSize == |
| (...skipping 246 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 612 | 625 |
| 613 template <typename ObjectVisitor> | 626 template <typename ObjectVisitor> |
| 614 void HeapObject::IterateBodyFast(InstanceType type, int object_size, | 627 void HeapObject::IterateBodyFast(InstanceType type, int object_size, |
| 615 ObjectVisitor* v) { | 628 ObjectVisitor* v) { |
| 616 BodyDescriptorApply<CallIterateBody, void>(type, this, object_size, v); | 629 BodyDescriptorApply<CallIterateBody, void>(type, this, object_size, v); |
| 617 } | 630 } |
| 618 } // namespace internal | 631 } // namespace internal |
| 619 } // namespace v8 | 632 } // namespace v8 |
| 620 | 633 |
| 621 #endif // V8_OBJECTS_BODY_DESCRIPTORS_INL_H_ | 634 #endif // V8_OBJECTS_BODY_DESCRIPTORS_INL_H_ |
| OLD | NEW |