Flutter Engine
The Flutter Engine
Loading...
Searching...
No Matches
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 750 of file flow_graph.h.

Constructor & Destructor Documentation

◆ LivenessAnalysis()

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

Definition at line 682 of file flow_graph.cc.

685 : zone_(Thread::Current()->zone()),
686 variable_count_(variable_count),
687 postorder_(postorder),
688 live_out_(postorder.length()),
689 kill_(postorder.length()),
690 live_in_(postorder.length()) {}
const intptr_t variable_count_
Definition flow_graph.h:805
GrowableArray< BitVector * > kill_
Definition flow_graph.h:817
GrowableArray< BitVector * > live_out_
Definition flow_graph.h:813
Zone * zone() const
Definition flow_graph.h:801
GrowableArray< BitVector * > live_in_
Definition flow_graph.h:821
const GrowableArray< BlockEntryInstr * > & postorder_
Definition flow_graph.h:807
static Thread * Current()
Definition thread.h:361

◆ ~LivenessAnalysis()

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

Definition at line 757 of file flow_graph.h.

757{}

Member Function Documentation

◆ Analyze()

void dart::LivenessAnalysis::Analyze ( )

Definition at line 734 of file flow_graph.cc.

734 {
735 const intptr_t block_count = postorder_.length();
736 for (intptr_t i = 0; i < block_count; i++) {
737 live_out_.Add(new (zone()) BitVector(zone(), variable_count_));
738 kill_.Add(new (zone()) BitVector(zone(), variable_count_));
739 live_in_.Add(new (zone()) BitVector(zone(), variable_count_));
740 }
741
744}
static int block_count(const SkSBlockAllocator< N > &pool)
virtual void ComputeInitialSets()=0

◆ ComputeInitialSets()

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

◆ ComputeLiveInAndLiveOutSets()

void dart::LivenessAnalysis::ComputeLiveInAndLiveOutSets ( )
protected

Definition at line 714 of file flow_graph.cc.

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

◆ Dump()

void dart::LivenessAnalysis::Dump ( )

Definition at line 754 of file flow_graph.cc.

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

◆ GetKillSet()

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

Definition at line 771 of file flow_graph.h.

771 {
772 return kill_[block->postorder_number()];
773 }

◆ GetLiveInSet()

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

Definition at line 767 of file flow_graph.h.

767 {
768 return GetLiveInSetAt(block->postorder_number());
769 }
BitVector * GetLiveInSetAt(intptr_t postorder_number) const
Definition flow_graph.h:759

◆ GetLiveInSetAt()

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

Definition at line 759 of file flow_graph.h.

759 {
760 return live_in_[postorder_number];
761 }

◆ GetLiveOutSet()

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

Definition at line 775 of file flow_graph.h.

775 {
776 return GetLiveOutSetAt(block->postorder_number());
777 }
BitVector * GetLiveOutSetAt(intptr_t postorder_number) const
Definition flow_graph.h:763

◆ GetLiveOutSetAt()

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

Definition at line 763 of file flow_graph.h.

763 {
764 return live_out_[postorder_number];
765 }

◆ UpdateLiveIn()

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

Definition at line 707 of file flow_graph.cc.

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

◆ UpdateLiveOut()

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

Definition at line 692 of file flow_graph.cc.

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

◆ zone()

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

Definition at line 801 of file flow_graph.h.

801{ return zone_; }

Member Data Documentation

◆ kill_

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

Definition at line 817 of file flow_graph.h.

◆ live_in_

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

Definition at line 821 of file flow_graph.h.

◆ live_out_

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

Definition at line 813 of file flow_graph.h.

◆ postorder_

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

Definition at line 807 of file flow_graph.h.

◆ variable_count_

const intptr_t dart::LivenessAnalysis::variable_count_
protected

Definition at line 805 of file flow_graph.h.

◆ zone_

Zone* dart::LivenessAnalysis::zone_
protected

Definition at line 803 of file flow_graph.h.


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