@@ -24,11 +24,26 @@ internal static void ThrowInvalidCastException(object fromType, void* toTypeHnd)
24
24
throw null ! ; // Provide hint to the inliner that this method does not return
25
25
}
26
26
27
- [ MethodImpl ( MethodImplOptions . InternalCall ) ]
28
- private static extern object IsInstanceOfAny_NoCacheLookup ( void * toTypeHnd , object obj ) ;
27
+ [ LibraryImport ( RuntimeHelpers . QCall ) ]
28
+ [ return : MarshalAs ( UnmanagedType . Bool ) ]
29
+ private static partial bool IsInstanceOf_NoCacheLookup ( void * toTypeHnd , [ MarshalAs ( UnmanagedType . Bool ) ] bool throwCastException , ObjectHandleOnStack obj ) ;
29
30
30
- [ MethodImpl ( MethodImplOptions . InternalCall ) ]
31
- private static extern object ChkCastAny_NoCacheLookup ( void * toTypeHnd , object obj ) ;
31
+ [ MethodImpl ( MethodImplOptions . NoInlining ) ]
32
+ private static object ? IsInstanceOfAny_NoCacheLookup ( void * toTypeHnd , object obj )
33
+ {
34
+ if ( IsInstanceOf_NoCacheLookup ( toTypeHnd , false , ObjectHandleOnStack . Create ( ref obj ) ) )
35
+ {
36
+ return obj ;
37
+ }
38
+ return null ;
39
+ }
40
+
41
+ [ MethodImpl ( MethodImplOptions . NoInlining ) ]
42
+ private static object ChkCastAny_NoCacheLookup ( void * toTypeHnd , object obj )
43
+ {
44
+ IsInstanceOf_NoCacheLookup ( toTypeHnd , true , ObjectHandleOnStack . Create ( ref obj ) ) ;
45
+ return obj ;
46
+ }
32
47
33
48
[ MethodImpl ( MethodImplOptions . InternalCall ) ]
34
49
private static extern void WriteBarrier ( ref object ? dst , object ? obj ) ;
@@ -464,13 +479,13 @@ private static void StelemRef_Helper_NoCacheLookup(ref object? element, void* el
464
479
{
465
480
Debug . Assert ( obj != null ) ;
466
481
467
- obj = IsInstanceOfAny_NoCacheLookup ( elementType , obj ) ;
468
- if ( obj == null )
482
+ object ? obj2 = IsInstanceOfAny_NoCacheLookup ( elementType , obj ) ;
483
+ if ( obj2 == null )
469
484
{
470
485
ThrowArrayMismatchException ( ) ;
471
486
}
472
487
473
- WriteBarrier ( ref element , obj ) ;
488
+ WriteBarrier ( ref element , obj2 ) ;
474
489
}
475
490
476
491
[ DebuggerHidden ]
@@ -496,8 +511,7 @@ private static unsafe void ArrayTypeCheck_Helper(object obj, void* elementType)
496
511
{
497
512
Debug . Assert ( obj != null ) ;
498
513
499
- obj = IsInstanceOfAny_NoCacheLookup ( elementType , obj ) ;
500
- if ( obj == null )
514
+ if ( IsInstanceOfAny_NoCacheLookup ( elementType , obj ) == null )
501
515
{
502
516
ThrowArrayMismatchException ( ) ;
503
517
}
0 commit comments