Flutter Engine
The Flutter Engine
Public Member Functions | Friends | List of all members
dart::CompressedStackMaps::Iterator< PayloadHandle > Class Template Reference

#include <object.h>

Public Member Functions

 Iterator (const PayloadHandle &maps, const PayloadHandle &global_table)
 
 Iterator (const Iterator &it)
 
bool MoveNext ()
 
bool Find (uint32_t pc_offset)
 
uint32_t pc_offset () const
 
intptr_t Length () const
 
intptr_t SpillSlotBitCount () const
 
bool IsObject (intptr_t bit_index) const
 

Friends

class StackMapEntry
 

Detailed Description

template<typename PayloadHandle>
class dart::CompressedStackMaps::Iterator< PayloadHandle >

Definition at line 6382 of file object.h.

Constructor & Destructor Documentation

◆ Iterator() [1/2]

template<typename PayloadHandle >
dart::CompressedStackMaps::Iterator< PayloadHandle >::Iterator ( const PayloadHandle &  maps,
const PayloadHandle &  global_table 
)
inline

Definition at line 6384 of file object.h.

6385 : maps_(maps),
6386 bits_container_(maps.UsesGlobalTable() ? global_table : maps) {
6387 ASSERT(!maps_.IsNull());
6388 ASSERT(!bits_container_.IsNull());
6389 ASSERT(!maps_.IsGlobalTable());
6390 ASSERT(!maps_.UsesGlobalTable() || bits_container_.IsGlobalTable());
6391 }
#define ASSERT(E)

◆ Iterator() [2/2]

template<typename PayloadHandle >
dart::CompressedStackMaps::Iterator< PayloadHandle >::Iterator ( const Iterator< PayloadHandle > &  it)
inline

Definition at line 6393 of file object.h.

6394 : maps_(it.maps_),
6395 bits_container_(it.bits_container_),
6396 next_offset_(it.next_offset_),
6397 current_pc_offset_(it.current_pc_offset_),
6398 current_global_table_offset_(it.current_global_table_offset_),
6399 current_spill_slot_bit_count_(it.current_spill_slot_bit_count_),
6400 current_non_spill_slot_bit_count_(it.current_spill_slot_bit_count_),
6401 current_bits_offset_(it.current_bits_offset_) {}

Member Function Documentation

◆ Find()

template<typename PayloadHandle >
bool dart::CompressedStackMaps::Iterator< PayloadHandle >::Find ( uint32_t  pc_offset)
inline

Definition at line 6457 of file object.h.

6457 {
6458 // We should never have an entry with a PC offset of 0 inside an
6459 // non-empty CSM, so fail.
6460 if (pc_offset == 0) return false;
6461 do {
6462 if (current_pc_offset_ >= pc_offset) break;
6463 } while (MoveNext());
6464 return current_pc_offset_ == pc_offset;
6465 }

◆ IsObject()

template<typename PayloadHandle >
bool dart::CompressedStackMaps::Iterator< PayloadHandle >::IsObject ( intptr_t  bit_index) const
inline

Definition at line 6488 of file object.h.

6488 {
6489 EnsureFullyLoadedEntry();
6490 ASSERT(bit_index >= 0 && bit_index < Length());
6491 const intptr_t byte_index = bit_index >> kBitsPerByteLog2;
6492 const intptr_t bit_remainder = bit_index & (kBitsPerByte - 1);
6493 uint8_t byte_mask = 1U << bit_remainder;
6494 const intptr_t byte_offset = current_bits_offset_ + byte_index;
6495 NoSafepointScope scope;
6496 return (bits_container_.data()[byte_offset] & byte_mask) != 0;
6497 }
constexpr intptr_t kBitsPerByteLog2
Definition: globals.h:462
constexpr intptr_t kBitsPerByte
Definition: globals.h:463

◆ Length()

template<typename PayloadHandle >
intptr_t dart::CompressedStackMaps::Iterator< PayloadHandle >::Length ( ) const
inline

Definition at line 6477 of file object.h.

6477 {
6478 EnsureFullyLoadedEntry();
6479 return current_spill_slot_bit_count_ + current_non_spill_slot_bit_count_;
6480 }

◆ MoveNext()

template<typename PayloadHandle >
bool dart::CompressedStackMaps::Iterator< PayloadHandle >::MoveNext ( )
inline

Definition at line 6405 of file object.h.

6405 {
6406 if (next_offset_ >= maps_.payload_size()) {
6407 return false;
6408 }
6409
6410 NoSafepointScope scope;
6411 ReadStream stream(maps_.data(), maps_.payload_size(), next_offset_);
6412
6413 auto const pc_delta = stream.ReadLEB128();
6414 ASSERT(pc_delta <= (kMaxUint32 - current_pc_offset_));
6415 current_pc_offset_ += pc_delta;
6416
6417 // Table-using CSMs have a table offset after the PC offset delta, whereas
6418 // the post-delta part of inlined entries has the same information as
6419 // global table entries.
6420 // See comments in UntaggedCompressedStackMaps for description of
6421 // encoding.
6422 if (maps_.UsesGlobalTable()) {
6423 current_global_table_offset_ = stream.ReadLEB128();
6424 ASSERT(current_global_table_offset_ < bits_container_.payload_size());
6425
6426 // Since generally we only use entries in the GC and the GC only needs
6427 // the rest of the entry information if the PC offset matches, we lazily
6428 // load and cache the information stored in the global object when it is
6429 // actually requested.
6430 current_spill_slot_bit_count_ = -1;
6431 current_non_spill_slot_bit_count_ = -1;
6432 current_bits_offset_ = -1;
6433
6434 next_offset_ = stream.Position();
6435 } else {
6436 current_spill_slot_bit_count_ = stream.ReadLEB128();
6437 ASSERT(current_spill_slot_bit_count_ >= 0);
6438
6439 current_non_spill_slot_bit_count_ = stream.ReadLEB128();
6440 ASSERT(current_non_spill_slot_bit_count_ >= 0);
6441
6442 const auto stackmap_bits =
6443 current_spill_slot_bit_count_ + current_non_spill_slot_bit_count_;
6444 const uintptr_t stackmap_size =
6445 Utils::RoundUp(stackmap_bits, kBitsPerByte) >> kBitsPerByteLog2;
6446 ASSERT(stackmap_size <= (maps_.payload_size() - stream.Position()));
6447
6448 current_bits_offset_ = stream.Position();
6449 next_offset_ = current_bits_offset_ + stackmap_size;
6450 }
6451
6452 return true;
6453 }
static constexpr T RoundUp(T x, uintptr_t alignment, uintptr_t offset=0)
Definition: utils.h:120
constexpr uint32_t kMaxUint32
Definition: globals.h:484

◆ pc_offset()

template<typename PayloadHandle >
uint32_t dart::CompressedStackMaps::Iterator< PayloadHandle >::pc_offset ( ) const
inline

Definition at line 6471 of file object.h.

6471 {
6472 ASSERT(HasLoadedEntry());
6473 return current_pc_offset_;
6474 }

◆ SpillSlotBitCount()

template<typename PayloadHandle >
intptr_t dart::CompressedStackMaps::Iterator< PayloadHandle >::SpillSlotBitCount ( ) const
inline

Definition at line 6482 of file object.h.

6482 {
6483 EnsureFullyLoadedEntry();
6484 return current_spill_slot_bit_count_;
6485 }

Friends And Related Function Documentation

◆ StackMapEntry

template<typename PayloadHandle >
friend class StackMapEntry
friend

Definition at line 6550 of file object.h.


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