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

[Local GC] Forbid inclusion of gcscan.h from VM and DAC directories #10332

Merged
merged 2 commits into from
Mar 22, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
5 changes: 2 additions & 3 deletions src/debug/daccess/enummem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "ipcmanagerinterface.h"
#include "binder.h"
#include "win32threadpool.h"
#include "gcscan.h"

#ifdef FEATURE_APPX
#include "appxutil.h"
Expand Down Expand Up @@ -407,7 +406,7 @@ HRESULT ClrDataAccess::DumpManagedObject(CLRDataEnumMemoryFlags flags, OBJECTREF
return status;
}

if (!GCScan::GetGcRuntimeStructuresValid ())
if (*g_gcDacGlobals->gc_structures_invalid_cnt != 0)
{
// GC is in progress, don't dump this object
return S_OK;
Expand Down Expand Up @@ -465,7 +464,7 @@ HRESULT ClrDataAccess::DumpManagedExcepObject(CLRDataEnumMemoryFlags flags, OBJE
return S_OK;
}

if (!GCScan::GetGcRuntimeStructuresValid ())
if (*g_gcDacGlobals->gc_structures_invalid_cnt != 0)
{
// GC is in progress, don't dump this object
return S_OK;
Expand Down
1 change: 1 addition & 0 deletions src/debug/daccess/request.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3827,6 +3827,7 @@ ClrDataAccess::EnumWksGlobalMemoryRegions(CLRDataEnumMemoryFlags flags)

Dereference(g_gcDacGlobals->ephemeral_heap_segment).EnumMem();
g_gcDacGlobals->alloc_allocated.EnumMem();
g_gcDacGlobals->gc_structures_invalid_cnt.EnumMem();
Dereference(g_gcDacGlobals->finalize_queue).EnumMem();

// Enumerate the entire generation table, which has variable size
Expand Down
1 change: 1 addition & 0 deletions src/debug/daccess/request_svr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,7 @@ ClrDataAccess::EnumSvrGlobalMemoryRegions(CLRDataEnumMemoryFlags flags)
DacEnumMemoryRegion(g_gcDacGlobals->g_heaps.GetAddr(),
sizeof(TADDR) * *g_gcDacGlobals->n_heaps);

g_gcDacGlobals->gc_structures_invalid_cnt.EnumMem();
g_gcDacGlobals->g_heaps.EnumMem();

for (int i=0; i < *g_gcDacGlobals->n_heaps; i++)
Expand Down
8 changes: 0 additions & 8 deletions src/debug/ee/dactable.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,6 @@
#include "../../vm/gcenv.h"
#include "../../vm/ecall.h"
#include "../../vm/rcwwalker.h"
#include "../../gc/gc.h"
#include "../../gc/gcscan.h"

#undef SERVER_GC
namespace WKS {
#include "../../gc/gcimpl.h"
#include "../../gc/gcpriv.h"
}

#ifdef DEBUGGING_SUPPORTED

Expand Down
5 changes: 5 additions & 0 deletions src/gc/gcee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,11 @@ void GCHeap::UnregisterFrozenSegment(segment_handle seg)
#endif // FEATURE_BASICFREEZE
}

bool GCHeap::RuntimeStructuresValid()
{
return GCScan::GetGcRuntimeStructuresValid();
}


#endif // !DACCESS_COMPILE

Expand Down
2 changes: 2 additions & 0 deletions src/gc/gcimpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ class GCHeap : public IGCHeapInternal

void SetGCInProgress(BOOL fInProgress);

bool RuntimeStructuresValid();

CLREvent * GetWaitForGCEvent();

HRESULT Initialize ();
Expand Down
3 changes: 3 additions & 0 deletions src/gc/gcinterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,9 @@ class IGCHeap {
// Sets whether or not a GC is in progress.
virtual void SetGCInProgress(BOOL fInProgress) = 0;

// Gets whether or not the GC runtime structures are in a valid state for heap traversal.
virtual bool RuntimeStructuresValid() = 0;

/*
============================================================================
Add/RemoveMemoryPressure support routines. These are on the interface
Expand Down
17 changes: 1 addition & 16 deletions src/gc/gcscan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@
#include "gc.h"
#include "objecthandle.h"

#ifdef DACCESS_COMPILE
SVAL_IMPL_INIT(int32_t, GCScan, m_GcStructuresInvalidCnt, 1);
#else //DACCESS_COMPILE
VOLATILE(int32_t) GCScan::m_GcStructuresInvalidCnt = 1;
#endif //DACCESS_COMPILE

bool GCScan::GetGcRuntimeStructuresValid ()
{
Expand All @@ -33,18 +29,7 @@ bool GCScan::GetGcRuntimeStructuresValid ()
return (int32_t)m_GcStructuresInvalidCnt == 0;
}

#ifdef DACCESS_COMPILE

#ifndef FEATURE_REDHAWK
void
GCScan::EnumMemoryRegions(CLRDataEnumMemoryFlags flags)
{
UNREFERENCED_PARAMETER(flags);
m_GcStructuresInvalidCnt.EnumMem();
}
#endif

#else
#ifndef DACCESS_COMPILE

//
// Dependent handle promotion scan support
Expand Down
4 changes: 0 additions & 4 deletions src/gc/gcscan.h
Original file line number Diff line number Diff line change
Expand Up @@ -89,11 +89,7 @@ class GCScan

static void VerifyHandleTable(int condemned, int max_gen, ScanContext* sc);

#ifdef DACCESS_COMPILE
SVAL_DECL(int32_t, m_GcStructuresInvalidCnt);
#else
static VOLATILE(int32_t) m_GcStructuresInvalidCnt;
#endif //DACCESS_COMPILE
};

// These two functions are utilized to scan the heap if requested by ETW
Expand Down
2 changes: 0 additions & 2 deletions src/inc/dacvars.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,6 @@ DEFINE_DACVAR(ULONG, PTR_SharedDomain, SharedDomain__m_pSharedDomain, SharedDoma

DEFINE_DACVAR(ULONG, DWORD, CExecutionEngine__TlsIndex, CExecutionEngine::TlsIndex)

DEFINE_DACVAR(ULONG, LONG, GCScan__m_GcStructuresInvalidCnt, GCScan::m_GcStructuresInvalidCnt)

#if defined(FEATURE_WINDOWSPHONE)
DEFINE_DACVAR(ULONG, int, CCLRErrorReportingManager__g_ECustomDumpFlavor, CCLRErrorReportingManager::g_ECustomDumpFlavor)
#endif
Expand Down
6 changes: 3 additions & 3 deletions src/vm/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
#include "eeconfig.h"
#include "gcheaputilities.h"
#include "field.h"
#include "gcscan.h"
#include "argdestination.h"


Expand Down Expand Up @@ -1773,12 +1772,13 @@ VOID Object::ValidateInner(BOOL bDeep, BOOL bVerifyNextHeader, BOOL bVerifySyncB

lastTest = 7;

_ASSERTE(GCHeapUtilities::IsGCHeapInitialized());
// try to validate next object's header
if (bDeep
&& bVerifyNextHeader
&& GCScan::GetGcRuntimeStructuresValid ()
&& GCHeapUtilities::GetGCHeap()->RuntimeStructuresValid()
//NextObj could be very slow if concurrent GC is going on
&& !(GCHeapUtilities::IsGCHeapInitialized() && GCHeapUtilities::GetGCHeap ()->IsConcurrentGCInProgress ()))
&& !GCHeapUtilities::GetGCHeap ()->IsConcurrentGCInProgress ())
{
Object * nextObj = GCHeapUtilities::GetGCHeap ()->NextObj (this);
if ((nextObj != NULL) &&
Expand Down
3 changes: 1 addition & 2 deletions src/vm/stubhelpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
#include "comdatetime.h"
#include "gcheaputilities.h"
#include "interoputil.h"
#include "gcscan.h"

#ifdef FEATURE_COMINTEROP
#include <oletls.h>
Expand Down Expand Up @@ -58,7 +57,7 @@ void StubHelpers::ValidateObjectInternal(Object *pObjUNSAFE, BOOL fValidateNextO
}
CONTRACTL_END;

_ASSERTE(GCScan::GetGcRuntimeStructuresValid());
_ASSERTE(GCHeapUtilities::GetGCHeap()->RuntimeStructuresValid());

// validate the object - there's no need to validate next object's
// header since we validate the next object explicitly below
Expand Down
3 changes: 1 addition & 2 deletions src/vm/syncblk.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@
#include "corhost.h"
#include "comdelegate.h"
#include "finalizerthread.h"
#include "gcscan.h"

#ifdef FEATURE_COMINTEROP
#include "runtimecallablewrapper.h"
Expand Down Expand Up @@ -2518,7 +2517,7 @@ BOOL ObjHeader::Validate (BOOL bVerifySyncBlkIndex)
//rest of the DWORD is SyncBlk Index
if (!(bits & BIT_SBLK_IS_HASHCODE))
{
if (bVerifySyncBlkIndex && GCScan::GetGcRuntimeStructuresValid ())
if (bVerifySyncBlkIndex && GCHeapUtilities::GetGCHeap()->RuntimeStructuresValid ())
{
DWORD sbIndex = bits & MASK_SYNCBLOCKINDEX;
ASSERT_AND_CHECK(SyncTableEntry::GetSyncTableEntry()[sbIndex].m_Object == obj);
Expand Down