@@ -2039,170 +2039,160 @@ FCIMPL2(MethodDesc*, RuntimeMethodHandle::GetMethodFromCanonical, MethodDesc *pM
2039
2039
}
2040
2040
FCIMPLEND
2041
2041
2042
-
2043
- FCIMPL2 (RuntimeMethodBody *, RuntimeMethodHandle::GetMethodBody, ReflectMethodObject *pMethodUNSAFE, ReflectClassBaseObject *pDeclaringTypeUNSAFE)
2042
+ extern " C" void QCALLTYPE RuntimeMethodHandle_GetMethodBody (MethodDesc* pMethod, EnregisteredTypeHandle pDeclaringType, QCall::ObjectHandleOnStack result)
2044
2043
{
2045
- CONTRACTL
2046
- {
2047
- FCALL_CHECK;
2048
- }
2049
- CONTRACTL_END;
2044
+ QCALL_CONTRACT;
2050
2045
2051
- struct _gc
2046
+ _ASSERTE (pMethod != NULL );
2047
+
2048
+ BEGIN_QCALL;
2049
+
2050
+ GCX_COOP ();
2051
+
2052
+ struct
2052
2053
{
2053
2054
RUNTIMEMETHODBODYREF MethodBodyObj;
2054
2055
RUNTIMEEXCEPTIONHANDLINGCLAUSEREF EHClauseObj;
2055
2056
RUNTIMELOCALVARIABLEINFOREF RuntimeLocalVariableInfoObj;
2056
- U1ARRAYREF U1Array;
2057
- BASEARRAYREF TempArray;
2058
- REFLECTCLASSBASEREF declaringType;
2059
- REFLECTMETHODREF refMethod;
2057
+ U1ARRAYREF U1Array;
2058
+ BASEARRAYREF TempArray;
2060
2059
} gc;
2061
-
2062
2060
gc.MethodBodyObj = NULL ;
2063
2061
gc.EHClauseObj = NULL ;
2064
2062
gc.RuntimeLocalVariableInfoObj = NULL ;
2065
2063
gc.U1Array = NULL ;
2066
2064
gc.TempArray = NULL ;
2067
- gc.declaringType = (REFLECTCLASSBASEREF)ObjectToOBJECTREF (pDeclaringTypeUNSAFE);
2068
- gc.refMethod = (REFLECTMETHODREF)ObjectToOBJECTREF (pMethodUNSAFE);
2069
-
2070
-
2071
- if (!gc.refMethod )
2072
- FCThrowRes (kArgumentNullException , W (" Arg_InvalidHandle" ));
2073
-
2074
- MethodDesc* pMethod = gc.refMethod ->GetMethod ();
2065
+ GCPROTECT_BEGIN (gc);
2075
2066
2076
- TypeHandle declaringType = gc. declaringType == NULL ? TypeHandle () : gc. declaringType -> GetType ( );
2067
+ TypeHandle declaringType = TypeHandle::FromPtr (pDeclaringType );
2077
2068
2078
- if (!pMethod->IsIL ())
2079
- return NULL ;
2080
-
2081
- HELPER_METHOD_FRAME_BEGIN_RET_PROTECT (gc);
2069
+ COR_ILMETHOD* pILHeader = NULL ;
2070
+ if (pMethod->IsIL ())
2082
2071
{
2083
- MethodDesc * pMethodIL = pMethod;
2072
+ MethodDesc* pMethodIL = pMethod;
2084
2073
if (pMethod->IsWrapperStub ())
2085
2074
pMethodIL = pMethod->GetWrappedMethodDesc ();
2086
2075
2087
- COR_ILMETHOD* pILHeader = pMethodIL->GetILHeader ();
2076
+ pILHeader = pMethodIL->GetILHeader ();
2077
+ }
2088
2078
2089
- if (pILHeader)
2090
- {
2091
- MethodTable * pExceptionHandlingClauseMT = CoreLibBinder::GetClass (CLASS__RUNTIME_EH_CLAUSE);
2092
- TypeHandle thEHClauseArray = ClassLoader::LoadArrayTypeThrowing (TypeHandle (pExceptionHandlingClauseMT), ELEMENT_TYPE_SZARRAY);
2079
+ if (pILHeader)
2080
+ {
2081
+ MethodTable * pExceptionHandlingClauseMT = CoreLibBinder::GetClass (CLASS__RUNTIME_EH_CLAUSE);
2082
+ TypeHandle thEHClauseArray = ClassLoader::LoadArrayTypeThrowing (TypeHandle (pExceptionHandlingClauseMT), ELEMENT_TYPE_SZARRAY);
2093
2083
2094
- MethodTable * pLocalVariableMT = CoreLibBinder::GetClass (CLASS__RUNTIME_LOCAL_VARIABLE_INFO);
2095
- TypeHandle thLocalVariableArray = ClassLoader::LoadArrayTypeThrowing (TypeHandle (pLocalVariableMT), ELEMENT_TYPE_SZARRAY);
2084
+ MethodTable * pLocalVariableMT = CoreLibBinder::GetClass (CLASS__RUNTIME_LOCAL_VARIABLE_INFO);
2085
+ TypeHandle thLocalVariableArray = ClassLoader::LoadArrayTypeThrowing (TypeHandle (pLocalVariableMT), ELEMENT_TYPE_SZARRAY);
2096
2086
2097
- Module* pModule = pMethod->GetModule ();
2098
- COR_ILMETHOD_DECODER::DecoderStatus status;
2099
- COR_ILMETHOD_DECODER header (pILHeader, pModule->GetMDImport (), &status);
2087
+ Module* pModule = pMethod->GetModule ();
2088
+ COR_ILMETHOD_DECODER::DecoderStatus status;
2089
+ COR_ILMETHOD_DECODER header (pILHeader, pModule->GetMDImport (), &status);
2100
2090
2101
- if (status != COR_ILMETHOD_DECODER::SUCCESS)
2091
+ if (status != COR_ILMETHOD_DECODER::SUCCESS)
2092
+ {
2093
+ if (status == COR_ILMETHOD_DECODER::VERIFICATION_ERROR)
2102
2094
{
2103
- if (status == COR_ILMETHOD_DECODER::VERIFICATION_ERROR)
2104
- {
2105
- // Throw a verification HR
2106
- COMPlusThrowHR (COR_E_VERIFICATION);
2107
- }
2108
- else
2109
- {
2110
- COMPlusThrowHR (COR_E_BADIMAGEFORMAT);
2111
- }
2095
+ // Throw a verification HR
2096
+ COMPlusThrowHR (COR_E_VERIFICATION);
2112
2097
}
2098
+ else
2099
+ {
2100
+ COMPlusThrowHR (COR_E_BADIMAGEFORMAT);
2101
+ }
2102
+ }
2113
2103
2114
- gc.MethodBodyObj = (RUNTIMEMETHODBODYREF)AllocateObject (CoreLibBinder::GetClass (CLASS__RUNTIME_METHOD_BODY));
2104
+ gc.MethodBodyObj = (RUNTIMEMETHODBODYREF)AllocateObject (CoreLibBinder::GetClass (CLASS__RUNTIME_METHOD_BODY));
2115
2105
2116
- gc.MethodBodyObj ->_maxStackSize = header.GetMaxStack ();
2117
- gc.MethodBodyObj ->_initLocals = !!(header.GetFlags () & CorILMethod_InitLocals);
2106
+ gc.MethodBodyObj ->_maxStackSize = header.GetMaxStack ();
2107
+ gc.MethodBodyObj ->_initLocals = !!(header.GetFlags () & CorILMethod_InitLocals);
2118
2108
2119
- if (header.IsFat ())
2120
- gc.MethodBodyObj ->_localVarSigToken = header.GetLocalVarSigTok ();
2121
- else
2122
- gc.MethodBodyObj ->_localVarSigToken = 0 ;
2109
+ if (header.IsFat ())
2110
+ gc.MethodBodyObj ->_localVarSigToken = header.GetLocalVarSigTok ();
2111
+ else
2112
+ gc.MethodBodyObj ->_localVarSigToken = 0 ;
2123
2113
2124
- // Allocate the array of IL and fill it in from the method header.
2125
- BYTE* pIL = const_cast <BYTE*>(header.Code );
2126
- COUNT_T cIL = header.GetCodeSize ();
2127
- gc.U1Array = (U1ARRAYREF) AllocatePrimitiveArray (ELEMENT_TYPE_U1, cIL);
2114
+ // Allocate the array of IL and fill it in from the method header.
2115
+ BYTE* pIL = const_cast <BYTE*>(header.Code );
2116
+ COUNT_T cIL = header.GetCodeSize ();
2117
+ gc.U1Array = (U1ARRAYREF) AllocatePrimitiveArray (ELEMENT_TYPE_U1, cIL);
2128
2118
2129
- SetObjectReference ((OBJECTREF*)&gc.MethodBodyObj ->_IL , gc.U1Array );
2130
- memcpyNoGCRefs (gc.MethodBodyObj ->_IL ->GetDataPtr (), pIL, cIL);
2119
+ SetObjectReference ((OBJECTREF*)&gc.MethodBodyObj ->_IL , gc.U1Array );
2120
+ memcpyNoGCRefs (gc.MethodBodyObj ->_IL ->GetDataPtr (), pIL, cIL);
2131
2121
2132
- // Allocate the array of exception clauses.
2133
- INT32 cEh = (INT32)header.EHCount ();
2134
- const COR_ILMETHOD_SECT_EH* ehInfo = header.EH ;
2135
- gc.TempArray = (BASEARRAYREF) AllocateSzArray (thEHClauseArray, cEh);
2122
+ // Allocate the array of exception clauses.
2123
+ INT32 cEh = (INT32)header.EHCount ();
2124
+ const COR_ILMETHOD_SECT_EH* ehInfo = header.EH ;
2125
+ gc.TempArray = (BASEARRAYREF) AllocateSzArray (thEHClauseArray, cEh);
2136
2126
2137
- SetObjectReference ((OBJECTREF*)&gc.MethodBodyObj ->_exceptionClauses , gc.TempArray );
2127
+ SetObjectReference ((OBJECTREF*)&gc.MethodBodyObj ->_exceptionClauses , gc.TempArray );
2138
2128
2139
- for (INT32 i = 0 ; i < cEh; i++)
2140
- {
2141
- COR_ILMETHOD_SECT_EH_CLAUSE_FAT ehBuff;
2142
- const COR_ILMETHOD_SECT_EH_CLAUSE_FAT* ehClause =
2143
- (const COR_ILMETHOD_SECT_EH_CLAUSE_FAT*)ehInfo->EHClause (i, &ehBuff);
2129
+ for (INT32 i = 0 ; i < cEh; i++)
2130
+ {
2131
+ COR_ILMETHOD_SECT_EH_CLAUSE_FAT ehBuff;
2132
+ const COR_ILMETHOD_SECT_EH_CLAUSE_FAT* ehClause =
2133
+ (const COR_ILMETHOD_SECT_EH_CLAUSE_FAT*)ehInfo->EHClause (i, &ehBuff);
2144
2134
2145
- gc.EHClauseObj = (RUNTIMEEXCEPTIONHANDLINGCLAUSEREF) AllocateObject (pExceptionHandlingClauseMT);
2135
+ gc.EHClauseObj = (RUNTIMEEXCEPTIONHANDLINGCLAUSEREF) AllocateObject (pExceptionHandlingClauseMT);
2146
2136
2147
- gc.EHClauseObj ->_flags = ehClause->GetFlags ();
2148
- gc.EHClauseObj ->_tryOffset = ehClause->GetTryOffset ();
2149
- gc.EHClauseObj ->_tryLength = ehClause->GetTryLength ();
2150
- gc.EHClauseObj ->_handlerOffset = ehClause->GetHandlerOffset ();
2151
- gc.EHClauseObj ->_handlerLength = ehClause->GetHandlerLength ();
2137
+ gc.EHClauseObj ->_flags = ehClause->GetFlags ();
2138
+ gc.EHClauseObj ->_tryOffset = ehClause->GetTryOffset ();
2139
+ gc.EHClauseObj ->_tryLength = ehClause->GetTryLength ();
2140
+ gc.EHClauseObj ->_handlerOffset = ehClause->GetHandlerOffset ();
2141
+ gc.EHClauseObj ->_handlerLength = ehClause->GetHandlerLength ();
2152
2142
2153
- if ((ehClause->GetFlags () & COR_ILEXCEPTION_CLAUSE_FILTER) == 0 )
2154
- gc.EHClauseObj ->_catchToken = ehClause->GetClassToken ();
2155
- else
2156
- gc.EHClauseObj ->_filterOffset = ehClause->GetFilterOffset ();
2143
+ if ((ehClause->GetFlags () & COR_ILEXCEPTION_CLAUSE_FILTER) == 0 )
2144
+ gc.EHClauseObj ->_catchToken = ehClause->GetClassToken ();
2145
+ else
2146
+ gc.EHClauseObj ->_filterOffset = ehClause->GetFilterOffset ();
2157
2147
2158
- gc.MethodBodyObj ->_exceptionClauses ->SetAt (i, (OBJECTREF) gc.EHClauseObj );
2159
- SetObjectReference ((OBJECTREF*)&(gc.EHClauseObj ->_methodBody ), (OBJECTREF)gc.MethodBodyObj );
2160
- }
2148
+ gc.MethodBodyObj ->_exceptionClauses ->SetAt (i, (OBJECTREF) gc.EHClauseObj );
2149
+ SetObjectReference ((OBJECTREF*)&(gc.EHClauseObj ->_methodBody ), (OBJECTREF)gc.MethodBodyObj );
2150
+ }
2161
2151
2162
- if (header.LocalVarSig != NULL )
2152
+ if (header.LocalVarSig != NULL )
2153
+ {
2154
+ SigTypeContext sigTypeContext (pMethod, declaringType, pMethod->LoadMethodInstantiation ());
2155
+ MetaSig metaSig (header.LocalVarSig ,
2156
+ header.cbLocalVarSig ,
2157
+ pModule,
2158
+ &sigTypeContext,
2159
+ MetaSig::sigLocalVars);
2160
+ INT32 cLocals = metaSig.NumFixedArgs ();
2161
+ gc.TempArray = (BASEARRAYREF) AllocateSzArray (thLocalVariableArray, cLocals);
2162
+ SetObjectReference ((OBJECTREF*)&gc.MethodBodyObj ->_localVariables , gc.TempArray );
2163
+
2164
+ for (INT32 i = 0 ; i < cLocals; i ++)
2163
2165
{
2164
- SigTypeContext sigTypeContext (pMethod, declaringType, pMethod->LoadMethodInstantiation ());
2165
- MetaSig metaSig (header.LocalVarSig ,
2166
- header.cbLocalVarSig ,
2167
- pModule,
2168
- &sigTypeContext,
2169
- MetaSig::sigLocalVars);
2170
- INT32 cLocals = metaSig.NumFixedArgs ();
2171
- gc.TempArray = (BASEARRAYREF) AllocateSzArray (thLocalVariableArray, cLocals);
2172
- SetObjectReference ((OBJECTREF*)&gc.MethodBodyObj ->_localVariables , gc.TempArray );
2173
-
2174
- for (INT32 i = 0 ; i < cLocals; i ++)
2175
- {
2176
- gc.RuntimeLocalVariableInfoObj = (RUNTIMELOCALVARIABLEINFOREF)AllocateObject (pLocalVariableMT);
2166
+ gc.RuntimeLocalVariableInfoObj = (RUNTIMELOCALVARIABLEINFOREF)AllocateObject (pLocalVariableMT);
2177
2167
2178
- gc.RuntimeLocalVariableInfoObj ->_localIndex = i;
2168
+ gc.RuntimeLocalVariableInfoObj ->_localIndex = i;
2179
2169
2180
- metaSig.NextArg ();
2170
+ metaSig.NextArg ();
2181
2171
2182
- CorElementType eType;
2183
- IfFailThrow (metaSig.GetArgProps ().PeekElemType (&eType));
2184
- if (ELEMENT_TYPE_PINNED == eType)
2185
- gc.RuntimeLocalVariableInfoObj ->_isPinned = TRUE ;
2172
+ CorElementType eType;
2173
+ IfFailThrow (metaSig.GetArgProps ().PeekElemType (&eType));
2174
+ if (ELEMENT_TYPE_PINNED == eType)
2175
+ gc.RuntimeLocalVariableInfoObj ->_isPinned = TRUE ;
2186
2176
2187
- TypeHandle tempType= metaSig.GetArgProps ().GetTypeHandleThrowing (pModule, &sigTypeContext);
2188
- OBJECTREF refLocalType = tempType.GetManagedClassObject ();
2189
- gc.RuntimeLocalVariableInfoObj ->SetType (refLocalType);
2190
- gc.MethodBodyObj ->_localVariables ->SetAt (i, (OBJECTREF) gc.RuntimeLocalVariableInfoObj );
2191
- }
2192
- }
2193
- else
2194
- {
2195
- INT32 cLocals = 0 ;
2196
- gc.TempArray = (BASEARRAYREF) AllocateSzArray (thLocalVariableArray, cLocals);
2197
- SetObjectReference ((OBJECTREF*)&gc.MethodBodyObj ->_localVariables , gc.TempArray );
2177
+ TypeHandle tempType= metaSig.GetArgProps ().GetTypeHandleThrowing (pModule, &sigTypeContext);
2178
+ OBJECTREF refLocalType = tempType.GetManagedClassObject ();
2179
+ gc.RuntimeLocalVariableInfoObj ->SetType (refLocalType);
2180
+ gc.MethodBodyObj ->_localVariables ->SetAt (i, (OBJECTREF) gc.RuntimeLocalVariableInfoObj );
2198
2181
}
2199
2182
}
2183
+ else
2184
+ {
2185
+ INT32 cLocals = 0 ;
2186
+ gc.TempArray = (BASEARRAYREF) AllocateSzArray (thLocalVariableArray, cLocals);
2187
+ SetObjectReference ((OBJECTREF*)&gc.MethodBodyObj ->_localVariables , gc.TempArray );
2188
+ }
2200
2189
}
2201
- HELPER_METHOD_FRAME_END ();
2202
2190
2203
- return (RuntimeMethodBody*)OBJECTREFToObject (gc.MethodBodyObj );
2191
+ result.Set (gc.MethodBodyObj );
2192
+
2193
+ GCPROTECT_END ();
2194
+ END_QCALL;
2204
2195
}
2205
- FCIMPLEND
2206
2196
2207
2197
FCIMPL1 (FC_BOOL_RET, RuntimeMethodHandle::IsConstructor, MethodDesc *pMethod)
2208
2198
{
0 commit comments