Skip to content

Commit

Permalink
Little progress.
Browse files Browse the repository at this point in the history
  • Loading branch information
mterwoord committed Jun 25, 2016
1 parent 38e8975 commit 6e5d762
Show file tree
Hide file tree
Showing 5 changed files with 34 additions and 24 deletions.
13 changes: 12 additions & 1 deletion Tests/Cosmos.Compiler.Tests.SimpleWriteLine.Kernel/Kernel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,13 +37,24 @@ protected override void Run()
Assert.AreEqual(4, xTempString.Length, "Dynamic string has wrong length!");
Assert.AreEqual(97, (int)xTempString[0], "First character of dynamic string is wrong!");

TestController.Completed();
Console.WriteLine(42);
DoPrint(42);
while (true)
;

//
//TestController.Completed();
}
catch (Exception E)
{
Console.WriteLine("Exception");
Console.WriteLine(E.ToString());
}
}

private static void DoPrint(int i)
{
Console.WriteLine(i.ToString());
}
}
}
2 changes: 1 addition & 1 deletion Tests/Cosmos.TestRunner.Core/DefaultEngineConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public static void Apply(Engine engine)
engine.StackCorruptionChecksLevel = StackCorruptionDetectionLevel.AllInstructions;
//engine.DebugStubEnabled = false;

engine.RunWithGDB = true;
//engine.RunWithGDB = true;
//engine.StartBochsDebugGui = true;

// Select kernels to be tested by adding them to the engine
Expand Down
15 changes: 6 additions & 9 deletions source/Cosmos.IL2CPU/AppAssembler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -341,11 +341,8 @@ protected void MethodEnd(MethodInfo aMethod)
XS.Set(XSRegisters.ECX, 0);
var xTotalArgsSize = (from item in aMethod.MethodBase.GetParameters()
select (int)ILOp.Align(ILOp.SizeOfType(item.ParameterType), 4)).Sum();
if (ILOp.GetMethodLabel(aMethod) == "SystemVoidSystemConsoleWriteLineSystemString")
{
;
;
}


if (!aMethod.MethodBase.IsStatic)
{
if (aMethod.MethodBase.DeclaringType.IsValueType)
Expand Down Expand Up @@ -1532,13 +1529,13 @@ protected void BeforeOp(MethodInfo aMethod, ILOpCode aOpCode, bool emitInt3NotNo

// if debugstub is active, emit a stack corruption detection. at this point EBP and ESP should have the same value.
// if not, we should somehow break here.
XS.Set(XSRegisters.EAX, XSRegisters.ESP);
XS.Set(XSRegisters.EBX, XSRegisters.EBP);
XS.Set(EAX, ESP);
XS.Set(EBX, EBP);
if (xStackDifference != 0)
{
XS.Add(XSRegisters.EAX, xStackDifference.Value);
XS.Add(EAX, xStackDifference.Value);
}
XS.Compare(XSRegisters.EAX, XSRegisters.EBX);
XS.Compare(EAX, EBX);
XS.Jump(ConditionalTestEnum.Equal, xLabel + ".StackCorruptionCheck_End");
XS.Push(EAX);
XS.Push(EBX);
Expand Down
22 changes: 10 additions & 12 deletions source/Cosmos.IL2CPU/IL/Call.cs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,14 @@ public static uint GetStackSizeToReservate(MethodBase aMethod)
}
if (!xMethodInfo.IsStatic)
{
xExtraStackSize -= GetNativePointerSize(xMethodInfo);
if (aMethod.DeclaringType.IsValueType)
{
xExtraStackSize -= 4;
}
else
{
xExtraStackSize -= GetNativePointerSize(xMethodInfo);
}
}
if (xExtraStackSize > 0)
{
Expand Down Expand Up @@ -79,19 +86,10 @@ public static void DoExecute(Cosmos.Assembler.Assembler Assembler, MethodInfo aC

public static unsafe void DoExecute(Cosmos.Assembler.Assembler Assembler, MethodInfo aCurrentMethod, MethodBase aTargetMethod, ILOpCode aCurrent, string currentLabel, string nextLabel, bool debugEnabled)
{
if (aTargetMethod.DeclaringType.IsValueType && !aTargetMethod.IsStatic)
if (GetMethodLabel(aTargetMethod) == "SystemStringSystemInt32ToString")
{
var xThisSize = Align(SizeOfType(aTargetMethod.DeclaringType), 4);
XS.Set(XSRegisters.EAX, XSRegisters.ESP);
XS.Add(XSRegisters.ESP, xThisSize);
XS.Push(XSRegisters.EAX);

return;
;
}
//if (aTargetMethod.IsVirtual) {
// Callvirt.DoExecute(Assembler, aCurrentMethod, aTargetMethod, aTargetMethodUID, aCurrentPosition);
// return;
//}
var xMethodInfo = aTargetMethod as SysReflection.MethodInfo;

// mTargetMethodInfo = GetService<IMetaDataInfoService>().GetMethodInfo(mMethod
Expand Down
6 changes: 5 additions & 1 deletion source/Cosmos.System/Console.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,10 @@ public void WriteLine(string aText) {

//TODO: Optimize this
public void Write(string aText) {
if (aText == null)
{
return;
}
for (int i = 0; i < aText.Length; i++) {
if (aText[i] == '\n') {
NewLine();
Expand Down Expand Up @@ -121,7 +125,7 @@ public int CursorSize
}

public bool CursorVisible {
get { return mText.GetCursorVisible(); }
get { return mText.GetCursorVisible(); }
set { mText.SetCursorVisible(value); }
}
}
Expand Down

0 comments on commit 6e5d762

Please sign in to comment.