Skip to content

Commit 97ee0de

Browse files
Move NotifyUnload method
1 parent c55a343 commit 97ee0de

File tree

5 files changed

+75
-77
lines changed

5 files changed

+75
-77
lines changed

src/coreclr/vm/ceeload.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1389,9 +1389,9 @@ void Module::FreeClassTables()
13891389
MethodTable * pMT = typeDefIter.GetElement();
13901390
if (pMT != NULL)
13911391
{
1392-
EEClass::NotifyUnload(pMT, true);
1393-
pMT->GetClass()->Destruct(pMT);
1394-
EEClass::NotifyUnload(pMT, false);
1392+
ClassLoader::NotifyUnload(pMT, true);
1393+
pMT->GetClass()->Destruct();
1394+
ClassLoader::NotifyUnload(pMT, false);
13951395
}
13961396
}
13971397

@@ -1412,15 +1412,15 @@ void Module::FreeClassTables()
14121412
continue;
14131413

14141414
MethodTable * pMT = th.AsMethodTable();
1415-
EEClass::NotifyUnload(pMT, true);
1415+
ClassLoader::NotifyUnload(pMT, true);
14161416

14171417
// We need to call destruct on instances of EEClass whose "canonical" dependent lives in this table
14181418
if (pMT->IsCanonicalMethodTable())
14191419
{
1420-
pMT->GetClass()->Destruct(pMT);
1420+
pMT->GetClass()->Destruct();
14211421
}
14221422

1423-
EEClass::NotifyUnload(pMT, false);
1423+
ClassLoader::NotifyUnload(pMT, false);
14241424
}
14251425
}
14261426
}

src/coreclr/vm/class.cpp

Lines changed: 1 addition & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -54,14 +54,13 @@ void *EEClass::operator new(
5454
}
5555

5656
//*******************************************************************************
57-
void EEClass::Destruct(MethodTable * pOwningMT)
57+
void EEClass::Destruct()
5858
{
5959
CONTRACTL
6060
{
6161
NOTHROW;
6262
GC_TRIGGERS;
6363
FORBID_FAULT;
64-
PRECONDITION(pOwningMT != NULL);
6564
}
6665
CONTRACTL_END
6766

@@ -111,68 +110,6 @@ void EEClass::Destruct(MethodTable * pOwningMT)
111110
#endif // FEATURE_COMINTEROP
112111
}
113112

114-
//*******************************************************************************
115-
void EEClass::NotifyUnload(MethodTable* pMT, bool unloadStarted)
116-
{
117-
CONTRACTL
118-
{
119-
NOTHROW;
120-
GC_TRIGGERS;
121-
MODE_ANY;
122-
FORBID_FAULT;
123-
PRECONDITION(pMT != NULL);
124-
}
125-
CONTRACTL_END
126-
127-
#ifdef PROFILING_SUPPORTED
128-
// If profiling, then notify the class is getting unloaded.
129-
{
130-
BEGIN_PROFILER_CALLBACK(CORProfilerTrackClasses());
131-
{
132-
if (pMT->ContainsGenericVariables() || pMT->IsArray())
133-
{
134-
// Don't notify the profiler about types with unbound variables or arrays.
135-
// See ClassLoadStarted callback for more details.
136-
return;
137-
}
138-
139-
// Calls to the profiler callback may throw, or otherwise fail, if
140-
// the profiler AVs/throws an unhandled exception/etc. We don't want
141-
// those failures to affect the runtime, so we'll ignore them.
142-
//
143-
// Note that the profiler callback may turn around and make calls into
144-
// the profiling runtime that may throw. This try/catch block doesn't
145-
// protect the profiler against such failures. To protect the profiler
146-
// against that, we will need try/catch blocks around all calls into the
147-
// profiling API.
148-
//
149-
// (Bug #26467)
150-
//
151-
152-
FAULT_NOT_FATAL();
153-
154-
EX_TRY
155-
{
156-
GCX_PREEMP();
157-
158-
if (unloadStarted)
159-
(&g_profControlBlock)->ClassUnloadStarted((ClassID) pMT);
160-
else
161-
(&g_profControlBlock)->ClassUnloadFinished((ClassID) pMT, S_OK);
162-
}
163-
EX_CATCH
164-
{
165-
// The exception here came from the profiler itself. We'll just
166-
// swallow the exception, since we don't want the profiler to bring
167-
// down the runtime.
168-
}
169-
EX_END_CATCH(RethrowTerminalExceptions);
170-
}
171-
END_PROFILER_CALLBACK();
172-
}
173-
#endif // PROFILING_SUPPORTED
174-
}
175-
176113
//*******************************************************************************
177114
/*static*/ EEClass *
178115
EEClass::CreateMinimalClass(LoaderHeap *pHeap, AllocMemTracker *pamTracker)

src/coreclr/vm/class.h

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -726,10 +726,7 @@ class EEClass // DO NOT CREATE A NEW EEClass USING NEW!
726726

727727
#ifndef DACCESS_COMPILE
728728
void *operator new(size_t size, LoaderHeap* pHeap, AllocMemTracker *pamTracker);
729-
void Destruct(MethodTable * pMT);
730-
731-
// Notify profiler about class unload
732-
static void NotifyUnload(MethodTable* pMT, bool unloadStarted);
729+
void Destruct();
733730

734731
static EEClass * CreateMinimalClass(LoaderHeap *pHeap, AllocMemTracker *pamTracker);
735732
#endif // !DACCESS_COMPILE

src/coreclr/vm/clsload.cpp

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2614,7 +2614,7 @@ TypeHandle ClassLoader::DoIncrementalLoad(const TypeKey *pTypeKey, TypeHandle ty
26142614

26152615
if (typeHnd.GetLoadLevel() >= CLASS_LOAD_EXACTPARENTS)
26162616
{
2617-
Notify(typeHnd);
2617+
NotifyLoad(typeHnd);
26182618
}
26192619

26202620
return typeHnd;
@@ -2828,7 +2828,7 @@ TypeHandle ClassLoader::PublishType(const TypeKey *pTypeKey, TypeHandle typeHnd)
28282828
// Notify profiler and debugger that a type load has completed
28292829
// Also adjust perf counters
28302830
/*static*/
2831-
void ClassLoader::Notify(TypeHandle typeHnd)
2831+
void ClassLoader::NotifyLoad(TypeHandle typeHnd)
28322832
{
28332833
CONTRACTL
28342834
{
@@ -2896,6 +2896,68 @@ void ClassLoader::Notify(TypeHandle typeHnd)
28962896
}
28972897
}
28982898

2899+
// Notify profiler that a MethodTable is being unloaded
2900+
/*static*/
2901+
void ClassLoader::NotifyUnload(MethodTable* pMT, bool unloadStarted)
2902+
{
2903+
CONTRACTL
2904+
{
2905+
NOTHROW;
2906+
GC_TRIGGERS;
2907+
MODE_ANY;
2908+
FORBID_FAULT;
2909+
PRECONDITION(pMT != NULL);
2910+
}
2911+
CONTRACTL_END
2912+
2913+
#ifdef PROFILING_SUPPORTED
2914+
// If profiling, then notify the class is getting unloaded.
2915+
{
2916+
BEGIN_PROFILER_CALLBACK(CORProfilerTrackClasses());
2917+
{
2918+
if (pMT->ContainsGenericVariables() || pMT->IsArray())
2919+
{
2920+
// Don't notify the profiler about types with unbound variables or arrays.
2921+
// See ClassLoadStarted callback for more details.
2922+
return;
2923+
}
2924+
2925+
// Calls to the profiler callback may throw, or otherwise fail, if
2926+
// the profiler AVs/throws an unhandled exception/etc. We don't want
2927+
// those failures to affect the runtime, so we'll ignore them.
2928+
//
2929+
// Note that the profiler callback may turn around and make calls into
2930+
// the profiling runtime that may throw. This try/catch block doesn't
2931+
// protect the profiler against such failures. To protect the profiler
2932+
// against that, we will need try/catch blocks around all calls into the
2933+
// profiling API.
2934+
//
2935+
// (Bug #26467)
2936+
//
2937+
2938+
FAULT_NOT_FATAL();
2939+
2940+
EX_TRY
2941+
{
2942+
GCX_PREEMP();
2943+
2944+
if (unloadStarted)
2945+
(&g_profControlBlock)->ClassUnloadStarted((ClassID) pMT);
2946+
else
2947+
(&g_profControlBlock)->ClassUnloadFinished((ClassID) pMT, S_OK);
2948+
}
2949+
EX_CATCH
2950+
{
2951+
// The exception here came from the profiler itself. We'll just
2952+
// swallow the exception, since we don't want the profiler to bring
2953+
// down the runtime.
2954+
}
2955+
EX_END_CATCH(RethrowTerminalExceptions);
2956+
}
2957+
END_PROFILER_CALLBACK();
2958+
}
2959+
#endif // PROFILING_SUPPORTED
2960+
}
28992961

29002962
//-----------------------------------------------------------------------------
29012963
// Common helper for LoadTypeHandleForTypeKey and LoadTypeHandleForTypeKeyNoLock.

src/coreclr/vm/clsload.hpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -910,7 +910,9 @@ class ClassLoader
910910

911911
// Notify profiler and debugger that a type load has completed
912912
// Also update perf counters
913-
static void Notify(TypeHandle typeHnd);
913+
static void NotifyLoad(TypeHandle typeHnd);
914+
// Notify profiler that a MethodTable is being unloaded
915+
static void NotifyUnload(MethodTable* pMT, bool unloadStarted);
914916

915917
// Phase CLASS_LOAD_EXACTPARENTS of class loading
916918
// Load exact parents and interfaces and dependent structures (generics dictionary, vtable fixes)

0 commit comments

Comments
 (0)