Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 9562c55

Browse files
jkoritzinskyAaronRobinsonMSFT
authored andcommitted
[release/3.0] Opt COM methods out of the new Windows instance-method handling (#24012)
* Opt COM methods out of the new Windows instance-method handling. * Remove calls to run the MarshalStructReturn tests since we're rolling back the calling convention support change.
1 parent d833cac commit 9562c55

File tree

4 files changed

+5
-6
lines changed

4 files changed

+5
-6
lines changed

src/vm/dllimport.cpp

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3956,7 +3956,10 @@ static void CreateNDirectStubWorker(StubState* pss,
39563956
BOOL fMarshalReturnValueFirst = FALSE;
39573957

39583958
BOOL fReverseWithReturnBufferArg = FALSE;
3959-
bool isInstanceMethod = fStubNeedsCOM || fThisCall;
3959+
// Only consider ThisCall methods to be instance methods.
3960+
// Techinically COM methods are also instance methods, but we don't want to change the behavior of the built-in
3961+
// COM abi work because there are many users that rely on the current behavior (for example WPF).
3962+
bool isInstanceMethod = fThisCall;
39603963

39613964
// We can only change fMarshalReturnValueFirst to true when we are NOT doing HRESULT-swapping!
39623965
// When we are HRESULT-swapping, the managed return type is actually the type of the last parameter and not the return type.

src/vm/ilmarshalers.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -583,9 +583,7 @@ class ILMarshaler
583583
bool byrefNativeReturn = false;
584584
CorElementType typ = ELEMENT_TYPE_VOID;
585585
UINT32 nativeSize = 0;
586-
bool nativeMethodIsMemberFunction = (m_pslNDirect->TargetHasThis() && IsCLRToNative(m_dwMarshalFlags))
587-
|| (m_pslNDirect->HasThis() && !IsCLRToNative(m_dwMarshalFlags))
588-
|| ((CorInfoCallConv)m_pslNDirect->GetStubTargetCallingConv() == CORINFO_CALLCONV_THISCALL);
586+
bool nativeMethodIsMemberFunction = (CorInfoCallConv)m_pslNDirect->GetStubTargetCallingConv() == CORINFO_CALLCONV_THISCALL;
589587

590588
// we need to convert value type return types to primitives as
591589
// JIT does not inline P/Invoke calls that return structures

tests/src/Interop/COM/NETClients/Primitives/NumericTests.cs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ public void Run()
3838
this.Marshal_Float(a / 100f, b / 100f);
3939
this.Marshal_Double(a / 100.0, b / 100.0);
4040
this.Marshal_ManyInts();
41-
this.Marshal_Struct_Return();
4241
}
4342

4443
static private bool EqualByBound(float expected, float actual)

tests/src/Interop/COM/NativeClients/Primitives/NumericTests.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -265,5 +265,4 @@ void Run_NumericTests()
265265
MarshalFloat(numericTesting, (float)a / 100.f, (float)b / 100.f);
266266
MarshalDouble(numericTesting, (double)a / 100.0, (double)b / 100.0);
267267
MarshalManyInts(numericTesting);
268-
MarshalStructReturn(numericTesting);
269268
}

0 commit comments

Comments
 (0)