Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 6b0830a

Browse files
authored
Use volatile load to read brick table entries (#17718)
Fixes #17716
1 parent bdfdfeb commit 6b0830a

File tree

2 files changed

+9
-15
lines changed

2 files changed

+9
-15
lines changed

src/gc/gc.cpp

Lines changed: 8 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6594,19 +6594,13 @@ void gc_heap::set_brick (size_t index, ptrdiff_t val)
65946594
}
65956595

65966596
inline
6597-
int gc_heap::brick_entry (size_t index)
6597+
int gc_heap::get_brick_entry (size_t index)
65986598
{
6599-
int val = brick_table [index];
6600-
if (val == 0)
6601-
{
6602-
return -32768;
6603-
}
6604-
else if (val < 0)
6605-
{
6606-
return val;
6607-
}
6608-
else
6609-
return val-1;
6599+
#ifdef MULTIPLE_HEAPS
6600+
return VolatileLoadWithoutBarrier(&brick_table [index]);
6601+
#else
6602+
return brick_table[index];
6603+
#endif
66106604
}
66116605

66126606

@@ -17155,7 +17149,7 @@ uint8_t* gc_heap::find_object (uint8_t* interior, uint8_t* low)
1715517149
#endif //MULTIPLE_HEAPS
1715617150
#endif //FFIND_OBJECT
1715717151

17158-
int brick_entry = brick_table [brick_of (interior)];
17152+
int brick_entry = get_brick_entry(brick_of (interior));
1715917153
if (brick_entry == 0)
1716017154
{
1716117155
// this is a pointer to a large object
@@ -27326,7 +27320,7 @@ uint8_t* gc_heap::find_first_object (uint8_t* start, uint8_t* first_object)
2732627320
{
2732727321
break;
2732827322
}
27329-
if ((brick_entry = brick_table [ prev_brick ]) >= 0)
27323+
if ((brick_entry = get_brick_entry(prev_brick)) >= 0)
2733027324
{
2733127325
break;
2733227326
}

src/gc/gcpriv.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1733,7 +1733,7 @@ class gc_heap
17331733
PER_HEAP
17341734
void set_brick (size_t index, ptrdiff_t val);
17351735
PER_HEAP
1736-
int brick_entry (size_t index);
1736+
int get_brick_entry (size_t index);
17371737
#ifdef MARK_ARRAY
17381738
PER_HEAP
17391739
unsigned int mark_array_marked (uint8_t* add);

0 commit comments

Comments
 (0)