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

Rangelistmap with native eh free il throw on Linux #79471

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
982daf3
Experimental
davidwrighton Oct 21, 2022
f443bfa
Experiment
davidwrighton Oct 21, 2022
2fa62aa
More progress
davidwrighton Oct 28, 2022
55a5bb6
Increase accuracy of comments around range section locking
davidwrighton Nov 14, 2022
f5357bb
Changes to RangeListMap to make it work
davidwrighton Nov 29, 2022
1abc9c6
Add low bit check indirection
davidwrighton Nov 29, 2022
5eee830
Rework to passing down the current locking status
davidwrighton Nov 29, 2022
e4fb4db
Allocation of RangeSection and freeing added, as well as testing for …
davidwrighton Nov 29, 2022
6505eb5
Fix some naming
davidwrighton Nov 29, 2022
62b0376
Miraculously it builds!
davidwrighton Nov 30, 2022
ebadf2a
May actually work. DAC access known to be broken.
davidwrighton Nov 30, 2022
c6fb27c
Merge branch 'main' of https://github.com/dotnet/runtime into rangeli…
davidwrighton Nov 30, 2022
3ecfff8
Fix handling of unwind table
davidwrighton Dec 1, 2022
209877b
Seems to work well on WinX64
davidwrighton Dec 2, 2022
50712b7
Fix performance of the DelegateConstruct method
davidwrighton Dec 2, 2022
38acd5c
It should build everywhere now
davidwrighton Dec 2, 2022
9148e31
Delete temporary bits
davidwrighton Dec 2, 2022
dce4bb1
Fix Windows builds
davidwrighton Dec 6, 2022
518011c
Fix contract issues
davidwrighton Dec 6, 2022
6db0e70
Fix CodeRangeMapRangeList to handle interval correctly
davidwrighton Dec 6, 2022
c8a74e2
It builds on Linux!
davidwrighton Dec 6, 2022
2a012b2
Make it even more lock free
davidwrighton Dec 6, 2022
de97c17
Remove confusion around Range interval specification Some uses were r…
davidwrighton Dec 8, 2022
a493cde
Attempt to appease the GCC build
davidwrighton Dec 8, 2022
1507207
Fix the math around fragment handling and index calculations
davidwrighton Dec 9, 2022
8d0f9bf
Remove use of native EH from the IL_Throw exception path, in combinat…
davidwrighton Dec 9, 2022
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
4 changes: 2 additions & 2 deletions src/coreclr/inc/daccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@
// pRS=pRS->pright;
// else
// {
// return pRS->pjit;
// return pRS->_pjit;
// }
// }
//
Expand All @@ -108,7 +108,7 @@
// In the assignment statement the compiler will automatically use
// the implicit conversion from PTR_RangeSection to RangeSection*,
// causing a host instance to be created. Finally, if an appropriate
// section is found the use of pRS->pjit will cause an implicit
// section is found the use of pRS->_pjit will cause an implicit
// conversion from PTR_IJitManager to IJitManager. The VPTR code
// will look at target memory to determine the actual derived class
// for the JitManager and instantiate the right class in the host so
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/inc/dacvars.h
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@

#define UNKNOWN_POINTER_TYPE SIZE_T

DEFINE_DACVAR_VOLATILE(PTR_RangeSection, ExecutionManager__m_CodeRangeList, ExecutionManager::m_CodeRangeList)
DEFINE_DACVAR(PTR_RangeSectionMap, ExecutionManager__g_pCodeRangeMap, ExecutionManager::g_pCodeRangeMap)
DEFINE_DACVAR(PTR_EECodeManager, ExecutionManager__m_pDefaultCodeMan, ExecutionManager::m_pDefaultCodeMan)
DEFINE_DACVAR_VOLATILE(LONG, ExecutionManager__m_dwReaderCount, ExecutionManager::m_dwReaderCount)
DEFINE_DACVAR_VOLATILE(LONG, ExecutionManager__m_dwWriterLock, ExecutionManager::m_dwWriterLock)
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/inc/vptr_list.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ VPTR_CLASS(EECodeManager)

VPTR_CLASS(RangeList)
VPTR_CLASS(LockedRangeList)
VPTR_CLASS(CodeRangeMapRangeList)

#ifdef EnC_SUPPORTED
VPTR_CLASS(EditAndContinueModule)
Expand Down
4 changes: 2 additions & 2 deletions src/coreclr/nativeaot/Runtime/inc/daccess.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@
// pRS=pRS->pright;
// else
// {
// return pRS->pjit;
// return pRS->_pjit;
// }
// }
//
Expand All @@ -106,7 +106,7 @@
// In the assignment statement the compiler will automatically use
// the implicit conversion from PTR_RangeSection to RangeSection*,
// causing a host instance to be created. Finally, if an appropriate
// section is found the use of pRS->pjit will cause an implicit
// section is found the use of pRS->_pjit will cause an implicit
// conversion from PTR_IJitManager to IJitManager. The VPTR code
// will look at target memory to determine the actual derived class
// for the JitManager and instantiate the right class in the host so
Expand Down
12 changes: 12 additions & 0 deletions src/coreclr/pal/inc/pal.h
Original file line number Diff line number Diff line change
Expand Up @@ -3235,6 +3235,18 @@ RaiseException(
IN DWORD nNumberOfArguments,
IN CONST ULONG_PTR *lpArguments);

struct PAL_SEHException;

PALIMPORT
VOID
PALAPI
RaiseExceptionProducePALExceptionOnly(
IN DWORD dwExceptionCode,
IN DWORD dwExceptionFlags,
IN DWORD nNumberOfArguments,
IN CONST ULONG_PTR *lpArguments,
PAL_SEHException *pPalException);

PALIMPORT
VOID
PALAPI
Expand Down
71 changes: 71 additions & 0 deletions src/coreclr/pal/src/exception/seh-unwind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -951,4 +951,75 @@ RaiseException(IN DWORD dwExceptionCode,
LOGEXIT("RaiseException returns\n");
}

/*++
Function:
RaiseException

See MSDN doc.
--*/
// no PAL_NORETURN, as callers must assume this can return for continuable exceptions.
__attribute__((noinline))
VOID
PALAPI
RaiseExceptionProducePALExceptionOnly(IN DWORD dwExceptionCode,
IN DWORD dwExceptionFlags,
IN DWORD nNumberOfArguments,
IN CONST ULONG_PTR *lpArguments,
PAL_SEHException *pPalException)
{
// PERF_ENTRY_ONLY is used here because RaiseException may or may not
// return. We can not get latency data without PERF_EXIT. For this reason,
// PERF_ENTRY_ONLY is used to profile frequency only.
PERF_ENTRY(RaiseExceptionProducePALExceptionOnly);
ENTRY("RaiseExceptionProducePALExceptionOnly(dwCode=%#x, dwFlags=%#x, nArgs=%u, lpArguments=%p)\n",
dwExceptionCode, dwExceptionFlags, nNumberOfArguments, lpArguments);

/* Validate parameters */
if (dwExceptionCode & RESERVED_SEH_BIT)
{
WARN("Exception code %08x has bit 28 set; clearing it.\n", dwExceptionCode);
dwExceptionCode ^= RESERVED_SEH_BIT;
}

if (nNumberOfArguments > EXCEPTION_MAXIMUM_PARAMETERS)
{
WARN("Number of arguments (%d) exceeds the limit "
"EXCEPTION_MAXIMUM_PARAMETERS (%d); ignoring extra parameters.\n",
nNumberOfArguments, EXCEPTION_MAXIMUM_PARAMETERS);
nNumberOfArguments = EXCEPTION_MAXIMUM_PARAMETERS;
}

CONTEXT *contextRecord;
EXCEPTION_RECORD *exceptionRecord;
AllocateExceptionRecords(&exceptionRecord, &contextRecord);

ZeroMemory(exceptionRecord, sizeof(EXCEPTION_RECORD));

exceptionRecord->ExceptionCode = dwExceptionCode;
exceptionRecord->ExceptionFlags = dwExceptionFlags;
exceptionRecord->ExceptionRecord = NULL;
exceptionRecord->ExceptionAddress = NULL; // will be set by RtlpRaiseException
exceptionRecord->NumberParameters = nNumberOfArguments;
if (nNumberOfArguments)
{
CopyMemory(exceptionRecord->ExceptionInformation, lpArguments,
nNumberOfArguments * sizeof(ULONG_PTR));
}

// Capture the context of RaiseException.
ZeroMemory(contextRecord, sizeof(CONTEXT));
contextRecord->ContextFlags = CONTEXT_FULL;
CONTEXT_CaptureContext(contextRecord);

// We have to unwind one level to get the actual context user code could be resumed at.
PAL_VirtualUnwind(contextRecord, NULL);

exceptionRecord->ExceptionAddress = (void *)CONTEXTGetPC(contextRecord);

*pPalException = PAL_SEHException(exceptionRecord, contextRecord);

LOGEXIT("RaiseExceptionProducePALExceptionOnly returns\n");
PERF_EXIT(RaiseExceptionProducePALExceptionOnly);
}

#endif // !HOST_WINDOWS
1 change: 0 additions & 1 deletion src/coreclr/vm/assembly.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -465,7 +465,6 @@ Assembly *Assembly::CreateDynamic(AssemblyBinder* pBinder, NativeAssemblyNamePar
if ((access & ASSEMBLY_ACCESS_COLLECT) != 0)
{
AssemblyLoaderAllocator *pCollectibleLoaderAllocator = new AssemblyLoaderAllocator();
pCollectibleLoaderAllocator->SetCollectible();
pLoaderAllocator = pCollectibleLoaderAllocator;

// Some of the initialization functions are not virtual. Call through the derived class
Expand Down
1 change: 0 additions & 1 deletion src/coreclr/vm/assemblynative.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1135,7 +1135,6 @@ extern "C" INT_PTR QCALLTYPE AssemblyNative_InitializeAssemblyLoadContext(INT_PT
{
// Create a new AssemblyLoaderAllocator for an AssemblyLoadContext
loaderAllocator = new AssemblyLoaderAllocator();
loaderAllocator->SetCollectible();

GCX_COOP();
LOADERALLOCATORREF pManagedLoaderAllocator = NULL;
Expand Down
2 changes: 1 addition & 1 deletion src/coreclr/vm/ceeload.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4397,7 +4397,7 @@ void Module::RunEagerFixupsUnlocked()
ExecutionManager::AddCodeRange(
base, base + (TADDR)pNativeImage->GetVirtualSize(),
ExecutionManager::GetReadyToRunJitManager(),
RangeSection::RANGE_SECTION_READYTORUN,
RangeSection::RANGE_SECTION_NONE,
this /* pHeapListOrZapModule */);
}
#endif // !DACCESS_COMPILE
Expand Down
Loading