private void CompileSingleMethod(ScannedMethodNode methodCodeNodeNeedingCode) { MethodDesc method = methodCodeNodeNeedingCode.Method; try { var importer = new ILImporter(this, method); methodCodeNodeNeedingCode.InitializeDependencies(_nodeFactory, importer.Import()); } catch (TypeSystemException ex) { // Try to compile the method again, but with a throwing method body this time. MethodIL throwingIL = TypeSystemThrowingILEmitter.EmitIL(method, ex); var importer = new ILImporter(this, method, throwingIL); methodCodeNodeNeedingCode.InitializeDependencies(_nodeFactory, importer.Import()); } catch (Exception ex) { throw new CodeGenerationFailedException(method, ex); } finally { if (_compilationCountdown != null) { _compilationCountdown.Signal(); } } }
protected override void ComputeDependencyNodeDependencies(List <DependencyNodeCore <NodeFactory> > obj) { foreach (DependencyNodeCore <NodeFactory> dependency in obj) { var methodCodeNodeNeedingCode = dependency as ScannedMethodNode; if (methodCodeNodeNeedingCode == null) { // To compute dependencies of the shadow method that tracks dictionary // dependencies we need to ensure there is code for the canonical method body. var dependencyMethod = (ShadowConcreteMethodNode)dependency; methodCodeNodeNeedingCode = (ScannedMethodNode)dependencyMethod.CanonicalMethodNode; } // We might have already compiled this method. if (methodCodeNodeNeedingCode.StaticDependenciesAreComputed) { continue; } MethodDesc method = methodCodeNodeNeedingCode.Method; try { var importer = new ILImporter(this, method); methodCodeNodeNeedingCode.InitializeDependencies(_nodeFactory, importer.Import()); } catch (TypeSystemException ex) { // Try to compile the method again, but with a throwing method body this time. MethodIL throwingIL = TypeSystemThrowingILEmitter.EmitIL(method, ex); var importer = new ILImporter(this, method, throwingIL); methodCodeNodeNeedingCode.InitializeDependencies(_nodeFactory, importer.Import()); } } }
private void CompileSingleMethod(CorInfoImpl corInfo, MethodCodeNode methodCodeNodeNeedingCode) { MethodDesc method = methodCodeNodeNeedingCode.Method; try { corInfo.CompileMethod(methodCodeNodeNeedingCode); } catch (TypeSystemException ex) { // TODO: fail compilation if a switch was passed // Try to compile the method again, but with a throwing method body this time. MethodIL throwingIL = TypeSystemThrowingILEmitter.EmitIL(method, ex); corInfo.CompileMethod(methodCodeNodeNeedingCode, throwingIL); // TODO: Log as a warning. For now, just log to the logger; but this needs to // have an error code, be supressible, the method name/sig needs to be properly formatted, etc. // https://github.com/dotnet/corert/issues/72 Logger.Writer.WriteLine($"Warning: Method `{method}` will always throw because: {ex.Message}"); } finally { if (_compilationCountdown != null) { _compilationCountdown.Signal(); } } }
protected override void ComputeDependencyNodeDependencies(List <DependencyNodeCore <NodeFactory> > obj) { foreach (DependencyNodeCore <NodeFactory> dependency in obj) { var methodCodeNodeNeedingCode = dependency as MethodCodeNode; if (methodCodeNodeNeedingCode == null) { // To compute dependencies of the shadow method that tracks dictionary // dependencies we need to ensure there is code for the canonical method body. var dependencyMethod = (ShadowConcreteMethodNode)dependency; methodCodeNodeNeedingCode = (MethodCodeNode)dependencyMethod.CanonicalMethodNode; } // We might have already compiled this method. if (methodCodeNodeNeedingCode.StaticDependenciesAreComputed) { continue; } MethodDesc method = methodCodeNodeNeedingCode.Method; if (Logger.IsVerbose) { string methodName = method.ToString(); Logger.Writer.WriteLine("Compiling " + methodName); } try { _corInfo.CompileMethod(methodCodeNodeNeedingCode); } catch (TypeSystemException ex) { // TODO: fail compilation if a switch was passed // Try to compile the method again, but with a throwing method body this time. MethodIL throwingIL = TypeSystemThrowingILEmitter.EmitIL(method, ex); _corInfo.CompileMethod(methodCodeNodeNeedingCode, throwingIL); // TODO: Log as a warning. For now, just log to the logger; but this needs to // have an error code, be supressible, the method name/sig needs to be properly formatted, etc. // https://github.com/dotnet/corert/issues/72 Logger.Writer.WriteLine($"Warning: Method `{method}` will always throw because: {ex.Message}"); } } }
protected override void ComputeDependencyNodeDependencies(List <DependencyNodeCore <NodeFactory> > obj) { foreach (DependencyNodeCore <NodeFactory> dependency in obj) { var methodCodeNodeNeedingCode = dependency as MethodCodeNode; if (methodCodeNodeNeedingCode == null) { // To compute dependencies of the shadow method that tracks dictionary // dependencies we need to ensure there is code for the canonical method body. var dependencyMethod = (ShadowConcreteMethodNode <MethodCodeNode>)dependency; methodCodeNodeNeedingCode = dependencyMethod.CanonicalMethodNode; } // We might have already compiled this method. if (methodCodeNodeNeedingCode.StaticDependenciesAreComputed) { continue; } MethodDesc method = methodCodeNodeNeedingCode.Method; if (Logger.IsVerbose) { string methodName = method.ToString(); Logger.Writer.WriteLine("Compiling " + methodName); } try { _corInfo.CompileMethod(methodCodeNodeNeedingCode); } catch (TypeSystemException ex) { // TODO: fail compilation if a switch was passed // Try to compile the method again, but with a throwing method body this time. MethodIL throwingIL = TypeSystemThrowingILEmitter.EmitIL(method, ex); _corInfo.CompileMethod(methodCodeNodeNeedingCode, throwingIL); // TODO: Log as a warning } } }
private void CompileSingleMethod(CorInfoImpl corInfo, MethodCodeNode methodCodeNodeNeedingCode) { MethodDesc method = methodCodeNodeNeedingCode.Method; TypeSystemException exception = _methodImportationErrorProvider.GetCompilationError(method); // If we previously failed to import the method, do not try to import it again and go // directly to the error path. if (exception == null) { try { corInfo.CompileMethod(methodCodeNodeNeedingCode); } catch (TypeSystemException ex) { exception = ex; } } if (exception != null) { // Try to compile the method again, but with a throwing method body this time. MethodIL throwingIL = TypeSystemThrowingILEmitter.EmitIL(method, exception); corInfo.CompileMethod(methodCodeNodeNeedingCode, throwingIL); if (exception is TypeSystemException.InvalidProgramException && method.OwningType is MetadataType mdOwningType && mdOwningType.HasCustomAttribute("System.Runtime.InteropServices", "ClassInterfaceAttribute")) { Logger.LogWarning(method, DiagnosticId.COMInteropNotSupportedInFullAOT); } if ((_compilationOptions & RyuJitCompilationOptions.UseResilience) != 0) { Logger.LogMessage($"Method '{method}' will always throw because: {exception.Message}"); } else { Logger.LogError($"Method will always throw because: {exception.Message}", 1005, method, MessageSubCategory.AotAnalysis); } } }
private void CompileSingleMethod(CorInfoImpl corInfo, MethodCodeNode methodCodeNodeNeedingCode) { try { MethodDesc method = methodCodeNodeNeedingCode.Method; TypeSystemException exception = _methodImportationErrorProvider.GetCompilationError(method); // If we previously failed to import the method, do not try to import it again and go // directly to the error path. if (exception == null) { try { corInfo.CompileMethod(methodCodeNodeNeedingCode); } catch (TypeSystemException ex) { exception = ex; } } if (exception != null) { // TODO: fail compilation if a switch was passed // Try to compile the method again, but with a throwing method body this time. MethodIL throwingIL = TypeSystemThrowingILEmitter.EmitIL(method, exception); corInfo.CompileMethod(methodCodeNodeNeedingCode, throwingIL); if (exception is TypeSystemException.InvalidProgramException && method.OwningType is MetadataType mdOwningType && mdOwningType.HasCustomAttribute("System.Runtime.InteropServices", "ClassInterfaceAttribute")) { Logger.LogWarning("COM interop is not supported with full ahead of time compilation", 3052, method, MessageSubCategory.AotAnalysis); } else { Logger.LogWarning($"Method will always throw because: {exception.Message}", 1005, method, MessageSubCategory.AotAnalysis); } } }