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

#include <code_descriptors.h>

Inheritance diagram for dart::DescriptorList:
dart::ZoneAllocated

Public Member Functions

 DescriptorList (Zone *zone, const GrowableArray< const Function * > *inline_id_to_function=nullptr)
 
 ~DescriptorList ()
 
void AddDescriptor (UntaggedPcDescriptors::Kind kind, intptr_t pc_offset, intptr_t deopt_id, TokenPosition token_pos, intptr_t try_index, intptr_t yield_index)
 
PcDescriptorsPtr FinalizePcDescriptors (uword entry_point)
 
- Public Member Functions inherited from dart::ZoneAllocated
 ZoneAllocated ()
 
void * operator new (size_t size)
 
void * operator new (size_t size, Zone *zone)
 
void operator delete (void *pointer)
 

Detailed Description

Definition at line 19 of file code_descriptors.h.

Constructor & Destructor Documentation

◆ DescriptorList()

dart::DescriptorList::DescriptorList ( Zone zone,
const GrowableArray< const Function * > *  inline_id_to_function = nullptr 
)
explicit

Definition at line 17 of file code_descriptors.cc.

20 : function_(Function::Handle(
21 zone,
22 FLAG_check_token_positions && (inline_id_to_function != nullptr)
23 ? inline_id_to_function->At(0)->ptr()
24 : Function::null())),
25 script_(Script::Handle(
26 zone,
27 function_.IsNull() ? Script::null() : function_.script())),
28 encoded_data_(zone, kInitialStreamSize),
29 prev_pc_offset(0),
30 prev_deopt_id(0),
31 prev_token_pos(0) {}
ScriptPtr script() const
Definition: object.cc:10881
static ObjectPtr null()
Definition: object.h:433
bool IsNull() const
Definition: object.h:363
static Object & Handle()
Definition: object.h:407

◆ ~DescriptorList()

dart::DescriptorList::~DescriptorList ( )
inline

Definition at line 25 of file code_descriptors.h.

25{}

Member Function Documentation

◆ AddDescriptor()

void dart::DescriptorList::AddDescriptor ( UntaggedPcDescriptors::Kind  kind,
intptr_t  pc_offset,
intptr_t  deopt_id,
TokenPosition  token_pos,
intptr_t  try_index,
intptr_t  yield_index 
)

Definition at line 33 of file code_descriptors.cc.

38 {
39 // yield index 0 is reserved for normal entry.
40 RELEASE_ASSERT(yield_index != 0);
41
42 ASSERT((kind == UntaggedPcDescriptors::kRuntimeCall) ||
43 (kind == UntaggedPcDescriptors::kBSSRelocation) ||
44 (kind == UntaggedPcDescriptors::kOther) ||
46 (deopt_id != DeoptId::kNone));
47
48 // When precompiling, we only use pc descriptors for exceptions,
49 // relocations and yield indices.
50 if (!FLAG_precompiled_mode || try_index != -1 ||
52 kind == UntaggedPcDescriptors::kBSSRelocation) {
53 const int32_t kind_and_metadata =
55 yield_index);
56
57 encoded_data_.WriteSLEB128(kind_and_metadata);
58 encoded_data_.WriteSLEB128(pc_offset - prev_pc_offset);
59 prev_pc_offset = pc_offset;
60
61 if (!FLAG_precompiled_mode) {
62 if (FLAG_check_token_positions && token_pos.IsReal()) {
63 if (!function_.IsNull() &&
64 !token_pos.IsWithin(function_.token_pos(),
65 function_.end_token_pos())) {
66 FATAL("Token position %s for PC descriptor %s at offset 0x%" Px
67 " invalid for function %s (%s, %s)",
68 token_pos.ToCString(),
70 function_.ToFullyQualifiedCString(),
71 function_.token_pos().ToCString(),
72 function_.end_token_pos().ToCString());
73 }
74 if (!script_.IsNull() && !script_.IsValidTokenPosition(token_pos)) {
75 FATAL("Token position %s for PC descriptor %s at offset 0x%" Px
76 " invalid for script %s of function %s",
77 token_pos.ToCString(),
79 script_.ToCString(), function_.ToFullyQualifiedCString());
80 }
81 }
82 const int32_t encoded_pos = token_pos.Serialize();
83 encoded_data_.WriteSLEB128(deopt_id - prev_deopt_id);
84 encoded_data_.WriteSLEB128(
85 Utils::SubWithWrapAround(encoded_pos, prev_token_pos));
86 prev_deopt_id = deopt_id;
87 prev_token_pos = encoded_pos;
88 }
89 }
90}
#define RELEASE_ASSERT(cond)
Definition: assert.h:327
C::only_if_signed< T, void > WriteSLEB128(T value)
Definition: datastream.h:514
static constexpr intptr_t kNone
Definition: deopt_id.h:27
const char * ToFullyQualifiedCString() const
Definition: object.cc:9762
TokenPosition token_pos() const
Definition: object.h:3446
TokenPosition end_token_pos() const
Definition: object.h:3455
virtual const char * ToCString() const
Definition: object.h:366
bool IsValidTokenPosition(TokenPosition token_pos) const
Definition: object.cc:13256
const char * ToCString() const
static uint32_t Encode(intptr_t kind, intptr_t try_index, intptr_t yield_index)
Definition: raw_object.h:2087
static const char * KindToCString(Kind k)
Definition: raw_object.cc:771
static constexpr intptr_t kInvalidYieldIndex
Definition: raw_object.h:2081
static T SubWithWrapAround(T a, T b)
Definition: utils.h:440
#define ASSERT(E)
#define FATAL(error)
#define Px
Definition: globals.h:410

◆ FinalizePcDescriptors()

PcDescriptorsPtr dart::DescriptorList::FinalizePcDescriptors ( uword  entry_point)

Definition at line 92 of file code_descriptors.cc.

92 {
93 if (encoded_data_.bytes_written() == 0) {
94 return Object::empty_descriptors().ptr();
95 }
96 return PcDescriptors::New(encoded_data_.buffer(),
97 encoded_data_.bytes_written());
98}
DART_FORCE_INLINE intptr_t bytes_written() const
Definition: datastream.h:338
uint8_t * buffer() const
Definition: datastream.h:615
static PcDescriptorsPtr New(const void *delta_encoded_data, intptr_t size)
Definition: object.cc:15794

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