Flutter Engine
The Flutter Engine
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
dart::LivenessAnalysis Class Referenceabstract

#include <flow_graph.h>

Inheritance diagram for dart::LivenessAnalysis:
dart::ValueObject dart::SSALivenessAnalysis dart::StoreOptimizer dart::VariableLivenessAnalysis

Public Member Functions

 LivenessAnalysis (intptr_t variable_count, const GrowableArray< BlockEntryInstr * > &postorder)
 
void Analyze ()
 
virtual ~LivenessAnalysis ()
 
BitVectorGetLiveInSetAt (intptr_t postorder_number) const
 
BitVectorGetLiveOutSetAt (intptr_t postorder_number) const
 
BitVectorGetLiveInSet (BlockEntryInstr *block) const
 
BitVectorGetKillSet (BlockEntryInstr *block) const
 
BitVectorGetLiveOutSet (BlockEntryInstr *block) const
 
void Dump ()
 
- Public Member Functions inherited from dart::ValueObject
 ValueObject ()
 
 ~ValueObject ()
 

Protected Member Functions

virtual void ComputeInitialSets ()=0
 
bool UpdateLiveOut (const BlockEntryInstr &instr)
 
bool UpdateLiveIn (const BlockEntryInstr &instr)
 
void ComputeLiveInAndLiveOutSets ()
 
Zonezone () const
 

Protected Attributes

Zonezone_
 
const intptr_t variable_count_
 
const GrowableArray< BlockEntryInstr * > & postorder_
 
GrowableArray< BitVector * > live_out_
 
GrowableArray< BitVector * > kill_
 
GrowableArray< BitVector * > live_in_
 

Detailed Description

Definition at line 748 of file flow_graph.h.

Constructor & Destructor Documentation

◆ LivenessAnalysis()

dart::LivenessAnalysis::LivenessAnalysis ( intptr_t  variable_count,
const GrowableArray< BlockEntryInstr * > &  postorder 
)

Definition at line 679 of file flow_graph.cc.

682 : zone_(Thread::Current()->zone()),
683 variable_count_(variable_count),
684 postorder_(postorder),
685 live_out_(postorder.length()),
686 kill_(postorder.length()),
687 live_in_(postorder.length()) {}
const intptr_t variable_count_
Definition: flow_graph.h:803
GrowableArray< BitVector * > kill_
Definition: flow_graph.h:815
GrowableArray< BitVector * > live_out_
Definition: flow_graph.h:811
Zone * zone() const
Definition: flow_graph.h:799
GrowableArray< BitVector * > live_in_
Definition: flow_graph.h:819
const GrowableArray< BlockEntryInstr * > & postorder_
Definition: flow_graph.h:805
static Thread * Current()
Definition: thread.h:362

◆ ~LivenessAnalysis()

virtual dart::LivenessAnalysis::~LivenessAnalysis ( )
inlinevirtual

Definition at line 755 of file flow_graph.h.

755{}

Member Function Documentation

◆ Analyze()

void dart::LivenessAnalysis::Analyze ( )

Definition at line 731 of file flow_graph.cc.

731 {
732 const intptr_t block_count = postorder_.length();
733 for (intptr_t i = 0; i < block_count; i++) {
734 live_out_.Add(new (zone()) BitVector(zone(), variable_count_));
735 kill_.Add(new (zone()) BitVector(zone(), variable_count_));
736 live_in_.Add(new (zone()) BitVector(zone(), variable_count_));
737 }
738
741}
static int block_count(const SkSBlockAllocator< N > &pool)
virtual void ComputeInitialSets()=0
void ComputeLiveInAndLiveOutSets()
Definition: flow_graph.cc:711

◆ ComputeInitialSets()

virtual void dart::LivenessAnalysis::ComputeInitialSets ( )
protectedpure virtual

◆ ComputeLiveInAndLiveOutSets()

void dart::LivenessAnalysis::ComputeLiveInAndLiveOutSets ( )
protected

Definition at line 711 of file flow_graph.cc.

711 {
712 const intptr_t block_count = postorder_.length();
713 bool changed;
714 do {
715 changed = false;
716
717 for (intptr_t i = 0; i < block_count; i++) {
718 const BlockEntryInstr& block = *postorder_[i];
719
720 // Live-in set depends only on kill set which does not
721 // change in this loop and live-out set. If live-out
722 // set does not change there is no need to recompute
723 // live-in set.
724 if (UpdateLiveOut(block) && UpdateLiveIn(block)) {
725 changed = true;
726 }
727 }
728 } while (changed);
729}
bool UpdateLiveOut(const BlockEntryInstr &instr)
Definition: flow_graph.cc:689
bool UpdateLiveIn(const BlockEntryInstr &instr)
Definition: flow_graph.cc:704

◆ Dump()

void dart::LivenessAnalysis::Dump ( )

Definition at line 751 of file flow_graph.cc.

751 {
752 const intptr_t block_count = postorder_.length();
753 for (intptr_t i = 0; i < block_count; i++) {
754 BlockEntryInstr* block = postorder_[i];
755 THR_Print("block @%" Pd " -> ", block->block_id());
756
757 Instruction* last = block->last_instruction();
758 for (intptr_t j = 0; j < last->SuccessorCount(); j++) {
759 BlockEntryInstr* succ = last->SuccessorAt(j);
760 THR_Print(" @%" Pd "", succ->block_id());
761 }
762 THR_Print("\n");
763
764 PrintBitVector(" live out", live_out_[i]);
765 PrintBitVector(" kill", kill_[i]);
766 PrintBitVector(" live in", live_in_[i]);
767 }
768}
#define THR_Print(format,...)
Definition: log.h:20
static void PrintBitVector(const char *tag, BitVector *v)
Definition: flow_graph.cc:743
#define Pd
Definition: globals.h:408

◆ GetKillSet()

BitVector * dart::LivenessAnalysis::GetKillSet ( BlockEntryInstr block) const
inline

Definition at line 769 of file flow_graph.h.

769 {
770 return kill_[block->postorder_number()];
771 }

◆ GetLiveInSet()

BitVector * dart::LivenessAnalysis::GetLiveInSet ( BlockEntryInstr block) const
inline

Definition at line 765 of file flow_graph.h.

765 {
766 return GetLiveInSetAt(block->postorder_number());
767 }
BitVector * GetLiveInSetAt(intptr_t postorder_number) const
Definition: flow_graph.h:757

◆ GetLiveInSetAt()

BitVector * dart::LivenessAnalysis::GetLiveInSetAt ( intptr_t  postorder_number) const
inline

Definition at line 757 of file flow_graph.h.

757 {
758 return live_in_[postorder_number];
759 }

◆ GetLiveOutSet()

BitVector * dart::LivenessAnalysis::GetLiveOutSet ( BlockEntryInstr block) const
inline

Definition at line 773 of file flow_graph.h.

773 {
774 return GetLiveOutSetAt(block->postorder_number());
775 }
BitVector * GetLiveOutSetAt(intptr_t postorder_number) const
Definition: flow_graph.h:761

◆ GetLiveOutSetAt()

BitVector * dart::LivenessAnalysis::GetLiveOutSetAt ( intptr_t  postorder_number) const
inline

Definition at line 761 of file flow_graph.h.

761 {
762 return live_out_[postorder_number];
763 }

◆ UpdateLiveIn()

bool dart::LivenessAnalysis::UpdateLiveIn ( const BlockEntryInstr instr)
protected

Definition at line 704 of file flow_graph.cc.

704 {
705 BitVector* live_out = live_out_[block.postorder_number()];
706 BitVector* kill = kill_[block.postorder_number()];
707 BitVector* live_in = live_in_[block.postorder_number()];
708 return live_in->KillAndAdd(kill, live_out);
709}

◆ UpdateLiveOut()

bool dart::LivenessAnalysis::UpdateLiveOut ( const BlockEntryInstr instr)
protected

Definition at line 689 of file flow_graph.cc.

689 {
690 BitVector* live_out = live_out_[block.postorder_number()];
691 bool changed = false;
692 Instruction* last = block.last_instruction();
693 ASSERT(last != nullptr);
694 for (intptr_t i = 0; i < last->SuccessorCount(); i++) {
695 BlockEntryInstr* succ = last->SuccessorAt(i);
696 ASSERT(succ != nullptr);
697 if (live_out->AddAll(live_in_[succ->postorder_number()])) {
698 changed = true;
699 }
700 }
701 return changed;
702}
#define ASSERT(E)

◆ zone()

Zone * dart::LivenessAnalysis::zone ( ) const
inlineprotected

Definition at line 799 of file flow_graph.h.

799{ return zone_; }

Member Data Documentation

◆ kill_

GrowableArray<BitVector*> dart::LivenessAnalysis::kill_
protected

Definition at line 815 of file flow_graph.h.

◆ live_in_

GrowableArray<BitVector*> dart::LivenessAnalysis::live_in_
protected

Definition at line 819 of file flow_graph.h.

◆ live_out_

GrowableArray<BitVector*> dart::LivenessAnalysis::live_out_
protected

Definition at line 811 of file flow_graph.h.

◆ postorder_

const GrowableArray<BlockEntryInstr*>& dart::LivenessAnalysis::postorder_
protected

Definition at line 805 of file flow_graph.h.

◆ variable_count_

const intptr_t dart::LivenessAnalysis::variable_count_
protected

Definition at line 803 of file flow_graph.h.

◆ zone_

Zone* dart::LivenessAnalysis::zone_
protected

Definition at line 801 of file flow_graph.h.


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