From 6ea69b45e09dae2aa0829358d1270c0481ba6902 Mon Sep 17 00:00:00 2001 From: Phil Date: Sat, 19 Oct 2024 00:41:47 -0700 Subject: [PATCH 1/6] - Update packages - Fixed Explorer tool / Emit binary --- .../Mosa.Compiler.Common.xUnit.csproj | 21 +++++++++++-------- .../Mosa.Compiler.Framework.xUnit.csproj | 21 +++++++++++-------- .../CompilerStages/LinkerEmitStage.cs | 2 -- .../Mosa.Tool.Bootstrap.csproj | 6 +++--- .../Mosa.Tool.Explorer.Avalonia.csproj | 6 +++--- Source/Mosa.Tool.Explorer/MainForm.cs | 7 ++++++- .../Mosa.Tool.Launcher.csproj | 6 +++--- .../Mosa.Utility.CreateCoreLib.csproj | 2 +- 8 files changed, 40 insertions(+), 31 deletions(-) diff --git a/Source/Mosa.Compiler.Common.xUnit/Mosa.Compiler.Common.xUnit.csproj b/Source/Mosa.Compiler.Common.xUnit/Mosa.Compiler.Common.xUnit.csproj index ad7d0a2e74..225101add8 100644 --- a/Source/Mosa.Compiler.Common.xUnit/Mosa.Compiler.Common.xUnit.csproj +++ b/Source/Mosa.Compiler.Common.xUnit/Mosa.Compiler.Common.xUnit.csproj @@ -5,18 +5,21 @@ - - + + - - - - - - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + all - + all diff --git a/Source/Mosa.Compiler.Framework.xUnit/Mosa.Compiler.Framework.xUnit.csproj b/Source/Mosa.Compiler.Framework.xUnit/Mosa.Compiler.Framework.xUnit.csproj index ad7d0a2e74..225101add8 100644 --- a/Source/Mosa.Compiler.Framework.xUnit/Mosa.Compiler.Framework.xUnit.csproj +++ b/Source/Mosa.Compiler.Framework.xUnit/Mosa.Compiler.Framework.xUnit.csproj @@ -5,18 +5,21 @@ - - + + - - - - - - + + all + runtime; build; native; contentfiles; analyzers; buildtransitive + + + + + + all - + all diff --git a/Source/Mosa.Compiler.Framework/CompilerStages/LinkerEmitStage.cs b/Source/Mosa.Compiler.Framework/CompilerStages/LinkerEmitStage.cs index 6abb3c6945..ef83b57fd5 100644 --- a/Source/Mosa.Compiler.Framework/CompilerStages/LinkerEmitStage.cs +++ b/Source/Mosa.Compiler.Framework/CompilerStages/LinkerEmitStage.cs @@ -16,8 +16,6 @@ protected override void Finalization() if (string.IsNullOrEmpty(MosaSettings.OutputFile)) return; - File.Delete(MosaSettings.OutputFile); - Compiler.PostEvent(CompilerEvent.LinkingStart); using (var file = new FileStream(MosaSettings.OutputFile, FileMode.Create)) diff --git a/Source/Mosa.Tool.Bootstrap/Mosa.Tool.Bootstrap.csproj b/Source/Mosa.Tool.Bootstrap/Mosa.Tool.Bootstrap.csproj index 05655f6606..64acefdf5b 100644 --- a/Source/Mosa.Tool.Bootstrap/Mosa.Tool.Bootstrap.csproj +++ b/Source/Mosa.Tool.Bootstrap/Mosa.Tool.Bootstrap.csproj @@ -8,9 +8,9 @@ - - - + + + diff --git a/Source/Mosa.Tool.Explorer.Avalonia/Mosa.Tool.Explorer.Avalonia.csproj b/Source/Mosa.Tool.Explorer.Avalonia/Mosa.Tool.Explorer.Avalonia.csproj index 485dcca87d..29c04168c3 100755 --- a/Source/Mosa.Tool.Explorer.Avalonia/Mosa.Tool.Explorer.Avalonia.csproj +++ b/Source/Mosa.Tool.Explorer.Avalonia/Mosa.Tool.Explorer.Avalonia.csproj @@ -19,9 +19,9 @@ - - - + + + diff --git a/Source/Mosa.Tool.Explorer/MainForm.cs b/Source/Mosa.Tool.Explorer/MainForm.cs index 5c1ff64b4b..8212f9f04c 100644 --- a/Source/Mosa.Tool.Explorer/MainForm.cs +++ b/Source/Mosa.Tool.Explorer/MainForm.cs @@ -13,7 +13,7 @@ using Mosa.Compiler.MosaTypeSystem.CLR; using Mosa.Tool.Explorer.Stages; using Mosa.Utility.Configuration; -using Reko.Core; + using static Mosa.Utility.Configuration.MosaSettings; namespace Mosa.Tool.Explorer; @@ -467,6 +467,11 @@ private void CompileAll() if (Compiler == null) return; + if (MosaSettings.EmitBinary & !Directory.Exists(MosaSettings.DefaultFolder)) + { + Directory.CreateDirectory(MosaSettings.DefaultFolder); + } + CompilerData.Stopwatch.Restart(); Compiler.ScheduleAll(); diff --git a/Source/Mosa.Tool.Launcher/Mosa.Tool.Launcher.csproj b/Source/Mosa.Tool.Launcher/Mosa.Tool.Launcher.csproj index 03b47e9fa5..b5ca4f9495 100644 --- a/Source/Mosa.Tool.Launcher/Mosa.Tool.Launcher.csproj +++ b/Source/Mosa.Tool.Launcher/Mosa.Tool.Launcher.csproj @@ -13,9 +13,9 @@ - - - + + + diff --git a/Source/Mosa.Utility.CreateCoreLib/Mosa.Utility.CreateCoreLib.csproj b/Source/Mosa.Utility.CreateCoreLib/Mosa.Utility.CreateCoreLib.csproj index 5bac3e90d9..50ed30d81a 100644 --- a/Source/Mosa.Utility.CreateCoreLib/Mosa.Utility.CreateCoreLib.csproj +++ b/Source/Mosa.Utility.CreateCoreLib/Mosa.Utility.CreateCoreLib.csproj @@ -8,7 +8,7 @@ - + From 9b62ca631386717f3757a83ad95ebd177e557704 Mon Sep 17 00:00:00 2001 From: Phil Date: Sat, 19 Oct 2024 01:00:37 -0700 Subject: [PATCH 2/6] - Update packages - Fixed Explorer tool / Emit binary --- Source/Mosa.Tool.Explorer/MainForm.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Mosa.Tool.Explorer/MainForm.cs b/Source/Mosa.Tool.Explorer/MainForm.cs index 8212f9f04c..70d5a03868 100644 --- a/Source/Mosa.Tool.Explorer/MainForm.cs +++ b/Source/Mosa.Tool.Explorer/MainForm.cs @@ -467,7 +467,7 @@ private void CompileAll() if (Compiler == null) return; - if (MosaSettings.EmitBinary & !Directory.Exists(MosaSettings.DefaultFolder)) + if (MosaSettings.EmitBinary && !Directory.Exists(MosaSettings.DefaultFolder)) { Directory.CreateDirectory(MosaSettings.DefaultFolder); } From 8e4674e1486cdb1c841f42facdf3172fc0a606b1 Mon Sep 17 00:00:00 2001 From: Phil Date: Sat, 19 Oct 2024 21:59:40 -0700 Subject: [PATCH 3/6] - Added Garbage Collection Point --- Source/Data/IR-Instructions.json | 10 +--------- .../Mosa.Compiler.Framework/BaseTransform.cs | 4 +--- Source/Mosa.Compiler.Framework/IR.cs | 3 +-- .../{StableObjectTracking.cs => GCPoint.cs} | 6 +++--- .../Instructions/UnstableObjectTracking.cs | 18 ------------------ .../Compound/BaseCompoundTransform.cs | 4 ---- 6 files changed, 6 insertions(+), 39 deletions(-) rename Source/Mosa.Compiler.Framework/Instructions/{StableObjectTracking.cs => GCPoint.cs} (70%) delete mode 100644 Source/Mosa.Compiler.Framework/Instructions/UnstableObjectTracking.cs diff --git a/Source/Data/IR-Instructions.json b/Source/Data/IR-Instructions.json index 24c4b650e9..4f9b7e9aa1 100644 --- a/Source/Data/IR-Instructions.json +++ b/Source/Data/IR-Instructions.json @@ -1251,14 +1251,6 @@ "ResultCount": 1, "OperandCount": 2 }, - { - "Name": "StableObjectTracking", - "FamilyName": "IR", - "ResultCount": 0, - "OperandCount": 0, - "IgnoreDuringCodeGeneration": "true", - "UnspecifiedSideEffect": "true" - }, { "Name": "StoreCompound", "FamilyName": "IR", @@ -1502,7 +1494,7 @@ "IgnoreInstructionBasicBlockTargets": "true" }, { - "Name": "UnstableObjectTracking", + "Name": "GCPoint", "FamilyName": "IR", "ResultCount": 0, "OperandCount": 0, diff --git a/Source/Mosa.Compiler.Framework/BaseTransform.cs b/Source/Mosa.Compiler.Framework/BaseTransform.cs index 2cb864187f..75b6c7156e 100644 --- a/Source/Mosa.Compiler.Framework/BaseTransform.cs +++ b/Source/Mosa.Compiler.Framework/BaseTransform.cs @@ -951,9 +951,7 @@ public static TriState AreStatusFlagsUsed(Node node, bool checkZero, bool checkC if (at.IsBlockEndInstruction) return TriState.Unknown; - if (at.Instruction == IR.StableObjectTracking - || at.Instruction == IR.UnstableObjectTracking - || at.Instruction == IR.Kill + if (at.Instruction == IR.Kill || at.Instruction == IR.KillAll || at.Instruction == IR.KillAllExcept || at.Instruction == IR.Gen) diff --git a/Source/Mosa.Compiler.Framework/IR.cs b/Source/Mosa.Compiler.Framework/IR.cs index 03e5b93576..87c92bc72f 100644 --- a/Source/Mosa.Compiler.Framework/IR.cs +++ b/Source/Mosa.Compiler.Framework/IR.cs @@ -190,7 +190,6 @@ public static class IR public static readonly BaseInstruction ShiftLeft64 = new ShiftLeft64(); public static readonly BaseInstruction ShiftRight32 = new ShiftRight32(); public static readonly BaseInstruction ShiftRight64 = new ShiftRight64(); - public static readonly BaseInstruction StableObjectTracking = new StableObjectTracking(); public static readonly BaseInstruction StoreCompound = new StoreCompound(); public static readonly BaseInstruction StoreR4 = new StoreR4(); public static readonly BaseInstruction StoreR8 = new StoreR8(); @@ -225,7 +224,7 @@ public static class IR public static readonly BaseInstruction Truncate64x32 = new Truncate64x32(); public static readonly BaseInstruction TryEnd = new TryEnd(); public static readonly BaseInstruction TryStart = new TryStart(); - public static readonly BaseInstruction UnstableObjectTracking = new UnstableObjectTracking(); + public static readonly BaseInstruction GCPoint = new GCPoint(); public static readonly BaseInstruction Rethrow = new Rethrow(); public static readonly BaseInstruction GetVirtualFunctionPtr = new GetVirtualFunctionPtr(); public static readonly BaseInstruction MemoryCopy = new MemoryCopy(); diff --git a/Source/Mosa.Compiler.Framework/Instructions/StableObjectTracking.cs b/Source/Mosa.Compiler.Framework/Instructions/GCPoint.cs similarity index 70% rename from Source/Mosa.Compiler.Framework/Instructions/StableObjectTracking.cs rename to Source/Mosa.Compiler.Framework/Instructions/GCPoint.cs index 20db6069bc..19e9259aab 100644 --- a/Source/Mosa.Compiler.Framework/Instructions/StableObjectTracking.cs +++ b/Source/Mosa.Compiler.Framework/Instructions/GCPoint.cs @@ -5,11 +5,11 @@ namespace Mosa.Compiler.Framework.Instructions; /// -/// StableObjectTracking +/// GCPoint /// -public sealed class StableObjectTracking : BaseIRInstruction +public sealed class GCPoint : BaseIRInstruction { - public StableObjectTracking() + public GCPoint() : base(0, 0) { } diff --git a/Source/Mosa.Compiler.Framework/Instructions/UnstableObjectTracking.cs b/Source/Mosa.Compiler.Framework/Instructions/UnstableObjectTracking.cs deleted file mode 100644 index 4e2f5d970a..0000000000 --- a/Source/Mosa.Compiler.Framework/Instructions/UnstableObjectTracking.cs +++ /dev/null @@ -1,18 +0,0 @@ -// Copyright (c) MOSA Project. Licensed under the New BSD License. - -// This code was generated by an automated template. - -namespace Mosa.Compiler.Framework.Instructions; - -/// -/// UnstableObjectTracking -/// -public sealed class UnstableObjectTracking : BaseIRInstruction -{ - public UnstableObjectTracking() - : base(0, 0) - { - } - - public override bool IgnoreDuringCodeGeneration => true; -} diff --git a/Source/Mosa.Compiler.Framework/Transforms/Compound/BaseCompoundTransform.cs b/Source/Mosa.Compiler.Framework/Transforms/Compound/BaseCompoundTransform.cs index 9785c0094c..14725cee46 100644 --- a/Source/Mosa.Compiler.Framework/Transforms/Compound/BaseCompoundTransform.cs +++ b/Source/Mosa.Compiler.Framework/Transforms/Compound/BaseCompoundTransform.cs @@ -26,8 +26,6 @@ protected static void CopyCompound(Transform transform, Context context, Operand var srcReg = transform.VirtualRegisters.AllocateNativeInteger(); var dstReg = transform.VirtualRegisters.AllocateNativeInteger(); - context.SetInstruction(IR.UnstableObjectTracking); - context.AppendInstruction(transform.AddInstruction, srcReg, sourceBase, source); context.AppendInstruction(transform.AddInstruction, dstReg, destinationBase, destination); @@ -72,8 +70,6 @@ protected static void CopyCompound(Transform transform, Context context, Operand continue; } } - - context.AppendInstruction(IR.StableObjectTracking); } #endregion Helpers From 24c407219bf4c1c23cdb266bfa4817311202bedd Mon Sep 17 00:00:00 2001 From: Phil Date: Sat, 19 Oct 2024 22:26:33 -0700 Subject: [PATCH 4/6] - Update minor build component --- .github/workflows/builds.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/builds.yml b/.github/workflows/builds.yml index d1475f6595..617021522f 100644 --- a/.github/workflows/builds.yml +++ b/.github/workflows/builds.yml @@ -38,7 +38,7 @@ jobs: - name: Setup MSBuild uses: microsoft/setup-msbuild@v2 - name: Setup Nuget.exe - uses: nuget/setup-nuget@v1 + uses: nuget/setup-nuget@v2 - name: Restore nuget Packages run: dotnet restore Source/Mosa.sln - name: Build From 77530fae4035abda4f74a8d0cec6d78e29595428 Mon Sep 17 00:00:00 2001 From: Phil Date: Sat, 19 Oct 2024 22:30:48 -0700 Subject: [PATCH 5/6] - Replace insecure methods --- Source/Mosa.Tool.Explorer.Avalonia/MainWindow.axaml.cs | 9 ++++----- Source/Mosa.Tool.Explorer/MainForm.cs | 4 ++-- 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/Source/Mosa.Tool.Explorer.Avalonia/MainWindow.axaml.cs b/Source/Mosa.Tool.Explorer.Avalonia/MainWindow.axaml.cs index 5a9b6eea16..7296055d45 100755 --- a/Source/Mosa.Tool.Explorer.Avalonia/MainWindow.axaml.cs +++ b/Source/Mosa.Tool.Explorer.Avalonia/MainWindow.axaml.cs @@ -257,7 +257,7 @@ private async void DumpAllMethodStages_OnClick(object _, RoutedEventArgs e) InstructionsStage.SelectedIndex = 0; - for (;;) + for (; ; ) { UpdateInstructionStageSelection(); @@ -275,7 +275,7 @@ private async void DumpAllMethodStages_OnClick(object _, RoutedEventArgs e) DebugStage.SelectedIndex = 0; - for (;;) + for (; ; ) { UpdateDebugResults(); @@ -414,7 +414,6 @@ private void Save2_OnClick(object _, RoutedEventArgs e) private void Last_OnClick(object _, RoutedEventArgs e) => SetTransformationStep(int.MaxValue); - private void SetBlock_OnIsCheckedChanged(object _, RoutedEventArgs e) => TransformsGrid_OnSelectionChanged(null, null); @@ -622,8 +621,8 @@ private bool ShowGraphviz() if (string.IsNullOrEmpty(Debug.Text) || !Debug.Text.StartsWith("digraph blocks")) return false; - var dot = Path.GetTempFileName(); - var img = Path.GetTempFileName(); + var dot = Path.GetRandomFileName(); + var img = Path.GetRandomFileName(); try { diff --git a/Source/Mosa.Tool.Explorer/MainForm.cs b/Source/Mosa.Tool.Explorer/MainForm.cs index 70d5a03868..80eb1fa240 100644 --- a/Source/Mosa.Tool.Explorer/MainForm.cs +++ b/Source/Mosa.Tool.Explorer/MainForm.cs @@ -1335,8 +1335,8 @@ private bool DisplayGraphviz() if (!tbDebugResult.Text.Contains("digraph blocks")) return false; - var dot = Path.GetTempFileName(); - var bmp = Path.GetTempFileName(); + var dot = Path.GetRandomFileName(); + var bmp = Path.GetRandomFileName(); try { From 5ab8bcc378b58d2b53099e618e9e94f8896d89d6 Mon Sep 17 00:00:00 2001 From: Phil Date: Sun, 20 Oct 2024 09:25:53 -0700 Subject: [PATCH 6/6] - Renamed GCPoint to SafePoint and stub stage --- Source/Data/IR-Instructions.json | 2 +- Source/Mosa.Compiler.Framework/Compiler.cs | 2 +- Source/Mosa.Compiler.Framework/IR.cs | 2 +- .../Instructions/{GCPoint.cs => SafePoint.cs} | 6 +++--- .../Stages/{PreciseGCStage.cs => SafePointStage.cs} | 4 ++-- 5 files changed, 8 insertions(+), 8 deletions(-) rename Source/Mosa.Compiler.Framework/Instructions/{GCPoint.cs => SafePoint.cs} (77%) rename Source/Mosa.Compiler.Framework/Stages/{PreciseGCStage.cs => SafePointStage.cs} (73%) diff --git a/Source/Data/IR-Instructions.json b/Source/Data/IR-Instructions.json index 4f9b7e9aa1..e453d10a7d 100644 --- a/Source/Data/IR-Instructions.json +++ b/Source/Data/IR-Instructions.json @@ -1494,7 +1494,7 @@ "IgnoreInstructionBasicBlockTargets": "true" }, { - "Name": "GCPoint", + "Name": "SafePoint", "FamilyName": "IR", "ResultCount": 0, "OperandCount": 0, diff --git a/Source/Mosa.Compiler.Framework/Compiler.cs b/Source/Mosa.Compiler.Framework/Compiler.cs index 0afdf88c98..5eb29149d5 100644 --- a/Source/Mosa.Compiler.Framework/Compiler.cs +++ b/Source/Mosa.Compiler.Framework/Compiler.cs @@ -198,7 +198,7 @@ public sealed class Compiler new DeadBlockStage(), new AdvancedBlockOrderingStage(), - //new PreciseGCStage(), + new SafePointStage(), new CodeGenerationStage(), mosaSettings.EmitBinary ? new ProtectedRegionLayoutStage() : null, diff --git a/Source/Mosa.Compiler.Framework/IR.cs b/Source/Mosa.Compiler.Framework/IR.cs index 87c92bc72f..4249c041a3 100644 --- a/Source/Mosa.Compiler.Framework/IR.cs +++ b/Source/Mosa.Compiler.Framework/IR.cs @@ -224,7 +224,7 @@ public static class IR public static readonly BaseInstruction Truncate64x32 = new Truncate64x32(); public static readonly BaseInstruction TryEnd = new TryEnd(); public static readonly BaseInstruction TryStart = new TryStart(); - public static readonly BaseInstruction GCPoint = new GCPoint(); + public static readonly BaseInstruction SafePoint = new SafePoint(); public static readonly BaseInstruction Rethrow = new Rethrow(); public static readonly BaseInstruction GetVirtualFunctionPtr = new GetVirtualFunctionPtr(); public static readonly BaseInstruction MemoryCopy = new MemoryCopy(); diff --git a/Source/Mosa.Compiler.Framework/Instructions/GCPoint.cs b/Source/Mosa.Compiler.Framework/Instructions/SafePoint.cs similarity index 77% rename from Source/Mosa.Compiler.Framework/Instructions/GCPoint.cs rename to Source/Mosa.Compiler.Framework/Instructions/SafePoint.cs index 19e9259aab..dea9f8bddd 100644 --- a/Source/Mosa.Compiler.Framework/Instructions/GCPoint.cs +++ b/Source/Mosa.Compiler.Framework/Instructions/SafePoint.cs @@ -5,11 +5,11 @@ namespace Mosa.Compiler.Framework.Instructions; /// -/// GCPoint +/// SafePoint /// -public sealed class GCPoint : BaseIRInstruction +public sealed class SafePoint : BaseIRInstruction { - public GCPoint() + public SafePoint() : base(0, 0) { } diff --git a/Source/Mosa.Compiler.Framework/Stages/PreciseGCStage.cs b/Source/Mosa.Compiler.Framework/Stages/SafePointStage.cs similarity index 73% rename from Source/Mosa.Compiler.Framework/Stages/PreciseGCStage.cs rename to Source/Mosa.Compiler.Framework/Stages/SafePointStage.cs index 80c5dab7c6..bece041e2b 100644 --- a/Source/Mosa.Compiler.Framework/Stages/PreciseGCStage.cs +++ b/Source/Mosa.Compiler.Framework/Stages/SafePointStage.cs @@ -3,9 +3,9 @@ namespace Mosa.Compiler.Framework.Stages; /// -/// This stage determines were object references are located in code. +/// This stage inserts the GC safe points. /// -public class PreciseGCStage : BaseMethodCompilerStage +public class SafePointStage : BaseMethodCompilerStage { private TraceLog trace;