Skip to content

Commit

Permalink
Fix (#1050)
Browse files Browse the repository at this point in the history
* -Merge

* - Fix

* - Fix

* - Fix
  • Loading branch information
tgiphil committed May 14, 2023
1 parent 24d4740 commit e338101
Show file tree
Hide file tree
Showing 4 changed files with 42 additions and 7 deletions.
2 changes: 2 additions & 0 deletions Source/Mosa.Platform.ARMv8A32/Transforms/IR/IRTransforms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public static class IRTransforms
new Add32(),
new AddCarryIn32(),
new AddCarryOut32(),
new AddManagedPointer(),
//new AddOverflowOut32(),
new AddR4(),
new AddR8(),
Expand Down Expand Up @@ -104,6 +105,7 @@ public static class IRTransforms
new Sub32(),
new SubCarryIn32(),
new SubCarryOut32(),
new SubManagedPointer(),
//new SubOverflowOut32(),
new SubR4(),
new SubR8(),
Expand Down
2 changes: 2 additions & 0 deletions Source/Mosa.Platform.x64/Transforms/IR/IRTransforms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public static class IRTransforms
new Add32(),
new AddCarryIn32(),
new AddCarryOut32(),
new AddManagedPointer(),
//new AddOverflowOut32(),
new AddR4(),
new AddR8(),
Expand Down Expand Up @@ -104,6 +105,7 @@ public static class IRTransforms
new Sub32(),
new SubCarryIn32(),
new SubCarryOut32(),
new SubManagedPointer(),
//new SubOverflowOut32(),
new SubR4(),
new SubR8(),
Expand Down
2 changes: 2 additions & 0 deletions Source/Mosa.Platform.x86/Transforms/IR/IRTransforms.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ public static class IRTransforms
new Add32(),
new AddCarryIn32(),
new AddCarryOut32(),
new AddManagedPointer(),
new AddOverflowOut32(),
new AddR4(),
new AddR8(),
Expand Down Expand Up @@ -102,6 +103,7 @@ public static class IRTransforms
new StoreParamObject(),
new StoreParamManagedPointer(),
new Sub32(),
new SubManagedPointer(),
new SubCarryIn32(),
new SubCarryOut32(),
new SubOverflowOut32(),
Expand Down
43 changes: 36 additions & 7 deletions Source/Mosa.Runtime/Internal.cs
Original file line number Diff line number Diff line change
Expand Up @@ -188,19 +188,35 @@ public static Pointer UnboxAny(Pointer src, Pointer dest, uint size)

#region Memory Manipulation

[MethodImpl(MethodImplOptions.AggressiveInlining)]
public static void MemoryCopy(Pointer dest, Pointer src, uint count)
{
// FUTURE: Improve
if (count % 4 == 0)
MemoryCopy4(dest, src, count);
else
MemoryCopy1(dest, src, count);
}

private static void MemoryCopy1(Pointer dest, Pointer src, uint count)
{
for (var i = 0; i < count; i++)
{
byte value = src.Load8(i);
var value = src.Load8(i);
dest.Store8(i, value);
}
}

private static void MemoryCopy4(Pointer dest, Pointer src, uint count)
{
for (var i = 0; i < count; i += 4)
{
var value = src.Load32(i);
dest.Store32(i, value);
}
}

public static void MemorySet(Pointer dest, byte value, uint count)
{
// FUTURE: Improve
for (var i = 0; i < count; i++)
{
dest.Store8(i, value);
Expand All @@ -209,7 +225,6 @@ public static void MemorySet(Pointer dest, byte value, uint count)

public static void MemorySet(Pointer dest, ushort value, uint count)
{
// FUTURE: Improve
for (var i = 0; i < count; i += 2)
{
dest.Store16(i, value);
Expand All @@ -218,7 +233,6 @@ public static void MemorySet(Pointer dest, ushort value, uint count)

public static void MemorySet(Pointer dest, uint value, uint count)
{
// FUTURE: Improve
for (var i = 0; i < count; i += 4)
{
dest.Store32(i, value);
Expand All @@ -227,13 +241,28 @@ public static void MemorySet(Pointer dest, uint value, uint count)

public static void MemoryClear(Pointer dest, uint count)
{
// FUTURE: Improve
for (int i = 0; i < count; i++)
if (count % 4 == 0)
MemoryClear4(dest, count);
else
MemoryClear1(dest, count);
}

private static void MemoryClear1(Pointer dest, uint count)
{
for (var i = 0; i < count; i++)
{
dest.Store8(i, 0);
}
}

private static void MemoryClear4(Pointer dest, uint count)
{
for (var i = 0; i < count; i += 4)
{
dest.Store32(i, 0);
}
}

#endregion Memory Manipulation

#region Virtual Machine
Expand Down

0 comments on commit e338101

Please sign in to comment.