[llvm-commits] [poolalloc] r66285 - in /poolalloc/trunk: include/dsa/DSNode.h lib/DSA/DataStructure.cpp

Gabor Greif ggreif at gmail.com
Fri Mar 6 16:24:58 PST 2009


On 6 Mrz., 20:05, John Criswell <crisw... at uiuc.edu> wrote:
> Author: criswell
> Date: Fri Mar  6 13:05:08 2009
> New Revision: 66285
>
> URL:http://llvm.org/viewvc/llvm-project?rev=66285&view=rev
> Log:
> Added missing methods to the specialization of the ilist for DSNodes.
> This makes the code compile (and hopefully work) with the new LLVM API.
> Reverted last change to DSNode constructors; it somehow intereferes with the
> ilist implementation.
>
> Modified:
>     poolalloc/trunk/include/dsa/DSNode.h
>     poolalloc/trunk/lib/DSA/DataStructure.cpp
>
> Modified: poolalloc/trunk/include/dsa/DSNode.h
> URL:http://llvm.org/viewvc/llvm-project/poolalloc/trunk/include/dsa/DSNod...
>
> =========================================================================== ===
> --- poolalloc/trunk/include/dsa/DSNode.h (original)
> +++ poolalloc/trunk/include/dsa/DSNode.h Fri Mar  6 13:05:08 2009
> @@ -434,6 +434,29 @@
>    void transferNodesFromList(iplist<DSNode, ilist_traits> &L2,
>                               ilist_iterator<DSNode> first,
>                               ilist_iterator<DSNode> last) {}
> +  DSNode *provideInitialHead() const {
> +    DSNode * sentinel = createSentinel();
> +    setPrev (sentinel, sentinel);
> +    return sentinel;
> +  }

By this you have decided to eagerly allocate a sentinel. Ok.

> +
> +  /// ensureHead - make sure that Head is either already
> +  /// initialized or assigned a fresh sentinel
> +  /// @return the sentinel
> +  static DSNode *ensureHead(DSNode *&Head) {
> +    if (!Head) {
> +      Head = createSentinel();
> +      noteHead (Head, Head);
> +      setNext(Head, Head);
> +      return Head;
> +    }

These above lines are not necessary. It is an ilist invariant
that a Head never goes back to NULL. And you have it non-null
by virtue of provideInitialHead().

> +    return getPrev(Head);

This line is still needed to get hold of the sentinel, in case
ilist chooses to change Head.

> +  }
> +
> +  /// noteHead - stash the sentinel into its default location
> +  static void noteHead(DSNode *NewHead, DSNode *Sentinel) {
> +    setPrev(NewHead, Sentinel);
> +  }

When ilist changes Head, this function gets called. Ok.
Of course, you could derive from default_ilist_traits, and
get this method inherited.

Cheers,

    Gabor


>  };
>
>  template<>
>
> Modified: poolalloc/trunk/lib/DSA/DataStructure.cpp
> URL:http://llvm.org/viewvc/llvm-project/poolalloc/trunk/lib/DSA/DataStruc...
>
> =========================================================================== ===
> --- poolalloc/trunk/lib/DSA/DataStructure.cpp (original)
> +++ poolalloc/trunk/lib/DSA/DataStructure.cpp Fri Mar  6 13:05:08 2009
> @@ -147,9 +147,6 @@
>    if (T) mergeTypeInfo(T, 0);
>    if (G) G->addNode(this);
>    ++NumNodeAllocated;
> -
> -  // Be good memory stewards and give our pointers a default of NULL
> -  Next = Prev = 0;
>  }
>
>  // DSNode copy constructor... do not copy over the referrers list!
> @@ -162,9 +159,6 @@
>      Links.resize(N.Links.size()); // Create the appropriate number of null links
>    G->addNode(this);
>    ++NumNodeAllocated;
> -
> -  // Be good memory stewards and give our pointers a default of NULL
> -  Next = Prev = 0;
>  }
>
>  DSNode::~DSNode() {
>
> _______________________________________________
> llvm-commits mailing list
> llvm-comm... at cs.uiuc.eduhttp://lists.cs.uiuc.edu/mailman/listinfo/llvm-commits




More information about the llvm-commits mailing list