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

#include <code_descriptors.h>

Inheritance diagram for dart::CatchEntryMovesMapBuilder:
dart::ZoneAllocated

Classes

class  TrieNode
 

Public Member Functions

 CatchEntryMovesMapBuilder ()
 
void NewMapping (intptr_t pc_offset)
 
void Append (const CatchEntryMove &move)
 
void EndMapping ()
 
TypedDataPtr FinalizeCatchEntryMovesMap ()
 
- 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 149 of file code_descriptors.h.

Constructor & Destructor Documentation

◆ CatchEntryMovesMapBuilder()

dart::CatchEntryMovesMapBuilder::CatchEntryMovesMapBuilder ( )

Definition at line 185 of file code_descriptors.cc.

186 : zone_(Thread::Current()->zone()),
187 root_(new TrieNode()),
188 current_pc_offset_(0),
189 stream_(zone_, 64) {}
static Thread * Current()
Definition: thread.h:362
AsciiTrie::TrieNode TrieNode
Definition: ascii_trie.cc:10

Member Function Documentation

◆ Append()

void dart::CatchEntryMovesMapBuilder::Append ( const CatchEntryMove move)

Definition at line 191 of file code_descriptors.cc.

191 {
192 moves_.Add(move);
193}

◆ EndMapping()

void dart::CatchEntryMovesMapBuilder::EndMapping ( )

Definition at line 200 of file code_descriptors.cc.

200 {
201 intptr_t suffix_length = 0;
202 TrieNode* suffix = root_;
203 // Find the largest common suffix, get the last node of the path.
204 for (intptr_t i = moves_.length() - 1; i >= 0; i--) {
205 TrieNode* n = suffix->Follow(moves_[i]);
206 if (n == nullptr) break;
207 suffix_length++;
208 suffix = n;
209 }
210 intptr_t length = moves_.length() - suffix_length;
211 intptr_t current_offset = stream_.bytes_written();
212
213 typedef ZoneWriteStream::Raw<sizeof(intptr_t), intptr_t> Writer;
214 Writer::Write(&stream_, current_pc_offset_);
215 Writer::Write(&stream_, length);
216 Writer::Write(&stream_, suffix_length);
217 Writer::Write(&stream_, suffix->Offset());
218
219 // Write the unshared part, adding it to the trie.
220 TrieNode* node = suffix;
221 for (intptr_t i = length - 1; i >= 0; i--) {
222 moves_[i].WriteTo(&stream_);
223
224 TrieNode* child = new (zone_) TrieNode(moves_[i], current_offset);
225 node->Insert(child);
226 node = child;
227 }
228}
DART_FORCE_INLINE intptr_t bytes_written() const
Definition: datastream.h:338
size_t length

◆ FinalizeCatchEntryMovesMap()

TypedDataPtr dart::CatchEntryMovesMapBuilder::FinalizeCatchEntryMovesMap ( )

Definition at line 230 of file code_descriptors.cc.

230 {
231 TypedData& td = TypedData::Handle(TypedData::New(
232 kTypedDataInt8ArrayCid, stream_.bytes_written(), Heap::kOld));
233 NoSafepointScope no_safepoint;
234 uint8_t* dest = reinterpret_cast<uint8_t*>(td.DataAddr(0));
235 uint8_t* src = stream_.buffer();
236 for (intptr_t i = 0; i < stream_.bytes_written(); i++) {
237 dest[i] = src[i];
238 }
239 return td.ptr();
240}
@ kOld
Definition: heap.h:39
uint8_t * buffer() const
Definition: datastream.h:615
static Object & Handle()
Definition: object.h:407
static TypedDataPtr New(intptr_t class_id, intptr_t len, Heap::Space space=Heap::kNew)
Definition: object.cc:25587
dest
Definition: zip.py:79

◆ NewMapping()

void dart::CatchEntryMovesMapBuilder::NewMapping ( intptr_t  pc_offset)

Definition at line 195 of file code_descriptors.cc.

195 {
196 moves_.Clear();
197 current_pc_offset_ = pc_offset;
198}

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