Skip to content

Commit 1d63e48

Browse files
authored
Preparing for precision garbase collection (#1250)
* - Preparing for SafePoints * - Preparing for SafePoints * - Preparing for SafePoints * - Preparing for SafePoints * Merge branch 'master' of https://github.com/mosa/MOSA-Project into 511-safepoints # Conflicts: # Source/Mosa.Compiler.Framework/Stages/SafePointStage.cs
1 parent d95db0a commit 1d63e48

File tree

8 files changed

+86
-6
lines changed

8 files changed

+86
-6
lines changed

Source/Data/IR-Instructions.json

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,6 +1501,22 @@
15011501
"IgnoreDuringCodeGeneration": "true",
15021502
"UnspecifiedSideEffect": "true"
15031503
},
1504+
{
1505+
"Name": "UnstableRegionStart",
1506+
"FamilyName": "IR",
1507+
"ResultCount": 0,
1508+
"OperandCount": 0,
1509+
"IgnoreDuringCodeGeneration": "true",
1510+
"UnspecifiedSideEffect": "true"
1511+
},
1512+
{
1513+
"Name": "UnstableRegionEnd",
1514+
"FamilyName": "IR",
1515+
"ResultCount": 0,
1516+
"OperandCount": 0,
1517+
"IgnoreDuringCodeGeneration": "true",
1518+
"UnspecifiedSideEffect": "true"
1519+
},
15041520
{
15051521
"Name": "Rethrow",
15061522
"FamilyName": "IR",

Source/Docs/mosa-runtime-tables.dot

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ digraph "MOSA Runtime Tables"
1111
];
1212

1313
"NameString" [
14-
label = "<f0>String Object|<f1>Object Header|<f2>Pointer to Method Table|<f3>String Length|<f4>Unicode String"
14+
label = "<f0>Internal String Object|<f1>Object Header|<f2>Pointer to Method Table|<f3>String Length|<f4>Unicode String"
1515
shape = "record"
1616
color = "red"
1717
];
@@ -209,7 +209,7 @@ digraph "MOSA Runtime Tables"
209209
];
210210

211211
"MethodDefinition" [
212-
label = "<f0>Method Definition|<f1>Pointer to Method Name|<f2>~Pointer to Custom Attributes|<f3>Method Attributes|<f4>Local & Parameter Stack Size|<f5>Pointer to Method|<f6>Pointer to Return Type Definition|<f7>~Pointer to Protected Region Table|<f8>Pointer to SafePoint Table|<f9>Number of Parameters|<f10>Pointer to Parameter Definition 1|...|Pointer to Parameter Definition N"
212+
label = "<f0>Method Definition|<f1>Pointer to Method Name|<f2>~Pointer to Custom Attributes|<f3>Method Attributes|<f4>Local & Parameter Stack Size|<f5>Pointer to Method|<f6>Pointer to Return Type Definition|<f7>~Pointer to Protected Region Table|<f8>Pointer to Method GC Data|<f9>Number of Parameters|<f10>Pointer to Parameter Definition 1|...|Pointer to Parameter Definition N"
213213
shape = "record"
214214
color = "purple"
215215
];
@@ -232,7 +232,7 @@ digraph "MOSA Runtime Tables"
232232
color = "blue"
233233
];
234234

235-
"MethodDefinition":f8 -> "SafePointTable":f0 [
235+
"MethodDefinition":f8 -> "Method GC Data":f0 [
236236
id = 0
237237
];
238238

@@ -258,14 +258,24 @@ digraph "MOSA Runtime Tables"
258258
id = 0
259259
color = "blue"
260260
];
261+
262+
"Method GC Data" [
263+
label = "<f0>Method GC Data|<f1>Pointer to SafePoint Table|<f2>Pointer to Method GC Stack Data"
264+
shape = "record"
265+
];
266+
267+
"Method GC Data":f1 -> "SafePoint":f0 [
268+
id = 0
269+
style = "dotted"
270+
];
261271

262272
"SafePointTable" [
263273
label = "<f0>SafePoint Table|<f1>Number of SafePoints|<f2>SafePoint 1|..|SafePoint N"
264274
shape = "record"
265275
];
266276

267277
"SafePoint" [
268-
label = "<f0>SafePoint|<f1>Address Offset|<f2>Address Range (signed)|<f3>Breakpoint Indicator|<f4>CPU Registers Bitmap (64 bit)"
278+
label = "<f0>SafePoint|<f1>Address Offset|<f2>Address Range (signed)|<f3>Breakpoint Indicator|<f4>CPU Registers Bitmap (32 bit)"
269279
shape = "record"
270280
];
271281

Source/Docs/runtime-tables.rst

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,15 @@ MOSA Runtime Tables
55
This diagram represents the internal runtime tables within the MOSA virtual machine:
66

77
.. graphviz:: mosa-runtime-tables.dot
8+
9+
Internal String Object
10+
----------------------
11+
12+
.. csv-table::
13+
:header: "Fields"
14+
:widths: 200
15+
16+
Object Header
17+
Pointer to Method Table
18+
String Length
19+
Unicode String

Source/Mosa.Compiler.Framework/IR.cs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -225,6 +225,8 @@ public static class IR
225225
public static readonly BaseInstruction TryEnd = new TryEnd();
226226
public static readonly BaseInstruction TryStart = new TryStart();
227227
public static readonly BaseInstruction SafePoint = new SafePoint();
228+
public static readonly BaseInstruction UnstableRegionStart = new UnstableRegionStart();
229+
public static readonly BaseInstruction UnstableRegionEnd = new UnstableRegionEnd();
228230
public static readonly BaseInstruction Rethrow = new Rethrow();
229231
public static readonly BaseInstruction GetVirtualFunctionPtr = new GetVirtualFunctionPtr();
230232
public static readonly BaseInstruction MemoryCopy = new MemoryCopy();
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) MOSA Project. Licensed under the New BSD License.
2+
3+
// This code was generated by an automated template.
4+
5+
namespace Mosa.Compiler.Framework.Instructions;
6+
7+
/// <summary>
8+
/// UnstableRegionEnd
9+
/// </summary>
10+
public sealed class UnstableRegionEnd : BaseIRInstruction
11+
{
12+
public UnstableRegionEnd()
13+
: base(0, 0)
14+
{
15+
}
16+
17+
public override bool IgnoreDuringCodeGeneration => true;
18+
}
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
// Copyright (c) MOSA Project. Licensed under the New BSD License.
2+
3+
// This code was generated by an automated template.
4+
5+
namespace Mosa.Compiler.Framework.Instructions;
6+
7+
/// <summary>
8+
/// UnstableRegionStart
9+
/// </summary>
10+
public sealed class UnstableRegionStart : BaseIRInstruction
11+
{
12+
public UnstableRegionStart()
13+
: base(0, 0)
14+
{
15+
}
16+
17+
public override bool IgnoreDuringCodeGeneration => true;
18+
}

Source/Mosa.Compiler.Framework/Stages/SafePointStage.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ namespace Mosa.Compiler.Framework.Stages;
66

77
// TODO:
88
// 1. Analyze method and determine:
9-
// A. Determine if method contain any refernces to objects, or have any managed pointers
9+
// A. Determine if method contains any references to objects, or have any managed pointers
1010
// B. Determine start/end ranges of objects and managed pointers on the local stack and parameters
1111
// C. Place SafePoint at:
1212
// i. Method prologue

Source/Mosa.Compiler.Framework/Transforms/Compound/BaseCompoundTransform.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,9 @@ protected static void CopyCompound(Transform transform, Context context, Operand
2626
var srcReg = transform.VirtualRegisters.AllocateNativeInteger();
2727
var dstReg = transform.VirtualRegisters.AllocateNativeInteger();
2828

29-
context.SetInstruction(transform.AddInstruction, srcReg, sourceBase, source);
29+
context.SetInstruction(IR.UnstableRegionStart);
30+
31+
context.AppendInstruction(transform.AddInstruction, srcReg, sourceBase, source);
3032
context.AppendInstruction(transform.AddInstruction, dstReg, destinationBase, destination);
3133

3234
var tmp = transform.VirtualRegisters.AllocateNativeInteger();
@@ -70,6 +72,8 @@ protected static void CopyCompound(Transform transform, Context context, Operand
7072
continue;
7173
}
7274
}
75+
76+
context.AppendInstruction(IR.UnstableRegionEnd);
7377
}
7478

7579
#endregion Helpers

0 commit comments

Comments
 (0)