Polaris: Listable Class Reference

Listable Class Reference

< base class which allows classes to be used in collections More...

#include <Listable.h>

Inheritance diagram for Listable:

Inheritance graph
[legend]
List of all members.

Public Member Functions

 Listable ()
virtual ~Listable ()
void assert_free ()
 Abort with a p-assert if the wrapper-pointer is NULL.
int fingerprint_ok ()
 return the fingerprint of the list (used for debugging).
Listablenext_ref () const
 return the next element of the list.
Listableprev_ref () const
 void operator delete (void * ptr, size_t size);
void operator delete (void *ptr, unsigned int size)
 void * operator new (size_t size);
void * operator new (unsigned int size)
 Overload the new/delete for garbage collection.
virtual Listablelistable_clone () const =0
 Copy and return a pointer to any Listable item (MUST be implemented correctly by subclasses for List copy functions to work).
virtual void print (ostream &o) const =0

Protected Attributes

packed_object _flags
 Contains flags for valid object and a flag determining (1st bit) whether the object is in an a collection (2nd bit) whether the object has been pulled (3rd bit) Additional bits are used for reference counting.

Friends

class Wrapper
class ProtoWrapper
class RefWrapper
class LiveWrapper
class Collection
class BaseIter
class BaseList
class BaseElement
class BaseRefElement
class BaseMapRoot
class Zombie
class UntypedAssign
ostream & operator<< (ostream &o, const Listable &l)
void _listable_set_wrapper (Listable *obj, Wrapper *l)
void _listable_ref_dec (Listable *obj)
void * operator new (unsigned int) throw (std::bad_alloc)
void operator delete (void *) throw ()
void dec_refs_delete_or_zombie (Listable *ptr)
 "Clean up:C++ garbage collection" _Byte_, 21(1):157(2)
void add_zombie_list (Listable *ptr)

Detailed Description

< base class which allows classes to be used in collections

Polaris Base

See also:
Listable.h

Listable.h

Listable.cc

Overview

The Listable class must be the base class of any object which can be placed in a collection. Listable contributes data and methods required for use by all Collections (including Elements and Map structures).

Description

The underlying formula for the Collection hierarchy is that Collections hold objects called "wrappers" rather than the objects themselves. When an object is placed in a Collection, a new wrapper is created and the object is manipulated through the wrapper. The Listable class contributes a standardized interface to the Wrapper classes and the Collection hierarchy.

The Listable class contributes only two pieces of data: a pointer to the wrapper which will "own" it and a structure which allows all references to the Listable object to be properly counted and also contains a number of other flags:

refs: Number of pointers to the object from the Collection hierarchy (including the object's own wrapper). Reference counting is required to ensure that an object is not prematurely deleted. If an object is deleted and there are still references to the object, the object will be turned into a Zombie (a stripped-down object containing nothing but the Listable info which ensures that any future attempts to access the object are caught--see Zombie man page). Further, if an object has been placed in a collection and there are NO references to it, it is automatically deleted. valid_bit: Is this a valid object or is this a Zombie? collect_bit: Is this object in a collection? pulled_bit: Has this object been pulled by an assign operation?

The vast majority of the methods associated with the Listable class are non-public and should only be used by the Collection hierarchy routines.

Definition at line 123 of file Listable.h.


Constructor & Destructor Documentation

Listable::Listable  ) 
 

... cout<<"+Listable="<<this<<endl;

... not pulled(), not in_collection() , valid()

Definition at line 41 of file Listable.cc.

References packed_object::_collect_bit, _flags, packed_object::_pulled_bit, packed_object::_refs, packed_object::_valid_bit, False, register_instance(), and True.

Listable::~Listable  )  [virtual]
 

Definition at line 62 of file Listable.cc.

References _flags, packed_object::_pulled_bit, assert_free(), and unregister_instance().


Member Function Documentation

void Listable::assert_free  )  [inline]
 

Abort with a p-assert if the wrapper-pointer is NULL.

< No longer an error -- now results in turning into a Zombie p_assert(_flags._refs == 0, "Listable::assert_free(): " "Attempt to delete object with outstanding references");

Definition at line 271 of file Listable.h.

Referenced by Definition::rename(), and ~Listable().

int Listable::fingerprint_ok  )  [inline]
 

return the fingerprint of the list (used for debugging).

Definition at line 282 of file Listable.h.

Referenced by StmtList::del(), HeapElem::print(), print(), and HeapStats::print_memory_leaks().

Listable * Listable::next_ref  )  const
 

return the next element of the list.

Reimplemented in NextEntry, and Statement.

Definition at line 88 of file Listable.cc.

References Wrapper::next_ref(), and Wrapper::object().

Referenced by _calc_loop_range(), _int_diff(), cdg2cfg(), convert_arithmetic_if(), enforce_standard_within_bounds(), get_in(), get_in_out(), get_out(), localize_goto(), Statement::next_ref(), parallel_loop_inside(), remove_postamble(), and unroll_loop().

Listable * Listable::prev_ref  )  const
 

void operator delete (void * ptr, size_t size);

Reimplemented in Statement.

Definition at line 100 of file Listable.cc.

References Wrapper::object(), and Wrapper::prev_ref().

Referenced by convert_arithmetic_if(), StmtList::del(), enforce_standard_within_bounds(), has_known_iteration_space(), in_parallel_region(), peel_loop_first(), Statement::prev_ref(), stripmine_horiz_loop(), stripmine_vert_loop(), and unroll_loop().

void Listable::operator delete void *  ptr,
unsigned int  size
 

void * operator new (size_t size);

2.Replaced operator delete with Zombie conversion. WHY: 1,2.This change, in combination with changes in dec_refs_delete_or_zombie, solve the cyclic reference count problem. (Please see Modification history for dec_refs_delete_or_zombie)

... since Zombie::CTOR zeroes this

... to restore them to previous values.

Reimplemented in Zombie.

Definition at line 135 of file Listable.cc.

References _flags, packed_object::_refs, context, count(), and remember_memory().

void* Listable::operator new unsigned int  size  ) 
 

Overload the new/delete for garbage collection.

Reimplemented in Zombie.

virtual Listable* Listable::listable_clone  )  const [pure virtual]
 

Copy and return a pointer to any Listable item (MUST be implemented correctly by subclasses for List copy functions to work).

Implemented in AbstractAccess, AccessDimension, ArrayBounds, ArrayDims, BinRep, CDElement, CDGNode, CDRepositoryEntry, CDRegion, myWorkSpace, BaseElement, BMNode, BaseRefElement, Database< S, T >, DatabaseData, Element< T >, KeyMapData, KeyDatabase< S, T >, MapData, KeyMap< S, T >, KeyMapData, List< T >, Map< S, T >, MapData, RefDatabase< S, T >, RefElement< T >, RefKeyDatabase< S, T >, MapData, RefKeyMap< S, T >, RefList< T >, IntElem, RefMap< S, T >, RefMapData, RefSet< T >, Set< T >, Zombie, CallSite, IPCPConstants, IPCPCallData, IPCPProcData, ReturnJumpFunction, JumpFunction, PropConstValue, PropConstWS, UnionFindSetElem, Data, ElementDV, DVfield, ActiveArc, DeadCodeElimWS, Definition, DefLoc, DefLocMap, DirectedEdge, AssertComment, AssertConcurrentRoutine, AssertCritical, AssertDepIO, AssertDepOverlap, AssertDepROvsRW, AssertDepRWvsWF, AssertDepWFvsRO, AssertDynLastValue, AssertEpilogue, AssertFirstValue, AssertForward, AssertInduction, AssertInline, AssertInstrument, Assertion, AssertLastValue, AssertLoopLabel, AssertMayMod, AssertNoDependence, AssertNoInline, AssertNoLastValue, AssertNoMod, AssertNoPutGet, AssertNoWait, AssertOverlap, AssertOverlapSort, AssertParallel, AssertParallelCondition, AssertPartialFirstValue, AssertPartialReduction, AssertPostamble, AssertPreamble, AssertPrivate, AssertPrivateDescr, AssertPrivateRefs, AssertPrivatizable, AssertPrologue, AssertRangeWritten, AssertReadOnlyRefs, AssertRecursiveInline, AssertReductDescr, AssertReduction, AssertRelation, AssertRTShadow, AssertRunTimeTest, AssertSafeCondition, AssertSchedule, AssertSerial, AssertShared, AssertSharedRefs, AssertSideEffectFree, AssertSubst, AssertTestMonotone, AssertUnknownShared, Directive, RecurrenceAssertion, DominatorWorkSpace, EquivalenceMember, ExprCountElem, ExprExponentElem, Expression, Format, GSAPathExpr, GSAPathMap, GSAWorkSpace, HeapElem, InlineObject, InlineWorkSpace, IntElem, IntraPCodeDomain, InterPCodeDomain, GlobalDefSite, LongElem, Monotonicity, pDominatorWorkSpace, AIRangeDict, ControlRangeDict, ExprSet, GSAControlRangeData, GSAControlRangeDict, GSARangeOrData, GSAFullRangeData, GSAFullRangeDict, PropCtrlRangeWS, PropRangeEdge, PropRangeWS, RangeAccessor, CompareData, SSAControlRangeData, SSAControlRangeDict, SSARangeOrData, SSAFullRangeData, SSAFullRangeDict, StmtTopOrderWS, StmtRanges, StmtRefRanges, RegistryElem, SharedBounds, SimBiGraph, SimBiGraphIterator, SimEdge, SimEdgeKernel, SimGraph, SimGraphIterator, SSAProgramUnit, s_control_type, Statement, StmtList, StringElem, SymbolAccess, SymbolAccessRef, IntElem, IntElem, TopSortNode, TranslateObject::SymRefElem, TranslateObject, UBiEdge, UBiGraph, UBiGraphIterator, UEdge, UGraph, UGraphIterator, ArgExprElem, MyWorkSpace, WorkSpace, MyWorkSpace, Database< String, VoidPtrDef >, Database< Statement *, IntElem >, Database< void *, IntElem >, Database< String, T >, Database< String, CommonBlock >, Database< int, Format >, Database< String, StmtRanges >, Database< String, IPCPProcData >, Database< String, IntElem >, Database< String, ProgramUnit >, Database< String, RefMap< Symbol, Expression > >, Database< String, Symbol >, Database< String, Equivalence >, Database< String, Namelist >, Database< String, IPCPCallData >, Database< ProgramUnit *, IntraPCodeDomain >, Database< String, BinRep >, Database< S, S >, Element< Expression >, List< IntElem >, List< IPCPConstants >, List< CDElement >, List< Statement >, List< WorkSpace >, List< StringElem >, List< ArgExprElem >, List< AccessDimension >, List< SharedBounds >, List< Data >, List< PropConstValue >, List< PropRangeEdge >, List< EquivalenceMember >, List< ArrayBounds >, List< s_control_type >, List< ActiveArc >, List< SimEdge >, List< ElementDV >, List< Assertion >, List< DVfield >, List< CDRepositoryEntry >, List< Expression >, List< AbstractAccess >, List< GSAPathExpr >, List< BinRep >, Map< Expression, IntElem >, Map< Symbol, IntElem >, Map< Statement, GSAControlRangeData >, Map< Symbol, GSAFullRangeData >, Map< Symbol, Expression >, Map< Statement, GSAPathMap >, Map< Symbol, GSARangeOrData >, Map< Symbol, DefLoc >, Map< HeapObject, HeapElem >, Map< Symbol, Set< Expression > >, Map< Symbol, RefSet< Expression > >, Map< Statement, InlineObject >, Map< Symbol, SSAFullRangeData >, Map< Symbol, UnionFindSetElem >, Map< Symbol, SymbolAccessRef >, Map< Symbol, SymbolAccess >, Map< Symbol, SymRefElem >, Map< Statement, Map< Symbol, Set< Expression > > >, Map< Symbol, CompareData >, Map< Statement, RefMap< Symbol, Expression > >, Map< Statement, SSAControlRangeData >, Map< Symbol, SSARangeOrData >, Map< Symbol, AbstractAccess >, Map< S, S >, RefDatabase< int, Statement >, RefDatabase< String, ProgramUnit >, RefElement< InlineWorkSpace >, RefElement< Statement >, RefElement< Listable >, RefElement< Symbol >, RefElement< AbstractAccess >, RefList< Statement >, RefList< Assertion >, RefList< Expression >, RefList< Symbol >, RefList< AbstractAccess >, RefMap< Symbol, Expression >, RefMap< Symbol, Statement >, RefMap< Format, Format >, RefMap< Symbol, Symbol >, RefSet< GSAFullRangeData >, RefSet< ProgramUnit >, RefSet< Statement >, RefSet< PropRangeEdge >, RefSet< SSAFullRangeData >, RefSet< Expression >, RefSet< Symbol >, Set< CallSite >, Set< Symbol * >, and Set< BinRep >.

Referenced by LiveWrapper::clone(), and BaseList::operator=().

virtual void Listable::print ostream &  o  )  const [pure virtual]
 

Implemented in AbstractAccess, AccessDimension, ArrayBounds, ArrayDims, BinRep, CDElement, CDGNode, CDRepositoryEntry, CDRegion, myWorkSpace, BaseElement, BMNode, BaseRefElement, Database< S, T >, DatabaseData, Element< T >, KeyMapData, KeyDatabase< S, T >, MapData, KeyMap< S, T >, KeyMapData, List< T >, Map< S, T >, MapData, RefDatabase< S, T >, RefElement< T >, RefKeyDatabase< S, T >, MapData, RefKeyMap< S, T >, RefList< T >, IntElem, RefMap< S, T >, RefMapData, RefSet< T >, Set< T >, Zombie, CommonBlock, CallSite, IPCPConstants, IPCPCallData, IPCPProcData, ReturnJumpFunction, PropConstValue, PropConstWS, UnionFindSetElem, Data, ElementDV, DVfield, ActiveArc, DeadCodeElimWS, Declaration, Definition, DefLoc, DefLocMap, Dictionary< T >, DirectedEdge, AssertComment, AssertConcurrentRoutine, AssertCritical, AssertDepIO, AssertDepOverlap, AssertDepROvsRW, AssertDepRWvsWF, AssertDepWFvsRO, AssertDynLastValue, AssertEpilogue, AssertFirstValue, AssertForward, AssertInduction, AssertInline, AssertInstrument, Assertion, AssertionList, AssertLastValue, AssertLoopLabel, AssertMayMod, AssertNoDependence, AssertNoInline, AssertNoLastValue, AssertNoMod, AssertNoPutGet, AssertNoWait, AssertOverlap, AssertOverlapSort, AssertParallel, AssertParallelCondition, AssertPartialFirstValue, AssertPartialReduction, AssertPostamble, AssertPreamble, AssertPrivate, AssertPrivateDescr, AssertPrivateRefs, AssertPrivatizable, AssertPrologue, AssertRangeWritten, AssertReadOnlyRefs, AssertRecursiveInline, AssertReductDescr, AssertReduction, AssertRelation, AssertRTShadow, AssertRunTimeTest, AssertSafeCondition, AssertSchedule, AssertSerial, AssertShared, AssertSharedRefs, AssertSideEffectFree, AssertSubst, AssertTestMonotone, AssertUnknownShared, Directive, RecurrenceAssertion, DominatorWorkSpace, EntryPoints, EquivalenceMember, Equivalence, DistributeExpr, ExprCountElem, ExprExponentElem, Expression, Format, FormatDB, GSAPathExpr, GSAPathMap, GSAWorkSpace, HeapElem, InlineObject, InlineWorkSpace, IntDef, IntElem, IntraPCodeDomain, InterPCodeDomain, GlobalDefSite, LongElem, Monotonicity, Namelist, pDominatorWorkSpace, PhiPlaceDef, Program, ProgramUnit, AIRangeDict, BaseStmtRanges, ControlRangeDict, ExprSet, GSAControlRangeData, GSAControlRangeDict, GSARangeOrData, GSAFullRangeData, GSAFullRangeDict, PropCtrlRangeWS, PropRangeEdge, PropRangeWS, RangeAccessor, CompareData, RangeComparator, SSAControlRangeData, SSAControlRangeDict, SSARangeOrData, SSAFullRangeData, SSAFullRangeDict, StmtTopOrderWS, RegistryElem, SharedBounds, SharedDims, SimBiGraph, SimBiGraphIterator, SimEdge, SimEdgeKernel, SimGraph, SimGraphIterator, SSAProgramUnit, s_control_type, NextEntry, Statement, StmtList, StringElem, BlockDataSymbol, FunctionSymbol, NamelistSymbol, PointerSymbol, ProgramSymbol, SubroutineSymbol, Symbol, SymbolicConstantSymbol, VariableSymbol, SymbolAccess, SymbolAccessRef, MapData, IntElem, IntElem, TopSortNode, TranslateObject::SymRefElem, TranslateObject, UBiEdge, UBiGraph, UBiGraphIterator, UEdge, UGraph, UGraphIterator, ArgExprElem, MyWorkSpace, WorkSpace, MyWorkSpace, Database< String, VoidPtrDef >, Database< Statement *, IntElem >, Database< void *, IntElem >, Database< String, T >, Database< String, CommonBlock >, Database< int, Format >, Database< String, StmtRanges >, Database< String, IPCPProcData >, Database< String, IntElem >, Database< String, ProgramUnit >, Database< String, RefMap< Symbol, Expression > >, Database< String, Symbol >, Database< String, Equivalence >, Database< String, Namelist >, Database< String, IPCPCallData >, Database< ProgramUnit *, IntraPCodeDomain >, Database< String, BinRep >, Database< S, S >, Element< Expression >, List< IntElem >, List< IPCPConstants >, List< CDElement >, List< Statement >, List< WorkSpace >, List< StringElem >, List< ArgExprElem >, List< AccessDimension >, List< SharedBounds >, List< Data >, List< PropConstValue >, List< PropRangeEdge >, List< EquivalenceMember >, List< ArrayBounds >, List< s_control_type >, List< ActiveArc >, List< SimEdge >, List< ElementDV >, List< Assertion >, List< DVfield >, List< CDRepositoryEntry >, List< Expression >, List< AbstractAccess >, List< GSAPathExpr >, List< BinRep >, Map< Expression, IntElem >, Map< Symbol, IntElem >, Map< Statement, GSAControlRangeData >, Map< Symbol, GSAFullRangeData >, Map< Symbol, Expression >, Map< Statement, GSAPathMap >, Map< Symbol, GSARangeOrData >, Map< Symbol, DefLoc >, Map< HeapObject, HeapElem >, Map< Symbol, Set< Expression > >, Map< Symbol, RefSet< Expression > >, Map< Statement, InlineObject >, Map< Symbol, SSAFullRangeData >, Map< Symbol, UnionFindSetElem >, Map< Symbol, SymbolAccessRef >, Map< Symbol, SymbolAccess >, Map< Symbol, SymRefElem >, Map< Statement, Map< Symbol, Set< Expression > > >, Map< Symbol, CompareData >, Map< Statement, RefMap< Symbol, Expression > >, Map< Statement, SSAControlRangeData >, Map< Symbol, SSARangeOrData >, Map< Symbol, AbstractAccess >, Map< S, S >, RefDatabase< int, Statement >, RefDatabase< String, ProgramUnit >, RefElement< InlineWorkSpace >, RefElement< Statement >, RefElement< Listable >, RefElement< Symbol >, RefElement< AbstractAccess >, RefList< Statement >, RefList< Assertion >, RefList< Expression >, RefList< Symbol >, RefList< AbstractAccess >, RefMap< Symbol, Expression >, RefMap< Symbol, Statement >, RefMap< Format, Format >, RefMap< Symbol, Symbol >, RefSet< GSAFullRangeData >, RefSet< ProgramUnit >, RefSet< Statement >, RefSet< PropRangeEdge >, RefSet< SSAFullRangeData >, RefSet< Expression >, RefSet< Symbol >, Set< CallSite >, Set< Symbol * >, Set< BinRep >, Dictionary< CommonBlock >, Dictionary< VoidPtrDef >, Dictionary< Equivalence >, Dictionary< Symbol >, and Dictionary< Namelist >.

Referenced by main(), operator<<(), Collection::print(), BaseRefElement::print(), BaseElement::print(), and Collection::structures_OK().


Friends And Related Function Documentation

friend class Wrapper [friend]
 

Definition at line 132 of file Listable.h.

friend class ProtoWrapper [friend]
 

Definition at line 133 of file Listable.h.

friend class RefWrapper [friend]
 

Definition at line 134 of file Listable.h.

friend class LiveWrapper [friend]
 

Definition at line 135 of file Listable.h.

friend class Collection [friend]
 

Definition at line 136 of file Listable.h.

friend class BaseIter [friend]
 

Definition at line 137 of file Listable.h.

friend class BaseList [friend]
 

Definition at line 138 of file Listable.h.

friend class BaseElement [friend]
 

Definition at line 139 of file Listable.h.

friend class BaseRefElement [friend]
 

Definition at line 140 of file Listable.h.

friend class BaseMapRoot [friend]
 

Definition at line 141 of file Listable.h.

friend class Zombie [friend]
 

Definition at line 142 of file Listable.h.

friend class UntypedAssign [friend]
 

Definition at line 143 of file Listable.h.

ostream& operator<< ostream &  o,
const Listable l
[friend]
 

Definition at line 238 of file Listable.h.

void _listable_set_wrapper Listable obj,
Wrapper l
[friend]
 

Definition at line 243 of file Listable.h.

Referenced by BaseElement::~BaseElement().

void _listable_ref_dec Listable obj  )  [friend]
 

Definition at line 248 of file Listable.h.

Referenced by BaseRefElement::~BaseRefElement().

void * Listable::operator new unsigned int  size  )  throw (std::bad_alloc) [friend]
 

Reimplemented in Zombie.

Definition at line 258 of file HeapStats.cc.

void operator delete void *  p  )  throw () [friend]
 

Definition at line 269 of file HeapStats.cc.

void dec_refs_delete_or_zombie Listable ptr  )  [friend]
 

"Clean up:C++ garbage collection" _Byte_, 21(1):157(2)

First, the reference count is decremented. If there are still outstanding references, the object is turned into a Zombie (in order to catch any future attempts to reference the object), otherwise it is deleted. This is a function rather than a method because the only reasonable location for this method is in Listable and it is too chancy having a method changing its own type.

Definition at line 74 of file Zombie.cc.

Referenced by BaseElement::del(), BaseElement::modify(), and BaseElement::~BaseElement().

void add_zombie_list Listable ptr  )  [friend]
 

Definition at line 53 of file Zombie.cc.


Member Data Documentation

struct packed_object Listable::_flags [protected]
 

Contains flags for valid object and a flag determining (1st bit) whether the object is in an a collection (2nd bit) whether the object has been pulled (3rd bit) Additional bits are used for reference counting.

Definition at line 165 of file Listable.h.

Referenced by Listable(), operator delete(), LiveWrapper::zombie_object(), and ~Listable().


The documentation for this class was generated from the following files:
 © 1995-2005 University of Illinois, Urbana-Champaign. All rights reserved.  Fri Mar 25 23:07:45 2005