@@ -941,25 +941,22 @@ hash_search_with_hash_value(HTAB *hashp,
941
941
case HASH_REMOVE :
942
942
if (currBucket != NULL )
943
943
{
944
- /* use volatile pointer to prevent code rearrangement */
945
- volatile HASHHDR * hctlv = hctl ;
946
-
947
944
/* if partitioned, must lock to touch nentries and freeList */
948
- if (IS_PARTITIONED (hctlv ))
949
- SpinLockAcquire (& hctlv -> mutex );
945
+ if (IS_PARTITIONED (hctl ))
946
+ SpinLockAcquire (& hctl -> mutex );
950
947
951
- Assert (hctlv -> nentries > 0 );
952
- hctlv -> nentries -- ;
948
+ Assert (hctl -> nentries > 0 );
949
+ hctl -> nentries -- ;
953
950
954
951
/* remove record from hash bucket's chain. */
955
952
* prevBucketPtr = currBucket -> link ;
956
953
957
954
/* add the record to the freelist for this table. */
958
- currBucket -> link = hctlv -> freeList ;
959
- hctlv -> freeList = currBucket ;
955
+ currBucket -> link = hctl -> freeList ;
956
+ hctl -> freeList = currBucket ;
960
957
961
- if (IS_PARTITIONED (hctlv ))
962
- SpinLockRelease (& hctlv -> mutex );
958
+ if (IS_PARTITIONED (hctl ))
959
+ SpinLockRelease (& hctl -> mutex );
963
960
964
961
/*
965
962
* better hope the caller is synchronizing access to this
@@ -1180,38 +1177,37 @@ hash_update_hash_key(HTAB *hashp,
1180
1177
static HASHBUCKET
1181
1178
get_hash_entry (HTAB * hashp )
1182
1179
{
1183
- /* use volatile pointer to prevent code rearrangement */
1184
- volatile HASHHDR * hctlv = hashp -> hctl ;
1180
+ HASHHDR * hctl = hashp -> hctl ;
1185
1181
HASHBUCKET newElement ;
1186
1182
1187
1183
for (;;)
1188
1184
{
1189
1185
/* if partitioned, must lock to touch nentries and freeList */
1190
- if (IS_PARTITIONED (hctlv ))
1191
- SpinLockAcquire (& hctlv -> mutex );
1186
+ if (IS_PARTITIONED (hctl ))
1187
+ SpinLockAcquire (& hctl -> mutex );
1192
1188
1193
1189
/* try to get an entry from the freelist */
1194
- newElement = hctlv -> freeList ;
1190
+ newElement = hctl -> freeList ;
1195
1191
if (newElement != NULL )
1196
1192
break ;
1197
1193
1198
1194
/* no free elements. allocate another chunk of buckets */
1199
- if (IS_PARTITIONED (hctlv ))
1200
- SpinLockRelease (& hctlv -> mutex );
1195
+ if (IS_PARTITIONED (hctl ))
1196
+ SpinLockRelease (& hctl -> mutex );
1201
1197
1202
- if (!element_alloc (hashp , hctlv -> nelem_alloc ))
1198
+ if (!element_alloc (hashp , hctl -> nelem_alloc ))
1203
1199
{
1204
1200
/* out of memory */
1205
1201
return NULL ;
1206
1202
}
1207
1203
}
1208
1204
1209
1205
/* remove entry from freelist, bump nentries */
1210
- hctlv -> freeList = newElement -> link ;
1211
- hctlv -> nentries ++ ;
1206
+ hctl -> freeList = newElement -> link ;
1207
+ hctl -> nentries ++ ;
1212
1208
1213
- if (IS_PARTITIONED (hctlv ))
1214
- SpinLockRelease (& hctlv -> mutex );
1209
+ if (IS_PARTITIONED (hctl ))
1210
+ SpinLockRelease (& hctl -> mutex );
1215
1211
1216
1212
return newElement ;
1217
1213
}
@@ -1536,8 +1532,7 @@ seg_alloc(HTAB *hashp)
1536
1532
static bool
1537
1533
element_alloc (HTAB * hashp , int nelem )
1538
1534
{
1539
- /* use volatile pointer to prevent code rearrangement */
1540
- volatile HASHHDR * hctlv = hashp -> hctl ;
1535
+ HASHHDR * hctl = hashp -> hctl ;
1541
1536
Size elementSize ;
1542
1537
HASHELEMENT * firstElement ;
1543
1538
HASHELEMENT * tmpElement ;
@@ -1548,7 +1543,7 @@ element_alloc(HTAB *hashp, int nelem)
1548
1543
return false;
1549
1544
1550
1545
/* Each element has a HASHELEMENT header plus user data. */
1551
- elementSize = MAXALIGN (sizeof (HASHELEMENT )) + MAXALIGN (hctlv -> entrysize );
1546
+ elementSize = MAXALIGN (sizeof (HASHELEMENT )) + MAXALIGN (hctl -> entrysize );
1552
1547
1553
1548
CurrentDynaHashCxt = hashp -> hcxt ;
1554
1549
firstElement = (HASHELEMENT * ) hashp -> alloc (nelem * elementSize );
@@ -1567,15 +1562,15 @@ element_alloc(HTAB *hashp, int nelem)
1567
1562
}
1568
1563
1569
1564
/* if partitioned, must lock to touch freeList */
1570
- if (IS_PARTITIONED (hctlv ))
1571
- SpinLockAcquire (& hctlv -> mutex );
1565
+ if (IS_PARTITIONED (hctl ))
1566
+ SpinLockAcquire (& hctl -> mutex );
1572
1567
1573
1568
/* freelist could be nonempty if two backends did this concurrently */
1574
- firstElement -> link = hctlv -> freeList ;
1575
- hctlv -> freeList = prevElement ;
1569
+ firstElement -> link = hctl -> freeList ;
1570
+ hctl -> freeList = prevElement ;
1576
1571
1577
- if (IS_PARTITIONED (hctlv ))
1578
- SpinLockRelease (& hctlv -> mutex );
1572
+ if (IS_PARTITIONED (hctl ))
1573
+ SpinLockRelease (& hctl -> mutex );
1579
1574
1580
1575
return true;
1581
1576
}
0 commit comments