@@ -558,6 +558,8 @@ private void CompileMethodCleanup()
558558 _actualInstructionSetUnsupported = default ( InstructionSetFlags ) ;
559559#endif
560560
561+ _instantiationToJitVisibleInstantiation = null ;
562+
561563 _pgoResults . Clear ( ) ;
562564 }
563565
@@ -644,6 +646,25 @@ private bool Get_CORINFO_METHOD_INFO(MethodDesc method, MethodIL methodIL, CORIN
644646 return true ;
645647 }
646648
649+ private Dictionary < Instantiation , IntPtr [ ] > _instantiationToJitVisibleInstantiation = null ;
650+ private CORINFO_CLASS_STRUCT_ * * GetJitInstantiation ( Instantiation inst )
651+ {
652+ IntPtr [ ] jitVisibleInstantiation ;
653+ if ( _instantiationToJitVisibleInstantiation == null )
654+ {
655+ _instantiationToJitVisibleInstantiation = new Dictionary < Instantiation , IntPtr [ ] > ( ) ;
656+ }
657+
658+ if ( ! _instantiationToJitVisibleInstantiation . TryGetValue ( inst , out jitVisibleInstantiation ) )
659+ {
660+ jitVisibleInstantiation = new IntPtr [ inst . Length ] ;
661+ for ( int i = 0 ; i < inst . Length ; i ++ )
662+ jitVisibleInstantiation [ i ] = ( IntPtr ) ObjectToHandle ( inst [ i ] ) ;
663+ _instantiationToJitVisibleInstantiation . Add ( inst , jitVisibleInstantiation ) ;
664+ }
665+ return ( CORINFO_CLASS_STRUCT_ * * ) GetPin ( jitVisibleInstantiation ) ;
666+ }
667+
647668 private void Get_CORINFO_SIG_INFO ( MethodDesc method , CORINFO_SIG_INFO * sig , bool suppressHiddenArgument = false )
648669 {
649670 Get_CORINFO_SIG_INFO ( method . Signature , sig ) ;
@@ -668,10 +689,12 @@ private void Get_CORINFO_SIG_INFO(MethodDesc method, CORINFO_SIG_INFO* sig, bool
668689 sig ->sigInst . classInstCount = ( uint ) owningTypeInst . Length ;
669690 if ( owningTypeInst . Length > 0 )
670691 {
671- var classInst = new IntPtr [ owningTypeInst . Length ] ;
672- for ( int i = 0 ; i < owningTypeInst . Length ; i ++ )
673- classInst [ i ] = ( IntPtr ) ObjectToHandle ( owningTypeInst [ i ] ) ;
674- sig ->sigInst . classInst = ( CORINFO_CLASS_STRUCT_ * * ) GetPin ( classInst ) ;
692+ sig ->sigInst . classInst = GetJitInstantiation ( owningTypeInst ) ;
693+ }
694+
695+ if ( method . Instantiation . Length != 0 )
696+ {
697+ sig ->sigInst . methInst = GetJitInstantiation ( method . Instantiation ) ;
675698 }
676699 }
677700
0 commit comments