public static TransitionBlock FromTarget(TargetDetails target) { switch (target.Architecture) { case TargetArchitecture.X86: return(X86TransitionBlock.Instance); case TargetArchitecture.X64: return(target.OperatingSystem == TargetOS.Windows ? X64WindowsTransitionBlock.Instance : X64UnixTransitionBlock.Instance); case TargetArchitecture.ARM: return(Arm32TransitionBlock.Instance); case TargetArchitecture.ARM64: return(Arm64TransitionBlock.Instance); default: throw new NotImplementedException(target.Architecture.ToString()); } }
private static IrFunction DeclareCopyFunc(BitcodeModule module , DIFile diFile , IDebugType <ITypeRef, DIType> voidType , DIDerivedType constFoo , DebugPointerType fooPtr ) { // Since the first parameter is passed by value // using the pointer + alloca + memcopy pattern, the actual // source, and therefore debug, signature is NOT a pointer. // However, that usage would create a signature with two // pointers as the arguments, which doesn't match the source // To get the correct debug info signature this inserts an // explicit DebugType<> that overrides the default behavior // to pair the LLVM pointer type with the original source type. var copySig = module.Context.CreateFunctionType(module.DIBuilder , voidType , DebugType.Create(fooPtr, constFoo) , fooPtr ); var copyFunc = module.CreateFunction(scope: diFile , name: "copy" , linkageName: null , file: diFile , line: 11 , signature: copySig , isLocalToUnit: true , isDefinition: true , scopeLine: 14 , debugFlags: DebugInfoFlags.Prototyped , isOptimized: false ).Linkage(Linkage.Internal) // static function .AddAttributes(FunctionAttributeIndex.Function, AttributeKind.NoUnwind, AttributeKind.NoInline, AttributeKind.OptimizeNone) .AddAttributes(FunctionAttributeIndex.Function, TargetDependentAttributes); TargetDetails.AddABIAttributesForByValueStructure(copyFunc, 0); return(copyFunc); }
private void FillSettingsToGui(TargetDetails td) { textBoxTLX.Value = td.TL.X; textBoxTL.Value = td.TL.Y; textBoxTRX.Value = td.TR.X; textBoxTR.Value = td.TR.Y; textBoxBRX.Value = td.BR.X; textBoxBR.Value = td.BR.Y; textBoxBLX.Value = td.BL.X; textBoxBL.Value = td.BL.Y; numBLCKradius.Value = (int)td.BlackR; numBLCx.Value = td.BlackCenter.X; numBLCy.Value = td.BlackCenter.Y; checkBoxCameraFlipped.Checked = td.CameraFlipped; checkBoxCameraOnTop.Checked = td.CameraOnTop; checkBoxIgnoreWhiteShots.Checked = td.IgnoreWhiteShots; }
public ConfigurablePInvokePolicy(TargetDetails target, IReadOnlyList <string> directPInvokes, IReadOnlyList <string> directPInvokeLists) { _directPInvokes = new Dictionary <string, HashSet <string> >(target.IsWindows ? StringComparer.OrdinalIgnoreCase : StringComparer.Ordinal); // * is always a direct call _directPInvokes.Add("*", null); foreach (var file in directPInvokeLists) { foreach (var entry in File.ReadLines(file)) { AddDirectPInvoke(entry); } } foreach (var entry in directPInvokes) { AddDirectPInvoke(entry); } _target = target; }
private static void Strike(ref List <List <long> > matrix, ref TargetDetails target) { for (var row = target.Row - target.Radius; row <= target.Row + target.Radius; row++) { if (row < 0 || row >= matrix.Count) { continue; } if (row == target.Row) { for (var col = target.Col + target.Radius; col >= target.Col - target.Radius; col--) { if (col < 0 || col >= matrix[row].Count) { continue; } matrix[row].RemoveAt(col); } } else { if (target.Col < 0 || target.Col >= matrix[row].Count) { continue; } matrix[row].RemoveAt(target.Col); } } for (int row = 0; row < matrix.Count; row++) { if (matrix[row].Count == 0) { matrix.RemoveAt(row); row--; } } }
public static void Initialize( TargetDetails target, IEnumerable <CorJitFlag> jitFlags, IEnumerable <KeyValuePair <string, string> > parameters, string jitPath = null) { var config = new JitConfigProvider(jitFlags, parameters); // Make sure we didn't try to initialize two instances of JIT configuration. // RyuJIT doesn't support multiple hosts in a single process. if (Interlocked.CompareExchange(ref s_instance, config, null) != null) { throw new InvalidOperationException(); } NativeLibrary.SetDllImportResolver(typeof(CorInfoImpl).Assembly, (libName, assembly, searchPath) => { IntPtr libHandle = IntPtr.Zero; if (libName == CorInfoImpl.JitLibrary) { if (!string.IsNullOrEmpty(jitPath)) { libHandle = NativeLibrary.Load(jitPath); } else { libHandle = NativeLibrary.Load("clrjit_" + GetTargetSpec(target), assembly, searchPath); } } if (libName == CorInfoImpl.JitSupportLibrary) { libHandle = NativeLibrary.Load("jitinterface_" + RuntimeInformation.ProcessArchitecture.ToString().ToLowerInvariant(), assembly, searchPath); } return(libHandle); }); CorInfoImpl.Startup(); }
public NodeFactory( CompilerTypeSystemContext context, CompilationModuleGroup compilationModuleGroup, MetadataManager metadataManager, InteropStubManager interoptStubManager, NameMangler nameMangler, LazyGenericsPolicy lazyGenericsPolicy, VTableSliceProvider vtableSliceProvider, DictionaryLayoutProvider dictionaryLayoutProvider, ImportedNodeProvider importedNodeProvider) { _target = context.Target; _context = context; _compilationModuleGroup = compilationModuleGroup; _vtableSliceProvider = vtableSliceProvider; _dictionaryLayoutProvider = dictionaryLayoutProvider; NameMangler = nameMangler; InteropStubManager = interoptStubManager; CreateNodeCaches(); MetadataManager = metadataManager; LazyGenericsPolicy = lazyGenericsPolicy; _importedNodeProvider = importedNodeProvider; }
/// <summary> /// Calculate machine ID based on compilation target architecture. /// </summary> /// <param name="target">Compilation target environment specification</param> /// <returns></returns> public static Machine MachineFromTarget(this TargetDetails target) { switch (target.Architecture) { case Internal.TypeSystem.TargetArchitecture.X64: return(Machine.Amd64); case Internal.TypeSystem.TargetArchitecture.X86: return(Machine.I386); case Internal.TypeSystem.TargetArchitecture.ARM64: return(Machine.Arm64); case Internal.TypeSystem.TargetArchitecture.ARM: return(Machine.ArmThumb2); case Internal.TypeSystem.TargetArchitecture.LoongArch64: return(Machine.LoongArch64); default: throw new NotImplementedException(target.Architecture.ToString()); } }
/// <summary> /// Determine OS machine override for the target operating system. /// </summary> public static MachineOSOverride MachineOSOverrideFromTarget(this TargetDetails target) { switch (target.OperatingSystem) { case TargetOS.Windows: return(MachineOSOverride.Windows); case TargetOS.Linux: return(MachineOSOverride.Linux); case TargetOS.OSX: return(MachineOSOverride.Apple); case TargetOS.FreeBSD: return(MachineOSOverride.FreeBSD); case TargetOS.NetBSD: return(MachineOSOverride.NetBSD); default: throw new NotImplementedException(target.OperatingSystem.ToString()); } }
public GCStaticEETypeNode(bool[] gcDesc, NodeFactory factory) { List <int> runLengths = new List <int>(); bool encodingGCPointers = false; int currentPointerCount = 0; foreach (bool pointerIsGC in gcDesc) { if (encodingGCPointers == pointerIsGC) { currentPointerCount++; } else { runLengths.Add(currentPointerCount * factory.Target.PointerSize); encodingGCPointers = pointerIsGC; } } runLengths.Add(currentPointerCount); _runLengths = runLengths.ToArray(); _targetPointerSize = factory.Target.PointerSize; _target = factory.Target; }
public ReadyToRunCompilerContext(TargetDetails details, SharedGenericsMode genericsMode, bool bubbleIncludesCorelib) : base(details, genericsMode) { _r2rFieldLayoutAlgorithm = new ReadyToRunMetadataFieldLayoutAlgorithm(); _systemObjectFieldLayoutAlgorithm = new SystemObjectFieldLayoutAlgorithm(_r2rFieldLayoutAlgorithm); // Only the Arm64 JIT respects the OS rules for vector type abi currently _vectorFieldLayoutAlgorithm = new VectorFieldLayoutAlgorithm(_r2rFieldLayoutAlgorithm, (details.Architecture == TargetArchitecture.ARM64) ? true : bubbleIncludesCorelib); string matchingVectorType = "Unknown"; if (details.MaximumSimdVectorLength == SimdVectorLength.Vector128Bit) { matchingVectorType = "Vector128`1"; } else if (details.MaximumSimdVectorLength == SimdVectorLength.Vector256Bit) { matchingVectorType = "Vector256`1"; } // No architecture has completely stable handling of Vector<T> in the abi (Arm64 may change to SVE) _vectorOfTFieldLayoutAlgorithm = new VectorOfTFieldLayoutAlgorithm(_r2rFieldLayoutAlgorithm, _vectorFieldLayoutAlgorithm, matchingVectorType, bubbleIncludesCorelib); }
/// <summary> /// Gets a value indicating whether the support for a given intrinsic is known at compile time. /// </summary> public static bool IsKnownSupportedIntrinsicAtCompileTime(MethodDesc method) { TargetDetails target = method.Context.Target; if (target.Architecture == TargetArchitecture.X64 || target.Architecture == TargetArchitecture.X86) { var owningType = (MetadataType)method.OwningType; if (owningType.Name == "X64") { if (target.Architecture != TargetArchitecture.X64) { return(true); } owningType = (MetadataType)owningType.ContainingType; } if (owningType.Namespace != "System.Runtime.Intrinsics.X86") { return(true); } // Sse and Sse2 are baseline required intrinsics. // RyuJIT also uses Sse41/Sse42 with the general purpose Vector APIs. // RyuJIT only respects Popcnt if Sse41/Sse42 is also enabled. // Avx/Avx2/Bmi1/Bmi2 require VEX encoding and RyuJIT currently can't enable them // without enabling VEX encoding everywhere. We don't support them. // This list complements EmitIsSupportedIL above. return(owningType.Name == "Sse" || owningType.Name == "Sse2" || owningType.Name == "Sse41" || owningType.Name == "Sse42" || owningType.Name == "Popcnt" || owningType.Name == "Bmi1" || owningType.Name == "Bmi2" || owningType.Name == "Avx" || owningType.Name == "Avx2"); } return(false); }
public static IEnumerable <object[]> GetTestMethods() { var target = new TargetDetails(TargetArchitecture.X64, TargetOS.Windows, TargetAbi.NativeAot); var context = new CompilerTypeSystemContext(target, SharedGenericsMode.CanonicalReferenceTypes, DelegateFeature.All); context.InputFilePaths = new Dictionary <string, string> { { "Test.CoreLib", @"Test.CoreLib.dll" }, { "ILCompiler.Compiler.Tests.Assets", @"ILCompiler.Compiler.Tests.Assets.dll" }, }; context.ReferenceFilePaths = new Dictionary <string, string>(); context.SetSystemModule(context.GetModuleForSimpleName("Test.CoreLib")); var testModule = context.GetModuleForSimpleName("ILCompiler.Compiler.Tests.Assets"); bool foundSomethingToCheck = false; foreach (var type in testModule.GetType("ILCompiler.Compiler.Tests.Assets", "DependencyGraph").GetNestedTypes()) { foundSomethingToCheck = true; yield return(new object[] { type.GetMethod("Entrypoint", null) }); } Assert.True(foundSomethingToCheck, "No methods to check?"); }
private int Run() { InitializeDefaultOptions(); ProcessCommandLine(); if (_commandLineOptions.OutputFilePath == null) { throw new CommandLineException("Output filename must be specified (/out <file>)"); } // // Set target Architecture and OS // if (_commandLineOptions.TargetArch != null) { if (_commandLineOptions.TargetArch.Equals("x86", StringComparison.OrdinalIgnoreCase)) { _targetArchitecture = TargetArchitecture.X86; } else if (_commandLineOptions.TargetArch.Equals("x64", StringComparison.OrdinalIgnoreCase)) { _targetArchitecture = TargetArchitecture.X64; } else if (_commandLineOptions.TargetArch.Equals("arm", StringComparison.OrdinalIgnoreCase)) { _targetArchitecture = TargetArchitecture.ARM; } else if (_commandLineOptions.TargetArch.Equals("armel", StringComparison.OrdinalIgnoreCase)) { _targetArchitecture = TargetArchitecture.ARM; } else if (_commandLineOptions.TargetArch.Equals("arm64", StringComparison.OrdinalIgnoreCase)) { _targetArchitecture = TargetArchitecture.ARM64; } else { throw new CommandLineException("Target architecture is not supported"); } } if (_commandLineOptions.TargetOS != null) { if (_commandLineOptions.TargetOS.Equals("windows", StringComparison.OrdinalIgnoreCase)) { _targetOS = TargetOS.Windows; } else if (_commandLineOptions.TargetOS.Equals("linux", StringComparison.OrdinalIgnoreCase)) { _targetOS = TargetOS.Linux; } else if (_commandLineOptions.TargetOS.Equals("osx", StringComparison.OrdinalIgnoreCase)) { _targetOS = TargetOS.OSX; } else { throw new CommandLineException("Target OS is not supported"); } } using (PerfEventSource.StartStopEvents.CompilationEvents()) { ICompilation compilation; using (PerfEventSource.StartStopEvents.LoadingEvents()) { // // Initialize type system context // SharedGenericsMode genericsMode = SharedGenericsMode.CanonicalReferenceTypes; var targetDetails = new TargetDetails(_targetArchitecture, _targetOS, TargetAbi.CoreRT, SimdVectorLength.None); CompilerTypeSystemContext typeSystemContext = new ReadyToRunCompilerContext(targetDetails, genericsMode); // // TODO: To support our pre-compiled test tree, allow input files that aren't managed assemblies since // some tests contain a mixture of both managed and native binaries. // // See: https://github.com/dotnet/corert/issues/2785 // // When we undo this this hack, replace this foreach with // typeSystemContext.InputFilePaths = _inputFilePaths; // Dictionary <string, string> inputFilePaths = new Dictionary <string, string>(); foreach (var inputFile in _inputFilePaths) { try { var module = typeSystemContext.GetModuleFromPath(inputFile.Value); inputFilePaths.Add(inputFile.Key, inputFile.Value); } catch (TypeSystemException.BadImageFormatException) { // Keep calm and carry on. } } typeSystemContext.InputFilePaths = inputFilePaths; typeSystemContext.ReferenceFilePaths = _referenceFilePaths; string systemModuleName = _commandLineOptions.SystemModule ?? DefaultSystemModule; typeSystemContext.SetSystemModule(typeSystemContext.GetModuleForSimpleName(systemModuleName)); if (typeSystemContext.InputFilePaths.Count == 0) { throw new CommandLineException("No input files specified"); } // // Initialize compilation group and compilation roots // // Single method mode? MethodDesc singleMethod = CheckAndParseSingleMethodModeArguments(typeSystemContext); var logger = new Logger(Console.Out, _commandLineOptions.Verbose); List <ModuleDesc> referenceableModules = new List <ModuleDesc>(); foreach (var inputFile in inputFilePaths) { try { referenceableModules.Add(typeSystemContext.GetModuleFromPath(inputFile.Value)); } catch { } // Ignore non-managed pe files } foreach (var referenceFile in _referenceFilePaths.Values) { try { referenceableModules.Add(typeSystemContext.GetModuleFromPath(referenceFile)); } catch { } // Ignore non-managed pe files } ProfileDataManager profileDataManager = new ProfileDataManager(logger, referenceableModules); CompilationModuleGroup compilationGroup; List <ICompilationRootProvider> compilationRoots = new List <ICompilationRootProvider>(); if (singleMethod != null) { // Compiling just a single method compilationGroup = new SingleMethodCompilationModuleGroup(singleMethod); compilationRoots.Add(new SingleMethodRootProvider(singleMethod)); } else { // Either single file, or multifile library, or multifile consumption. EcmaModule entrypointModule = null; foreach (var inputFile in typeSystemContext.InputFilePaths) { EcmaModule module = typeSystemContext.GetModuleFromPath(inputFile.Value); if (module.PEReader.PEHeaders.IsExe) { if (entrypointModule != null) { throw new Exception("Multiple EXE modules"); } entrypointModule = module; } } List <EcmaModule> inputModules = new List <EcmaModule>(); foreach (var inputFile in typeSystemContext.InputFilePaths) { EcmaModule module = typeSystemContext.GetModuleFromPath(inputFile.Value); compilationRoots.Add(new ReadyToRunRootProvider(module, profileDataManager)); inputModules.Add(module); if (!_commandLineOptions.InputBubble) { break; } } List <ModuleDesc> versionBubbleModules = new List <ModuleDesc>(); if (_commandLineOptions.InputBubble) { // In large version bubble mode add reference paths to the compilation group foreach (string referenceFile in _referenceFilePaths.Values) { try { // Currently SimpleTest.targets has no easy way to filter out non-managed assemblies // from the reference list. EcmaModule module = typeSystemContext.GetModuleFromPath(referenceFile); versionBubbleModules.Add(module); } catch (TypeSystemException.BadImageFormatException ex) { Console.WriteLine("Warning: cannot open reference assembly '{0}': {1}", referenceFile, ex.Message); } } } compilationGroup = new ReadyToRunSingleAssemblyCompilationModuleGroup( typeSystemContext, inputModules, versionBubbleModules, _commandLineOptions.CompileBubbleGenerics, _commandLineOptions.Partial ? profileDataManager : null); } // // Compile // string inputFilePath = ""; foreach (var input in typeSystemContext.InputFilePaths) { inputFilePath = input.Value; break; } ReadyToRunCodegenCompilationBuilder builder = new ReadyToRunCodegenCompilationBuilder(typeSystemContext, compilationGroup, inputFilePath); string compilationUnitPrefix = ""; builder.UseCompilationUnitPrefix(compilationUnitPrefix); ILProvider ilProvider = new ReadyToRunILProvider(); DependencyTrackingLevel trackingLevel = _commandLineOptions.DgmlLogFileName == null ? DependencyTrackingLevel.None : (_commandLineOptions.GenerateFullDgmlLog ? DependencyTrackingLevel.All : DependencyTrackingLevel.First); builder .UseIbcTuning(_commandLineOptions.Tuning) .UseResilience(_commandLineOptions.Resilient) .UseMapFile(_commandLineOptions.GenerateMapFile) .UseParallelism(_commandLineOptions.Parallelism) .UseILProvider(ilProvider) .UseJitPath(_commandLineOptions.JitPath) .UseBackendOptions(_commandLineOptions.CodegenOptions) .UseLogger(logger) .UseDependencyTracking(trackingLevel) .UseCompilationRoots(compilationRoots) .UseOptimizationMode(_optimizationMode); compilation = builder.ToCompilation(); } compilation.Compile(_commandLineOptions.OutputFilePath.FullName); if (_commandLineOptions.DgmlLogFileName != null) { compilation.WriteDependencyLog(_commandLineOptions.DgmlLogFileName.FullName); } } return(0); }
private static int GetClassConstructorContextAlignment(TargetDetails target) { // TODO: Assert that StaticClassConstructionContext type has the expected alignment // (need to make it a well known type?) return(target.PointerSize); }
public static int GetClassConstructorContextStorageSize(TargetDetails target, MetadataType type) { int alignmentRequired = Math.Max(type.NonGCStaticFieldAlignment, GetClassConstructorContextAlignment(target)); return(AlignmentHelper.AlignUp(GetClassConstructorContextSize(type.Context.Target), alignmentRequired)); }
// Name: changeButton_Click // // Description: // Check that each field in the form has a value. // Extract the values and save the current connection // information. // Set the connection string in the ingresConnection1 control. // If the default check box is checked write the configuration // into the configuration file. // // Inputs: // sender changeButton. // e Event arguments. // // Outputs: // None. // // Returns: // None. // // History: // 02-Oct-2006 ([email protected]) // Created. // 02-Feb-2006 ([email protected]) // Removed specifying of version in the call to CheckVersion. private void changeButton_Click(object sender, EventArgs e) { TargetDetails newSource = new TargetDetails(); if (InstanceCheckItems() == DialogResult.OK) { if (hostComboBox.SelectedValue != null) { newSource.host = hostComboBox.SelectedValue.ToString(); } else { newSource.host = hostComboBox.Text.ToString(); } if (instanceComboBox.SelectedValue != null) { newSource.port = String.Format(rm.GetString("PortAddress"), instanceComboBox.SelectedValue.ToString()); } else { newSource.port = String.Format(rm.GetString("PortAddress"), instanceComboBox.Text.ToString()); } if (useridTextBox != null) { newSource.user = useridTextBox.Text; } if (passwordTextBox != null) { newSource.pwd = passwordTextBox.Text; } if (databaseComboBox.SelectedValue != null) { newSource.db = databaseComboBox.SelectedValue.ToString(); } else { newSource.db = databaseComboBox.Text.ToString(); } savedSource = currentSource; currentSource = newSource; SetConnection(ingresConnection1, currentSource.GetConnectionString()); if (connectDefaultCheckBox.Checked == true) { WriteConfiguration(appConfigFile); defaultSourceRadioButton.Checked = true; } try { if (CheckVersion() == true) { SetInstanceControls(); SetStatus(currentSource); SetStaticControls(); } else { DialogResult result = MessageBox.Show(rm.GetString("ErrorVersion"), rm.GetString("InstanceCaption"), MessageBoxButtons.RetryCancel, MessageBoxIcon.Error); if (result != DialogResult.Retry) { currentSource = savedSource; } } } catch { // Data adapter initialization error. InstanceFormInitialize(); LoadHelpTopic("ConnectHelp"); ShowPanel(infoPanels, helpPanel); } } }
public HeaderNode(TargetDetails target) { _target = target; }
public InliningInfoNode(TargetDetails target, EcmaModule globalContext) : base(target) { _globalContext = globalContext; }
public ExternalReferencesTableNode(string blobName, TargetDetails targetDetails) { _blobName = blobName; _endSymbol = new ObjectAndOffsetSymbolNode(this, 0, "__external_" + blobName + "_references_End", true); _target = targetDetails; }
public TypesTableNode(TargetDetails target) : base(target) { }
public OwnerCompositeExecutableNode(TargetDetails target, string ownerExecutableName) : base(target) { _ownerExecutableName = ownerExecutableName; }
public InstanceEntryPointTableNode(TargetDetails target) : base(target) { }
private int Run(string[] args) { InitializeDefaultOptions(); ProcessCommandLine(args); if (_commandLineOptions.Help) { Console.WriteLine(_commandLineOptions.HelpText); return(1); } if (_commandLineOptions.OutputFilePath == null && !_commandLineOptions.OutNearInput) { throw new CommandLineException(SR.MissingOutputFile); } if (_commandLineOptions.SingleFileCompilation && !_commandLineOptions.OutNearInput) { throw new CommandLineException(SR.MissingOutNearInput); } ConfigureTarget(); InstructionSetSupport instructionSetSupport = ConfigureInstructionSetSupport(); SharedGenericsMode genericsMode = SharedGenericsMode.CanonicalReferenceTypes; var targetDetails = new TargetDetails(_targetArchitecture, _targetOS, _armelAbi ? TargetAbi.CoreRTArmel : TargetAbi.CoreRT, instructionSetSupport.GetVectorTSimdVector()); bool versionBubbleIncludesCoreLib = false; if (_commandLineOptions.InputBubble) { versionBubbleIncludesCoreLib = true; } else { if (!_commandLineOptions.SingleFileCompilation) { foreach (var inputFile in _inputFilePaths) { if (String.Compare(inputFile.Key, "System.Private.CoreLib", StringComparison.OrdinalIgnoreCase) == 0) { versionBubbleIncludesCoreLib = true; break; } } } if (!versionBubbleIncludesCoreLib) { foreach (var inputFile in _unrootedInputFilePaths) { if (String.Compare(inputFile.Key, "System.Private.CoreLib", StringComparison.OrdinalIgnoreCase) == 0) { versionBubbleIncludesCoreLib = true; break; } } } } // // Initialize type system context // _typeSystemContext = new ReadyToRunCompilerContext(targetDetails, genericsMode, versionBubbleIncludesCoreLib); string compositeRootPath = _commandLineOptions.CompositeRootPath; // Collections for already loaded modules Dictionary <string, string> inputFilePaths = new Dictionary <string, string>(); Dictionary <string, string> unrootedInputFilePaths = new Dictionary <string, string>(); HashSet <ModuleDesc> versionBubbleModulesHash = new HashSet <ModuleDesc>(); using (PerfEventSource.StartStopEvents.LoadingEvents()) { // // TODO: To support our pre-compiled test tree, allow input files that aren't managed assemblies since // some tests contain a mixture of both managed and native binaries. // // See: https://github.com/dotnet/corert/issues/2785 // // When we undo this this hack, replace this foreach with // typeSystemContext.InputFilePaths = inFilePaths; // foreach (var inputFile in _inputFilePaths) { try { var module = _typeSystemContext.GetModuleFromPath(inputFile.Value); _allInputFilePaths.Add(inputFile.Key, inputFile.Value); inputFilePaths.Add(inputFile.Key, inputFile.Value); _referenceableModules.Add(module); if (compositeRootPath == null) { compositeRootPath = Path.GetDirectoryName(inputFile.Value); } } catch (TypeSystemException.BadImageFormatException) { // Keep calm and carry on. } } foreach (var unrootedInputFile in _unrootedInputFilePaths) { try { var module = _typeSystemContext.GetModuleFromPath(unrootedInputFile.Value); if (!_allInputFilePaths.ContainsKey(unrootedInputFile.Key)) { _allInputFilePaths.Add(unrootedInputFile.Key, unrootedInputFile.Value); unrootedInputFilePaths.Add(unrootedInputFile.Key, unrootedInputFile.Value); _referenceableModules.Add(module); if (compositeRootPath == null) { compositeRootPath = Path.GetDirectoryName(unrootedInputFile.Value); } } } catch (TypeSystemException.BadImageFormatException) { // Keep calm and carry on. } } CheckManagedCppInputFiles(_allInputFilePaths.Values); _typeSystemContext.InputFilePaths = _allInputFilePaths; _typeSystemContext.ReferenceFilePaths = _referenceFilePaths; if (_typeSystemContext.InputFilePaths.Count == 0) { if (_commandLineOptions.InputFilePaths.Count > 0) { Console.WriteLine(SR.InputWasNotLoadable); return(2); } throw new CommandLineException(SR.NoInputFiles); } foreach (var referenceFile in _referenceFilePaths.Values) { try { EcmaModule module = _typeSystemContext.GetModuleFromPath(referenceFile); _referenceableModules.Add(module); if (_commandLineOptions.InputBubble && _inputbubblereferenceFilePaths.Count == 0) { // In large version bubble mode add reference paths to the compilation group // Consider bubble as large if no explicit bubble references were passed versionBubbleModulesHash.Add(module); } } catch { } // Ignore non-managed pe files } if (_commandLineOptions.InputBubble) { foreach (var referenceFile in _inputbubblereferenceFilePaths.Values) { try { EcmaModule module = _typeSystemContext.GetModuleFromPath(referenceFile); versionBubbleModulesHash.Add(module); } catch { } // Ignore non-managed pe files } } } string systemModuleName = _commandLineOptions.SystemModule ?? DefaultSystemModule; _typeSystemContext.SetSystemModule((EcmaModule)_typeSystemContext.GetModuleForSimpleName(systemModuleName)); CompilerTypeSystemContext typeSystemContext = _typeSystemContext; if (_commandLineOptions.SingleFileCompilation) { var singleCompilationInputFilePaths = new Dictionary <string, string>(StringComparer.OrdinalIgnoreCase); foreach (var inputFile in inputFilePaths) { var singleCompilationVersionBubbleModulesHash = new HashSet <ModuleDesc>(versionBubbleModulesHash); singleCompilationInputFilePaths.Clear(); singleCompilationInputFilePaths.Add(inputFile.Key, inputFile.Value); typeSystemContext.InputFilePaths = singleCompilationInputFilePaths; if (!_commandLineOptions.InputBubble) { bool singleCompilationVersionBubbleIncludesCoreLib = versionBubbleIncludesCoreLib || (String.Compare(inputFile.Key, "System.Private.CoreLib", StringComparison.OrdinalIgnoreCase) == 0); typeSystemContext = new ReadyToRunCompilerContext(targetDetails, genericsMode, singleCompilationVersionBubbleIncludesCoreLib, _typeSystemContext); typeSystemContext.InputFilePaths = singleCompilationInputFilePaths; typeSystemContext.ReferenceFilePaths = _referenceFilePaths; typeSystemContext.SetSystemModule((EcmaModule)typeSystemContext.GetModuleForSimpleName(systemModuleName)); } RunSingleCompilation(singleCompilationInputFilePaths, instructionSetSupport, compositeRootPath, unrootedInputFilePaths, singleCompilationVersionBubbleModulesHash, typeSystemContext); } // In case of inputbubble ni.dll are created as ni.dll.tmp in order to not interfere with crossgen2, move them all to ni.dll // See https://github.com/dotnet/runtime/issues/55663#issuecomment-898161751 for more details if (_commandLineOptions.InputBubble) { foreach (var inputFile in inputFilePaths) { var tmpOutFile = inputFile.Value.Replace(".dll", ".ni.dll.tmp"); var outFile = inputFile.Value.Replace(".dll", ".ni.dll"); Console.WriteLine($@"Moving R2R PE file: {tmpOutFile} to {outFile}"); System.IO.File.Move(tmpOutFile, outFile); } } } else { RunSingleCompilation(inputFilePaths, instructionSetSupport, compositeRootPath, unrootedInputFilePaths, versionBubbleModulesHash, typeSystemContext); } return(0); }
public GCStaticEETypeNode(TargetDetails target, GCPointerMap gcMap) { _gcMap = gcMap; _target = target; }
public ReadyToRunHeaderNode(TargetDetails target) { _target = target; }
/// <summary> /// Fill in PE header information into a PEHeaderBuilder used by PEBuilder. /// </summary> /// <param name="relocsStripped">Relocs are not present in the PE executable</param> /// <param name="dllCharacteristics">Extra DLL characteristics to apply</param> /// <param name="subsystem">Targeting subsystem</param> /// <param name="target">Target architecture to set in the header</param> public static PEHeaderBuilder Create(Characteristics imageCharacteristics, DllCharacteristics dllCharacteristics, Subsystem subsystem, TargetDetails target) { bool is64BitTarget = target.PointerSize == sizeof(long); imageCharacteristics &= ~(Characteristics.Bit32Machine | Characteristics.LargeAddressAware); imageCharacteristics |= (is64BitTarget ? Characteristics.LargeAddressAware : Characteristics.Bit32Machine); ulong imageBase = PE32HeaderConstants.ImageBase; if (target.IsWindows && is64BitTarget && (imageBase <= uint.MaxValue)) { // Base addresses below 4 GiB are reserved for WoW on x64 and disallowed on ARM64. // If the input assembly was compiled for anycpu, its base address is 32-bit and we need to fix it. imageBase = (imageCharacteristics & Characteristics.Dll) != 0 ? PE64HeaderConstants.DllImageBase : PE64HeaderConstants.ExeImageBase; } int fileAlignment = 0x200; if (!target.IsWindows && !is64BitTarget) { // To minimize wasted VA space on 32 bit systems align file to page bounaries (presumed to be 4K). fileAlignment = 0x1000; } int sectionAlignment = 0x1000; if (!target.IsWindows && is64BitTarget) { // On Linux, we must match the bottom 12 bits of section RVA's to their file offsets. For this reason // we need the same alignment for both. sectionAlignment = fileAlignment; } dllCharacteristics &= DllCharacteristics.AppContainer; // In Crossgen1, this is under a debug-specific condition 'if (0 == CLRConfig::GetConfigValue(CLRConfig::INTERNAL_NoASLRForNgen))' dllCharacteristics |= DllCharacteristics.DynamicBase; // Without NxCompatible the PE executable cannot execute on Windows ARM64 dllCharacteristics |= DllCharacteristics.NxCompatible | DllCharacteristics.TerminalServerAware; if (is64BitTarget) { dllCharacteristics |= DllCharacteristics.HighEntropyVirtualAddressSpace; } else { dllCharacteristics |= DllCharacteristics.NoSeh; } return(new PEHeaderBuilder( machine: target.MachineFromTarget(), sectionAlignment: sectionAlignment, fileAlignment: fileAlignment, imageBase: imageBase, majorLinkerVersion: PEHeaderConstants.MajorLinkerVersion, minorLinkerVersion: PEHeaderConstants.MinorLinkerVersion, majorOperatingSystemVersion: PEHeaderConstants.MajorOperatingSystemVersion, minorOperatingSystemVersion: PEHeaderConstants.MinorOperatingSystemVersion, majorImageVersion: PEHeaderConstants.MajorImageVersion, minorImageVersion: PEHeaderConstants.MinorImageVersion, majorSubsystemVersion: PEHeaderConstants.MajorSubsystemVersion, minorSubsystemVersion: PEHeaderConstants.MinorSubsystemVersion, subsystem: subsystem, dllCharacteristics: dllCharacteristics, imageCharacteristics: imageCharacteristics, sizeOfStackReserve: (is64BitTarget ? PE64HeaderConstants.SizeOfStackReserve : PE32HeaderConstants.SizeOfStackReserve), sizeOfStackCommit: (is64BitTarget ? PE64HeaderConstants.SizeOfStackCommit : PE32HeaderConstants.SizeOfStackCommit), sizeOfHeapReserve: (is64BitTarget ? PE64HeaderConstants.SizeOfHeapReserve : PE32HeaderConstants.SizeOfHeapReserve), sizeOfHeapCommit: (is64BitTarget ? PE64HeaderConstants.SizeOfHeapCommit : PE32HeaderConstants.SizeOfHeapCommit))); }
public HeaderTableNode(TargetDetails target) { Target = target; }
public CompilerTypeSystemContext(TargetDetails details, SharedGenericsMode genericsMode) : base(details) { _genericsMode = genericsMode; }
public MethodEntryPointTableNode(TargetDetails target) : base(target) { }