Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Public Member Functions | List of all members
dart::CodeSourceMapReader Class Reference

#include <code_descriptors.h>

Inheritance diagram for dart::CodeSourceMapReader:
dart::ValueObject

Public Member Functions

 CodeSourceMapReader (const CodeSourceMap &map, const Array &functions, const Function &root)
 
void GetInlinedFunctionsAt (int32_t pc_offset, GrowableArray< const Function * > *function_stack, GrowableArray< TokenPosition > *token_positions)
 
 NOT_IN_PRODUCT (void PrintJSONInlineIntervals(JSONObject *jsobj))
 
void DumpInlineIntervals (uword start)
 
void DumpSourcePositions (uword start)
 
intptr_t GetNullCheckNameIndexAt (int32_t pc_offset)
 
- Public Member Functions inherited from dart::ValueObject
 ValueObject ()
 
 ~ValueObject ()
 

Detailed Description

Definition at line 332 of file code_descriptors.h.

Constructor & Destructor Documentation

◆ CodeSourceMapReader()

dart::CodeSourceMapReader::CodeSourceMapReader ( const CodeSourceMap map,
const Array functions,
const Function root 
)
inline

Definition at line 334 of file code_descriptors.h.

337 : map_(map), functions_(functions), root_(root) {}

Member Function Documentation

◆ DumpInlineIntervals()

void dart::CodeSourceMapReader::DumpInlineIntervals ( uword  start)

Definition at line 691 of file code_descriptors.cc.

691 {
692 GrowableArray<const Function*> function_stack;
693 GrowableArray<TokenPosition> token_positions;
694 LogBlock lb;
695 NoSafepointScope no_safepoint;
696 ReadStream stream(map_.Data(), map_.Length());
697
698 int32_t current_pc_offset = 0;
699 function_stack.Add(&root_);
700 token_positions.Add(InitialPosition());
701
702 THR_Print("Inline intervals for function '%s' {\n",
704 while (stream.PendingBytes() > 0) {
705 int32_t arg;
706 const uint8_t opcode = CodeSourceMapOps::Read(&stream, &arg);
707 switch (opcode) {
709 const TokenPosition& old_token = token_positions.Last();
710 token_positions.Last() = TokenPosition::Deserialize(
711 Utils::AddWithWrapAround(arg, old_token.Serialize()));
712 break;
713 }
715 THR_Print("%" Px "-%" Px ": ", start + current_pc_offset,
716 start + current_pc_offset + arg - 1);
717 for (intptr_t i = 0; i < function_stack.length(); i++) {
718 THR_Print("%s", function_stack[i]->ToCString());
719 if (token_positions[i].IsReal()) {
720 THR_Print(" @%" Pd, token_positions[i].Pos());
721 }
722 }
723 THR_Print("\n");
724 current_pc_offset += arg;
725 break;
726 }
728 function_stack.Add(
729 &Function::Handle(Function::RawCast(functions_.At(arg))));
730 token_positions.Add(InitialPosition());
731 break;
732 }
734 // We never pop the root function.
735 ASSERT(function_stack.length() > 1);
736 ASSERT(token_positions.length() > 1);
737 function_stack.RemoveLast();
738 token_positions.RemoveLast();
739 break;
740 }
742 break;
743 }
744 default:
745 UNREACHABLE();
746 }
747 }
748 THR_Print("}\n");
749}
#define UNREACHABLE()
Definition assert.h:248
ObjectPtr At(intptr_t index) const
Definition object.h:10854
uint8_t * Data() const
Definition object.h:6215
intptr_t Length() const
Definition object.h:6214
const char * ToFullyQualifiedCString() const
Definition object.cc:9820
static Object & Handle()
Definition object.h:407
static ObjectPtr RawCast(ObjectPtr obj)
Definition object.h:325
static TokenPosition Deserialize(int32_t value)
static T AddWithWrapAround(T a, T b)
Definition utils.h:416
#define THR_Print(format,...)
Definition log.h:20
#define ASSERT(E)
#define Px
Definition globals.h:410
#define Pd
Definition globals.h:408
static constexpr uint8_t kAdvancePC
static constexpr uint8_t kNullCheck
static uint8_t Read(ReadStream *stream, int32_t *arg1, int32_t *arg2=nullptr)
static constexpr uint8_t kPopFunction
static constexpr uint8_t kPushFunction
static constexpr uint8_t kChangePosition

◆ DumpSourcePositions()

void dart::CodeSourceMapReader::DumpSourcePositions ( uword  start)

Definition at line 751 of file code_descriptors.cc.

751 {
752 GrowableArray<const Function*> function_stack;
753 GrowableArray<TokenPosition> token_positions;
754 LogBlock lb;
755 NoSafepointScope no_safepoint;
756 ReadStream stream(map_.Data(), map_.Length());
757
758 int32_t current_pc_offset = 0;
759 function_stack.Add(&root_);
760 token_positions.Add(InitialPosition());
761
762 THR_Print("Source positions for function '%s' {\n",
764 while (stream.PendingBytes() > 0) {
765 int32_t arg;
766 const uint8_t opcode = CodeSourceMapOps::Read(&stream, &arg);
767 switch (opcode) {
769 const TokenPosition& old_token =
770 token_positions[token_positions.length() - 1];
771 token_positions[token_positions.length() - 1] =
773 Utils::AddWithWrapAround(arg, old_token.Serialize()));
774 break;
775 }
777 THR_Print("%" Px "-%" Px ": ", start + current_pc_offset,
778 start + current_pc_offset + arg - 1);
779 for (intptr_t i = 0; i < function_stack.length(); i++) {
780 THR_Print("%s@%s", function_stack[i]->ToCString(),
781 token_positions[i].ToCString());
782 }
783 THR_Print("\n");
784 current_pc_offset += arg;
785 break;
786 }
788 function_stack.Add(
789 &Function::Handle(Function::RawCast(functions_.At(arg))));
790 token_positions.Add(InitialPosition());
791 break;
792 }
794 // We never pop the root function.
795 ASSERT(function_stack.length() > 1);
796 ASSERT(token_positions.length() > 1);
797 function_stack.RemoveLast();
798 token_positions.RemoveLast();
799 break;
800 }
802 THR_Print("%" Px "-%" Px ": null check PP#%" Pd32 "\n",
803 start + current_pc_offset, start + current_pc_offset, arg);
804 break;
805 }
806 default:
807 UNREACHABLE();
808 }
809 }
810 THR_Print("}\n");
811}
#define Pd32
Definition globals.h:412

◆ GetInlinedFunctionsAt()

void dart::CodeSourceMapReader::GetInlinedFunctionsAt ( int32_t  pc_offset,
GrowableArray< const Function * > *  function_stack,
GrowableArray< TokenPosition > *  token_positions 
)

Definition at line 578 of file code_descriptors.cc.

581 {
582 function_stack->Clear();
583 token_positions->Clear();
584
585 NoSafepointScope no_safepoint;
586 ReadStream stream(map_.Data(), map_.Length());
587
588 int32_t current_pc_offset = 0;
589 function_stack->Add(&root_);
590 token_positions->Add(InitialPosition());
591
592 while (stream.PendingBytes() > 0) {
593 int32_t arg;
594 const uint8_t opcode = CodeSourceMapOps::Read(&stream, &arg);
595 switch (opcode) {
597 const TokenPosition& old_token = token_positions->Last();
598 token_positions->Last() = TokenPosition::Deserialize(
599 Utils::AddWithWrapAround(arg, old_token.Serialize()));
600 break;
601 }
603 current_pc_offset += arg;
604 if (current_pc_offset > pc_offset) {
605 return;
606 }
607 break;
608 }
610 function_stack->Add(
611 &Function::Handle(Function::RawCast(functions_.At(arg))));
612 token_positions->Add(InitialPosition());
613 break;
614 }
616 // We never pop the root function.
617 ASSERT(function_stack->length() > 1);
618 ASSERT(token_positions->length() > 1);
619 function_stack->RemoveLast();
620 token_positions->RemoveLast();
621 break;
622 }
624 break;
625 }
626 default:
627 UNREACHABLE();
628 }
629 }
630}

◆ GetNullCheckNameIndexAt()

intptr_t dart::CodeSourceMapReader::GetNullCheckNameIndexAt ( int32_t  pc_offset)

Definition at line 813 of file code_descriptors.cc.

813 {
814 NoSafepointScope no_safepoint;
815 ReadStream stream(map_.Data(), map_.Length());
816
817 int32_t current_pc_offset = 0;
818
819 while (stream.PendingBytes() > 0) {
820 int32_t arg;
821 const uint8_t opcode = CodeSourceMapOps::Read(&stream, &arg);
822 switch (opcode) {
824 break;
825 }
827 current_pc_offset += arg;
828 RELEASE_ASSERT(current_pc_offset <= pc_offset);
829 break;
830 }
832 break;
833 }
835 break;
836 }
838 if (current_pc_offset == pc_offset) {
839 return arg;
840 }
841 break;
842 }
843 default:
844 UNREACHABLE();
845 }
846 }
847
848 UNREACHABLE();
849 return -1;
850}
#define RELEASE_ASSERT(cond)
Definition assert.h:327

◆ NOT_IN_PRODUCT()

dart::CodeSourceMapReader::NOT_IN_PRODUCT ( void   PrintJSONInlineIntervalsJSONObject *jsobj)

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