Cleanup hashBvGlobalData
authorMike Danes <onemihaid@hotmail.com>
Sat, 16 Jun 2018 19:21:40 +0000 (22:21 +0300)
committerMike Danes <onemihaid@hotmail.com>
Sat, 30 Jun 2018 19:34:09 +0000 (22:34 +0300)
Each compiler object contains a hashBvGlobalData that's 80 bytes in size. Only 16 bytes are actually used - the hash and node free lists.
* hbvFreeVectorList is supposed to be used by hashBv::freeVector but nothing calls that and getNewVector does not attempt to use the free list
* hbvHashSizeLog2 is always 0
* hashBvNextIterator is used only in HbvNext and that function is never used

Commit migrated from https://github.com/dotnet/coreclr/commit/235bc725acdf8a66b19f1c51cfe83f573562f80d

src/coreclr/src/jit/hashbv.cpp
src/coreclr/src/jit/hashbv.h

index db8dda1..6aee93e 100644 (file)
@@ -358,7 +358,7 @@ bool hashBvNode::sameAs(hashBvNode* other)
 hashBv::hashBv(Compiler* comp)
 {
     this->compiler      = comp;
-    this->log2_hashSize = globalData()->hbvHashSizeLog2;
+    this->log2_hashSize = 0;
 
     int hts = hashtable_size();
     nodeArr = getNewVector(hts);
@@ -424,20 +424,6 @@ hashBv*& hashBv::hbvFreeList(hashBvGlobalData* data)
     return data->hbvFreeList;
 }
 
-void hashBv::freeVector(hashBvNode* vect, int vectorLength)
-{
-    // not enough space to do anything with it
-    if (vectorLength < 2)
-    {
-        return;
-    }
-
-    hbvFreeListNode* f              = (hbvFreeListNode*)vect;
-    f->next                         = globalData()->hbvFreeVectorList;
-    globalData()->hbvFreeVectorList = f;
-    f->size                         = vectorLength;
-}
-
 void hashBv::hbvFree()
 {
     Compiler* comp = this->compiler;
@@ -547,7 +533,6 @@ void hashBv::Resize(int newSize)
         return;
     }
 
-    int oldSizeLog2  = log2_hashSize;
     int log2_newSize = genLog2((unsigned)newSize);
 
     hashBvNode** newNodes = this->getNewVector(newSize);
@@ -1297,7 +1282,6 @@ bool hashBv::MultiTraverseLHSBigger(hashBv* other)
 
     // this is larger
     hashBvNode*** cursors;
-    int           shiftFactor     = this->log2_hashSize - other->log2_hashSize;
     int           expansionFactor = hts / ots;
     cursors                       = (hashBvNode***)alloca(expansionFactor * sizeof(void*));
 
@@ -2016,12 +2000,3 @@ more_data:
         goto more_data;
     }
 }
-
-indexType HbvNext(hashBv* bv, Compiler* comp)
-{
-    if (bv)
-    {
-        bv->globalData()->hashBvNextIterator.initFrom(bv);
-    }
-    return bv->globalData()->hashBvNextIterator.nextBit();
-}
index cadb182..b07b3d8 100644 (file)
@@ -186,8 +186,6 @@ public:
 
 public:
     hashBv(Compiler* comp);
-    hashBv(hashBv* other);
-    // hashBv() {}
     static hashBv* Create(Compiler* comp);
     static void Init(Compiler* comp);
     static hashBv* CreateFrom(hashBv* other, Compiler* comp);
@@ -215,11 +213,8 @@ private:
 
     // maintain free lists for vectors
     hashBvNode** getNewVector(int vectorLength);
-    void freeVector(hashBvNode* vect, int vectorLength);
     int getNodeCount();
 
-    hashBvNode* getFreeList();
-
 public:
     inline hashBvNode* getOrAddNodeForIndex(indexType index)
     {
@@ -281,16 +276,6 @@ public:
 // --------------------------------------------------------------------
 // --------------------------------------------------------------------
 
-class hbvFreeListNode
-{
-public:
-    hbvFreeListNode* next;
-    int              size;
-};
-
-// --------------------------------------------------------------------
-// --------------------------------------------------------------------
-
 class hashBvIterator
 {
 public:
@@ -318,17 +303,10 @@ class hashBvGlobalData
     friend class hashBv;
     friend class hashBvNode;
 
-    hashBvNode*      hbvNodeFreeList;
-    hashBv*          hbvFreeList;
-    unsigned short   hbvHashSizeLog2;
-    hbvFreeListNode* hbvFreeVectorList;
-
-public:
-    hashBvIterator hashBvNextIterator;
+    hashBvNode* hbvNodeFreeList;
+    hashBv*     hbvFreeList;
 };
 
-indexType HbvNext(hashBv* bv, Compiler* comp);
-
 // clang-format off
 #define FOREACH_HBV_BIT_SET(index, bv) \
     { \