Fixed a bug when expire registers.
authorZhigang Gong <zhigang.gong@linux.intel.com>
Tue, 19 Feb 2013 11:52:03 +0000 (19:52 +0800)
committerZhigang Gong <zhigang.gong@linux.intel.com>
Wed, 10 Apr 2013 06:52:33 +0000 (14:52 +0800)
The previous implementation forgot to change the head when
the to expired register is at the left side of the current
head. Thus the algorithm will be broken, as the algorithm need
the head has the smallest offset.

Without this patch, the register expireing doesn't work. Thus
any kernel function need more than 44 DWORD registers or 11
DWORD vec4 will fail to get registers.

The calculation is:

(Register file size / (type size * simdwidth) - special registers)
(4K / (4 * 16)) - 20 = 44

Signed-off-by: Zhigang Gong <zhigang.gong@linux.intel.com>
Reviewed-by: Homer Hsing <homer.xing@intel.com>
backend/src/backend/context.cpp

index 400c610..180e8bb 100644 (file)
@@ -200,17 +200,17 @@ namespace gbe
       GBE_ASSERT(prev->offset + prev->size <= offset);
       prev->next = newBlock;
       newBlock->prev = prev;
-    }
+    } else
+      this->head = newBlock;  // prev is NULL means newBlock should be the head.
+
     if (list) {
       GBE_ASSERT(offset + size <= list->offset);
       list->prev = newBlock;
       newBlock->next = list;
     }
 
-    // There were no block anymore
-    if (prev == NULL && list == NULL)
-      this->head = newBlock;
-    else {
+    if (prev != NULL || list != NULL)
+    {
       // Coalesce the blocks if possible
       this->coalesce(prev, newBlock);
       this->coalesce(newBlock, list);