Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2020072

Browse files
jkoritzinskypull[bot]
authored andcommitted
Simplify our global new/delete implementations (dotnet#101826)
1 parent 484f70e commit 2020072

File tree

9 files changed

+30
-383
lines changed

9 files changed

+30
-383
lines changed

src/coreclr/inc/clrconfigvalues.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -817,7 +817,6 @@ CONFIG_STRING_INFO(INTERNAL_DumpOnClassLoad, W("DumpOnClassLoad"), "Dumps inform
817817
CONFIG_DWORD_INFO(INTERNAL_ExpandAllOnLoad, W("ExpandAllOnLoad"), 0, "")
818818
CONFIG_DWORD_INFO(INTERNAL_ForceRelocs, W("ForceRelocs"), 0, "")
819819
CONFIG_DWORD_INFO(INTERNAL_GenerateLongJumpDispatchStubRatio, W("GenerateLongJumpDispatchStubRatio"), 0, "Useful for testing VSD on AMD64")
820-
CONFIG_DWORD_INFO(INTERNAL_HashStack, W("HashStack"), 0, "")
821820
CONFIG_DWORD_INFO(INTERNAL_HostManagerConfig, W("HostManagerConfig"), (DWORD)-1, "")
822821
CONFIG_DWORD_INFO(INTERNAL_HostTestThreadAbort, W("HostTestThreadAbort"), 0, "")
823822
CONFIG_STRING_INFO(INTERNAL_InvokeHalt, W("InvokeHalt"), "Throws an assert when the given method is invoked through reflection.")

src/coreclr/inc/clrhost.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -65,10 +65,6 @@ BOOL ClrVirtualProtect(LPVOID lpAddress, SIZE_T dwSize, DWORD flNewProtect, PDWO
6565
HANDLE ClrGetProcessExecutableHeap();
6666
#endif
6767

68-
#ifdef FAILPOINTS_ENABLED
69-
extern int RFS_HashStack();
70-
#endif
71-
7268
// Critical section support for CLR DLLs other than the EE.
7369
// Include the header defining each Crst type and its corresponding level (relative rank). This is
7470
// auto-generated from a tool that takes a high-level description of each Crst type and its dependencies.

src/coreclr/inc/holder.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -997,19 +997,6 @@ FORCEINLINE void Delete(TYPE *value)
997997
template<typename _TYPE>
998998
using NewHolder = SpecializedWrapper<_TYPE, Delete<_TYPE>>;
999999

1000-
//-----------------------------------------------------------------------------
1001-
// NewExecutableHolder : New'ed memory holder for executable memory.
1002-
//
1003-
// {
1004-
// NewExecutableHolder<Foo> foo = (Foo*) new (executable) Byte[num];
1005-
// } // delete foo on out of scope
1006-
//-----------------------------------------------------------------------------
1007-
// IJW
1008-
template<class T> void DeleteExecutable(T *p);
1009-
1010-
template<typename _TYPE>
1011-
using NewExecutableHolder = SpecializedWrapper<_TYPE, DeleteExecutable<_TYPE>>;
1012-
10131000
//-----------------------------------------------------------------------------
10141001
// NewArrayHolder : New []'ed pointer holder
10151002
// {

src/coreclr/inc/switches.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,13 +33,6 @@
3333
#define LOGGING
3434
#endif
3535

36-
#if !defined(FEATURE_UTILCODE_NO_DEPENDENCIES)
37-
// Failpoint support
38-
#if defined(_DEBUG) && !defined(DACCESS_COMPILE) && !defined(TARGET_UNIX)
39-
#define FAILPOINTS_ENABLED
40-
#endif
41-
#endif //!defined(FEATURE_UTILCODE_NO_DEPENDENCIES)
42-
4336
#if 0
4437
// Enable to track details of EESuspension
4538
#define TIME_SUSPEND

src/coreclr/inc/utilcode.h

Lines changed: 0 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -3716,37 +3716,6 @@ namespace util
37163716
}
37173717
}
37183718

3719-
3720-
/* ------------------------------------------------------------------------ *
3721-
* Overloaded operators for the executable heap
3722-
* ------------------------------------------------------------------------ */
3723-
3724-
#ifdef HOST_WINDOWS
3725-
3726-
struct CExecutable { int x; };
3727-
extern const CExecutable executable;
3728-
3729-
void * __cdecl operator new(size_t n, const CExecutable&);
3730-
void * __cdecl operator new[](size_t n, const CExecutable&);
3731-
void * __cdecl operator new(size_t n, const CExecutable&, const std::nothrow_t&) noexcept;
3732-
void * __cdecl operator new[](size_t n, const CExecutable&, const std::nothrow_t&) noexcept;
3733-
3734-
3735-
//
3736-
// Executable heap delete to match the executable heap new above.
3737-
//
3738-
template<class T> void DeleteExecutable(T *p)
3739-
{
3740-
if (p != NULL)
3741-
{
3742-
p->T::~T();
3743-
3744-
HeapFree(ClrGetProcessExecutableHeap(), 0, p);
3745-
}
3746-
}
3747-
3748-
#endif // HOST_WINDOWS
3749-
37503719
INDEBUG(BOOL DbgIsExecutable(LPVOID lpMem, SIZE_T length);)
37513720

37523721
BOOL ThreadWillCreateGuardPage(SIZE_T sizeReservedStack, SIZE_T sizeCommittedStack);

src/coreclr/utilcode/clrhost.cpp

Lines changed: 0 additions & 73 deletions
Original file line numberDiff line numberDiff line change
@@ -39,79 +39,6 @@ void* GetClrModuleBase()
3939

4040
thread_local int t_CantAllocCount;
4141

42-
#ifdef FAILPOINTS_ENABLED
43-
typedef int (*FHashStack) ();
44-
45-
static FHashStack fHashStack = 0;
46-
static _TEB *HashStackSetupThread = NULL;
47-
static _TEB *RFSCustomDataSetupThread = NULL;
48-
49-
static void SetupHashStack ()
50-
{
51-
CANNOT_HAVE_CONTRACT;
52-
53-
FHashStack oldValue = InterlockedCompareExchangeT(&fHashStack,
54-
reinterpret_cast<FHashStack>(1), reinterpret_cast<FHashStack>(0));
55-
if ((size_t) oldValue >= 2) {
56-
return;
57-
}
58-
else if ((size_t) oldValue == 0) {
59-
// We are the first thread to initialize
60-
HashStackSetupThread = NtCurrentTeb();
61-
62-
if (CLRConfig::GetConfigValue(CLRConfig::INTERNAL_HashStack) == 0) {
63-
fHashStack = (FHashStack) 2;
64-
return;
65-
}
66-
67-
PAL_TRY(void *, unused, NULL) {
68-
FHashStack func;
69-
HMODULE hmod = WszLoadLibrary(W("mscorrfs.dll"), NULL, 0);
70-
if (hmod) {
71-
func = (FHashStack)GetProcAddress (hmod, "HashStack");
72-
if (func == 0) {
73-
func = (FHashStack)2;
74-
}
75-
}
76-
else
77-
func = (FHashStack)2;
78-
fHashStack = func;
79-
}
80-
PAL_EXCEPT(EXCEPTION_EXECUTE_HANDLER)
81-
{
82-
fHashStack = (FHashStack) 2;
83-
}
84-
PAL_ENDTRY;
85-
}
86-
else if (NtCurrentTeb() == HashStackSetupThread) {
87-
// We get here while initializing
88-
return;
89-
}
90-
else {
91-
// All other threads will wait
92-
while (fHashStack == (FHashStack) 1) {
93-
ClrSleepEx (100, FALSE);
94-
}
95-
}
96-
}
97-
98-
int RFS_HashStack ()
99-
{
100-
CANNOT_HAVE_CONTRACT;
101-
102-
if ((size_t)fHashStack < 2) {
103-
SetupHashStack ();
104-
}
105-
106-
if ((size_t)fHashStack <= 2) {
107-
return 0;
108-
}
109-
else
110-
return fHashStack ();
111-
}
112-
113-
#endif // FAILPOINTS_ENABLED
114-
11542
DWORD GetClrModulePathName(SString& buffer)
11643
{
11744
#ifdef HOST_WINDOWS

0 commit comments

Comments
 (0)