@@ -2536,20 +2536,6 @@ Stub * MakeInstantiatingStubWorker(MethodDesc *pMD)
2536
2536
}
2537
2537
#endif // defined(FEATURE_SHARE_GENERIC_CODE)
2538
2538
2539
- extern " C" size_t CallDescrWorkerInternalReturnAddressOffset;
2540
-
2541
- bool IsCallDescrWorkerInternalReturnAddress (PCODE pCode)
2542
- {
2543
- LIMITED_METHOD_CONTRACT;
2544
- #ifdef FEATURE_EH_FUNCLETS
2545
- size_t CallDescrWorkerInternalReturnAddress = (size_t )CallDescrWorkerInternal + CallDescrWorkerInternalReturnAddressOffset;
2546
-
2547
- return pCode == CallDescrWorkerInternalReturnAddress;
2548
- #else // FEATURE_EH_FUNCLETS
2549
- return false ;
2550
- #endif // FEATURE_EH_FUNCLETS
2551
- }
2552
-
2553
2539
// =============================================================================
2554
2540
// This function generates the real code when from Preemptive mode.
2555
2541
// It is specifically designed to work with the UnmanagedCallersOnlyAttribute.
@@ -2645,76 +2631,60 @@ extern "C" PCODE STDCALL PreStubWorker(TransitionBlock* pTransitionBlock, Method
2645
2631
2646
2632
pPFrame->Push (CURRENT_THREAD);
2647
2633
2648
- EX_TRY
2649
- {
2650
- bool propagateExceptionToNativeCode = IsCallDescrWorkerInternalReturnAddress (pTransitionBlock->m_ReturnAddress );
2634
+ INSTALL_MANAGED_EXCEPTION_DISPATCHER;
2635
+ INSTALL_UNWIND_AND_CONTINUE_HANDLER;
2651
2636
2652
- INSTALL_MANAGED_EXCEPTION_DISPATCHER_EX;
2653
- INSTALL_UNWIND_AND_CONTINUE_HANDLER_EX;
2637
+ // Make sure the method table is restored, and method instantiation if present
2638
+ pMD->CheckRestore ();
2639
+ CONSISTENCY_CHECK (GetAppDomain ()->CheckCanExecuteManagedCode (pMD));
2654
2640
2655
- // Make sure the method table is restored, and method instantiation if present
2656
- pMD->CheckRestore ();
2657
- CONSISTENCY_CHECK (GetAppDomain ()->CheckCanExecuteManagedCode (pMD));
2641
+ MethodTable* pDispatchingMT = NULL ;
2642
+ if (pMD->IsVtableMethod ())
2643
+ {
2644
+ OBJECTREF curobj = pPFrame->GetThis ();
2658
2645
2659
- MethodTable* pDispatchingMT = NULL ;
2660
- if (pMD->IsVtableMethod ())
2646
+ if (curobj != NULL ) // Check for virtual function called non-virtually on a NULL object
2661
2647
{
2662
- OBJECTREF curobj = pPFrame-> GetThis ();
2648
+ pDispatchingMT = curobj-> GetMethodTable ();
2663
2649
2664
- if (curobj != NULL ) // Check for virtual function called non-virtually on a NULL object
2650
+ if (pDispatchingMT-> IsIDynamicInterfaceCastable ())
2665
2651
{
2666
- pDispatchingMT = curobj->GetMethodTable ();
2652
+ MethodTable* pMDMT = pMD->GetMethodTable ();
2653
+ TypeHandle objectType (pDispatchingMT);
2654
+ TypeHandle methodType (pMDMT);
2667
2655
2668
- if (pDispatchingMT->IsIDynamicInterfaceCastable ())
2656
+ GCStress<cfg_any>::MaybeTrigger ();
2657
+ INDEBUG (curobj = NULL ); // curobj is unprotected and CanCastTo() can trigger GC
2658
+ if (!objectType.CanCastTo (methodType))
2669
2659
{
2670
- MethodTable* pMDMT = pMD->GetMethodTable ();
2671
- TypeHandle objectType (pDispatchingMT);
2672
- TypeHandle methodType (pMDMT);
2673
-
2674
- GCStress<cfg_any>::MaybeTrigger ();
2675
- INDEBUG (curobj = NULL ); // curobj is unprotected and CanCastTo() can trigger GC
2676
- if (!objectType.CanCastTo (methodType))
2677
- {
2678
- // Apparently IDynamicInterfaceCastable magic was involved when we chose this method to be called
2679
- // that's why we better stick to the MethodTable it belongs to, otherwise
2680
- // DoPrestub() will fail not being able to find implementation for pMD in pDispatchingMT.
2660
+ // Apparently IDynamicInterfaceCastable magic was involved when we chose this method to be called
2661
+ // that's why we better stick to the MethodTable it belongs to, otherwise
2662
+ // DoPrestub() will fail not being able to find implementation for pMD in pDispatchingMT.
2681
2663
2682
- pDispatchingMT = pMDMT;
2683
- }
2664
+ pDispatchingMT = pMDMT;
2684
2665
}
2666
+ }
2685
2667
2686
- // For value types, the only virtual methods are interface implementations.
2687
- // Thus pDispatching == pMT because there
2688
- // is no inheritance in value types. Note the BoxedEntryPointStubs are shared
2689
- // between all sharable generic instantiations, so the == test is on
2690
- // canonical method tables.
2668
+ // For value types, the only virtual methods are interface implementations.
2669
+ // Thus pDispatching == pMT because there
2670
+ // is no inheritance in value types. Note the BoxedEntryPointStubs are shared
2671
+ // between all sharable generic instantiations, so the == test is on
2672
+ // canonical method tables.
2691
2673
#ifdef _DEBUG
2692
- MethodTable* pMDMT = pMD->GetMethodTable (); // put this here to see what the MT is in debug mode
2693
- _ASSERTE (!pMD->GetMethodTable ()->IsValueType () ||
2694
- (pMD->IsUnboxingStub () && (pDispatchingMT->GetCanonicalMethodTable () == pMDMT->GetCanonicalMethodTable ())));
2674
+ MethodTable* pMDMT = pMD->GetMethodTable (); // put this here to see what the MT is in debug mode
2675
+ _ASSERTE (!pMD->GetMethodTable ()->IsValueType () ||
2676
+ (pMD->IsUnboxingStub () && (pDispatchingMT->GetCanonicalMethodTable () == pMDMT->GetCanonicalMethodTable ())));
2695
2677
#endif // _DEBUG
2696
- }
2697
- }
2698
-
2699
- GCX_PREEMP_THREAD_EXISTS (CURRENT_THREAD);
2700
- {
2701
- pbRetVal = pMD->DoPrestub (pDispatchingMT, CallerGCMode::Coop);
2702
2678
}
2703
-
2704
- UNINSTALL_UNWIND_AND_CONTINUE_HANDLER_EX (propagateExceptionToNativeCode);
2705
- UNINSTALL_MANAGED_EXCEPTION_DISPATCHER_EX (propagateExceptionToNativeCode);
2706
2679
}
2707
- EX_CATCH
2680
+
2681
+ GCX_PREEMP_THREAD_EXISTS (CURRENT_THREAD);
2708
2682
{
2709
- if (g_isNewExceptionHandlingEnabled)
2710
- {
2711
- OBJECTHANDLE ohThrowable = CURRENT_THREAD->LastThrownObjectHandle ();
2712
- _ASSERTE (ohThrowable);
2713
- StackTraceInfo::AppendElement (ohThrowable, 0 , (UINT_PTR)pTransitionBlock, pMD, NULL );
2714
- }
2715
- EX_RETHROW;
2683
+ pbRetVal = pMD->DoPrestub (pDispatchingMT, CallerGCMode::Coop);
2716
2684
}
2717
- EX_END_CATCH (SwallowAllExceptions)
2685
+
2686
+ UNINSTALL_UNWIND_AND_CONTINUE_HANDLER;
2687
+ UNINSTALL_MANAGED_EXCEPTION_DISPATCHER;
2718
2688
2719
2689
{
2720
2690
HardwareExceptionHolder;
@@ -3184,10 +3154,8 @@ EXTERN_C PCODE STDCALL ExternalMethodFixupWorker(TransitionBlock * pTransitionBl
3184
3154
3185
3155
pEMFrame->Push (CURRENT_THREAD); // Push the new ExternalMethodFrame onto the frame stack
3186
3156
3187
- bool propagateExceptionToNativeCode = IsCallDescrWorkerInternalReturnAddress (pTransitionBlock->m_ReturnAddress );
3188
-
3189
- INSTALL_MANAGED_EXCEPTION_DISPATCHER_EX;
3190
- INSTALL_UNWIND_AND_CONTINUE_HANDLER_EX;
3157
+ INSTALL_MANAGED_EXCEPTION_DISPATCHER;
3158
+ INSTALL_UNWIND_AND_CONTINUE_HANDLER;
3191
3159
3192
3160
bool fVirtual = false ;
3193
3161
MethodDesc * pMD = NULL ;
@@ -3429,8 +3397,8 @@ EXTERN_C PCODE STDCALL ExternalMethodFixupWorker(TransitionBlock * pTransitionBl
3429
3397
}
3430
3398
// Ready to return
3431
3399
3432
- UNINSTALL_UNWIND_AND_CONTINUE_HANDLER_EX (propagateExceptionToNativeCode) ;
3433
- UNINSTALL_MANAGED_EXCEPTION_DISPATCHER_EX (propagateExceptionToNativeCode) ;
3400
+ UNINSTALL_UNWIND_AND_CONTINUE_HANDLER ;
3401
+ UNINSTALL_MANAGED_EXCEPTION_DISPATCHER ;
3434
3402
3435
3403
pEMFrame->Pop (CURRENT_THREAD); // Pop the ExternalMethodFrame from the frame stack
3436
3404
0 commit comments