Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(153)

Side by Side Diff: runtime/vm/raw_object.h

Issue 2962543002: Revert "VM: Reland Inline instance object hash code into object header on 64bit." (Closed)
Patch Set: Created 3 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « runtime/vm/profiler.cc ('k') | runtime/vm/raw_object.cc » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file 1 // Copyright (c) 2012, the Dart project authors. Please see the AUTHORS file
2 // for details. All rights reserved. Use of this source code is governed by a 2 // for details. All rights reserved. Use of this source code is governed by a
3 // BSD-style license that can be found in the LICENSE file. 3 // BSD-style license that can be found in the LICENSE file.
4 4
5 #ifndef RUNTIME_VM_RAW_OBJECT_H_ 5 #ifndef RUNTIME_VM_RAW_OBJECT_H_
6 #define RUNTIME_VM_RAW_OBJECT_H_ 6 #define RUNTIME_VM_RAW_OBJECT_H_
7 7
8 #include "platform/assert.h" 8 #include "platform/assert.h"
9 #include "vm/atomic.h" 9 #include "vm/atomic.h"
10 #include "vm/exceptions.h" 10 #include "vm/exceptions.h"
(...skipping 253 matching lines...) Expand 10 before | Expand all | Expand 10 after
264 kMarkBit = 0, 264 kMarkBit = 0,
265 kCanonicalBit = 1, 265 kCanonicalBit = 1,
266 kVMHeapObjectBit = 2, 266 kVMHeapObjectBit = 2,
267 kRememberedBit = 3, 267 kRememberedBit = 3,
268 kReservedTagPos = 4, // kReservedBit{100K,1M,10M} 268 kReservedTagPos = 4, // kReservedBit{100K,1M,10M}
269 kReservedTagSize = 4, 269 kReservedTagSize = 4,
270 kSizeTagPos = kReservedTagPos + kReservedTagSize, // = 8 270 kSizeTagPos = kReservedTagPos + kReservedTagSize, // = 8
271 kSizeTagSize = 8, 271 kSizeTagSize = 8,
272 kClassIdTagPos = kSizeTagPos + kSizeTagSize, // = 16 272 kClassIdTagPos = kSizeTagPos + kSizeTagSize, // = 16
273 kClassIdTagSize = 16, 273 kClassIdTagSize = 16,
274 #if defined(HASH_IN_OBJECT_HEADER)
275 kHashTagPos = kClassIdTagPos + kClassIdTagSize, // = 32
276 kHashTagSize = 16,
277 #endif
278 }; 274 };
279 275
280 COMPILE_ASSERT(kClassIdTagSize == (sizeof(classid_t) * kBitsPerByte)); 276 COMPILE_ASSERT(kClassIdTagSize == (sizeof(classid_t) * kBitsPerByte));
281 277
282 // Encodes the object size in the tag in units of object alignment. 278 // Encodes the object size in the tag in units of object alignment.
283 class SizeTag { 279 class SizeTag {
284 public: 280 public:
285 static const intptr_t kMaxSizeTag = ((1 << RawObject::kSizeTagSize) - 1) 281 static const intptr_t kMaxSizeTag = ((1 << RawObject::kSizeTagSize) - 1)
286 << kObjectAlignmentLog2; 282 << kObjectAlignmentLog2;
287 283
288 static uword encode(intptr_t size) { 284 static uword encode(intptr_t size) {
289 return SizeBits::encode(SizeToTagValue(size)); 285 return SizeBits::encode(SizeToTagValue(size));
290 } 286 }
291 287
292 static intptr_t decode(uword tag) { 288 static intptr_t decode(uword tag) {
293 return TagValueToSize(SizeBits::decode(tag)); 289 return TagValueToSize(SizeBits::decode(tag));
294 } 290 }
295 291
296 static uword update(intptr_t size, uword tag) { 292 static uword update(intptr_t size, uword tag) {
297 return SizeBits::update(SizeToTagValue(size), tag); 293 return SizeBits::update(SizeToTagValue(size), tag);
298 } 294 }
299 295
300 private: 296 private:
301 // The actual unscaled bit field used within the tag field. 297 // The actual unscaled bit field used within the tag field.
302 class SizeBits 298 class SizeBits
303 : public BitField<uint32_t, intptr_t, kSizeTagPos, kSizeTagSize> {}; 299 : public BitField<uword, intptr_t, kSizeTagPos, kSizeTagSize> {};
304 300
305 static intptr_t SizeToTagValue(intptr_t size) { 301 static intptr_t SizeToTagValue(intptr_t size) {
306 ASSERT(Utils::IsAligned(size, kObjectAlignment)); 302 ASSERT(Utils::IsAligned(size, kObjectAlignment));
307 return (size > kMaxSizeTag) ? 0 : (size >> kObjectAlignmentLog2); 303 return (size > kMaxSizeTag) ? 0 : (size >> kObjectAlignmentLog2);
308 } 304 }
309 static intptr_t TagValueToSize(intptr_t value) { 305 static intptr_t TagValueToSize(intptr_t value) {
310 return value << kObjectAlignmentLog2; 306 return value << kObjectAlignmentLog2;
311 } 307 }
312 }; 308 };
313 309
314 class ClassIdTag 310 class ClassIdTag
315 : public BitField<uint32_t, intptr_t, kClassIdTagPos, kClassIdTagSize> {}; 311 : public BitField<uword, intptr_t, kClassIdTagPos, kClassIdTagSize> {};
316 312
317 bool IsWellFormed() const { 313 bool IsWellFormed() const {
318 uword value = reinterpret_cast<uword>(this); 314 uword value = reinterpret_cast<uword>(this);
319 return (value & kSmiTagMask) == 0 || 315 return (value & kSmiTagMask) == 0 ||
320 Utils::IsAligned(value - kHeapObjectTag, kWordSize); 316 Utils::IsAligned(value - kHeapObjectTag, kWordSize);
321 } 317 }
322 bool IsHeapObject() const { 318 bool IsHeapObject() const {
323 ASSERT(IsWellFormed()); 319 ASSERT(IsWellFormed());
324 uword value = reinterpret_cast<uword>(this); 320 uword value = reinterpret_cast<uword>(this);
325 return (value & kSmiTagMask) == kHeapObjectTag; 321 return (value & kSmiTagMask) == kHeapObjectTag;
(...skipping 23 matching lines...) Expand all
349 } 345 }
350 346
351 // Support for GC marking bit. 347 // Support for GC marking bit.
352 bool IsMarked() const { return MarkBit::decode(ptr()->tags_); } 348 bool IsMarked() const { return MarkBit::decode(ptr()->tags_); }
353 void SetMarkBit() { 349 void SetMarkBit() {
354 ASSERT(!IsMarked()); 350 ASSERT(!IsMarked());
355 UpdateTagBit<MarkBit>(true); 351 UpdateTagBit<MarkBit>(true);
356 } 352 }
357 void SetMarkBitUnsynchronized() { 353 void SetMarkBitUnsynchronized() {
358 ASSERT(!IsMarked()); 354 ASSERT(!IsMarked());
359 uint32_t tags = ptr()->tags_; 355 uword tags = ptr()->tags_;
360 ptr()->tags_ = MarkBit::update(true, tags); 356 ptr()->tags_ = MarkBit::update(true, tags);
361 } 357 }
362 void ClearMarkBit() { 358 void ClearMarkBit() {
363 ASSERT(IsMarked()); 359 ASSERT(IsMarked());
364 UpdateTagBit<MarkBit>(false); 360 UpdateTagBit<MarkBit>(false);
365 } 361 }
366 // Returns false if the bit was already set. 362 // Returns false if the bit was already set.
367 // TODO(koda): Add "must use result" annotation here, after we add support. 363 // TODO(koda): Add "must use result" annotation here, after we add support.
368 bool TryAcquireMarkBit() { return TryAcquireTagBit<MarkBit>(); } 364 bool TryAcquireMarkBit() { return TryAcquireTagBit<MarkBit>(); }
369 365
370 // Support for object tags. 366 // Support for object tags.
371 bool IsCanonical() const { return CanonicalObjectTag::decode(ptr()->tags_); } 367 bool IsCanonical() const { return CanonicalObjectTag::decode(ptr()->tags_); }
372 void SetCanonical() { UpdateTagBit<CanonicalObjectTag>(true); } 368 void SetCanonical() { UpdateTagBit<CanonicalObjectTag>(true); }
373 void ClearCanonical() { UpdateTagBit<CanonicalObjectTag>(false); } 369 void ClearCanonical() { UpdateTagBit<CanonicalObjectTag>(false); }
374 bool IsVMHeapObject() const { return VMHeapObjectTag::decode(ptr()->tags_); } 370 bool IsVMHeapObject() const { return VMHeapObjectTag::decode(ptr()->tags_); }
375 void SetVMHeapObject() { UpdateTagBit<VMHeapObjectTag>(true); } 371 void SetVMHeapObject() { UpdateTagBit<VMHeapObjectTag>(true); }
376 372
377 // Support for GC remembered bit. 373 // Support for GC remembered bit.
378 bool IsRemembered() const { return RememberedBit::decode(ptr()->tags_); } 374 bool IsRemembered() const { return RememberedBit::decode(ptr()->tags_); }
379 void SetRememberedBit() { 375 void SetRememberedBit() {
380 ASSERT(!IsRemembered()); 376 ASSERT(!IsRemembered());
381 UpdateTagBit<RememberedBit>(true); 377 UpdateTagBit<RememberedBit>(true);
382 } 378 }
383 void SetRememberedBitUnsynchronized() { 379 void SetRememberedBitUnsynchronized() {
384 ASSERT(!IsRemembered()); 380 ASSERT(!IsRemembered());
385 uint32_t tags = ptr()->tags_; 381 uword tags = ptr()->tags_;
386 ptr()->tags_ = RememberedBit::update(true, tags); 382 ptr()->tags_ = RememberedBit::update(true, tags);
387 } 383 }
388 void ClearRememberedBit() { UpdateTagBit<RememberedBit>(false); } 384 void ClearRememberedBit() { UpdateTagBit<RememberedBit>(false); }
389 void ClearRememberedBitUnsynchronized() { 385 void ClearRememberedBitUnsynchronized() {
390 uint32_t tags = ptr()->tags_; 386 uword tags = ptr()->tags_;
391 ptr()->tags_ = RememberedBit::update(false, tags); 387 ptr()->tags_ = RememberedBit::update(false, tags);
392 } 388 }
393 // Returns false if the bit was already set. 389 // Returns false if the bit was already set.
394 // TODO(koda): Add "must use result" annotation here, after we add support. 390 // TODO(koda): Add "must use result" annotation here, after we add support.
395 bool TryAcquireRememberedBit() { return TryAcquireTagBit<RememberedBit>(); } 391 bool TryAcquireRememberedBit() { return TryAcquireTagBit<RememberedBit>(); }
396 392
397 #define DEFINE_IS_CID(clazz) \ 393 #define DEFINE_IS_CID(clazz) \
398 bool Is##clazz() const { return ((GetClassId() == k##clazz##Cid)); } 394 bool Is##clazz() const { return ((GetClassId() == k##clazz##Cid)); }
399 CLASS_LIST(DEFINE_IS_CID) 395 CLASS_LIST(DEFINE_IS_CID)
400 #undef DEFINE_IS_CID 396 #undef DEFINE_IS_CID
401 397
402 #define DEFINE_IS_CID(clazz) \ 398 #define DEFINE_IS_CID(clazz) \
403 bool IsTypedData##clazz() const { \ 399 bool IsTypedData##clazz() const { \
404 return ((GetClassId() == kTypedData##clazz##Cid)); \ 400 return ((GetClassId() == kTypedData##clazz##Cid)); \
405 } \ 401 } \
406 bool IsTypedDataView##clazz() const { \ 402 bool IsTypedDataView##clazz() const { \
407 return ((GetClassId() == kTypedData##clazz##ViewCid)); \ 403 return ((GetClassId() == kTypedData##clazz##ViewCid)); \
408 } \ 404 } \
409 bool IsExternalTypedData##clazz() const { \ 405 bool IsExternalTypedData##clazz() const { \
410 return ((GetClassId() == kExternalTypedData##clazz##Cid)); \ 406 return ((GetClassId() == kExternalTypedData##clazz##Cid)); \
411 } 407 }
412 CLASS_LIST_TYPED_DATA(DEFINE_IS_CID) 408 CLASS_LIST_TYPED_DATA(DEFINE_IS_CID)
413 #undef DEFINE_IS_CID 409 #undef DEFINE_IS_CID
414 410
415 bool IsStringInstance() const { return IsStringClassId(GetClassId()); } 411 bool IsStringInstance() const { return IsStringClassId(GetClassId()); }
416 bool IsRawNull() const { return GetClassId() == kNullCid; }
417 bool IsDartInstance() const { 412 bool IsDartInstance() const {
418 return (!IsHeapObject() || (GetClassId() >= kInstanceCid)); 413 return (!IsHeapObject() || (GetClassId() >= kInstanceCid));
419 } 414 }
420 bool IsFreeListElement() const { 415 bool IsFreeListElement() const {
421 return ((GetClassId() == kFreeListElement)); 416 return ((GetClassId() == kFreeListElement));
422 } 417 }
423 bool IsForwardingCorpse() const { 418 bool IsForwardingCorpse() const {
424 return ((GetClassId() == kForwardingCorpse)); 419 return ((GetClassId() == kForwardingCorpse));
425 } 420 }
426 bool IsPseudoObject() const { 421 bool IsPseudoObject() const {
427 return IsFreeListElement() || IsForwardingCorpse(); 422 return IsFreeListElement() || IsForwardingCorpse();
428 } 423 }
429 424
430 intptr_t Size() const { 425 intptr_t Size() const {
431 uint32_t tags = ptr()->tags_; 426 uword tags = ptr()->tags_;
432 intptr_t result = SizeTag::decode(tags); 427 intptr_t result = SizeTag::decode(tags);
433 if (result != 0) { 428 if (result != 0) {
434 #if defined(DEBUG) 429 #if defined(DEBUG)
435 // TODO(22501) Array::MakeFixedLength has a race with this code: we might 430 // TODO(22501) Array::MakeFixedLength has a race with this code: we might
436 // have loaded tags field and then MakeFixedLength could have updated it 431 // have loaded tags field and then MakeFixedLength could have updated it
437 // leading to inconsistency between SizeFromClass() and 432 // leading to inconsistency between SizeFromClass() and
438 // SizeTag::decode(tags). We are working around it by reloading tags_ and 433 // SizeTag::decode(tags). We are working around it by reloading tags_ and
439 // recomputing size from tags. 434 // recomputing size from tags.
440 const intptr_t size_from_class = SizeFromClass(); 435 const intptr_t size_from_class = SizeFromClass();
441 if ((result > size_from_class) && (GetClassId() == kArrayCid) && 436 if ((result > size_from_class) && (GetClassId() == kArrayCid) &&
(...skipping 89 matching lines...) Expand 10 before | Expand all | Expand 10 after
531 static bool IsTypedDataClassId(intptr_t index); 526 static bool IsTypedDataClassId(intptr_t index);
532 static bool IsTypedDataViewClassId(intptr_t index); 527 static bool IsTypedDataViewClassId(intptr_t index);
533 static bool IsExternalTypedDataClassId(intptr_t index); 528 static bool IsExternalTypedDataClassId(intptr_t index);
534 static bool IsInternalVMdefinedClassId(intptr_t index); 529 static bool IsInternalVMdefinedClassId(intptr_t index);
535 static bool IsVariableSizeClassId(intptr_t index); 530 static bool IsVariableSizeClassId(intptr_t index);
536 static bool IsImplicitFieldClassId(intptr_t index); 531 static bool IsImplicitFieldClassId(intptr_t index);
537 532
538 static intptr_t NumberOfTypedDataClasses(); 533 static intptr_t NumberOfTypedDataClasses();
539 534
540 private: 535 private:
541 uint32_t tags_; // Various object tags (bits). 536 uword tags_; // Various object tags (bits).
542 #if defined(HASH_IN_OBJECT_HEADER)
543 // On 64 bit there is a hash field in the header for the identity hash.
544 uint32_t hash_;
545 #endif
546 537
547 class MarkBit : public BitField<uint32_t, bool, kMarkBit, 1> {}; 538 class MarkBit : public BitField<uword, bool, kMarkBit, 1> {};
548 539
549 class RememberedBit : public BitField<uint32_t, bool, kRememberedBit, 1> {}; 540 class RememberedBit : public BitField<uword, bool, kRememberedBit, 1> {};
550 541
551 class CanonicalObjectTag : public BitField<uint32_t, bool, kCanonicalBit, 1> { 542 class CanonicalObjectTag : public BitField<uword, bool, kCanonicalBit, 1> {};
552 };
553 543
554 class VMHeapObjectTag : public BitField<uint32_t, bool, kVMHeapObjectBit, 1> { 544 class VMHeapObjectTag : public BitField<uword, bool, kVMHeapObjectBit, 1> {};
555 };
556 545
557 class ReservedBits 546 class ReservedBits
558 : public BitField<uint32_t, intptr_t, kReservedTagPos, kReservedTagSize> { 547 : public BitField<uword, intptr_t, kReservedTagPos, kReservedTagSize> {};
559 };
560 548
561 // TODO(koda): After handling tags_, return const*, like Object::raw_ptr(). 549 // TODO(koda): After handling tags_, return const*, like Object::raw_ptr().
562 RawObject* ptr() const { 550 RawObject* ptr() const {
563 ASSERT(IsHeapObject()); 551 ASSERT(IsHeapObject());
564 return reinterpret_cast<RawObject*>(reinterpret_cast<uword>(this) - 552 return reinterpret_cast<RawObject*>(reinterpret_cast<uword>(this) -
565 kHeapObjectTag); 553 kHeapObjectTag);
566 } 554 }
567 555
568 intptr_t VisitPointersPredefined(ObjectPointerVisitor* visitor, 556 intptr_t VisitPointersPredefined(ObjectPointerVisitor* visitor,
569 intptr_t class_id); 557 intptr_t class_id);
570 558
571 intptr_t SizeFromClass() const; 559 intptr_t SizeFromClass() const;
572 560
573 intptr_t GetClassId() const { 561 intptr_t GetClassId() const {
574 uint32_t tags = ptr()->tags_; 562 uword tags = ptr()->tags_;
575 return ClassIdTag::decode(tags); 563 return ClassIdTag::decode(tags);
576 } 564 }
577 565
578 void SetClassId(intptr_t new_cid) { 566 void SetClassId(intptr_t new_cid) {
579 uint32_t tags = ptr()->tags_; 567 uword tags = ptr()->tags_;
580 ptr()->tags_ = ClassIdTag::update(new_cid, tags); 568 ptr()->tags_ = ClassIdTag::update(new_cid, tags);
581 } 569 }
582 570
583 template <class TagBitField> 571 template <class TagBitField>
584 void UpdateTagBit(bool value) { 572 void UpdateTagBit(bool value) {
585 uint32_t tags = ptr()->tags_; 573 uword tags = ptr()->tags_;
586 uint32_t old_tags; 574 uword old_tags;
587 do { 575 do {
588 old_tags = tags; 576 old_tags = tags;
589 uint32_t new_tags = TagBitField::update(value, old_tags); 577 uword new_tags = TagBitField::update(value, old_tags);
590 tags = AtomicOperations::CompareAndSwapUint32(&ptr()->tags_, old_tags, 578 tags = AtomicOperations::CompareAndSwapWord(&ptr()->tags_, old_tags,
591 new_tags); 579 new_tags);
592 } while (tags != old_tags); 580 } while (tags != old_tags);
593 } 581 }
594 582
595 template <class TagBitField> 583 template <class TagBitField>
596 bool TryAcquireTagBit() { 584 bool TryAcquireTagBit() {
597 uint32_t tags = ptr()->tags_; 585 uword tags = ptr()->tags_;
598 uint32_t old_tags; 586 uword old_tags;
599 do { 587 do {
600 old_tags = tags; 588 old_tags = tags;
601 if (TagBitField::decode(tags)) return false; 589 if (TagBitField::decode(tags)) return false;
602 uint32_t new_tags = TagBitField::update(true, old_tags); 590 uword new_tags = TagBitField::update(true, old_tags);
603 tags = AtomicOperations::CompareAndSwapUint32(&ptr()->tags_, old_tags, 591 tags = AtomicOperations::CompareAndSwapWord(&ptr()->tags_, old_tags,
604 new_tags); 592 new_tags);
605 } while (tags != old_tags); 593 } while (tags != old_tags);
606 return true; 594 return true;
607 } 595 }
608 596
609 // All writes to heap objects should ultimately pass through one of the 597 // All writes to heap objects should ultimately pass through one of the
610 // methods below or their counterparts in Object, to ensure that the 598 // methods below or their counterparts in Object, to ensure that the
611 // write barrier is correctly applied. 599 // write barrier is correctly applied.
612 600
613 template <typename type> 601 template <typename type>
614 void StorePointer(type const* addr, type value) { 602 void StorePointer(type const* addr, type value) {
(...skipping 708 matching lines...) Expand 10 before | Expand all | Expand 10 after
1323 // Is kKindShiftSize enough bits? 1311 // Is kKindShiftSize enough bits?
1324 COMPILE_ASSERT(kLastKind <= 1 << ((1 << kKindShiftSize) - 1)); 1312 COMPILE_ASSERT(kLastKind <= 1 << ((1 << kKindShiftSize) - 1));
1325 1313
1326 static const intptr_t kTryIndexPos = kKindShiftSize; 1314 static const intptr_t kTryIndexPos = kKindShiftSize;
1327 static const intptr_t kTryIndexSize = kBitsPerWord - kKindShiftSize; 1315 static const intptr_t kTryIndexSize = kBitsPerWord - kKindShiftSize;
1328 }; 1316 };
1329 1317
1330 private: 1318 private:
1331 RAW_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors); 1319 RAW_HEAP_OBJECT_IMPLEMENTATION(PcDescriptors);
1332 1320
1333 // Number of descriptors. This only needs to be an int32_t, but we make it a 1321 int32_t length_; // Number of descriptors.
1334 // uword so that the variable length data is 64 bit aligned on 64 bit
1335 // platforms.
1336 uword length_;
1337 1322
1338 // Variable length data follows here. 1323 // Variable length data follows here.
1339 uint8_t* data() { OPEN_ARRAY_START(uint8_t, intptr_t); } 1324 uint8_t* data() { OPEN_ARRAY_START(uint8_t, intptr_t); }
1340 const uint8_t* data() const { OPEN_ARRAY_START(uint8_t, intptr_t); } 1325 const uint8_t* data() const { OPEN_ARRAY_START(uint8_t, intptr_t); }
1341 1326
1342 friend class Object; 1327 friend class Object;
1343 }; 1328 };
1344 1329
1345 1330
1346 // CodeSourceMap encodes a mapping from code PC ranges to source token 1331 // CodeSourceMap encodes a mapping from code PC ranges to source token
1347 // positions and the stack of inlined functions. 1332 // positions and the stack of inlined functions.
1348 class RawCodeSourceMap : public RawObject { 1333 class RawCodeSourceMap : public RawObject {
1349 private: 1334 private:
1350 RAW_HEAP_OBJECT_IMPLEMENTATION(CodeSourceMap); 1335 RAW_HEAP_OBJECT_IMPLEMENTATION(CodeSourceMap);
1351 1336
1352 // Length in bytes. This only needs to be an int32_t, but we make it a uword 1337 int32_t length_; // Length in bytes.
1353 // so that the variable length data is 64 bit aligned on 64 bit platforms.
1354 uword length_;
1355 1338
1356 // Variable length data follows here. 1339 // Variable length data follows here.
1357 uint8_t* data() { OPEN_ARRAY_START(uint8_t, intptr_t); } 1340 uint8_t* data() { OPEN_ARRAY_START(uint8_t, intptr_t); }
1358 const uint8_t* data() const { OPEN_ARRAY_START(uint8_t, intptr_t); } 1341 const uint8_t* data() const { OPEN_ARRAY_START(uint8_t, intptr_t); }
1359 1342
1360 friend class Object; 1343 friend class Object;
1361 }; 1344 };
1362 1345
1363 1346
1364 // StackMap is an immutable representation of the layout of the stack at a 1347 // StackMap is an immutable representation of the layout of the stack at a
1365 // PC. The stack map representation consists of a bit map which marks each 1348 // PC. The stack map representation consists of a bit map which marks each
1366 // live object index starting from the base of the frame. 1349 // live object index starting from the base of the frame.
1367 // 1350 //
1368 // The bit map representation is optimized for dense and small bit maps, without 1351 // The bit map representation is optimized for dense and small bit maps, without
1369 // any upper bound. 1352 // any upper bound.
1370 class RawStackMap : public RawObject { 1353 class RawStackMap : public RawObject {
1371 RAW_HEAP_OBJECT_IMPLEMENTATION(StackMap); 1354 RAW_HEAP_OBJECT_IMPLEMENTATION(StackMap);
1372 1355
1373 // Regarding changing this to a bitfield: ARM64 requires register_bit_count_ 1356 // Regarding changing this to a bitfield: ARM64 requires register_bit_count_
1374 // to be as large as 96, meaning 7 bits, leaving 25 bits for the length, or 1357 // to be as large as 96, meaning 7 bits, leaving 25 bits for the length, or
1375 // as large as ~33 million entries. If that is sufficient, then these two 1358 // as large as ~33 million entries. If that is sufficient, then these two
1376 // fields can be merged into a BitField. 1359 // fields can be merged into a BitField.
1377 int32_t length_; // Length of payload, in bits. 1360 int32_t length_; // Length of payload, in bits.
1378 int32_t slow_path_bit_count_; // Slow path live values, included in length_. 1361 int32_t slow_path_bit_count_; // Slow path live values, included in length_.
1379 1362
1380 // Offset from code entry point corresponding to this stack map 1363 // Offset from code entry point corresponding to this stack map
1381 // representation. This only needs to be an int32_t, but we make it a uword 1364 // representation.
1382 // so that the variable length data is 64 bit aligned on 64 bit platforms. 1365 uint32_t pc_offset_;
1383 uword pc_offset_;
1384 1366
1385 // Variable length data follows here (bitmap of the stack layout). 1367 // Variable length data follows here (bitmap of the stack layout).
1386 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); } 1368 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); }
1387 const uint8_t* data() const { OPEN_ARRAY_START(uint8_t, uint8_t); } 1369 const uint8_t* data() const { OPEN_ARRAY_START(uint8_t, uint8_t); }
1388 }; 1370 };
1389 1371
1390 1372
1391 class RawLocalVarDescriptors : public RawObject { 1373 class RawLocalVarDescriptors : public RawObject {
1392 public: 1374 public:
1393 enum VarInfoKind { 1375 enum VarInfoKind {
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
1427 index_kind = KindBits::update(kind, index_kind); 1409 index_kind = KindBits::update(kind, index_kind);
1428 } 1410 }
1429 int32_t index() const { return IndexBits::decode(index_kind) - kIndexBias; } 1411 int32_t index() const { return IndexBits::decode(index_kind) - kIndexBias; }
1430 void set_index(int32_t index) { 1412 void set_index(int32_t index) {
1431 index_kind = IndexBits::update(index + kIndexBias, index_kind); 1413 index_kind = IndexBits::update(index + kIndexBias, index_kind);
1432 } 1414 }
1433 }; 1415 };
1434 1416
1435 private: 1417 private:
1436 RAW_HEAP_OBJECT_IMPLEMENTATION(LocalVarDescriptors); 1418 RAW_HEAP_OBJECT_IMPLEMENTATION(LocalVarDescriptors);
1437 // Number of descriptors. This only needs to be an int32_t, but we make it a 1419 int32_t num_entries_; // Number of descriptors.
1438 // uword so that the variable length data is 64 bit aligned on 64 bit
1439 // platforms.
1440 uword num_entries_;
1441 1420
1442 RawObject** from() { 1421 RawObject** from() {
1443 return reinterpret_cast<RawObject**>(&ptr()->names()[0]); 1422 return reinterpret_cast<RawObject**>(&ptr()->names()[0]);
1444 } 1423 }
1445 RawString** names() { 1424 RawString** names() {
1446 // Array of [num_entries_] variable names. 1425 // Array of [num_entries_] variable names.
1447 OPEN_ARRAY_START(RawString*, RawString*); 1426 OPEN_ARRAY_START(RawString*, RawString*);
1448 } 1427 }
1449 RawString** nameAddrAt(intptr_t i) { return &(ptr()->names()[i]); } 1428 RawString** nameAddrAt(intptr_t i) { return &(ptr()->names()[i]); }
1450 1429
(...skipping 487 matching lines...) Expand 10 before | Expand all | Expand 10 after
1938 1917
1939 1918
1940 class RawOneByteString : public RawString { 1919 class RawOneByteString : public RawString {
1941 RAW_HEAP_OBJECT_IMPLEMENTATION(OneByteString); 1920 RAW_HEAP_OBJECT_IMPLEMENTATION(OneByteString);
1942 1921
1943 // Variable length data follows here. 1922 // Variable length data follows here.
1944 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); } 1923 uint8_t* data() { OPEN_ARRAY_START(uint8_t, uint8_t); }
1945 const uint8_t* data() const { OPEN_ARRAY_START(uint8_t, uint8_t); } 1924 const uint8_t* data() const { OPEN_ARRAY_START(uint8_t, uint8_t); }
1946 1925
1947 friend class ApiMessageReader; 1926 friend class ApiMessageReader;
1927 friend class SnapshotReader;
1948 friend class RODataSerializationCluster; 1928 friend class RODataSerializationCluster;
1949 friend class SnapshotReader;
1950 friend class String;
1951 }; 1929 };
1952 1930
1953 1931
1954 class RawTwoByteString : public RawString { 1932 class RawTwoByteString : public RawString {
1955 RAW_HEAP_OBJECT_IMPLEMENTATION(TwoByteString); 1933 RAW_HEAP_OBJECT_IMPLEMENTATION(TwoByteString);
1956 1934
1957 // Variable length data follows here. 1935 // Variable length data follows here.
1958 uint16_t* data() { OPEN_ARRAY_START(uint16_t, uint16_t); } 1936 uint16_t* data() { OPEN_ARRAY_START(uint16_t, uint16_t); }
1959 const uint16_t* data() const { OPEN_ARRAY_START(uint16_t, uint16_t); } 1937 const uint16_t* data() const { OPEN_ARRAY_START(uint16_t, uint16_t); }
1960 1938
1939 friend class SnapshotReader;
1961 friend class RODataSerializationCluster; 1940 friend class RODataSerializationCluster;
1962 friend class SnapshotReader;
1963 friend class String;
1964 }; 1941 };
1965 1942
1966 1943
1967 template <typename T> 1944 template <typename T>
1968 class ExternalStringData { 1945 class ExternalStringData {
1969 public: 1946 public:
1970 ExternalStringData(const T* data, void* peer, Dart_PeerFinalizer callback) 1947 ExternalStringData(const T* data, void* peer, Dart_PeerFinalizer callback)
1971 : data_(data), peer_(peer), callback_(callback) {} 1948 : data_(data), peer_(peer), callback_(callback) {}
1972 ~ExternalStringData() { 1949 ~ExternalStringData() {
1973 if (callback_ != NULL) (*callback_)(peer_); 1950 if (callback_ != NULL) (*callback_)(peer_);
(...skipping 15 matching lines...) Expand all
1989 1966
1990 class RawExternalOneByteString : public RawString { 1967 class RawExternalOneByteString : public RawString {
1991 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalOneByteString); 1968 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalOneByteString);
1992 1969
1993 public: 1970 public:
1994 typedef ExternalStringData<uint8_t> ExternalData; 1971 typedef ExternalStringData<uint8_t> ExternalData;
1995 1972
1996 private: 1973 private:
1997 ExternalData* external_data_; 1974 ExternalData* external_data_;
1998 friend class Api; 1975 friend class Api;
1999 friend class String;
2000 }; 1976 };
2001 1977
2002 1978
2003 class RawExternalTwoByteString : public RawString { 1979 class RawExternalTwoByteString : public RawString {
2004 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalTwoByteString); 1980 RAW_HEAP_OBJECT_IMPLEMENTATION(ExternalTwoByteString);
2005 1981
2006 public: 1982 public:
2007 typedef ExternalStringData<uint16_t> ExternalData; 1983 typedef ExternalStringData<uint16_t> ExternalData;
2008 1984
2009 private: 1985 private:
2010 ExternalData* external_data_; 1986 ExternalData* external_data_;
2011 friend class Api; 1987 friend class Api;
2012 friend class String;
2013 }; 1988 };
2014 1989
2015 1990
2016 class RawBool : public RawInstance { 1991 class RawBool : public RawInstance {
2017 RAW_HEAP_OBJECT_IMPLEMENTATION(Bool); 1992 RAW_HEAP_OBJECT_IMPLEMENTATION(Bool);
2018 1993
2019 bool value_; 1994 bool value_;
2020 }; 1995 };
2021 1996
2022 1997
(...skipping 498 matching lines...) Expand 10 before | Expand all | Expand 10 after
2521 kTypedDataInt8ArrayViewCid + 15); 2496 kTypedDataInt8ArrayViewCid + 15);
2522 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14); 2497 COMPILE_ASSERT(kByteBufferCid == kExternalTypedDataInt8ArrayCid + 14);
2523 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1); 2498 COMPILE_ASSERT(kNullCid == kByteBufferCid + 1);
2524 return (kNullCid - kTypedDataInt8ArrayCid); 2499 return (kNullCid - kTypedDataInt8ArrayCid);
2525 } 2500 }
2526 2501
2527 2502
2528 } // namespace dart 2503 } // namespace dart
2529 2504
2530 #endif // RUNTIME_VM_RAW_OBJECT_H_ 2505 #endif // RUNTIME_VM_RAW_OBJECT_H_
OLDNEW
« no previous file with comments | « runtime/vm/profiler.cc ('k') | runtime/vm/raw_object.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698