summaryrefslogtreecommitdiff
path: root/lang/mozart/files/patch-platform-emulator-cac.cc
blob: f84e09eddc173bcf6b792ef82e0cfdbba69e2b34 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
--- ./platform/emulator/cac.cc.orig	Tue Apr  6 08:27:38 2004
+++ ./platform/emulator/cac.cc	Sat Sep  3 18:46:08 2005
@@ -15,8 +15,8 @@
  *    Organization or Person (Year(s))
  * 
  *  Last change:
- *    $Date: 2004/04/06 12:27:38 $ by $Author: popow $
- *    $Revision: 1.76 $
+ *    $Date: 2004/08/11 14:49:03 $ by $Author: popow $
+ *    $Revision: 1.76.2.2 $
  * 
  *  This file is part of Mozart, an implementation 
  *  of Oz 3:
@@ -552,9 +552,8 @@
   ret->nextGCStep();
   // an alive board must be copied at every GC step exactly once:
   Assert(ret->isEqGCStep(oz_getGCStep()));
-#else
-  ret->setCopyStep(oz_getCopyStep());
 #endif
+  ret->setCopyStep(oz_getCopyStep());
 
   cacStack.push(ret, PTR_BOARD);
 
@@ -764,52 +763,54 @@
   } else {
     // construct anew, GC"ing keys/values along;
     //
-    int oldSize, newSize;
-    DictNode* old;
-
-    //
-    oldSize = dictHTSizes[sizeIndex];
-    old = table;
+    const int tableSize = dictHTSizes[sizeIndex];
 
     // can be zero too:
-    int tableSize = (int) ((double) entries * GDT_IDEALENTRIES);
-    Assert(tableSize < oldSize);
-    sizeIndex--;
-    while (sizeIndex >= 0 && dictHTSizes[sizeIndex] >= tableSize)
-      sizeIndex--;
-    Assert(sizeIndex < 0 || dictHTSizes[sizeIndex] < tableSize);
-    sizeIndex++;
-    Assert(sizeIndex >= 0 && dictHTSizes[sizeIndex] >= tableSize);
+    int newTableSize = (int) ((double) entries / GDT_IDEALENTRIES);
+    int newSizeIndex = sizeIndex - 1;
+    DictNode* old = table;
+
+    //
+    Assert(newTableSize < tableSize);
+    while (newSizeIndex >= 0 && dictHTSizes[newSizeIndex] >= newTableSize)
+      newSizeIndex--;
+    Assert(newSizeIndex < 0 || dictHTSizes[newSizeIndex] < newTableSize);
+    newSizeIndex++;
+    Assert(newSizeIndex >= 0 && dictHTSizes[newSizeIndex] >= newTableSize);
     // Must not oscillate:
-    Assert(dictHTSizes[sizeIndex] < oldSize);
+    Assert(dictHTSizes[newSizeIndex] < tableSize);
     // Next GC should not attempt compactification:
-    Assert(entries >= (dictHTSizes[sizeIndex] / GDT_MINFULL));
+    Assert(entries >= (dictHTSizes[newSizeIndex] / GDT_MINFULL));
 
     // construct the table anew (keep the 'entries' counter);
-    tableSize = dictHTSizes[sizeIndex];
-    maxEntries = (int) (GDT_MAXENTRIES * tableSize);
-    table = (DictNode *) oz_heapMalloc(tableSize * sizeof(DictNode));
-    for (int i = tableSize; i--; )
-      (void) new (&table[i]) DictNode;
+    newTableSize = dictHTSizes[newSizeIndex];
+
+    //
+    DictHashTable *dht = new DictHashTable(*this);
+    // 'entries' copied;
+    an = (DictNode *) oz_heapMalloc(newTableSize * sizeof(DictNode));
+    for (int i = newTableSize; i--; )
+      (void) new (&an[i]) DictNode;
+    dht->table = an;
+    dht->sizeIndex = newSizeIndex;
+    dht->maxEntries = (int) (GDT_MAXENTRIES * newTableSize);
 
     //
-    for (int i = oldSize; i--; old++) {
+    for (int i = tableSize; i--; old++) {
       if (!old->isEmpty()) {
 	if (!old->isPointer()) {
-	  _cacDictEntry(old);
+	  dht->_cacDictEntry(old);
 	} else {
 	  DictNode *sptr = old->getDictNodeSPtr();
 	  DictNode *eptr = old->getDictNodeEPtr();
 	  do {
-	    _cacDictEntry(sptr++);
+	    dht->_cacDictEntry(sptr++);
 	  } while (sptr < eptr);
 	}
       }
     }
 
     //      
-    DictHashTable *dht = new DictHashTable(*this);
-    dht->table = table;
     return (dht);
   }
   Assert(0);