uint8_t* ha = g_gc_highest_address;
uint8_t* saved_g_lowest_address = min (start, g_gc_lowest_address);
uint8_t* saved_g_highest_address = max (end, g_gc_highest_address);
+ seg_mapping* new_seg_mapping_table = nullptr;
#ifdef BACKGROUND_GC
// This value is only for logging purpose - it's not necessarily exactly what we
// would commit for mark array but close enough for diagnostics purpose.
#ifdef GROWABLE_SEG_MAPPING_TABLE
{
- seg_mapping* new_seg_mapping_table = (seg_mapping*)(mem + st_table_offset_aligned);
+ new_seg_mapping_table = (seg_mapping*)(mem + st_table_offset_aligned);
new_seg_mapping_table = (seg_mapping*)((uint8_t*)new_seg_mapping_table -
size_seg_mapping_table_of (0, (align_lower_segment (saved_g_lowest_address))));
memcpy(&new_seg_mapping_table[seg_mapping_word_of(g_gc_lowest_address)],
&seg_mapping_table[seg_mapping_word_of(g_gc_lowest_address)],
size_seg_mapping_table_of(g_gc_lowest_address, g_gc_highest_address));
- seg_mapping_table = new_seg_mapping_table;
+ // new_seg_mapping_table gets assigned to seg_mapping_table at the bottom of this function,
+ // not here. The reason for this is that, if we fail at mark array committing (OOM) and we've
+ // already switched seg_mapping_table to point to the new mapping table, we'll decommit it and
+ // run into trouble. By not assigning here, we're making sure that we will not change seg_mapping_table
+ // if an OOM occurs.
}
#endif //GROWABLE_SEG_MAPPING_TABLE
translated_ct = translate_card_table (ct);
dprintf (GC_TABLE_LOG, ("card table: %Ix(translated: %Ix), seg map: %Ix, mark array: %Ix",
- (size_t)ct, (size_t)translated_ct, (size_t)seg_mapping_table, (size_t)card_table_mark_array (ct)));
+ (size_t)ct, (size_t)translated_ct, (size_t)new_seg_mapping_table, (size_t)card_table_mark_array (ct)));
#ifdef BACKGROUND_GC
if (hp->should_commit_mark_array())
g_gc_card_table = translated_ct;
}
+ seg_mapping_table = new_seg_mapping_table;
+
+ GCToOSInterface::FlushProcessWriteBuffers();
g_gc_lowest_address = saved_g_lowest_address;
g_gc_highest_address = saved_g_highest_address;