Skip to content

Commit

Permalink
Fix exception handling in interface method that checks for marshallin…
Browse files Browse the repository at this point in the history
…g requirements (dotnet#252)
  • Loading branch information
Fadi Hanna authored Nov 26, 2019
1 parent 30488b2 commit ff2c9c0
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1993,11 +1993,23 @@ private bool pInvokeMarshalingRequired(CORINFO_METHOD_STRUCT_* handle, CORINFO_S
return false;
}

MethodIL stubIL = _compilation.GetMethodIL(method);
if (stubIL == null)
MethodIL stubIL = null;
try
{
// This is the case of a PInvoke method that requires marshallers, which we can't use in this compilation
Debug.Assert(!_compilation.NodeFactory.CompilationModuleGroup.GeneratesPInvoke(method));
stubIL = _compilation.GetMethodIL(method);
if (stubIL == null)
{
// This is the case of a PInvoke method that requires marshallers, which we can't use in this compilation
Debug.Assert(!_compilation.NodeFactory.CompilationModuleGroup.GeneratesPInvoke(method));
return true;
}
}
catch (RequiresRuntimeJitException)
{
// The PInvoke IL emitter will throw for known unsupported scenario. We cannot propagate the exception here since
// this interface call might be used to check if a certain pinvoke can be inlined in the caller. Throwing means that the
// caller will not get compiled. Instead, we'll return true to let the JIT know that it cannot inline the pinvoke, and
// the actual pinvoke call will be handled by a stub that we create and compile in the runtime.
return true;
}

Expand Down

0 comments on commit ff2c9c0

Please sign in to comment.