Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix issue 47805 #52183

Merged
merged 38 commits into from
May 4, 2021
Merged
Changes from all commits
Commits
Show all changes
38 commits
Select commit Hold shift + click to select a range
3d639f2
delete backport.yml so I can push to master
PeterSolMS Aug 21, 2020
c78344e
Merge remote-tracking branch 'upstream/master'
PeterSolMS Aug 27, 2020
0fc9aeb
Undo unintended changes
PeterSolMS Aug 27, 2020
9073278
Merge remote-tracking branch 'upstream/master'
PeterSolMS Aug 31, 2020
eb4f188
Merge remote-tracking branch 'upstream/master'
PeterSolMS Sep 28, 2020
c809f97
Merge remote-tracking branch 'upstream/master'
PeterSolMS Oct 2, 2020
808750e
Merge remote-tracking branch 'upstream/master'
PeterSolMS Oct 20, 2020
8985284
Merge remote-tracking branch 'upstream/master'
PeterSolMS Nov 5, 2020
61be136
Merge remote-tracking branch 'upstream/master'
PeterSolMS Nov 13, 2020
5893c56
Merge remote-tracking branch 'upstream/master'
PeterSolMS Nov 17, 2020
827db97
Merge remote-tracking branch 'upstream/master'
PeterSolMS Nov 26, 2020
a0df529
Merge remote-tracking branch 'upstream/master'
PeterSolMS Nov 30, 2020
15e891c
Merge from upstream/master
PeterSolMS Nov 30, 2020
ddea2eb
Merge remote-tracking branch 'upstream/master'
PeterSolMS Dec 1, 2020
bdeba60
delete backport.yml so I can push to master
PeterSolMS Aug 21, 2020
e5afb51
Undo unintended changes
PeterSolMS Aug 27, 2020
6887c32
Merge from upstream/master
PeterSolMS Nov 30, 2020
4f1f430
Merge branch 'master' of https://github.com/PeterSolMS/runtime-1
PeterSolMS Dec 1, 2020
989a242
Undo unintended Mono changes that somehow crept in.
PeterSolMS Dec 1, 2020
5370012
Merge remote-tracking branch 'upstream/master'
PeterSolMS Dec 7, 2020
9522406
Merge remote-tracking branch 'upstream/master'
PeterSolMS Dec 8, 2020
a31ce60
Merge remote-tracking branch 'upstream/master'
PeterSolMS Dec 16, 2020
0ba8f94
Merge remote-tracking branch 'upstream/master'
PeterSolMS Dec 21, 2020
6bc4d50
Merge remote-tracking branch 'upstream/master'
PeterSolMS Jan 7, 2021
c6f573a
Merge remote-tracking branch 'upstream/master'
PeterSolMS Jan 18, 2021
94e74a4
Merge remote-tracking branch 'upstream/master'
PeterSolMS Jan 25, 2021
871da36
Merge remote-tracking branch 'upstream/master'
PeterSolMS Jan 29, 2021
5e9cdd6
Merge remote-tracking branch 'upstream/master'
PeterSolMS Feb 4, 2021
88fadae
Merge remote-tracking branch 'upstream/master'
PeterSolMS Feb 15, 2021
3b69fdd
Merge remote-tracking branch 'upstream/master'
PeterSolMS Feb 25, 2021
7c8c021
Merge remote-tracking branch 'upstream/main' into main
PeterSolMS Mar 11, 2021
2623256
Merge remote-tracking branch 'upstream/main' into main
PeterSolMS Mar 15, 2021
9fcb397
Merge remote-tracking branch 'upstream/main' into main
PeterSolMS Mar 22, 2021
4651147
Merge remote-tracking branch 'upstream/main' into main
PeterSolMS Apr 7, 2021
40bb09a
Merge remote-tracking branch 'upstream/main' into main
PeterSolMS Apr 19, 2021
54dfb86
Fix issue 47805 - in this case, the BGC_MARKED_BY_FGC bit (0x2) set i…
PeterSolMS May 3, 2021
3b06b39
Address code review feedback.
PeterSolMS May 4, 2021
7f2c25e
Coding convention fixes - added blanks before opening parentheses.
PeterSolMS May 4, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
89 changes: 63 additions & 26 deletions src/coreclr/gc/gc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4114,7 +4114,16 @@ size_t gcard_of ( uint8_t*);
// We only do this when we decide to compact.
#define BGC_MARKED_BY_FGC (size_t)0x2
#define MAKE_FREE_OBJ_IN_COMPACT (size_t)0x4
#endif //DOUBLY_LINKED_FL
#define ALLOWED_SPECIAL_HEADER_BITS (GC_MARKED|BGC_MARKED_BY_FGC|MAKE_FREE_OBJ_IN_COMPACT)
#else //DOUBLY_LINKED_FL
#define ALLOWED_SPECIAL_HEADER_BITS (GC_MARKED)
#endif //!DOUBLY_LINKED_FL

#ifdef HOST_64BIT
#define SPECIAL_HEADER_BITS (0x7)
#else
#define SPECIAL_HEADER_BITS (0x3)
#endif

#define slot(i, j) ((uint8_t**)(i))[(j)+1]

Expand Down Expand Up @@ -4216,11 +4225,7 @@ class CObjectHeader : public Object

MethodTable *GetMethodTable() const
{
return( (MethodTable *) (((size_t) RawGetMethodTable()) & (~(GC_MARKED
#ifdef DOUBLY_LINKED_FL
| BGC_MARKED_BY_FGC | MAKE_FREE_OBJ_IN_COMPACT
#endif //DOUBLY_LINKED_FL
))));
return( (MethodTable *) (((size_t) RawGetMethodTable()) & (~SPECIAL_HEADER_BITS)));
}

void SetMarked()
Expand Down Expand Up @@ -4288,6 +4293,26 @@ class CObjectHeader : public Object
}
#endif //DOUBLY_LINKED_FL

size_t ClearSpecialBits()
{
size_t special_bits = ((size_t)RawGetMethodTable()) & SPECIAL_HEADER_BITS;
if (special_bits != 0)
{
assert ((special_bits & (~ALLOWED_SPECIAL_HEADER_BITS)) == 0);
RawSetMethodTable ((MethodTable*)(((size_t)RawGetMethodTable()) & ~(SPECIAL_HEADER_BITS)));
}
return special_bits;
}

void SetSpecialBits (size_t special_bits)
{
assert ((special_bits & (~ALLOWED_SPECIAL_HEADER_BITS)) == 0);
if (special_bits != 0)
{
RawSetMethodTable ((MethodTable*)(((size_t)RawGetMethodTable()) | special_bits));
}
}

CGCDesc *GetSlotMap ()
{
assert (GetMethodTable()->ContainsPointers());
Expand Down Expand Up @@ -4455,6 +4480,17 @@ inline
BOOL is_plug_padded (uint8_t* node){return FALSE;}
#endif //SHORT_PLUGS

inline
size_t clear_special_bits (uint8_t* node)
{
return header(node)->ClearSpecialBits();
}

inline
void set_special_bits (uint8_t* node, size_t special_bits)
{
header(node)->SetSpecialBits (special_bits);
}

inline size_t unused_array_size(uint8_t * p)
{
Expand Down Expand Up @@ -20926,16 +20962,16 @@ void gc_heap::enque_pinned_plug (uint8_t* plug,

if (save_pre_plug_info_p)
{
#ifdef SHORT_PLUGS
BOOL is_padded = is_plug_padded (last_object_in_last_plug);
if (is_padded)
clear_plug_padded (last_object_in_last_plug);
#endif //SHORT_PLUGS
// In the case of short plugs or doubly linked free lists, there may be extra bits
// set in the method table pointer.
// Clear these bits for the copy saved in saved_pre_plug, but not for the copy
// saved in saved_pre_plug_reloc.
// This is because we need these bits for compaction, but not for mark & sweep.
size_t special_bits = clear_special_bits (last_object_in_last_plug);
// now copy the bits over
memcpy (&(m.saved_pre_plug), &(((plug_and_gap*)plug)[-1]), sizeof (gap_reloc_pair));
#ifdef SHORT_PLUGS
if (is_padded)
set_plug_padded (last_object_in_last_plug);
#endif //SHORT_PLUGS
// restore the bits in the original
set_special_bits (last_object_in_last_plug, special_bits);

memcpy (&(m.saved_pre_plug_reloc), &(((plug_and_gap*)plug)[-1]), sizeof (gap_reloc_pair));

Expand All @@ -20945,7 +20981,7 @@ void gc_heap::enque_pinned_plug (uint8_t* plug,
{
record_interesting_data_point (idp_pre_short);
#ifdef SHORT_PLUGS
if (is_padded)
if (is_plug_padded (last_object_in_last_plug))
record_interesting_data_point (idp_pre_short_padded);
#endif //SHORT_PLUGS
dprintf (3, ("encountered a short object %Ix right before pinned plug %Ix!",
Expand Down Expand Up @@ -20989,16 +21025,17 @@ void gc_heap::save_post_plug_info (uint8_t* last_pinned_plug, uint8_t* last_obje
assert (last_pinned_plug == m.first);
m.saved_post_plug_info_start = (uint8_t*)&(((plug_and_gap*)post_plug)[-1]);

#ifdef SHORT_PLUGS
BOOL is_padded = is_plug_padded (last_object_in_last_plug);
if (is_padded)
clear_plug_padded (last_object_in_last_plug);
#endif //SHORT_PLUGS
// In the case of short plugs or doubly linked free lists, there may be extra bits
// set in the method table pointer.
// Clear these bits for the copy saved in saved_post_plug, but not for the copy
// saved in saved_post_plug_reloc.
// This is because we need these bits for compaction, but not for mark & sweep.
// Note that currently none of these bits will ever be set in the object saved *after*
// a pinned plug - this object is currently pinned along with the pinned object before it
size_t special_bits = clear_special_bits (last_object_in_last_plug);
memcpy (&(m.saved_post_plug), m.saved_post_plug_info_start, sizeof (gap_reloc_pair));
#ifdef SHORT_PLUGS
if (is_padded)
set_plug_padded (last_object_in_last_plug);
#endif //SHORT_PLUGS
// restore the bits in the original
set_special_bits (last_object_in_last_plug, special_bits);

memcpy (&(m.saved_post_plug_reloc), m.saved_post_plug_info_start, sizeof (gap_reloc_pair));

Expand All @@ -21017,7 +21054,7 @@ void gc_heap::save_post_plug_info (uint8_t* last_pinned_plug, uint8_t* last_obje
dprintf (3, ("PP %Ix last obj %Ix is too short", last_pinned_plug, last_object_in_last_plug));
record_interesting_data_point (idp_post_short);
#ifdef SHORT_PLUGS
if (is_padded)
if (is_plug_padded (last_object_in_last_plug))
record_interesting_data_point (idp_post_short_padded);
#endif //SHORT_PLUGS
m.set_post_short();
Expand Down