@@ -1605,8 +1605,8 @@ void Object::set_vm_isolate_snapshot_object_table(const Array& table) {
1605
1605
1606
1606
// Make unused space in an object whose type has been transformed safe
1607
1607
// for traversing during GC.
1608
- // The unused part of the transformed object is marked as an TypedDataInt8Array
1609
- // object.
1608
+ // The unused part of the transformed object is marked as a FreeListElement
1609
+ // object that is not inserted into to the freelist .
1610
1610
void Object::MakeUnusedSpaceTraversable(const Object& obj,
1611
1611
intptr_t original_size,
1612
1612
intptr_t used_size) {
@@ -1615,62 +1615,19 @@ void Object::MakeUnusedSpaceTraversable(const Object& obj,
1615
1615
ASSERT(original_size >= used_size);
1616
1616
if (original_size > used_size) {
1617
1617
intptr_t leftover_size = original_size - used_size;
1618
-
1619
1618
uword addr = UntaggedObject::ToAddr(obj.ptr()) + used_size;
1620
- if (leftover_size >= TypedData::InstanceSize(0)) {
1621
- // Update the leftover space as a TypedDataInt8Array object.
1622
- TypedDataPtr raw =
1623
- static_cast<TypedDataPtr>(UntaggedObject::FromAddr(addr));
1624
- uword new_tags =
1625
- UntaggedObject::ClassIdTag::update(kTypedDataInt8ArrayCid, 0);
1626
- new_tags = UntaggedObject::SizeTag::update(leftover_size, new_tags);
1627
- const bool is_old = obj.ptr()->IsOldObject();
1628
- new_tags = UntaggedObject::AlwaysSetBit::update(true, new_tags);
1629
- new_tags = UntaggedObject::NotMarkedBit::update(true, new_tags);
1630
- new_tags =
1631
- UntaggedObject::OldAndNotRememberedBit::update(is_old, new_tags);
1632
- new_tags = UntaggedObject::NewBit::update(!is_old, new_tags);
1633
- // On architectures with a relaxed memory model, the concurrent marker may
1634
- // observe the write of the filler object's header before observing the
1635
- // new array length, and so treat it as a pointer. Ensure it is a Smi so
1636
- // the marker won't dereference it.
1637
- ASSERT((new_tags & kSmiTagMask) == kSmiTag);
1638
-
1639
- intptr_t leftover_len = (leftover_size - TypedData::InstanceSize(0));
1640
- ASSERT(TypedData::InstanceSize(leftover_len) == leftover_size);
1641
- raw->untag()->set_length<std::memory_order_release>(
1642
- Smi::New(leftover_len));
1643
- raw->untag()->tags_ = new_tags;
1644
- raw->untag()->RecomputeDataField();
1619
+ if (obj.ptr()->IsNewObject()) {
1620
+ FreeListElement::AsElementNew(addr, leftover_size);
1645
1621
} else {
1646
- // Update the leftover space as a basic object.
1647
- ASSERT(leftover_size == Object::InstanceSize());
1648
- ObjectPtr raw = static_cast<ObjectPtr>(UntaggedObject::FromAddr(addr));
1649
- uword new_tags = UntaggedObject::ClassIdTag::update(kInstanceCid, 0);
1650
- new_tags = UntaggedObject::SizeTag::update(leftover_size, new_tags);
1651
- const bool is_old = obj.ptr()->IsOldObject();
1652
- new_tags = UntaggedObject::AlwaysSetBit::update(true, new_tags);
1653
- new_tags = UntaggedObject::NotMarkedBit::update(true, new_tags);
1654
- new_tags =
1655
- UntaggedObject::OldAndNotRememberedBit::update(is_old, new_tags);
1656
- new_tags = UntaggedObject::NewBit::update(!is_old, new_tags);
1657
- // On architectures with a relaxed memory model, the concurrent marker may
1658
- // observe the write of the filler object's header before observing the
1659
- // new array length, and so treat it as a pointer. Ensure it is a Smi so
1660
- // the marker won't dereference it.
1661
- ASSERT((new_tags & kSmiTagMask) == kSmiTag);
1662
-
1663
- // The array might have an uninitialized alignment gap since the visitors
1664
- // for Arrays are precise based on element count, but the visitors for
1665
- // Instance are based on the size rounded to the allocation unit, so we
1666
- // need to ensure the alignment gap is initialized.
1667
- for (intptr_t offset = Instance::UnroundedSize();
1668
- offset < Instance::InstanceSize(); offset += sizeof(uword)) {
1669
- reinterpret_cast<std::atomic<uword>*>(addr + offset)
1670
- ->store(0, std::memory_order_release);
1671
- }
1672
- raw->untag()->tags_ = new_tags;
1673
- }
1622
+ FreeListElement::AsElement(addr, leftover_size);
1623
+ }
1624
+ // On architectures with a relaxed memory model, the concurrent marker may
1625
+ // observe the write of the filler object's header before observing the
1626
+ // new array length, and so treat it as a pointer. Ensure it is a Smi so
1627
+ // the marker won't dereference it.
1628
+ ASSERT((*reinterpret_cast<uword*>(addr) & kSmiTagMask) == kSmiTag);
1629
+ ASSERT((*reinterpret_cast<uword*>(addr + kWordSize) & kSmiTagMask) ==
1630
+ kSmiTag);
1674
1631
}
1675
1632
}
1676
1633
0 commit comments