Flutter Engine
The Flutter Engine
Public Member Functions | List of all members
dart::compiler::ObjectPoolBuilder Class Reference

#include <object_pool_builder.h>

Inheritance diagram for dart::compiler::ObjectPoolBuilder:
dart::ValueObject

Public Member Functions

 ObjectPoolBuilder (ObjectPoolBuilder *parent=nullptr)
 
 ~ObjectPoolBuilder ()
 
void Reset ()
 
void InitializeWithZone (Zone *zone)
 
intptr_t AddObject (const Object &obj, ObjectPoolBuilderEntry::Patchability patchable=ObjectPoolBuilderEntry::kNotPatchable, ObjectPoolBuilderEntry::SnapshotBehavior snapshot_behavior=ObjectPoolBuilderEntry::kSnapshotable)
 
intptr_t AddImmediate (uword imm, ObjectPoolBuilderEntry::Patchability patchable=ObjectPoolBuilderEntry::kNotPatchable, ObjectPoolBuilderEntry::SnapshotBehavior snapshotability=ObjectPoolBuilderEntry::kSnapshotable)
 
intptr_t AddImmediate64 (uint64_t imm)
 
intptr_t AddImmediate128 (simd128_value_t imm)
 
intptr_t FindObject (const Object &obj, ObjectPoolBuilderEntry::Patchability patchable=ObjectPoolBuilderEntry::kNotPatchable, ObjectPoolBuilderEntry::SnapshotBehavior snapshot_behavior=ObjectPoolBuilderEntry::kSnapshotable)
 
intptr_t FindObject (const Object &obj, const Object &equivalence)
 
intptr_t FindImmediate (uword imm)
 
intptr_t FindImmediate64 (uint64_t imm)
 
intptr_t FindImmediate128 (simd128_value_t imm)
 
intptr_t FindNativeFunction (const ExternalLabel *label, ObjectPoolBuilderEntry::Patchability patchable)
 
intptr_t CurrentLength () const
 
ObjectPoolBuilderEntryEntryAt (intptr_t i)
 
const ObjectPoolBuilderEntryEntryAt (intptr_t i) const
 
intptr_t AddObject (ObjectPoolBuilderEntry entry)
 
bool TryCommitToParent ()
 
bool HasParent () const
 
- Public Member Functions inherited from dart::ValueObject
 ValueObject ()
 
 ~ValueObject ()
 

Detailed Description

Definition at line 193 of file object_pool_builder.h.

Constructor & Destructor Documentation

◆ ObjectPoolBuilder()

dart::compiler::ObjectPoolBuilder::ObjectPoolBuilder ( ObjectPoolBuilder parent = nullptr)
inlineexplicit

Definition at line 201 of file object_pool_builder.h.

202 : parent_(parent),
203 base_index_(parent != nullptr ? parent->CurrentLength() : 0),
204 zone_(nullptr) {}

◆ ~ObjectPoolBuilder()

dart::compiler::ObjectPoolBuilder::~ObjectPoolBuilder ( )
inline

Definition at line 206 of file object_pool_builder.h.

206 {
207 if (zone_ != nullptr) {
208 Reset();
209 zone_ = nullptr;
210 }
211 }

Member Function Documentation

◆ AddImmediate()

intptr_t dart::compiler::ObjectPoolBuilder::AddImmediate ( uword  imm,
ObjectPoolBuilderEntry::Patchability  patchable = ObjectPoolBuilderEntry::kNotPatchable,
ObjectPoolBuilderEntry::SnapshotBehavior  snapshotability = ObjectPoolBuilderEntry::kSnapshotable 
)

Definition at line 666 of file assembler_base.cc.

669 {
670 return AddObject(ObjectPoolBuilderEntry(
671 imm, ObjectPoolBuilderEntry::kImmediate, patchable, snapshotability));
672}
intptr_t AddObject(const Object &obj, ObjectPoolBuilderEntry::Patchability patchable=ObjectPoolBuilderEntry::kNotPatchable, ObjectPoolBuilderEntry::SnapshotBehavior snapshot_behavior=ObjectPoolBuilderEntry::kSnapshotable)

◆ AddImmediate128()

intptr_t dart::compiler::ObjectPoolBuilder::AddImmediate128 ( simd128_value_t  imm)

◆ AddImmediate64()

intptr_t dart::compiler::ObjectPoolBuilder::AddImmediate64 ( uint64_t  imm)

Definition at line 674 of file assembler_base.cc.

674 {
675#if defined(TARGET_ARCH_IS_32_BIT)
676 return AddObject(
677 ObjectPoolBuilderEntry(imm, ObjectPoolBuilderEntry::kImmediate64,
679#else
680 return AddImmediate(imm);
681#endif
682}
intptr_t AddImmediate(uword imm, ObjectPoolBuilderEntry::Patchability patchable=ObjectPoolBuilderEntry::kNotPatchable, ObjectPoolBuilderEntry::SnapshotBehavior snapshotability=ObjectPoolBuilderEntry::kSnapshotable)

◆ AddObject() [1/2]

intptr_t dart::compiler::ObjectPoolBuilder::AddObject ( const Object obj,
ObjectPoolBuilderEntry::Patchability  patchable = ObjectPoolBuilderEntry::kNotPatchable,
ObjectPoolBuilderEntry::SnapshotBehavior  snapshot_behavior = ObjectPoolBuilderEntry::kSnapshotable 
)

Definition at line 658 of file assembler_base.cc.

661 {
662 DEBUG_ASSERT(IsNotTemporaryScopedHandle(obj));
663 return AddObject(ObjectPoolBuilderEntry(&obj, patchable, snapshot_behavior));
664}
#define DEBUG_ASSERT(cond)
Definition: assert.h:321

◆ AddObject() [2/2]

intptr_t dart::compiler::ObjectPoolBuilder::AddObject ( ObjectPoolBuilderEntry  entry)

Definition at line 690 of file assembler_base.cc.

690 {
692 (IsNotTemporaryScopedHandle(*entry.obj_) &&
693 (entry.equivalence_ == nullptr ||
694 IsNotTemporaryScopedHandle(*entry.equivalence_))));
695
696 if (entry.type() == ObjectPoolBuilderEntry::kTaggedObject) {
697 // If the owner of the object pool wrapper specified a specific zone we
698 // should use we'll do so.
699 if (zone_ != nullptr) {
700 entry.obj_ = &NewZoneHandle(zone_, *entry.obj_);
701 if (entry.equivalence_ != nullptr) {
702 entry.equivalence_ = &NewZoneHandle(zone_, *entry.equivalence_);
703 }
704 }
705 }
706
707#if defined(TARGET_ARCH_IS_32_BIT)
708 if (entry.type() == ObjectPoolBuilderEntry::kImmediate64) {
709 ASSERT(entry.patchable() == ObjectPoolBuilderEntry::kNotPatchable);
710 uint64_t imm = entry.imm64_;
711 intptr_t idx = AddImmediate(Utils::Low32Bits(imm));
713 object_pool_index_table_.Insert(ObjIndexPair(entry, idx));
714 return idx;
715 }
716 if (entry.type() == ObjectPoolBuilderEntry::kImmediate128) {
717 ASSERT(entry.patchable() == ObjectPoolBuilderEntry::kNotPatchable);
718 intptr_t idx = AddImmediate(entry.imm128_.int_storage[0]);
719 AddImmediate(entry.imm128_.int_storage[1]);
720 AddImmediate(entry.imm128_.int_storage[2]);
721 AddImmediate(entry.imm128_.int_storage[3]);
722 object_pool_index_table_.Insert(ObjIndexPair(entry, idx));
723 return idx;
724 }
725#else
726 if (entry.type() == ObjectPoolBuilderEntry::kImmediate128) {
727 ASSERT(entry.patchable() == ObjectPoolBuilderEntry::kNotPatchable);
728 uword lo64 =
729 (static_cast<uword>(entry.imm128_.int_storage[0]) & 0xffffffff) |
730 (static_cast<uword>(entry.imm128_.int_storage[1]) << 32);
731 uword hi64 =
732 (static_cast<uword>(entry.imm128_.int_storage[2]) & 0xffffffff) |
733 (static_cast<uword>(entry.imm128_.int_storage[3]) << 32);
734 intptr_t idx = AddImmediate(lo64);
735 AddImmediate(hi64);
736 object_pool_index_table_.Insert(ObjIndexPair(entry, idx));
737 return idx;
738 }
739#endif
740
741 const intptr_t idx = base_index_ + object_pool_.length();
742 object_pool_.Add(entry);
743 if (entry.patchable() == ObjectPoolBuilderEntry::kNotPatchable) {
744 // The object isn't patchable. Record the index for fast lookup.
745 object_pool_index_table_.Insert(ObjIndexPair(entry, idx));
746 }
747 return idx;
748}
static int32_t Low32Bits(int64_t value)
Definition: utils.h:369
static int32_t High32Bits(int64_t value)
Definition: utils.h:373
#define ASSERT(E)
Object & NewZoneHandle(Zone *zone)
Definition: runtime_api.cc:141
uintptr_t uword
Definition: globals.h:501

◆ CurrentLength()

intptr_t dart::compiler::ObjectPoolBuilder::CurrentLength ( ) const
inline

Definition at line 256 of file object_pool_builder.h.

256 {
257 return object_pool_.length() + used_from_parent_.length();
258 }
intptr_t length() const

◆ EntryAt() [1/2]

ObjectPoolBuilderEntry & dart::compiler::ObjectPoolBuilder::EntryAt ( intptr_t  i)
inline

Definition at line 259 of file object_pool_builder.h.

259 {
260 if (i < used_from_parent_.length()) {
261 return parent_->EntryAt(used_from_parent_[i]);
262 }
263 return object_pool_[i - used_from_parent_.length()];
264 }
ObjectPoolBuilderEntry & EntryAt(intptr_t i)

◆ EntryAt() [2/2]

const ObjectPoolBuilderEntry & dart::compiler::ObjectPoolBuilder::EntryAt ( intptr_t  i) const
inline

Definition at line 265 of file object_pool_builder.h.

265 {
266 if (i < used_from_parent_.length()) {
267 return parent_->EntryAt(used_from_parent_[i]);
268 }
269 return object_pool_[i - used_from_parent_.length()];
270 }

◆ FindImmediate()

intptr_t dart::compiler::ObjectPoolBuilder::FindImmediate ( uword  imm)

Definition at line 784 of file assembler_base.cc.

784 {
785 return FindObject(
786 ObjectPoolBuilderEntry(imm, ObjectPoolBuilderEntry::kImmediate,
788}
intptr_t FindObject(const Object &obj, ObjectPoolBuilderEntry::Patchability patchable=ObjectPoolBuilderEntry::kNotPatchable, ObjectPoolBuilderEntry::SnapshotBehavior snapshot_behavior=ObjectPoolBuilderEntry::kSnapshotable)

◆ FindImmediate128()

intptr_t dart::compiler::ObjectPoolBuilder::FindImmediate128 ( simd128_value_t  imm)

Definition at line 800 of file assembler_base.cc.

800 {
801 return FindObject(
802 ObjectPoolBuilderEntry(imm, ObjectPoolBuilderEntry::kImmediate128,
804}

◆ FindImmediate64()

intptr_t dart::compiler::ObjectPoolBuilder::FindImmediate64 ( uint64_t  imm)

Definition at line 790 of file assembler_base.cc.

790 {
791#if defined(TARGET_ARCH_IS_32_BIT)
792 return FindObject(
793 ObjectPoolBuilderEntry(imm, ObjectPoolBuilderEntry::kImmediate64,
795#else
796 return FindImmediate(imm);
797#endif
798}

◆ FindNativeFunction()

intptr_t dart::compiler::ObjectPoolBuilder::FindNativeFunction ( const ExternalLabel label,
ObjectPoolBuilderEntry::Patchability  patchable 
)

Definition at line 806 of file assembler_base.cc.

808 {
809 return FindObject(ObjectPoolBuilderEntry(
810 label->address(), ObjectPoolBuilderEntry::kNativeFunction, patchable));
811}

◆ FindObject() [1/2]

intptr_t dart::compiler::ObjectPoolBuilder::FindObject ( const Object obj,
const Object equivalence 
)

Definition at line 778 of file assembler_base.cc.

779 {
780 return FindObject(ObjectPoolBuilderEntry(
781 &obj, &equivalence, ObjectPoolBuilderEntry::kNotPatchable));
782}

◆ FindObject() [2/2]

intptr_t dart::compiler::ObjectPoolBuilder::FindObject ( const Object obj,
ObjectPoolBuilderEntry::Patchability  patchable = ObjectPoolBuilderEntry::kNotPatchable,
ObjectPoolBuilderEntry::SnapshotBehavior  snapshot_behavior = ObjectPoolBuilderEntry::kSnapshotable 
)

Definition at line 771 of file assembler_base.cc.

774 {
775 return FindObject(ObjectPoolBuilderEntry(&obj, patchable, snapshot_behavior));
776}

◆ HasParent()

bool dart::compiler::ObjectPoolBuilder::HasParent ( ) const
inline

Definition at line 279 of file object_pool_builder.h.

279{ return parent_ != nullptr; }

◆ InitializeWithZone()

void dart::compiler::ObjectPoolBuilder::InitializeWithZone ( Zone zone)
inline

Definition at line 222 of file object_pool_builder.h.

222 {
223 ASSERT(object_pool_.length() == 0);
224 ASSERT(zone_ == nullptr && zone != nullptr);
225 zone_ = zone;
226 }

◆ Reset()

void dart::compiler::ObjectPoolBuilder::Reset ( )

Definition at line 645 of file assembler_base.cc.

645 {
646 // Null out the handles we've accumulated.
647 for (intptr_t i = 0; i < object_pool_.length(); ++i) {
648 if (object_pool_[i].type() == ObjectPoolBuilderEntry::kTaggedObject) {
649 SetToNull(const_cast<Object*>(object_pool_[i].obj_));
650 SetToNull(const_cast<Object*>(object_pool_[i].equivalence_));
651 }
652 }
653
654 object_pool_.Clear();
655 object_pool_index_table_.Clear();
656}
GLenum type
void SetToNull(Object *obj)
Definition: runtime_api.cc:137

◆ TryCommitToParent()

bool dart::compiler::ObjectPoolBuilder::TryCommitToParent ( )

Definition at line 813 of file assembler_base.cc.

813 {
814 ASSERT(parent_ != nullptr);
815 if (parent_->CurrentLength() != base_index_) {
816 return false;
817 }
818 for (intptr_t i = 0; i < object_pool_.length(); i++) {
819 intptr_t idx = parent_->AddObject(object_pool_[i]);
820 ASSERT(idx == (base_index_ + i));
821 }
822 return true;
823}

The documentation for this class was generated from the following files: