Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
Classes | Public Member Functions | Protected Member Functions | Private Member Functions | List of all members
dart::BlockEntryInstr Class Referenceabstract

#include <il.h>

Inheritance diagram for dart::BlockEntryInstr:
dart::TemplateInstruction< 0, NoThrow > dart::BlockEntryWithInitialDefs dart::JoinEntryInstr dart::TargetEntryInstr dart::CatchBlockEntryInstr dart::FunctionEntryInstr dart::GraphEntryInstr dart::OsrEntryInstr dart::IndirectEntryInstr dart::NativeEntryInstr

Classes

class  InstructionsIterable
 

Public Member Functions

virtual intptr_t PredecessorCount () const =0
 
virtual BlockEntryInstrPredecessorAt (intptr_t index) const =0
 
intptr_t preorder_number () const
 
void set_preorder_number (intptr_t number)
 
intptr_t postorder_number () const
 
void set_postorder_number (intptr_t number)
 
intptr_t block_id () const
 
void set_start_pos (intptr_t pos)
 
intptr_t start_pos () const
 
void set_end_pos (intptr_t pos)
 
intptr_t end_pos () const
 
BlockEntryInstrdominator () const
 
BlockEntryInstrImmediateDominator () const
 
const GrowableArray< BlockEntryInstr * > & dominated_blocks ()
 
void AddDominatedBlock (BlockEntryInstr *block)
 
void ClearDominatedBlocks ()
 
bool Dominates (BlockEntryInstr *other) const
 
Instructionlast_instruction () const
 
void set_last_instruction (Instruction *instr)
 
ParallelMoveInstrparallel_move () const
 
bool HasParallelMove () const
 
bool HasNonRedundantParallelMove () const
 
ParallelMoveInstrGetParallelMove ()
 
bool DiscoverBlock (BlockEntryInstr *predecessor, GrowableArray< BlockEntryInstr * > *preorder, GrowableArray< intptr_t > *parent)
 
virtual bool CanBecomeDeoptimizationTarget () const
 
virtual bool ComputeCanDeoptimize () const
 
virtual bool HasUnknownSideEffects () const
 
intptr_t try_index () const
 
void set_try_index (intptr_t index)
 
bool InsideTryBlock () const
 
LoopInfoloop_info () const
 
void set_loop_info (LoopInfo *loop_info)
 
bool IsLoopHeader () const
 
intptr_t NestingDepth () const
 
virtual BlockEntryInstrGetBlock ()
 
virtual TokenPosition token_pos () const
 
void ReplaceAsPredecessorWith (BlockEntryInstr *new_block)
 
void set_block_id (intptr_t block_id)
 
intptr_t stack_depth () const
 
void set_stack_depth (intptr_t s)
 
void ClearAllInstructions ()
 
InstructionsIterable instructions ()
 
- Public Member Functions inherited from dart::TemplateInstruction< 0, NoThrow >
 TemplateInstruction (intptr_t deopt_id=DeoptId::kNone)
 
 TemplateInstruction (const InstructionSource &source, intptr_t deopt_id=DeoptId::kNone)
 
virtual intptr_t InputCount () const
 
virtual ValueInputAt (intptr_t i) const
 
virtual bool MayThrow () const
 

Protected Member Functions

 BlockEntryInstr (intptr_t block_id, intptr_t try_index, intptr_t deopt_id, intptr_t stack_depth)
 
bool FindOsrEntryAndRelink (GraphEntryInstr *graph_entry, Instruction *parent, BitVector *block_marks)
 

Private Member Functions

virtual void ClearPredecessors ()=0
 
virtual void AddPredecessor (BlockEntryInstr *predecessor)=0
 

Additional Inherited Members

- Public Types inherited from dart::TemplateInstruction< 0, NoThrow >
using BaseClass = typename NoCSE< Instruction, PureInstruction >::Base
 
- Protected Attributes inherited from dart::TemplateInstruction< 0, NoThrow >
EmbeddedArray< Value *, Ninputs_
 

Detailed Description

Definition at line 1644 of file il.h.

Constructor & Destructor Documentation

◆ BlockEntryInstr()

dart::BlockEntryInstr::BlockEntryInstr ( intptr_t  block_id,
intptr_t  try_index,
intptr_t  deopt_id,
intptr_t  stack_depth 
)
inlineprotected

Definition at line 1776 of file il.h.

1780 : TemplateInstruction(deopt_id),
1781 block_id_(block_id),
1782 try_index_(try_index),
1783 stack_depth_(stack_depth),
1784 dominated_blocks_(1) {}
intptr_t try_index() const
Definition il.h:1724
intptr_t block_id() const
Definition il.h:1655
intptr_t stack_depth() const
Definition il.h:1750
TemplateInstruction(intptr_t deopt_id=DeoptId::kNone)
Definition il.h:1501

Member Function Documentation

◆ AddDominatedBlock()

void dart::BlockEntryInstr::AddDominatedBlock ( BlockEntryInstr block)
inline

Definition at line 1671 of file il.h.

1671 {
1672 ASSERT(!block->IsFunctionEntry() || this->IsGraphEntry());
1673 block->set_dominator(this);
1674 dominated_blocks_.Add(block);
1675 }
#define ASSERT(E)

◆ AddPredecessor()

virtual void dart::BlockEntryInstr::AddPredecessor ( BlockEntryInstr predecessor)
privatepure virtual

◆ block_id()

intptr_t dart::BlockEntryInstr::block_id ( ) const
inline

Definition at line 1655 of file il.h.

1655{ return block_id_; }

◆ CanBecomeDeoptimizationTarget()

virtual bool dart::BlockEntryInstr::CanBecomeDeoptimizationTarget ( ) const
inlinevirtual

Definition at line 1714 of file il.h.

1714 {
1715 // BlockEntry environment is copied to Goto and Branch instructions
1716 // when we insert new blocks targeting this block.
1717 return true;
1718 }

◆ ClearAllInstructions()

void dart::BlockEntryInstr::ClearAllInstructions ( )

Definition at line 1896 of file il.cc.

1896 {
1897 JoinEntryInstr* join = this->AsJoinEntry();
1898 if (join != nullptr) {
1899 for (PhiIterator it(join); !it.Done(); it.Advance()) {
1900 it.Current()->UnuseAllInputs();
1901 }
1902 }
1903 UnuseAllInputs();
1904 for (ForwardInstructionIterator it(this); !it.Done(); it.Advance()) {
1905 it.Current()->UnuseAllInputs();
1906 }
1907}
SINT Vec< 2 *N, T > join(const Vec< N, T > &lo, const Vec< N, T > &hi)
Definition SkVx.h:242

◆ ClearDominatedBlocks()

void dart::BlockEntryInstr::ClearDominatedBlocks ( )
inline

Definition at line 1676 of file il.h.

1676{ dominated_blocks_.Clear(); }

◆ ClearPredecessors()

virtual void dart::BlockEntryInstr::ClearPredecessors ( )
privatepure virtual

◆ ComputeCanDeoptimize()

virtual bool dart::BlockEntryInstr::ComputeCanDeoptimize ( ) const
inlinevirtual

Definition at line 1720 of file il.h.

1720{ return false; }

◆ DiscoverBlock()

bool dart::BlockEntryInstr::DiscoverBlock ( BlockEntryInstr predecessor,
GrowableArray< BlockEntryInstr * > *  preorder,
GrowableArray< intptr_t > *  parent 
)

Definition at line 1690 of file il.cc.

1692 {
1693 // If this block has a predecessor (i.e., is not the graph entry) we can
1694 // assume the preorder array is non-empty.
1695 ASSERT((predecessor == nullptr) || !preorder->is_empty());
1696 // Blocks with a single predecessor cannot have been reached before.
1697 ASSERT(IsJoinEntry() || !IsMarked(this, preorder));
1698
1699 // 1. If the block has already been reached, add current_block as a
1700 // basic-block predecessor and we are done.
1701 if (IsMarked(this, preorder)) {
1702 ASSERT(predecessor != nullptr);
1703 AddPredecessor(predecessor);
1704 return false;
1705 }
1706
1707 // 2. Otherwise, clear the predecessors which might have been computed on
1708 // some earlier call to DiscoverBlocks and record this predecessor.
1710 if (predecessor != nullptr) AddPredecessor(predecessor);
1711
1712 // 3. The predecessor is the spanning-tree parent. The graph entry has no
1713 // parent, indicated by -1.
1714 intptr_t parent_number =
1715 (predecessor == nullptr) ? -1 : predecessor->preorder_number();
1716 parent->Add(parent_number);
1717
1718 // 4. Assign the preorder number and add the block entry to the list.
1719 set_preorder_number(preorder->length());
1720 preorder->Add(this);
1721
1722 // The preorder and parent arrays are indexed by
1723 // preorder block number, so they should stay in lockstep.
1724 ASSERT(preorder->length() == parent->length());
1725
1726 // 5. Iterate straight-line successors to record assigned variables and
1727 // find the last instruction in the block. The graph entry block consists
1728 // of only the entry instruction, so that is the last instruction in the
1729 // block.
1730 Instruction* last = this;
1731 for (ForwardInstructionIterator it(this); !it.Done(); it.Advance()) {
1732 last = it.Current();
1733 }
1735 if (last->IsGoto()) last->AsGoto()->set_block(this);
1736
1737 return true;
1738}
void Add(const T &value)
intptr_t length() const
void set_preorder_number(intptr_t number)
Definition il.h:1650
virtual void ClearPredecessors()=0
intptr_t preorder_number() const
Definition il.h:1649
virtual void AddPredecessor(BlockEntryInstr *predecessor)=0
void set_last_instruction(Instruction *instr)
Definition il.h:1681
static bool IsMarked(BlockEntryInstr *block, GrowableArray< BlockEntryInstr * > *preorder)
Definition il.cc:1679

◆ dominated_blocks()

const GrowableArray< BlockEntryInstr * > & dart::BlockEntryInstr::dominated_blocks ( )
inline

Definition at line 1667 of file il.h.

1667 {
1668 return dominated_blocks_;
1669 }

◆ Dominates()

bool dart::BlockEntryInstr::Dominates ( BlockEntryInstr other) const

Definition at line 1806 of file il.cc.

1806 {
1807 // TODO(fschneider): Make this faster by e.g. storing dominators for each
1808 // block while computing the dominator tree.
1809 ASSERT(other != nullptr);
1810 BlockEntryInstr* current = other;
1811 while (current != nullptr && current != this) {
1812 current = current->dominator();
1813 }
1814 return current == this;
1815}
BlockEntryInstr(intptr_t block_id, intptr_t try_index, intptr_t deopt_id, intptr_t stack_depth)
Definition il.h:1776

◆ dominator()

BlockEntryInstr * dart::BlockEntryInstr::dominator ( ) const
inline

Definition at line 1664 of file il.h.

1664{ return dominator_; }

◆ end_pos()

intptr_t dart::BlockEntryInstr::end_pos ( ) const
inline

Definition at line 1662 of file il.h.

1662{ return end_pos_; }

◆ FindOsrEntryAndRelink()

bool dart::BlockEntryInstr::FindOsrEntryAndRelink ( GraphEntryInstr graph_entry,
Instruction parent,
BitVector block_marks 
)
protected

Definition at line 1747 of file il.cc.

1749 {
1750 const intptr_t osr_id = graph_entry->osr_id();
1751
1752 // Search for the instruction with the OSR id. Use a depth first search
1753 // because basic blocks have not been discovered yet. Prune unreachable
1754 // blocks by replacing the normal entry with a jump to the block
1755 // containing the OSR entry point.
1756
1757 // Do not visit blocks more than once.
1758 if (block_marks->Contains(block_id())) return false;
1759 block_marks->Add(block_id());
1760
1761 // Search this block for the OSR id.
1762 Instruction* instr = this;
1763 for (ForwardInstructionIterator it(this); !it.Done(); it.Advance()) {
1764 instr = it.Current();
1765 if (instr->GetDeoptId() == osr_id) {
1766 // Sanity check that we found a stack check instruction.
1767 ASSERT(instr->IsCheckStackOverflow());
1768 // Loop stack check checks are always in join blocks so that they can
1769 // be the target of a goto.
1770 ASSERT(IsJoinEntry());
1771 // The instruction should be the first instruction in the block so
1772 // we can simply jump to the beginning of the block.
1773 ASSERT(instr->previous() == this);
1774
1775 ASSERT(stack_depth() == instr->AsCheckStackOverflow()->stack_depth());
1776 auto normal_entry = graph_entry->normal_entry();
1777 auto osr_entry = new OsrEntryInstr(
1778 graph_entry, normal_entry->block_id(), normal_entry->try_index(),
1779 normal_entry->deopt_id(), stack_depth());
1780
1781 auto goto_join = new GotoInstr(AsJoinEntry(),
1782 CompilerState::Current().GetNextDeoptId());
1783 ASSERT(parent != nullptr);
1784 goto_join->CopyDeoptIdFrom(*parent);
1785 osr_entry->LinkTo(goto_join);
1786
1787 // Remove normal function entries & add osr entry.
1788 graph_entry->set_normal_entry(nullptr);
1789 graph_entry->set_unchecked_entry(nullptr);
1790 graph_entry->set_osr_entry(osr_entry);
1791
1792 return true;
1793 }
1794 }
1795
1796 // Recursively search the successors.
1797 for (intptr_t i = instr->SuccessorCount() - 1; i >= 0; --i) {
1798 if (instr->SuccessorAt(i)->FindOsrEntryAndRelink(graph_entry, instr,
1799 block_marks)) {
1800 return true;
1801 }
1802 }
1803 return false;
1804}
static CompilerState & Current()

◆ GetBlock()

virtual BlockEntryInstr * dart::BlockEntryInstr::GetBlock ( )
inlinevirtual

Definition at line 1736 of file il.h.

1736{ return this; }

◆ GetParallelMove()

ParallelMoveInstr * dart::BlockEntryInstr::GetParallelMove ( )
inline

Definition at line 1691 of file il.h.

1691 {
1692 if (parallel_move_ == nullptr) {
1693 parallel_move_ = new ParallelMoveInstr();
1694 }
1695 return parallel_move_;
1696 }

◆ HasNonRedundantParallelMove()

bool dart::BlockEntryInstr::HasNonRedundantParallelMove ( ) const
inline

Definition at line 1687 of file il.h.

1687 {
1688 return HasParallelMove() && !parallel_move()->IsRedundant();
1689 }
ParallelMoveInstr * parallel_move() const
Definition il.h:1683
bool HasParallelMove() const
Definition il.h:1685
bool IsRedundant() const
Definition il.cc:4925

◆ HasParallelMove()

bool dart::BlockEntryInstr::HasParallelMove ( ) const
inline

Definition at line 1685 of file il.h.

1685{ return parallel_move_ != nullptr; }

◆ HasUnknownSideEffects()

virtual bool dart::BlockEntryInstr::HasUnknownSideEffects ( ) const
inlinevirtual

Reimplemented in dart::JoinEntryInstr.

Definition at line 1722 of file il.h.

1722{ return false; }

◆ ImmediateDominator()

BlockEntryInstr * dart::BlockEntryInstr::ImmediateDominator ( ) const

Definition at line 1817 of file il.cc.

1817 {
1818 Instruction* last = dominator()->last_instruction();
1819 if ((last->SuccessorCount() == 1) && (last->SuccessorAt(0) == this)) {
1820 return dominator();
1821 }
1822 return nullptr;
1823}
BlockEntryInstr * dominator() const
Definition il.h:1664
Instruction * last_instruction() const
Definition il.h:1680

◆ InsideTryBlock()

bool dart::BlockEntryInstr::InsideTryBlock ( ) const
inline

Definition at line 1728 of file il.h.

1728{ return try_index_ != kInvalidTryIndex; }
static constexpr intptr_t kInvalidTryIndex

◆ instructions()

InstructionsIterable dart::BlockEntryInstr::instructions ( )
inline

Definition at line 1768 of file il.h.

1768{ return InstructionsIterable(this); }

◆ IsLoopHeader()

bool dart::BlockEntryInstr::IsLoopHeader ( ) const

Definition at line 1825 of file il.cc.

1825 {
1826 return loop_info_ != nullptr && loop_info_->header() == this;
1827}
BlockEntryInstr * header() const
Definition loops.h:252

◆ last_instruction()

Instruction * dart::BlockEntryInstr::last_instruction ( ) const
inline

Definition at line 1680 of file il.h.

1680{ return last_instruction_; }

◆ loop_info()

LoopInfo * dart::BlockEntryInstr::loop_info ( ) const
inline

Definition at line 1731 of file il.h.

1731{ return loop_info_; }

◆ NestingDepth()

intptr_t dart::BlockEntryInstr::NestingDepth ( ) const

Definition at line 1829 of file il.cc.

1829 {
1830 return loop_info_ == nullptr ? 0 : loop_info_->NestingDepth();
1831}
intptr_t NestingDepth() const
Definition loops.cc:1062

◆ parallel_move()

ParallelMoveInstr * dart::BlockEntryInstr::parallel_move ( ) const
inline

Definition at line 1683 of file il.h.

1683{ return parallel_move_; }

◆ postorder_number()

intptr_t dart::BlockEntryInstr::postorder_number ( ) const
inline

Definition at line 1652 of file il.h.

1652{ return postorder_number_; }

◆ PredecessorAt()

virtual BlockEntryInstr * dart::BlockEntryInstr::PredecessorAt ( intptr_t  index) const
pure virtual

◆ PredecessorCount()

virtual intptr_t dart::BlockEntryInstr::PredecessorCount ( ) const
pure virtual

◆ preorder_number()

intptr_t dart::BlockEntryInstr::preorder_number ( ) const
inline

Definition at line 1649 of file il.h.

1649{ return preorder_number_; }

◆ ReplaceAsPredecessorWith()

void dart::BlockEntryInstr::ReplaceAsPredecessorWith ( BlockEntryInstr new_block)

Definition at line 1838 of file il.cc.

1838 {
1839 // Set the last instruction of the new block to that of the old block.
1840 Instruction* last = last_instruction();
1841 new_block->set_last_instruction(last);
1842 // For each successor, update the predecessors.
1843 for (intptr_t sidx = 0; sidx < last->SuccessorCount(); ++sidx) {
1844 // If the successor is a target, update its predecessor.
1845 TargetEntryInstr* target = last->SuccessorAt(sidx)->AsTargetEntry();
1846 if (target != nullptr) {
1847 target->predecessor_ = new_block;
1848 continue;
1849 }
1850 // If the successor is a join, update each predecessor and the phis.
1851 JoinEntryInstr* join = last->SuccessorAt(sidx)->AsJoinEntry();
1852 ASSERT(join != nullptr);
1853 // Find the old predecessor index.
1854 intptr_t old_index = join->IndexOfPredecessor(this);
1855 intptr_t pred_count = join->PredecessorCount();
1856 ASSERT(old_index >= 0);
1857 ASSERT(old_index < pred_count);
1858 // Find the new predecessor index while reordering the predecessors.
1859 intptr_t new_id = new_block->block_id();
1860 intptr_t new_index = old_index;
1861 if (block_id() < new_id) {
1862 // Search upwards, bubbling down intermediate predecessors.
1863 for (; new_index < pred_count - 1; ++new_index) {
1864 if (join->predecessors_[new_index + 1]->block_id() > new_id) break;
1865 join->predecessors_[new_index] = join->predecessors_[new_index + 1];
1866 }
1867 } else {
1868 // Search downwards, bubbling up intermediate predecessors.
1869 for (; new_index > 0; --new_index) {
1870 if (join->predecessors_[new_index - 1]->block_id() < new_id) break;
1871 join->predecessors_[new_index] = join->predecessors_[new_index - 1];
1872 }
1873 }
1874 join->predecessors_[new_index] = new_block;
1875 // If the new and old predecessor index match there is nothing to update.
1876 if ((join->phis() == nullptr) || (old_index == new_index)) return;
1877 // Otherwise, reorder the predecessor uses in each phi.
1878 for (PhiIterator it(join); !it.Done(); it.Advance()) {
1879 PhiInstr* phi = it.Current();
1880 ASSERT(phi != nullptr);
1881 ASSERT(pred_count == phi->InputCount());
1882 // Save the predecessor use.
1883 Value* pred_use = phi->InputAt(old_index);
1884 // Move uses between old and new.
1885 intptr_t step = (old_index < new_index) ? 1 : -1;
1886 for (intptr_t use_idx = old_index; use_idx != new_index;
1887 use_idx += step) {
1888 phi->SetInputAt(use_idx, phi->InputAt(use_idx + step));
1889 }
1890 // Write the predecessor use.
1891 phi->SetInputAt(new_index, pred_use);
1892 }
1893 }
1894}
static int step(int x, SkScalar min, SkScalar max)
Definition BlurTest.cpp:215
uint32_t * target

◆ set_block_id()

void dart::BlockEntryInstr::set_block_id ( intptr_t  block_id)
inline

Definition at line 1747 of file il.h.

1747{ block_id_ = block_id; }

◆ set_end_pos()

void dart::BlockEntryInstr::set_end_pos ( intptr_t  pos)
inline

Definition at line 1661 of file il.h.

1661{ end_pos_ = pos; }
SkPoint pos

◆ set_last_instruction()

void dart::BlockEntryInstr::set_last_instruction ( Instruction instr)
inline

Definition at line 1681 of file il.h.

1681{ last_instruction_ = instr; }

◆ set_loop_info()

void dart::BlockEntryInstr::set_loop_info ( LoopInfo loop_info)
inline

Definition at line 1732 of file il.h.

1732{ loop_info_ = loop_info; }
LoopInfo * loop_info() const
Definition il.h:1731

◆ set_postorder_number()

void dart::BlockEntryInstr::set_postorder_number ( intptr_t  number)
inline

Definition at line 1653 of file il.h.

1653{ postorder_number_ = number; }

◆ set_preorder_number()

void dart::BlockEntryInstr::set_preorder_number ( intptr_t  number)
inline

Definition at line 1650 of file il.h.

1650{ preorder_number_ = number; }

◆ set_stack_depth()

void dart::BlockEntryInstr::set_stack_depth ( intptr_t  s)
inline

Definition at line 1751 of file il.h.

1751{ stack_depth_ = s; }
struct MyStruct s

◆ set_start_pos()

void dart::BlockEntryInstr::set_start_pos ( intptr_t  pos)
inline

Definition at line 1659 of file il.h.

1659{ start_pos_ = pos; }

◆ set_try_index()

void dart::BlockEntryInstr::set_try_index ( intptr_t  index)
inline

Definition at line 1725 of file il.h.

1725{ try_index_ = index; }

◆ stack_depth()

intptr_t dart::BlockEntryInstr::stack_depth ( ) const
inline

Definition at line 1750 of file il.h.

1750{ return stack_depth_; }

◆ start_pos()

intptr_t dart::BlockEntryInstr::start_pos ( ) const
inline

Definition at line 1660 of file il.h.

1660{ return start_pos_; }

◆ token_pos()

virtual TokenPosition dart::BlockEntryInstr::token_pos ( ) const
inlinevirtual

Definition at line 1738 of file il.h.

1738 {
1739 return TokenPosition::kControlFlow;
1740 }

◆ try_index()

intptr_t dart::BlockEntryInstr::try_index ( ) const
inline

Definition at line 1724 of file il.h.

1724{ return try_index_; }

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