Skip to content

Commit

Permalink
- Preparing for SafePoints
Browse files Browse the repository at this point in the history
  • Loading branch information
tgiphil committed Nov 24, 2024
1 parent b215b2e commit 66ec4b4
Show file tree
Hide file tree
Showing 6 changed files with 59 additions and 1 deletion.
16 changes: 16 additions & 0 deletions Source/Data/IR-Instructions.json
Original file line number Diff line number Diff line change
Expand Up @@ -1501,6 +1501,22 @@
"IgnoreDuringCodeGeneration": "true",
"UnspecifiedSideEffect": "true"
},
{
"Name": "UnstableRegionStart",
"FamilyName": "IR",
"ResultCount": 0,
"OperandCount": 0,
"IgnoreDuringCodeGeneration": "true",
"UnspecifiedSideEffect": "true"
},
{
"Name": "UnstableRegionEnd",
"FamilyName": "IR",
"ResultCount": 0,
"OperandCount": 0,
"IgnoreDuringCodeGeneration": "true",
"UnspecifiedSideEffect": "true"
},
{
"Name": "Rethrow",
"FamilyName": "IR",
Expand Down
2 changes: 2 additions & 0 deletions Source/Mosa.Compiler.Framework/IR.cs
Original file line number Diff line number Diff line change
Expand Up @@ -225,6 +225,8 @@ public static class IR
public static readonly BaseInstruction TryEnd = new TryEnd();
public static readonly BaseInstruction TryStart = new TryStart();
public static readonly BaseInstruction SafePoint = new SafePoint();
public static readonly BaseInstruction UnstableRegionStart = new UnstableRegionStart();
public static readonly BaseInstruction UnstableRegionEnd = new UnstableRegionEnd();
public static readonly BaseInstruction Rethrow = new Rethrow();
public static readonly BaseInstruction GetVirtualFunctionPtr = new GetVirtualFunctionPtr();
public static readonly BaseInstruction MemoryCopy = new MemoryCopy();
Expand Down
18 changes: 18 additions & 0 deletions Source/Mosa.Compiler.Framework/Instructions/UnstableRegionEnd.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) MOSA Project. Licensed under the New BSD License.

// This code was generated by an automated template.

namespace Mosa.Compiler.Framework.Instructions;

/// <summary>
/// UnstableRegionEnd
/// </summary>
public sealed class UnstableRegionEnd : BaseIRInstruction
{
public UnstableRegionEnd()
: base(0, 0)
{
}

public override bool IgnoreDuringCodeGeneration => true;
}
18 changes: 18 additions & 0 deletions Source/Mosa.Compiler.Framework/Instructions/UnstableRegionStart.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
// Copyright (c) MOSA Project. Licensed under the New BSD License.

// This code was generated by an automated template.

namespace Mosa.Compiler.Framework.Instructions;

/// <summary>
/// UnstableRegionStart
/// </summary>
public sealed class UnstableRegionStart : BaseIRInstruction
{
public UnstableRegionStart()
: base(0, 0)
{
}

public override bool IgnoreDuringCodeGeneration => true;
}
2 changes: 1 addition & 1 deletion Source/Mosa.Compiler.Framework/Stages/SafePointStage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ namespace Mosa.Compiler.Framework.Stages;

// TODO:
// 1. Analyze method and determine:
// A. Determine if method contain any refernces to objects, or have any managed pointers
// A. Determine if method contains any references to objects, or have any managed pointers
// B. Determine start/end ranges of objects and managed pointers on the local stack and parameters
// C. Place SafePoint at:
// i. Method prologue
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,8 @@ protected static void CopyCompound(Transform transform, Context context, Operand
var srcReg = transform.VirtualRegisters.AllocateNativeInteger();
var dstReg = transform.VirtualRegisters.AllocateNativeInteger();

context.SetInstruction(IR.UnstableRegionStart);

context.SetInstruction(transform.AddInstruction, srcReg, sourceBase, source);
context.AppendInstruction(transform.AddInstruction, dstReg, destinationBase, destination);

Expand Down Expand Up @@ -70,6 +72,8 @@ protected static void CopyCompound(Transform transform, Context context, Operand
continue;
}
}

context.SetInstruction(IR.UnstableRegionEnd);
}

#endregion Helpers
Expand Down

0 comments on commit 66ec4b4

Please sign in to comment.