private CORINFO_MODULE_STRUCT_* _methodScope; // Needed to resolve CORINFO_EH_CLAUSE tokens public void CompileMethod(MethodCodeNode methodCodeNodeNeedingCode) { try { _methodCodeNode = methodCodeNodeNeedingCode; CORINFO_METHOD_INFO methodInfo; MethodIL methodIL = Get_CORINFO_METHOD_INFO(MethodBeingCompiled, out methodInfo); _methodScope = methodInfo.scope; try { CompilerTypeSystemContext typeSystemContext = _compilation.TypeSystemContext; MethodDebugInformation debugInfo = _compilation.GetDebugInfo(methodIL); if (!_compilation.Options.NoLineNumbers) { IEnumerable<ILSequencePoint> ilSequencePoints = debugInfo.GetSequencePoints(); if (ilSequencePoints != null) { SetSequencePoints(ilSequencePoints); } } IEnumerable<ILLocalVariable> localVariables = debugInfo.GetLocalVariables(); if (localVariables != null) { SetLocalVariables(localVariables); } IEnumerable<string> parameters = debugInfo.GetParameterNames(); if (parameters != null) { SetParameterNames(parameters); } } catch (Exception e) { // Debug info not successfully loaded. _compilation.Log.WriteLine(e.Message + " (" + methodCodeNodeNeedingCode.GetName() + ")"); } CorInfoImpl _this = this; IntPtr exception; IntPtr nativeEntry; uint codeSize; var result = JitCompileMethod(out exception, _jit, (IntPtr)Unsafe.AsPointer(ref _this), _unmanagedCallbacks, ref methodInfo, (uint)CorJitFlag.CORJIT_FLG_CALL_GETJITFLAGS, out nativeEntry, out codeSize); if (exception != IntPtr.Zero) { char* szMessage = GetExceptionMessage(exception); string message = szMessage != null ? new string(szMessage) : "JIT Exception"; throw new Exception(message); } if (result != CorJitResult.CORJIT_OK) { throw new Exception("JIT Failed"); } PublishCode(); } finally { CompileMethodCleanup(); } }
private CORINFO_MODULE_STRUCT_* _methodScope; // Needed to resolve CORINFO_EH_CLAUSE tokens public void CompileMethod(MethodCodeNode methodCodeNodeNeedingCode) { try { _methodCodeNode = methodCodeNodeNeedingCode; CORINFO_METHOD_INFO methodInfo; Get_CORINFO_METHOD_INFO(MethodBeingCompiled, out methodInfo); _methodScope = methodInfo.scope; try { CompilerTypeSystemContext typeSystemContext = _compilation.TypeSystemContext; if (!_compilation.Options.NoLineNumbers) { IEnumerable<ILSequencePoint> ilSequencePoints = typeSystemContext.GetSequencePointsForMethod(MethodBeingCompiled); if (ilSequencePoints != null) { SetSequencePoints(ilSequencePoints); } } IEnumerable<ILLocalVariable> localVariables = typeSystemContext.GetLocalVariableNamesForMethod(MethodBeingCompiled); if (localVariables != null) { SetLocalVariables(localVariables); } IEnumerable<string> parameters = typeSystemContext.GetParameterNamesForMethod(MethodBeingCompiled); if (parameters != null) { SetParameterNames(parameters); } } catch (Exception e) { // Debug info not successfully loaded. _compilation.Log.WriteLine(e.Message + " (" + methodCodeNodeNeedingCode.GetName() + ")"); } IntPtr exception; IntPtr nativeEntry; uint codeSize; JitWrapper(out exception, _jit, _comp, ref methodInfo, (uint)CorJitFlag.CORJIT_FLG_CALL_GETJITFLAGS, out nativeEntry, out codeSize); if (exception != IntPtr.Zero) { char* szMessage = GetExceptionMessage(exception); string message = szMessage != null ? new string(szMessage) : "JIT Exception"; throw new Exception(message); } PublishCode(); } finally { CompileMethodCleanup(); } }
public void CompileMethod(MethodCodeNode methodCodeNodeNeedingCode) { try { _methodCodeNode = methodCodeNodeNeedingCode; CORINFO_METHOD_INFO methodInfo; Get_CORINFO_METHOD_INFO(MethodBeingCompiled, out methodInfo); uint flags = (uint)( CorJitFlag.CORJIT_FLG_SKIP_VERIFICATION | CorJitFlag.CORJIT_FLG_READYTORUN | CorJitFlag.CORJIT_FLG_RELOC | CorJitFlag.CORJIT_FLG_DEBUG_INFO | CorJitFlag.CORJIT_FLG_PREJIT); if (_compilation.Options.TargetOS != TargetOS.Windows) { flags |= (uint) CorJitFlag.CORJIT_FLG_CFI_UNWIND; } try { CompilerTypeSystemContext typeSystemContext = _compilation.TypeSystemContext; if (!_compilation.Options.NoLineNumbers) { IEnumerable<ILSequencePoint> ilSequencePoints = typeSystemContext.GetSequencePointsForMethod(MethodBeingCompiled); if (ilSequencePoints != null) { SetSequencePoints(ilSequencePoints); } } IEnumerable<ILLocalVariable> localVariables = typeSystemContext.GetLocalVariableNamesForMethod(MethodBeingCompiled); if (localVariables != null) { SetLocalVariables(localVariables); } IEnumerable<string> parameters = typeSystemContext.GetParameterNamesForMethod(MethodBeingCompiled); if (parameters != null) { SetParameterNames(parameters); } } catch (Exception e) { // Debug info not successfully loaded. _compilation.Log.WriteLine(e.Message + " (" + methodCodeNodeNeedingCode.GetName() + ")"); } IntPtr exception; IntPtr nativeEntry; uint codeSize; JitWrapper(out exception, _jit, _comp, ref methodInfo, flags, out nativeEntry, out codeSize); if (exception != IntPtr.Zero) { char* szMessage = GetExceptionMessage(exception); string message = szMessage != null ? new string(szMessage) : "JIT Exception"; throw new Exception(message); } PublishCode(); } finally { CompileMethodCleanup(); } }