Flutter Engine
The Flutter Engine
Public Member Functions | Static Public Attributes | List of all members
dart::CodeSourceMapBuilder Class Reference

#include <code_descriptors.h>

Inheritance diagram for dart::CodeSourceMapBuilder:
dart::ZoneAllocated

Public Member Functions

 CodeSourceMapBuilder (Zone *zone, bool stack_traces_only, const GrowableArray< intptr_t > &caller_inline_id, const GrowableArray< TokenPosition > &inline_id_to_token_pos, const GrowableArray< const Function * > &inline_id_to_function)
 
void BeginCodeSourceRange (int32_t pc_offset, const InstructionSource &source)
 
void EndCodeSourceRange (int32_t pc_offset, const InstructionSource &source)
 
void NoteDescriptor (UntaggedPcDescriptors::Kind kind, int32_t pc_offset, const InstructionSource &source)
 
void NoteNullCheck (int32_t pc_offset, const InstructionSource &source, intptr_t name_index)
 
void WriteFunctionEntrySourcePosition (const InstructionSource &source)
 
TokenPosition RootPosition (const InstructionSource &source)
 
ArrayPtr InliningIdToFunction ()
 
CodeSourceMapPtr Finalize ()
 
const GrowableArray< const Function * > & inline_id_to_function () const
 
- 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)
 

Static Public Attributes

static const TokenPositionkInitialPosition
 

Detailed Description

Definition at line 231 of file code_descriptors.h.

Constructor & Destructor Documentation

◆ CodeSourceMapBuilder()

dart::CodeSourceMapBuilder::CodeSourceMapBuilder ( Zone zone,
bool  stack_traces_only,
const GrowableArray< intptr_t > &  caller_inline_id,
const GrowableArray< TokenPosition > &  inline_id_to_token_pos,
const GrowableArray< const Function * > &  inline_id_to_function 
)

Definition at line 291 of file code_descriptors.cc.

297 : zone_(zone),
298 buffered_pc_offset_(0),
299 buffered_inline_id_stack_(),
300 buffered_token_pos_stack_(),
301 written_pc_offset_(0),
302 written_inline_id_stack_(),
303 written_token_pos_stack_(),
304 caller_inline_id_(caller_inline_id),
305 inline_id_to_token_pos_(inline_id_to_token_pos),
306 inline_id_to_function_(inline_id_to_function),
307 inlined_functions_(
309 script_(Script::Handle(zone, Script::null())),
310 stream_(zone, 64),
311 stack_traces_only_(stack_traces_only) {
312 buffered_inline_id_stack_.Add(0);
313 buffered_token_pos_stack_.Add(kInitialPosition);
314 written_inline_id_stack_.Add(0);
315 written_token_pos_stack_.Add(kInitialPosition);
316}
void Add(const T &value)
static const TokenPosition & kInitialPosition
const GrowableArray< const Function * > & inline_id_to_function() const
static GrowableObjectArrayPtr New(Heap::Space space=Heap::kNew)
Definition: object.h:11144
@ kOld
Definition: heap.h:39
static ObjectPtr null()
Definition: object.h:433
static Object & Handle()
Definition: object.h:407

Member Function Documentation

◆ BeginCodeSourceRange()

void dart::CodeSourceMapBuilder::BeginCodeSourceRange ( int32_t  pc_offset,
const InstructionSource source 
)

Definition at line 430 of file code_descriptors.cc.

432 {
433 StartInliningInterval(pc_offset, source);
434}
SkBitmap source
Definition: examples.cpp:28

◆ EndCodeSourceRange()

void dart::CodeSourceMapBuilder::EndCodeSourceRange ( int32_t  pc_offset,
const InstructionSource source 
)

Definition at line 436 of file code_descriptors.cc.

437 {
438 if (pc_offset == buffered_pc_offset_) {
439 return; // Empty intermediate instruction.
440 }
441 StartInliningInterval(pc_offset, source);
442 if (source.token_pos != buffered_token_pos_stack_.Last()) {
443 if (!stack_traces_only_) {
444 FlushBuffer();
445 }
446 BufferChangePosition(source.token_pos);
447 }
448 BufferAdvancePC(pc_offset - buffered_pc_offset_);
449}

◆ Finalize()

CodeSourceMapPtr dart::CodeSourceMapBuilder::Finalize ( )

Definition at line 505 of file code_descriptors.cc.

505 {
506 if (!stack_traces_only_) {
507 FlushBuffer();
508 }
509 intptr_t length = stream_.bytes_written();
510 const auto& map = CodeSourceMap::Handle(zone_, CodeSourceMap::New(length));
511 NoSafepointScope no_safepoint;
512 if (length > 0) {
513 ASSERT(stream_.buffer() != nullptr);
514 memmove(map.Data(), stream_.buffer(), length);
515 }
516 return map.ptr();
517}
DART_FORCE_INLINE intptr_t bytes_written() const
Definition: datastream.h:338
static CodeSourceMapPtr New(intptr_t length)
Definition: object.cc:15923
uint8_t * buffer() const
Definition: datastream.h:615
#define ASSERT(E)
size_t length
SI auto map(std::index_sequence< I... >, Fn &&fn, const Args &... args) -> skvx::Vec< sizeof...(I), decltype(fn(args[0]...))>
Definition: SkVx.h:680

◆ inline_id_to_function()

const GrowableArray< const Function * > & dart::CodeSourceMapBuilder::inline_id_to_function ( ) const
inline

Definition at line 261 of file code_descriptors.h.

261 {
262 return inline_id_to_function_;
263 }

◆ InliningIdToFunction()

ArrayPtr dart::CodeSourceMapBuilder::InliningIdToFunction ( )

Definition at line 498 of file code_descriptors.cc.

498 {
499 if (inlined_functions_.Length() == 0) {
500 return Object::empty_array().ptr();
501 }
502 return Array::MakeFixedLength(inlined_functions_);
503}
static ArrayPtr MakeFixedLength(const GrowableObjectArray &growable_array, bool unique=false)
Definition: object.cc:24935
intptr_t Length() const
Definition: object.h:11072

◆ NoteDescriptor()

void dart::CodeSourceMapBuilder::NoteDescriptor ( UntaggedPcDescriptors::Kind  kind,
int32_t  pc_offset,
const InstructionSource source 
)

Definition at line 451 of file code_descriptors.cc.

453 {
454 const uint8_t kCanThrow =
455 UntaggedPcDescriptors::kIcCall | UntaggedPcDescriptors::kUnoptStaticCall |
456 UntaggedPcDescriptors::kRuntimeCall | UntaggedPcDescriptors::kOther;
457 if ((kind & kCanThrow) != 0) {
458 StartInliningInterval(pc_offset, source);
459 BufferChangePosition(source.token_pos);
460 BufferAdvancePC(pc_offset - buffered_pc_offset_);
461 FlushBuffer();
462 }
463}

◆ NoteNullCheck()

void dart::CodeSourceMapBuilder::NoteNullCheck ( int32_t  pc_offset,
const InstructionSource source,
intptr_t  name_index 
)

Definition at line 465 of file code_descriptors.cc.

467 {
468 StartInliningInterval(pc_offset, source);
469 BufferChangePosition(source.token_pos);
470 BufferAdvancePC(pc_offset - buffered_pc_offset_);
471 FlushBuffer();
472 WriteNullCheck(name_index);
473}

◆ RootPosition()

TokenPosition dart::CodeSourceMapBuilder::RootPosition ( const InstructionSource source)

Definition at line 487 of file code_descriptors.cc.

488 {
489 if (source.inlining_id <= 0) return source.token_pos;
490
491 intptr_t id = source.inlining_id;
492 while (caller_inline_id_[id] != 0) {
493 id = caller_inline_id_[id];
494 }
495 return inline_id_to_token_pos_[id - 1];
496}
const uintptr_t id

◆ WriteFunctionEntrySourcePosition()

void dart::CodeSourceMapBuilder::WriteFunctionEntrySourcePosition ( const InstructionSource source)

Definition at line 422 of file code_descriptors.cc.

423 {
424 ASSERT(written_pc_offset_ == 0 && buffered_pc_offset_ == 0);
425 ASSERT(stream_.bytes_written() == 0);
426 WriteChangePosition(source.token_pos);
427 WriteAdvancePC(0);
428}

Member Data Documentation

◆ kInitialPosition

const TokenPosition & dart::CodeSourceMapBuilder::kInitialPosition
static
Initial value:
=
TokenPosition::kDartCodePrologue

Definition at line 243 of file code_descriptors.h.


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