Skip to content

Commit

Permalink
.
Browse files Browse the repository at this point in the history
  • Loading branch information
mterwoord committed Jun 16, 2016
1 parent 990591c commit 40ff5ad
Show file tree
Hide file tree
Showing 24 changed files with 53 additions and 49 deletions.
2 changes: 1 addition & 1 deletion Users/Matthijs/DebugCompiler/MyEngine.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ public void Test(Type kernelToRun)
var xEngine = new Engine();
// Sets the time before an error is registered. For example if set to 60 then if a kernel runs for more than 60 seconds then
// that kernel will be marked as a failure and terminated
xEngine.AllowedSecondsInKernel = 15;
xEngine.AllowedSecondsInKernel = 30;

// If you want to test only specific platforms, add them to the list, like next line. By default, all platforms are run.
xEngine.RunTargets.Add(RunTargetEnum.Bochs);
Expand Down
4 changes: 2 additions & 2 deletions source/Cosmos.Core.Plugs/Assemblers/UpdateIDT.cs
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object a

if (Array.IndexOf(xInterruptsWithParam, j) == -1)
{
new CPUx86.Push { DestinationValue = 0 };
XS.Push(0);
}
new CPUx86.Push { DestinationValue = (uint)j };
XS.Push((uint)j);
XS.PushAllRegisters();

XS.Sub(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.ESP), 4);
Expand Down
2 changes: 1 addition & 1 deletion source/Cosmos.IL2CPU/IL/Box.cs
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ public override void Execute(MethodInfo aMethod, ILOpCode aOpCode)

uint xSize = Align(SizeOfType(xType.Value), 4);
string xTypeID = GetTypeIDLabel(xType.Value);
new CPUx86.Push { DestinationValue = (ObjectImpl.FieldDataOffset + xSize) };
XS.Push((ObjectImpl.FieldDataOffset + xSize));
XS.Call(LabelName.Get(GCImplementationRefs.AllocNewObjectRef));
XS.Pop(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.EAX));
XS.Set(XSRegisters.ESI, XSRegisters.EAX, sourceIsIndirect: true);
Expand Down
2 changes: 1 addition & 1 deletion source/Cosmos.IL2CPU/IL/Callvirt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ public static void DoExecute(Cosmos.Assembler.Assembler Assembler, MethodInfo aM
XS.Set(XSRegisters.EAX, XSRegisters.EAX, sourceIsIndirect: true);
XS.Push(XSRegisters.EAX, isIndirect: true);
}
new CPU.Push { DestinationValue = aTargetMethodUID };
XS.Push(aTargetMethodUID);
XS.Call(LabelName.Get(VTablesImplRefs.GetMethodAddressForTypeRef));
if (xExtraStackSize > 0)
{
Expand Down
6 changes: 3 additions & 3 deletions source/Cosmos.IL2CPU/IL/Cgt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
/*
XS.Jump(ConditionalTestEnum.GreaterThan, LabelTrue);
XS.Label(LabelFalse);
new CPUx86.Push { DestinationValue = 0 };
XS.Push(0);
XS.Jump(xNextLabel);
XS.Label(LabelTrue );
new CPUx86.Push { DestinationValue = 1 };*/
XS.Push(1);*/
}
else
{
Expand All @@ -100,7 +100,7 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
XS.Jump(xNextLabel);
XS.Label(LabelFalse );
XS.Add(XSRegisters.OldToNewRegister(RegistersEnum.ESP), 4);
new CPUx86.Push { DestinationValue = 0 };
XS.Push(0);
}
}
}
Expand Down
14 changes: 7 additions & 7 deletions source/Cosmos.IL2CPU/IL/Cgt_Un.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,10 +71,10 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
/*
XS.Jump(ConditionalTestEnum.Above, LabelTrue);
XS.Label(LabelFalse);
new CPUx86.Push { DestinationValue = 0 };
XS.Push(0);
new CPUx86.Jump { DestinationLabel = GetLabel(aMethod, aOpCode.NextPosition) };
XS.Label(LabelTrue );
new CPUx86.Push { DestinationValue = 1 };
XS.Push(1);
*/
}
else
Expand Down Expand Up @@ -103,7 +103,7 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
new Jump { DestinationLabel = GetLabel(aMethod, aOpCode.NextPosition) };
XS.Label(LabelFalse );
XS.Add(XSRegisters.OldToNewRegister(RegistersEnum.ESP), 4);
new CPUx86.Push { DestinationValue = 0 };
XS.Push(0);
}
}
}
Expand Down Expand Up @@ -168,11 +168,11 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
// //XS.Push(XSRegisters.EDI);
//
// XS.Jump(ConditionalTestEnum.Above, LabelTrue);
// new CPUx86.Push { DestinationValue = 0 };
// XS.Push(0);
// XS.Jump(NextInstructionLabel);
//
// XS.Label(LabelTrue);
// new CPUx86.Push{DestinationValue=1};
// XS.Push(1);
//
// } else
// {
Expand All @@ -182,11 +182,11 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
// XS.Jump(LabelFalse);
// XS.Label(LabelTrue);
// XS.Add(XSRegisters.ESP, 4);
// new CPUx86.Push { DestinationValue = 1 };
// XS.Push(1);
// XS.Jump(NextInstructionLabel);
// XS.Label(LabelFalse);
// XS.Add(XSRegisters.ESP, 4);
// new CPUx86.Push { DestinationValue = 0 };
// XS.Push(0);
// XS.Jump(NextInstructionLabel);
// }
// }
Expand Down
2 changes: 1 addition & 1 deletion source/Cosmos.IL2CPU/IL/Clt.cs
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )

XS.Label(LabelFalse );
XS.Add(XSRegisters.OldToNewRegister(RegistersEnum.ESP), 4);
new CPUx86.Push { DestinationValue = 0 };
XS.Push(0);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion source/Cosmos.IL2CPU/IL/Clt_Un.cs
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
new Jump { DestinationLabel = GetLabel(aMethod, aOpCode.NextPosition) };
XS.Label(LabelFalse );
XS.Add(XSRegisters.OldToNewRegister(RegistersEnum.ESP), 4);
new CPUx86.Push { DestinationValue = 0 };
XS.Push(0);
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion source/Cosmos.IL2CPU/IL/Div_Un.cs
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
XS.Divide(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.ESI));

// save result to stack
new CPUx86.Push { DestinationValue = 0 };
XS.Push(0);
XS.Push(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.EAX));

//TODO: implement proper derivation correction and overflow detection
Expand Down
2 changes: 1 addition & 1 deletion source/Cosmos.IL2CPU/IL/Isinst.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
new CPUx86.Jump { DestinationLabel = GetLabel(aMethod, aOpCode.NextPosition) };
XS.Label(mReturnNullLabel );
XS.Add(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.ESP), 4);
new CPUx86.Push { DestinationValue = 0 };
XS.Push(0);
}
}
}
6 changes: 3 additions & 3 deletions source/Cosmos.IL2CPU/IL/Ldarga.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )

// for( int i = 0; i < ( xCurArgSize / 4 ); i++ )
// {
// new CPUx86.Push { DestinationValue = ( uint )( xCurArgSize - ( ( i + 1 ) * 4 ) ) };
// XS.Push(( uint )( xCurArgSize - ( ( i + 1 ) * 4 ) ));
// }
// Assembler.Stack.Push( ( int )xCurArgSize, xParams[ xCorrectedOpValValue ].ParameterType );

Expand All @@ -83,7 +83,7 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )

// Assembler.Stack.Push( new StackContents.Item( 4, typeof( uint ) ) );

// //new CPUx86.Push { DestinationValue = ( uint )mAddress };
// //XS.Push(( uint )mAddress);
// //
// Assembler.Stack.Push( new StackContents.Item( 4, typeof( uint ) ) );

Expand Down Expand Up @@ -136,7 +136,7 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
// public override void DoAssemble() {
// XS.Push(XSRegisters.EBP);
// Assembler.Stack.Push(new StackContent(4, typeof(uint)));
// new CPU.Push { DestinationValue = (uint)mAddress };
// XS.Push((uint)mAddress);
// Assembler.Stack.Push(new StackContent(4, typeof(uint)));
// Add(Assembler, GetServiceProvider(), mCurLabel, mMethodInformation, mCurOffset, mNextLabel);
// }
Expand Down
3 changes: 2 additions & 1 deletion source/Cosmos.IL2CPU/IL/Ldc_I4.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
using Cosmos.IL2CPU.ILOpCodes;
using CPUx86 = Cosmos.Assembler.x86;
using System.Collections.Generic;
using XSharp.Compiler;

namespace Cosmos.IL2CPU.X86.IL
{
Expand All @@ -13,7 +14,7 @@ public Ldc_I4( Cosmos.Assembler.Assembler aAsmblr ) : base( aAsmblr ) { }

public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
{
new CPUx86.Push { DestinationValue = (uint)( ( OpInt )aOpCode ).Value };
XS.Push((uint)((OpInt)aOpCode).Value);
}

}
Expand Down
11 changes: 6 additions & 5 deletions source/Cosmos.IL2CPU/IL/Ldnull.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using XSharp.Compiler;
using CPUx86 = Cosmos.Assembler.x86;
namespace Cosmos.IL2CPU.X86.IL
{
Expand All @@ -12,25 +13,25 @@ public Ldnull( Cosmos.Assembler.Assembler aAsmblr )

public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
{
new CPUx86.Push { DestinationValue = 0 };
XS.Push(0);
}


// using System;
// using System.IO;
//
//
//
//
// using CPU = Cosmos.Assembler.x86;
// using Cosmos.IL2CPU.X86;
//
//
// namespace Cosmos.IL2CPU.IL.X86 {
// [Cosmos.Assembler.OpCode(OpCodeEnum.Ldnull)]
// public class Ldnull: Op {
// public Ldnull(ILReader aReader, MethodInformation aMethodInfo)
// : base(aReader, aMethodInfo) {
// }
// public override void DoAssemble() {
// new CPU.Push { DestinationValue = 0 };
// XS.Push(0);
// Assembler.Stack.Push(new StackContent(4, typeof(uint)));
// }
// }
Expand Down
2 changes: 1 addition & 1 deletion source/Cosmos.IL2CPU/IL/Ldtoken.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
//{
// mTokenAddress = GetService<IMetaDataInfoService>().GetTypeIdLabel( mType );
//}
//new CPUx86.Push { DestinationValue = xToken.Value };
//XS.Push(xToken.Value);
XS.Push(xTokenAddress);
}

Expand Down
4 changes: 2 additions & 2 deletions source/Cosmos.IL2CPU/IL/Newarr.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,10 +36,10 @@ public override void Execute(MethodInfo aMethod, ILOpCode aOpCode)
XS.Pop(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.ESI));
XS.Push(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.ESI));
//Assembler.StackSizes.Push(xElementCountSize);
new CPUx86.Push { DestinationValue = xSize };
XS.Push(xSize);
new Mul(Assembler).Execute(aMethod, aOpCode);
// the total items size is now on the stack
new CPUx86.Push { DestinationValue = (ObjectImpl.FieldDataOffset + 4) };
XS.Push((ObjectImpl.FieldDataOffset + 4));
new Add(Assembler).Execute(aMethod, aOpCode);
// the total array size is now on the stack.
XS.Call(LabelName.Get(GCImplementationRefs.AllocNewObjectRef));
Expand Down
2 changes: 1 addition & 1 deletion source/Cosmos.IL2CPU/IL/Newobj.cs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ public static void Assemble(Cosmos.Assembler.Assembler aAssembler, MethodInfo aM

uint xMemSize = GetStorageSize(objectType);
int xExtraSize = 12; // additional size for set values after alloc
new CPUx86.Push { DestinationValue = (uint)(xMemSize + xExtraSize) };
XS.Push((uint)(xMemSize + xExtraSize));
if (xHasCalcSize)
{
XS.Pop(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.EAX));
Expand Down
4 changes: 2 additions & 2 deletions source/Cosmos.IL2CPU/IL/Rem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ public override void Execute(MethodInfo aMethod, ILOpCode aOpCode) {
XS.IntegerDivide(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.ESI));

// save result to stack
new CPUx86.Push { DestinationValue = 0 };
XS.Push(0);
XS.Push(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.EDX));

//TODO: implement proper derivation correction and overflow detection
Expand All @@ -102,7 +102,7 @@ public override void Execute(MethodInfo aMethod, ILOpCode aOpCode) {
// divide low part
XS.Divide(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.ESI));
// save low result
new CPUx86.Push { DestinationValue = 0};
XS.Push(0);
XS.Push(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.EDX));

XS.Label(LabelEnd);
Expand Down
4 changes: 2 additions & 2 deletions source/Cosmos.IL2CPU/IL/Rem_Un.cs
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
XS.Divide(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.ESI));

// save remainder to stack
new CPUx86.Push { DestinationValue = 0 };
XS.Push(0);
XS.Push(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.EDX));

//TODO: implement proper derivation correction and overflow detection
Expand All @@ -107,7 +107,7 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
// divide low part
XS.Divide(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.ESI));
// save remainder result
new CPUx86.Push { DestinationValue = 0 };
XS.Push(0);
XS.Push(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.EDX));

XS.Label(LabelEnd);
Expand Down
18 changes: 10 additions & 8 deletions source/Cosmos.IL2CPU/IL/Sizeof.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
using CPUx86 = Cosmos.Assembler.x86;
using Cosmos.IL2CPU.ILOpCodes;
using Cosmos.Assembler;
using XSharp.Compiler;

namespace Cosmos.IL2CPU.X86.IL
{
[Cosmos.IL2CPU.OpCode( ILOpCode.Code.Sizeof )]
Expand All @@ -14,26 +16,26 @@ public Sizeof( Cosmos.Assembler.Assembler aAsmblr )

public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
{
OpType xType = ( OpType )aOpCode;
OpType xType = ( OpType )aOpCode;
uint xSize = SizeOfType( xType.Value );
new CPUx86.Push { DestinationValue = xSize };
XS.Push(xSize);
}


// using System;
// using System.Collections.Generic;
// using System.IO;
//
//
//
//
// using CPU = Cosmos.Assembler.x86;
// using Cosmos.IL2CPU.X86;
// using Cosmos.IL2CPU.Compiler;
//
//
// namespace Cosmos.IL2CPU.IL.X86 {
// [Cosmos.Assembler.OpCode(OpCodeEnum.Sizeof)]
// public class Sizeof: Op {
// private Type mType;
//
//
// //public static void ScanOp(ILReader aReader, MethodInformation aMethodInfo, SortedList<string, object> aMethodData) {
// // Type xTypeRef = aReader.OperandValueType;
// // if (xTypeRef == null)
Expand All @@ -42,7 +44,7 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
// // }
// // Engine.RegisterType(xTypeRef);
// //}
//
//
// public Sizeof(ILReader aReader, MethodInformation aMethodInfo)
// : base(aReader, aMethodInfo) {
// mType = aReader.OperandValueType;
Expand All @@ -52,7 +54,7 @@ public override void Execute( MethodInfo aMethod, ILOpCode aOpCode )
// public override void DoAssemble() {
// uint xSize;
// GetService<IMetaDataInfoService>().GetTypeFieldInfo(mType, out xSize);
// new CPU.Push { DestinationValue =xSize};
// XS.Push(xSize);
// Assembler.Stack.Push(new StackContent(4, typeof(int)));
// }
// }
Expand Down
2 changes: 1 addition & 1 deletion source/Cosmos.IL2CPU/IL/Stelem_Ref.cs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ public static void Assemble(Cosmos.Assembler.Assembler aAssembler, uint aElement

XS.Add(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.ECX), (uint)(ObjectImpl.FieldDataOffset + 4));

new CPUx86.Push { DestinationValue = aElementSize };
XS.Push(aElementSize);
XS.Push(XSRegisters.OldToNewRegister(CPUx86.RegistersEnum.EBX));


Expand Down
2 changes: 1 addition & 1 deletion source/Cosmos.IL2CPU/IL/Unbox.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public override void Execute(MethodInfo aMethod, ILOpCode aOpCode)
new CPU.Jump { DestinationLabel = GetLabel(aMethod, aOpCode.NextPosition) };
XS.Label(mReturnNullLabel);
XS.Add(XSRegisters.OldToNewRegister(CPU.RegistersEnum.ESP), 4);
new CPUx86.Push { DestinationValue = 0 };
XS.Push(0);
}
}
}
2 changes: 1 addition & 1 deletion source/Cosmos.IL2CPU/IL/Unbox_Any.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public override void Execute(MethodInfo aMethod, ILOpCode aOpCode)
new CPU.Jump { DestinationLabel = GetLabel(aMethod, aOpCode.NextPosition) };
XS.Label(mReturnNullLabel);
XS.Add(XSRegisters.OldToNewRegister(CPU.RegistersEnum.ESP), 4);
new CPUx86.Push { DestinationValue = 0 };
XS.Push(0);
}
}
}
2 changes: 1 addition & 1 deletion source/Cosmos.IL2CPU/Plugs/Assemblers/CtorImplAssembler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object a
Console.Write("");
}
XS.Comment("-- push argsize");
new CPUx86.Push { DestinationValue = xSize };
XS.Push(xSize);
XS.Comment("-- stfld ArgSize");
Stfld.DoExecute(xAssembler, xMethodInfo, "$$ArgSize$$", xMethodInfo.MethodBase.DeclaringType, true, false);

Expand Down
2 changes: 1 addition & 1 deletion source/Unused/Cosmos.Kernel.Plugs/Assemblers/CPUID.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public override void AssembleNew(Cosmos.Assembler.Assembler aAssembler, object a
XS.Popfd();
new CPUx86.Push("eax");*/
new CPUx86.Push { DestinationValue = 0 };
XS.Push(0);
}
}
public class GetCPUIDInternal: AssemblerMethod {
Expand Down

0 comments on commit 40ff5ad

Please sign in to comment.