Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/dotnet/runtime.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAndrew Au <andrewau@microsoft.com>2021-03-16 22:34:56 +0300
committerGitHub <noreply@github.com>2021-03-16 22:34:56 +0300
commited305e4ca46d20e05f79dc339b34d71ca5ba6fdc (patch)
tree3df018a9bbdb7885fa1cc5bdf174f67acf1be6e6 /src/coreclr/gc
parent0533a943611d4c7149c3fa9ec15b1320b4890bc5 (diff)
Do not pin free object for STRESS_REGIONS (#49547)
Diffstat (limited to 'src/coreclr/gc')
-rw-r--r--src/coreclr/gc/gc.cpp17
1 files changed, 9 insertions, 8 deletions
diff --git a/src/coreclr/gc/gc.cpp b/src/coreclr/gc/gc.cpp
index f5fb30c3f5d..9307b16a9a5 100644
--- a/src/coreclr/gc/gc.cpp
+++ b/src/coreclr/gc/gc.cpp
@@ -22994,18 +22994,19 @@ void gc_heap::mark_phase (int condemned_gen_number, BOOL mark_only_p)
if ((num_gen0_regions % pinning_seg_interval) == 0)
{
int align_const = get_alignment_constant (TRUE);
- // Pinning the first object in the region.
- uint8_t* obj_to_pin = heap_segment_mem (gen0_region);
- pin_by_gc (obj_to_pin);
-
- obj_to_pin += Align (size (obj_to_pin), align_const);
- // Pinning the middle object in the region.
+ // Pinning the first and the middle object in the region.
+ uint8_t* boundary = heap_segment_mem (gen0_region);
+ uint8_t* obj_to_pin = boundary;
+ int num_pinned_objs = 0;
while (obj_to_pin < heap_segment_allocated (gen0_region))
{
- if (obj_to_pin > region_mid)
+ if (obj_to_pin >= boundary && !((CObjectHeader*)obj_to_pin)->IsFree())
{
pin_by_gc (obj_to_pin);
- break;
+ num_pinned_objs++;
+ if (num_pinned_objs >= 2)
+ break;
+ boundary += (gen0_region_size / 2) + 1;
}
obj_to_pin += Align (size (obj_to_pin), align_const);
}