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

Cleanup some code under FEATURE_STUBS_AS_IL #104731

Merged
merged 33 commits into from
Sep 19, 2024
Merged
Show file tree
Hide file tree
Changes from 11 commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
c06cc3f
Use direct SinglecastDelegateInvokeStub on windows x86
huoyaoyuan Jul 11, 2024
4845202
Cleanup ifdefs
huoyaoyuan Jul 11, 2024
faf25e7
EmitDebugBreak is unused
huoyaoyuan Jul 11, 2024
09fcf2b
endif format
huoyaoyuan Jul 11, 2024
19057f9
Restore comment
huoyaoyuan Jul 11, 2024
157325b
Fix JIT_InternalThrowFromHelper reference
huoyaoyuan Jul 11, 2024
c98be47
Use IL stub for Delegate.Invoke
huoyaoyuan Jul 15, 2024
72fd2d6
Remove SinglecastDelegateInvokeStub in asm
huoyaoyuan Jul 15, 2024
e60b3f1
Fix method name and argument count
huoyaoyuan Jul 17, 2024
7f117aa
Code quality
huoyaoyuan Jul 17, 2024
cd648fa
Delete JIT_InternalThrow and CorInfoException
huoyaoyuan Jul 17, 2024
b078f3a
Apply the same codegen to ilc
huoyaoyuan Jul 17, 2024
1ae9027
Add KeepAlive
huoyaoyuan Jul 18, 2024
a862368
Emit recursive call instead
huoyaoyuan Jul 21, 2024
39dc3f6
Merge branch 'main' into stubs-as-il
huoyaoyuan Jul 21, 2024
2c0510b
Merge branch 'main' into stubs-as-il
huoyaoyuan Jul 22, 2024
98b8b4e
Fix type
huoyaoyuan Jul 23, 2024
9130aa8
Merge branch 'main' into stubs-as-il
huoyaoyuan Jul 29, 2024
ee90e03
Add tests for indirect delegate invocation
huoyaoyuan Aug 1, 2024
b5304ad
Use public reflection instead.
huoyaoyuan Aug 1, 2024
22e344e
Use ldvirtftn to bypass this check
huoyaoyuan Aug 6, 2024
27ae5ba
Merge branch 'main'
huoyaoyuan Aug 6, 2024
0785f0b
Use winner from CompareExchange
huoyaoyuan Aug 7, 2024
8992882
Apply suggestions from code review
huoyaoyuan Sep 18, 2024
e06998c
Merge branch 'main' into stubs-as-il
huoyaoyuan Sep 18, 2024
c221eed
Return Stub from GetInvokeMethodStub
huoyaoyuan Sep 18, 2024
1c640f8
Delete NEWSTUB_FL_MULTICAST and dependents
huoyaoyuan Sep 18, 2024
e39afa1
Rename
huoyaoyuan Sep 19, 2024
eebbc01
Renumber
huoyaoyuan Sep 19, 2024
c2cf515
Merge branch 'main'
huoyaoyuan Sep 19, 2024
bc1a766
Format
huoyaoyuan Sep 19, 2024
ee674a3
Update src/coreclr/vm/method.hpp
jkotas Sep 19, 2024
fdd83eb
Handle new stub in ILStubManager
jkotas Sep 19, 2024
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
1 change: 1 addition & 0 deletions src/coreclr/debug/ee/frameinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1563,6 +1563,7 @@ StackWalkAction DebuggerWalkStackProc(CrawlFrame *pCF, void *data)
_ASSERTE(md->IsDynamicMethod());
DynamicMethodDesc* dMD = md->AsDynamicMethodDesc();
use |= dMD->IsMulticastStub();
use |= dMD->IsSinglecastStub();
huoyaoyuan marked this conversation as resolved.
Show resolved Hide resolved
use |= dMD->GetILStubType() == DynamicMethodDesc::StubTailCallCallTarget;

if (use)
Expand Down
16 changes: 0 additions & 16 deletions src/coreclr/inc/corinfo.h
Original file line number Diff line number Diff line change
Expand Up @@ -920,22 +920,6 @@ enum CORINFO_EH_CLAUSE_FLAGS
CORINFO_EH_CLAUSE_SAMETRY = 0x0010, // This clause covers same try block as the previous one
};

// This enumeration is passed to InternalThrow
enum CorInfoException
{
CORINFO_NullReferenceException,
CORINFO_DivideByZeroException,
CORINFO_InvalidCastException,
CORINFO_IndexOutOfRangeException,
CORINFO_OverflowException,
CORINFO_SynchronizationLockException,
CORINFO_ArrayTypeMismatchException,
CORINFO_RankException,
CORINFO_ArgumentNullException,
CORINFO_ArgumentException,
CORINFO_Exception_Count,
};

// These are used to detect array methods as NamedIntrinsic in JIT importer,
// which otherwise don't have a name.
enum class CorInfoArrayIntrinsic
Expand Down
21 changes: 0 additions & 21 deletions src/coreclr/vm/amd64/AsmHelpers.asm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
include AsmMacros.inc
include asmconstants.inc

extern JIT_InternalThrow:proc
extern NDirectImportWorker:proc
extern ThePreStub:proc
extern ProfileEnter:proc
Expand Down Expand Up @@ -565,26 +564,6 @@ NESTED_ENTRY ProfileTailcallNaked, _TEXT
ret
NESTED_END ProfileTailcallNaked, _TEXT


extern JIT_InternalThrowFromHelper:proc

LEAF_ENTRY SinglecastDelegateInvokeStub, _TEXT

test rcx, rcx
jz NullObject


mov rax, [rcx + OFFSETOF__DelegateObject___methodPtr]
mov rcx, [rcx + OFFSETOF__DelegateObject___target] ; replace "this" pointer

jmp rax

NullObject:
mov rcx, CORINFO_NullReferenceException_ASM
jmp JIT_InternalThrow

LEAF_END SinglecastDelegateInvokeStub, _TEXT

ifdef FEATURE_TIERED_COMPILATION

extern OnCallCountThresholdReached:proc
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/vm/amd64/JitHelpers_Fast.asm
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,6 @@ ifdef _DEBUG
extern JIT_WriteBarrier_Debug:proc
endif

extern JIT_InternalThrow:proc


; JIT_ByRefWriteBarrier has weird semantics, see usage in StubLinkerX86.cpp
;
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/vm/amd64/JitHelpers_Slow.asm
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,6 @@ extern g_pStringClass:QWORD
extern FramedAllocateString:proc
extern JIT_NewArr1:proc

extern JIT_InternalThrow:proc

ifdef _DEBUG
; Version for when we're sure to be in the GC, checks whether or not the card
; needs to be updated
Expand Down
18 changes: 0 additions & 18 deletions src/coreclr/vm/amd64/asmconstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,12 +124,6 @@ ASMCONSTANTS_C_ASSERT(OFFSETOF__ThreadExceptionState__m_pCurrentTracker



#define OFFSETOF__DelegateObject___methodPtr 0x18
ASMCONSTANT_OFFSETOF_ASSERT(DelegateObject, _methodPtr);

#define OFFSETOF__DelegateObject___target 0x08
ASMCONSTANT_OFFSETOF_ASSERT(DelegateObject, _target);

#define OFFSETOF__MethodTable__m_dwFlags 0x00
ASMCONSTANTS_C_ASSERT(OFFSETOF__MethodTable__m_dwFlags
== offsetof(MethodTable, m_dwFlags));
Expand Down Expand Up @@ -198,18 +192,6 @@ ASMCONSTANTS_C_ASSERT(OFFSETOF__DynamicStaticsInfo__m_pNonGCStatics
ASMCONSTANTS_C_ASSERT(OFFSETOF__DynamicStaticsInfo__m_pGCStatics
== offsetof(DynamicStaticsInfo, m_pGCStatics));

#define CORINFO_NullReferenceException_ASM 0
ASMCONSTANTS_C_ASSERT( CORINFO_NullReferenceException_ASM
== CORINFO_NullReferenceException);

#define CORINFO_IndexOutOfRangeException_ASM 3
ASMCONSTANTS_C_ASSERT( CORINFO_IndexOutOfRangeException_ASM
== CORINFO_IndexOutOfRangeException);

#define CORINFO_ArgumentException_ASM 9
ASMCONSTANTS_C_ASSERT( CORINFO_ArgumentException_ASM
== CORINFO_ArgumentException);


// MachState offsets (AMD64\gmscpu.h)

Expand Down
1 change: 0 additions & 1 deletion src/coreclr/vm/amd64/cgencpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ class ComCallMethodDesc;
//
// functions implemented in AMD64 assembly
//
huoyaoyuan marked this conversation as resolved.
Show resolved Hide resolved
EXTERN_C void SinglecastDelegateInvokeStub();

#define COMMETHOD_PREPAD 16 // # extra bytes to allocate in addition to sizeof(ComCallMethodDesc)
#define COMMETHOD_CALL_PRESTUB_SIZE 6 // 32-bit indirect relative call
Expand Down
17 changes: 0 additions & 17 deletions src/coreclr/vm/amd64/unixasmhelpers.S
Original file line number Diff line number Diff line change
Expand Up @@ -182,23 +182,6 @@ NESTED_END OnHijackTripThread, _TEXT

#endif // FEATURE_HIJACK

LEAF_ENTRY SinglecastDelegateInvokeStub, _TEXT

test rdi, rdi
jz NullObject


mov rax, [rdi + OFFSETOF__DelegateObject___methodPtr]
mov rdi, [rdi + OFFSETOF__DelegateObject___target] // replace "this" pointer

jmp rax

NullObject:
mov rdi, CORINFO_NullReferenceException_ASM
jmp C_FUNC(JIT_InternalThrow)

LEAF_END SinglecastDelegateInvokeStub, _TEXT

#ifdef FEATURE_TIERED_COMPILATION

NESTED_ENTRY OnCallCountThresholdReachedStub, _TEXT, NoHandler
Expand Down
14 changes: 0 additions & 14 deletions src/coreclr/vm/arm/asmconstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,6 @@

#define REDIRECTSTUB_SP_OFFSET_CONTEXT 0

#define CORINFO_NullReferenceException_ASM 0
ASMCONSTANTS_C_ASSERT( CORINFO_NullReferenceException_ASM
== CORINFO_NullReferenceException);

#define CORINFO_IndexOutOfRangeException_ASM 3
ASMCONSTANTS_C_ASSERT( CORINFO_IndexOutOfRangeException_ASM
== CORINFO_IndexOutOfRangeException);


// Offset of the array containing the address of captured registers in MachState
#define MachState__captureR4_R11 0x0
Expand All @@ -64,12 +56,6 @@ ASMCONSTANTS_C_ASSERT(LazyMachState_captureSp == offsetof(LazyMachState, capture
#define LazyMachState_captureIp (LazyMachState_captureSp+4)
ASMCONSTANTS_C_ASSERT(LazyMachState_captureIp == offsetof(LazyMachState, captureIp))

#define DelegateObject___methodPtr 0x0c
ASMCONSTANTS_C_ASSERT(DelegateObject___methodPtr == offsetof(DelegateObject, _methodPtr));

#define DelegateObject___target 0x04
ASMCONSTANTS_C_ASSERT(DelegateObject___target == offsetof(DelegateObject, _target));

#define MethodTable__m_BaseSize 0x04
ASMCONSTANTS_C_ASSERT(MethodTable__m_BaseSize == offsetof(MethodTable, m_BaseSize));

Expand Down
16 changes: 0 additions & 16 deletions src/coreclr/vm/arm/asmhelpers.S
Original file line number Diff line number Diff line change
Expand Up @@ -152,22 +152,6 @@ CallDescrWorkerInternalReturnAddressOffset:

LEAF_END LazyMachStateCaptureState, _TEXT

// void SinglecastDelegateInvokeStub(Delegate *pThis)
LEAF_ENTRY SinglecastDelegateInvokeStub, _TEXT
cmp r0, #0
beq LOCAL_LABEL(LNullThis)

ldr r12, [r0, #DelegateObject___methodPtr]
ldr r0, [r0, #DelegateObject___target]

bx r12

LOCAL_LABEL(LNullThis):
mov r0, #CORINFO_NullReferenceException_ASM
b C_FUNC(JIT_InternalThrow)

LEAF_END SinglecastDelegateInvokeStub, _TEXT

//
// r12 = UMEntryThunk*
//
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/vm/arm/cgencpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -939,8 +939,6 @@ class StubLinkerCPU : public StubLinker
VOID EmitComputedInstantiatingMethodStub(MethodDesc* pSharedMD, struct ShuffleEntry *pShuffleEntryArray, void* extraArg);
};

extern "C" void SinglecastDelegateInvokeStub();

#ifdef _MSC_VER
#pragma warning(push)
#pragma warning(disable:4359) // Prevent "warning C4359: 'UMEntryThunkCode': Alignment specifier is less than actual alignment (8), and will be ignored." in crossbitness scenario
Expand Down
15 changes: 0 additions & 15 deletions src/coreclr/vm/arm64/asmconstants.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,15 +72,6 @@ ASMCONSTANTS_C_ASSERT(CallDescrData__pTarget == offsetof(CallDescrD
ASMCONSTANTS_C_ASSERT(CallDescrData__pRetBuffArg == offsetof(CallDescrData, pRetBuffArg))
ASMCONSTANTS_C_ASSERT(CallDescrData__returnValue == offsetof(CallDescrData, returnValue))

#define CORINFO_NullReferenceException_ASM 0
ASMCONSTANTS_C_ASSERT( CORINFO_NullReferenceException_ASM
== CORINFO_NullReferenceException);


#define CORINFO_IndexOutOfRangeException_ASM 3
ASMCONSTANTS_C_ASSERT( CORINFO_IndexOutOfRangeException_ASM
== CORINFO_IndexOutOfRangeException);


// Offset of the array containing the address of captured registers in MachState
#define MachState__captureX19_X29 0x0
Expand Down Expand Up @@ -109,12 +100,6 @@ ASMCONSTANTS_C_ASSERT(LazyMachState_captureIp == offsetof(LazyMachState, capture
#define VASigCookie__pNDirectILStub 0x8
ASMCONSTANTS_C_ASSERT(VASigCookie__pNDirectILStub == offsetof(VASigCookie, pNDirectILStub))

#define DelegateObject___methodPtr 0x18
ASMCONSTANTS_C_ASSERT(DelegateObject___methodPtr == offsetof(DelegateObject, _methodPtr));

#define DelegateObject___target 0x08
ASMCONSTANTS_C_ASSERT(DelegateObject___target == offsetof(DelegateObject, _target));

#define SIZEOF__GSCookie 0x8
ASMCONSTANTS_C_ASSERT(SIZEOF__GSCookie == sizeof(GSCookie));

Expand Down
16 changes: 0 additions & 16 deletions src/coreclr/vm/arm64/asmhelpers.S
Original file line number Diff line number Diff line change
Expand Up @@ -272,22 +272,6 @@ LEAF_ENTRY JIT_WriteBarrier_Callable, _TEXT
br x17
LEAF_END JIT_WriteBarrier_Callable, _TEXT

// void SinglecastDelegateInvokeStub(Delegate *pThis)
LEAF_ENTRY SinglecastDelegateInvokeStub, _TEXT
cmp x0, #0
beq LOCAL_LABEL(LNullThis)

ldr x16, [x0, #DelegateObject___methodPtr]
ldr x0, [x0, #DelegateObject___target]

br x16

LOCAL_LABEL(LNullThis):
mov x0, #CORINFO_NullReferenceException_ASM
b C_FUNC(JIT_InternalThrow)

LEAF_END SinglecastDelegateInvokeStub, _TEXT

//
// x12 = UMEntryThunk*
//
Expand Down
17 changes: 0 additions & 17 deletions src/coreclr/vm/arm64/asmhelpers.asm
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@
IMPORT PreStubWorker
IMPORT NDirectImportWorker
IMPORT VSD_ResolveWorker
IMPORT JIT_InternalThrow
IMPORT ComPreStubWorker
IMPORT COMToCLRWorker
IMPORT CallDescrWorkerUnwindFrameChainHandler
Expand Down Expand Up @@ -317,22 +316,6 @@ EphemeralCheckEnabled

LEAF_END JIT_UpdateWriteBarrierState

; void SinglecastDelegateInvokeStub(Delegate *pThis)
LEAF_ENTRY SinglecastDelegateInvokeStub
cmp x0, #0
beq LNullThis

ldr x16, [x0, #DelegateObject___methodPtr]
ldr x0, [x0, #DelegateObject___target]

br x16

LNullThis
mov x0, #CORINFO_NullReferenceException_ASM
b JIT_InternalThrow

LEAF_END

#ifdef FEATURE_COMINTEROP

; ------------------------------------------------------------------
Expand Down
2 changes: 0 additions & 2 deletions src/coreclr/vm/arm64/cgencpu.h
Original file line number Diff line number Diff line change
Expand Up @@ -518,8 +518,6 @@ class StubLinkerCPU : public StubLinker

};

extern "C" void SinglecastDelegateInvokeStub();


// preferred alignment for data
#define DATA_ALIGNMENT 8
Expand Down
1 change: 1 addition & 0 deletions src/coreclr/vm/class.h
Original file line number Diff line number Diff line change
Expand Up @@ -1893,6 +1893,7 @@ class DelegateEEClass : public EEClass
PTR_Stub m_pStaticCallStub;
PTR_Stub m_pInstRetBuffCallStub;
PTR_MethodDesc m_pInvokeMethod;
PTR_Stub m_pSingleCastInvokeStub;
jkotas marked this conversation as resolved.
Show resolved Hide resolved
PTR_Stub m_pMultiCastInvokeStub;
PTR_Stub m_pWrapperDelegateInvokeStub;
UMThunkMarshInfo* m_pUMThunkMarshInfo;
Expand Down
Loading
Loading