Skip to content
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
18 changes: 12 additions & 6 deletions src/coreclr/vm/appdomain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -174,8 +174,8 @@ OBJECTREF *PinnedHeapHandleBucket::TryAllocateEmbeddedFreeHandle()
}
CONTRACTL_END;

OBJECTREF pPreallocatedSentinelObject = ObjectFromHandle(g_pPreallocatedSentinelObject);
_ASSERTE(pPreallocatedSentinelObject != NULL);
OBJECTREF pPreallocatedSentinelObject = g_pPreallocatedSentinelObject;
_ASSERTE(pPreallocatedSentinelObject != NULL);

for (int i = m_CurrentEmbeddedFreePos; i < m_CurrentPos; i++)
{
Expand Down Expand Up @@ -405,8 +405,8 @@ void PinnedHeapHandleTable::ReleaseHandlesLocked(OBJECTREF *pObjRef, DWORD nRele
_ASSERTE(m_Crst.OwnedByCurrentThread());
#endif

OBJECTREF pPreallocatedSentinelObject = ObjectFromHandle(g_pPreallocatedSentinelObject);
_ASSERTE(pPreallocatedSentinelObject != NULL);
OBJECTREF pPreallocatedSentinelObject = g_pPreallocatedSentinelObject;
_ASSERTE(pPreallocatedSentinelObject != NULL);


// Add the released handles to the list of available handles.
Expand Down Expand Up @@ -807,8 +807,14 @@ void SystemDomain::PreallocateSpecialObjects()

_ASSERTE(g_pPreallocatedSentinelObject == NULL);

OBJECTREF pPreallocatedSentinelObject = AllocateObject(g_pObjectClass);
g_pPreallocatedSentinelObject = AppDomain::GetCurrentDomain()->CreatePinningHandle( pPreallocatedSentinelObject );
g_pPreallocatedSentinelObject = TryAllocateFrozenObject(g_pObjectClass);
if (g_pPreallocatedSentinelObject == NULL)
{
OBJECTREF pPreallocatedSentinelObject = AllocateObject(g_pObjectClass);
// Keep the fallback object alive and immovable for the lifetime of the runtime.
OBJECTHANDLE handle = AppDomain::GetCurrentDomain()->CreatePinningHandle(pPreallocatedSentinelObject);
g_pPreallocatedSentinelObject = ObjectFromHandle(handle);
}
}

void SystemDomain::CreatePreallocatedExceptions()
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/vm/vars.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -124,11 +124,11 @@ GVAL_IMPL_INIT(PTR_WSTR, g_EntryAssemblyPath, NULL);

#ifndef DACCESS_COMPILE

// <TODO> @TODO - PROMOTE. </TODO>
OBJECTHANDLE g_pPreallocatedOutOfMemoryException;
OBJECTHANDLE g_pPreallocatedStackOverflowException;
OBJECTHANDLE g_pPreallocatedExecutionEngineException;
OBJECTHANDLE g_pPreallocatedSentinelObject;

OBJECTREF g_pPreallocatedSentinelObject = NULL;

//
//
Expand Down
4 changes: 1 addition & 3 deletions src/coreclr/vm/vars.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,14 +396,12 @@ GVAL_DECL(PTR_WSTR, g_EntryAssemblyPath);
// Global System Information
extern SYSTEM_INFO g_SystemInfo;

// <TODO>@TODO - PROMOTE.</TODO>
// <TODO>@TODO - I'd like to make these private members of CLRException some day.</TODO>
EXTERN OBJECTHANDLE g_pPreallocatedOutOfMemoryException;
EXTERN OBJECTHANDLE g_pPreallocatedStackOverflowException;
EXTERN OBJECTHANDLE g_pPreallocatedExecutionEngineException;

// we use this as a dummy object to indicate free space in the handle tables -- this object is never visible to the world
EXTERN OBJECTHANDLE g_pPreallocatedSentinelObject;
EXTERN OBJECTREF g_pPreallocatedSentinelObject;

EXTERN MethodTable* g_pCastHelpers;

Expand Down
Loading