From e722622bdf06f149e0932cfaed986a611b71db8e Mon Sep 17 00:00:00 2001 From: mterwoord_cp <7cd3fd84a0151ea055c2f79e4d2eef9576fe9afesxUZAwxD> Date: Tue, 17 Aug 2010 12:29:54 +0000 Subject: [PATCH] --- source/Cosmos/Cosmos.Kernel/Debugger.cs | 2 +- source2/IL2PCU/Cosmos.IL2CPU.X86/AppAssemblerNasm.cs | 3 ++- source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Ldfld.cs | 6 ------ source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Ldloc.cs | 5 ----- source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Ldsfld.cs | 10 +--------- source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Newarr.cs | 5 ----- source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Newobj.cs | 12 +----------- source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Stelem_Ref.cs | 4 ++-- source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Stfld.cs | 9 --------- source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Stloc.cs | 8 +------- source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Stsfld.cs | 5 ----- source2/IL2PCU/Cosmos.IL2CPU/GCImplementation.cs | 4 ++-- source2/Kernel/System/Cosmos.System/Console.cs | 4 ++++ .../Kernel/System/Cosmos.System/Cosmos.System.csproj | 4 ++++ source2/Kernel/System/Cosmos.System/Kernel.cs | 6 +++++- .../System/Hardware/Cosmos.Hardware/TextScreen.cs | 1 + source2/Users/Kudzu/Breakpoints/BreakpointsOS.cs | 4 ++++ 17 files changed, 28 insertions(+), 64 deletions(-) diff --git a/source/Cosmos/Cosmos.Kernel/Debugger.cs b/source/Cosmos/Cosmos.Kernel/Debugger.cs index e2da21f39..28989d770 100644 --- a/source/Cosmos/Cosmos.Kernel/Debugger.cs +++ b/source/Cosmos/Cosmos.Kernel/Debugger.cs @@ -22,7 +22,7 @@ namespace Cosmos.Debug { //xSingleString = "Message Module: \"" + aModule + "\""; //xSingleString += " Data: \"" + aData + "\""; //Send(xSingleString); - } + } public static unsafe void SendError(string aModule, string aData) { diff --git a/source2/IL2PCU/Cosmos.IL2CPU.X86/AppAssemblerNasm.cs b/source2/IL2PCU/Cosmos.IL2CPU.X86/AppAssemblerNasm.cs index 2d0381f8e..3a5f16e84 100644 --- a/source2/IL2PCU/Cosmos.IL2CPU.X86/AppAssemblerNasm.cs +++ b/source2/IL2PCU/Cosmos.IL2CPU.X86/AppAssemblerNasm.cs @@ -45,7 +45,8 @@ namespace Cosmos.IL2CPU.X86 new ConditionalJump { Condition = ConditionalTestEnum.Equal, DestinationLabel = ".BeforeQuickReturn" }; new Move { DestinationRef = ElementReference.New(xName), DestinationIsIndirect = true, Size = 8, SourceValue = 1 }; new Jump { DestinationLabel = ".AfterCCTorAlreadyCalledCheck"}; - new Label(".BeforeQuickReturn"); + new Label(".BeforeQuickReturn"); + new Move { DestinationReg = RegistersEnum.ECX, SourceValue = 0 }; new Return { }; new Label(".AfterCCTorAlreadyCalledCheck"); } diff --git a/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Ldfld.cs b/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Ldfld.cs index 3d5ba50b8..2f4d2b699 100644 --- a/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Ldfld.cs +++ b/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Ldfld.cs @@ -112,12 +112,6 @@ namespace Cosmos.IL2CPU.X86.IL default: throw new Exception("Remainder size " + xFieldInfo.FieldType.ToString() + (xSize) + " not supported!"); } -#if! SKIP_GC_CODE - if (xNeedsGC) { - new CPUx86.Push { DestinationReg = CPUx86.Registers.ESP, DestinationIsIndirect = true }; - new CPUx86.Call { DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName(GCImplementationRefs.IncRefCountRef) }; - } -#endif Assembler.Stack.Push(new StackContents.Item((int)xSize, xFieldInfo.FieldType)); } diff --git a/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Ldloc.cs b/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Ldloc.cs index 32a70d4e4..cf0fc23ad 100644 --- a/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Ldloc.cs +++ b/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Ldloc.cs @@ -52,11 +52,6 @@ namespace Cosmos.IL2CPU.X86.IL } } new CPUx86.Push { DestinationReg = CPUx86.Registers.EAX }; - if(!xVar.LocalType.IsValueType) - { - new CPUx86.Push { DestinationReg = CPUx86.Registers.EAX }; - new CPUx86.Call { DestinationLabel =MethodAndTypeLabelsHolder.GC_IncRefLabel }; - } } Assembler.Stack.Push((int)xSize, xVar.LocalType); } diff --git a/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Ldsfld.cs b/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Ldsfld.cs index 5478d5b43..947df05fa 100644 --- a/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Ldsfld.cs +++ b/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Ldsfld.cs @@ -23,7 +23,7 @@ namespace Cosmos.IL2CPU.X86.IL System.Reflection.FieldInfo xField = xOpCode.Value; // call cctor: - var xCctor = (xType.GetConstructors(BindingFlags.Static | BindingFlags.NonPublic) ?? new ConstructorInfo[0]).SingleOrDefault(); + var xCctor = (xField.DeclaringType.GetConstructors(BindingFlags.Static | BindingFlags.NonPublic) ?? new ConstructorInfo[0]).SingleOrDefault(); if (xCctor != null) { new CPUx86.Call { DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName(xCctor) }; @@ -107,14 +107,6 @@ namespace Cosmos.IL2CPU.X86.IL } Assembler.Stack.Push( new StackContents.Item( ( int )xSize, null ) ); - - if( xNeedsGC ) - { - new Dup( Assembler ).Execute( aMethod, aOpCode ); - - new CPUx86.Call { DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName( GCImplementationRefs.IncRefCountRef ) }; - Assembler.Stack.Pop(); - } } diff --git a/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Newarr.cs b/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Newarr.cs index 4ab4f716b..61772a1ca 100644 --- a/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Newarr.cs +++ b/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Newarr.cs @@ -44,11 +44,6 @@ namespace Cosmos.IL2CPU.X86.IL new CPUx86.Call { DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName( GCImplementationRefs.AllocNewObjectRef ) }; new CPUx86.Push { DestinationReg = CPUx86.Registers.ESP, DestinationIsIndirect = true }; new CPUx86.Push { DestinationReg = CPUx86.Registers.ESP, DestinationIsIndirect = true }; - new CPUx86.Push { DestinationReg = CPUx86.Registers.ESP, DestinationIsIndirect = true }; - new CPUx86.Push { DestinationReg = CPUx86.Registers.ESP, DestinationIsIndirect = true }; - - new CPUx86.Call { DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName( GCImplementationRefs.IncRefCountRef ) }; - new CPUx86.Call { DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName( GCImplementationRefs.IncRefCountRef ) }; Assembler.Stack.Push( new StackContents.Item( 4, typeof( Array ) ) ); new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX }; diff --git a/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Newobj.cs b/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Newobj.cs index 10eef902f..a7f8e042a 100644 --- a/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Newobj.cs +++ b/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Newobj.cs @@ -92,17 +92,7 @@ namespace Cosmos.IL2CPU.X86.IL new CPUx86.Call { DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName( GCImplementationRefs.AllocNewObjectRef ) }; new CPUx86.Push { DestinationReg = CPUx86.Registers.ESP, DestinationIsIndirect = true }; new CPUx86.Push { DestinationReg = CPUx86.Registers.ESP, DestinationIsIndirect = true }; - new CPUx86.Push { DestinationReg = CPUx86.Registers.ESP, DestinationIsIndirect = true }; - new CPUx86.Push { DestinationReg = CPUx86.Registers.ESP, DestinationIsIndirect = true }; - - // We IncRef here twice because it's effectively pushed on the stack twice: - // * once for the .ctor parameter - // * once for the "returnvalue" of the newobj il op - - // todo: probably we want to check for exceptions after calling IncRef - new CPUx86.Call { DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName( GCImplementationRefs.IncRefCountRef ) }; - new CPUx86.Call { DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName( GCImplementationRefs.IncRefCountRef ) }; - + uint xObjSize = 0; //int xGCFieldCount = ( from item in aCtorDeclTypeInfo.Fields.Values //where item.NeedsGC diff --git a/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Stelem_Ref.cs b/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Stelem_Ref.cs index a2a334d22..4da79765e 100644 --- a/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Stelem_Ref.cs +++ b/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Stelem_Ref.cs @@ -20,9 +20,9 @@ namespace Cosmos.IL2CPU.X86.IL { aAssembler.Stack.Pop(); aAssembler.Stack.Pop(); aAssembler.Stack.Pop(); - new CPUx86.Push { DestinationReg = CPUx86.Registers.ESP, DestinationIsIndirect = true, DestinationDisplacement = (int)(xStackSize + 4) }; + //new CPUx86.Push { DestinationReg = CPUx86.Registers.ESP, DestinationIsIndirect = true, DestinationDisplacement = (int)(xStackSize + 4) }; - new CPUx86.Call { DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName(GCImplementationRefs.DecRefCountRef) }; + //new CPUx86.Call { DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName(GCImplementationRefs.DecRefCountRef) }; new CPUx86.Move { DestinationReg = CPUx86.Registers.EBX, SourceReg = CPUx86.Registers.ESP, SourceIsIndirect = true, SourceDisplacement = (int)xStackSize }; // the index new CPUx86.Move { DestinationReg = CPUx86.Registers.ECX, SourceReg = CPUx86.Registers.ESP, SourceIsIndirect = true, SourceDisplacement = (int)xStackSize + 4 }; // the index diff --git a/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Stfld.cs b/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Stfld.cs index fd3da0e93..99f709b74 100644 --- a/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Stfld.cs +++ b/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Stfld.cs @@ -47,15 +47,6 @@ namespace Cosmos.IL2CPU.X86.IL uint xRoundedSize = Align(xSize, 4); -#if! SKIP_GC_CODE - if (aNeedsGC) { - new CPUx86.Push { DestinationReg = CPUx86.Registers.ESP, DestinationIsIndirect = true, DestinationDisplacement = 4 }; - //Ldfld(aAssembler, aType, aField, false); - new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX }; - new CPUx86.Push { DestinationReg = CPUx86.Registers.EAX, DestinationIsIndirect = true, DestinationDisplacement = (int)(xActualOffset) }; - new CPUx86.Call { DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName(GCImplementationRefs.DecRefCountRef) }; - } -#endif new CPUx86.Move { DestinationReg = CPUx86.Registers.ECX, SourceReg = CPUx86.Registers.ESP, SourceIsIndirect = true, SourceDisplacement = (int)xRoundedSize }; new CPUx86.Add { DestinationReg = CPUx86.Registers.ECX, diff --git a/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Stloc.cs b/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Stloc.cs index cfbad663d..245ff1530 100644 --- a/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Stloc.cs +++ b/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Stloc.cs @@ -20,13 +20,7 @@ namespace Cosmos.IL2CPU.X86.IL var xField = aOpCode as ILOpCodes.OpVar; var xFieldInfo = aMethod.MethodBase.GetMethodBody().LocalVariables[xField.Value]; var xEBPOffset = ((int)GetEBPOffsetForLocal(aMethod, xField)); -#if !SKIP_GC_CODE - if (!xFieldInfo.LocalType.IsValueType) - { - new CPUx86.Push { DestinationReg = CPUx86.Registers.EBP, DestinationIsIndirect = true, DestinationDisplacement =(int) 0 - xEBPOffset }; - new CPUx86.Call { DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName(GCImplementationRefs.DecRefCountRef) }; - } -#endif + new Comment("EBPOffset = " + xEBPOffset); for (int i = (int)GetStackCountForLocal(aMethod, xFieldInfo) - 1; i >= 0; i--) { diff --git a/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Stsfld.cs b/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Stsfld.cs index 44de41090..3d5a7ae32 100644 --- a/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Stsfld.cs +++ b/source2/IL2PCU/Cosmos.IL2CPU.X86/IL/Stsfld.cs @@ -50,11 +50,6 @@ namespace Cosmos.IL2CPU.X86.IL xOffset += SizeOfType( xInfo.FieldType ); } string xDataName = DataMember.GetStaticFieldName(xField); - if( xNeedsGC ) - { - new CPUx86.Push { DestinationRef = ElementReference.New( xDataName ), DestinationIsIndirect = true }; - new CPUx86.Call { DestinationLabel = MethodInfoLabelGenerator.GenerateLabelName( GCImplementationRefs.DecRefCountRef ) }; - } for( int i = 0; i < ( xSize / 4 ); i++ ) { new CPUx86.Pop { DestinationReg = CPUx86.Registers.EAX }; diff --git a/source2/IL2PCU/Cosmos.IL2CPU/GCImplementation.cs b/source2/IL2PCU/Cosmos.IL2CPU/GCImplementation.cs index 173ed658b..e5273ae5d 100644 --- a/source2/IL2PCU/Cosmos.IL2CPU/GCImplementation.cs +++ b/source2/IL2PCU/Cosmos.IL2CPU/GCImplementation.cs @@ -72,7 +72,7 @@ namespace Cosmos.IL2CPU { // WriteNumber(xCount, false); // Console.WriteLine(); //#endif - throw new NotImplementedException(); + //throw new NotImplementedException(); } @@ -136,7 +136,7 @@ namespace Cosmos.IL2CPU { //#endif //// } /// - throw new NotImplementedException(); + //throw new NotImplementedException(); } #if GC_DEBUG diff --git a/source2/Kernel/System/Cosmos.System/Console.cs b/source2/Kernel/System/Cosmos.System/Console.cs index 89936285d..26a8f3549 100644 --- a/source2/Kernel/System/Cosmos.System/Console.cs +++ b/source2/Kernel/System/Cosmos.System/Console.cs @@ -5,6 +5,10 @@ using System.Text; namespace Cosmos.System { public class Console { + public Console() + { + Cosmos.Debug.Debugger.Send("Cosmos.System..ctor()"); + } protected int mX = 0; public int X { get { return mX; } diff --git a/source2/Kernel/System/Cosmos.System/Cosmos.System.csproj b/source2/Kernel/System/Cosmos.System/Cosmos.System.csproj index 3ea0faf78..204cfbb2e 100644 --- a/source2/Kernel/System/Cosmos.System/Cosmos.System.csproj +++ b/source2/Kernel/System/Cosmos.System/Cosmos.System.csproj @@ -56,6 +56,10 @@ + + {A1F83D9F-2D44-4264-A08B-416797123018} + Cosmos.Kernel + {819DB8FC-5DA1-461F-83C9-2F5C88088C94} Cosmos.Sys diff --git a/source2/Kernel/System/Cosmos.System/Kernel.cs b/source2/Kernel/System/Cosmos.System/Kernel.cs index 80616f46c..8a0fff379 100644 --- a/source2/Kernel/System/Cosmos.System/Kernel.cs +++ b/source2/Kernel/System/Cosmos.System/Kernel.cs @@ -16,7 +16,10 @@ namespace Cosmos.System { // Start the system up using the properties for configuration. public void Start() { - if (mStarted) { + Cosmos.Debug.Debugger.Send("Starting kernel"); + if (mStarted) + { + Cosmos.Debug.Debugger.Send("ERROR: Kernel Already Started"); throw new Exception("Kernel has already been started. A kernel cannot be started twice."); } mStarted = true; @@ -25,6 +28,7 @@ namespace Cosmos.System { //Hardware.VGAScreen.SetTextMode(VGAScreen.TextSize.Size80x25); // Clear before booting + Cosmos.Debug.Debugger.Send("Clearing screen"); Global.Console.Clear(); WriteLine("Cosmos kernel boot initiated."); diff --git a/source2/Kernel/System/Hardware/Cosmos.Hardware/TextScreen.cs b/source2/Kernel/System/Hardware/Cosmos.Hardware/TextScreen.cs index 156599cff..f21abc3f1 100644 --- a/source2/Kernel/System/Hardware/Cosmos.Hardware/TextScreen.cs +++ b/source2/Kernel/System/Hardware/Cosmos.Hardware/TextScreen.cs @@ -14,6 +14,7 @@ namespace Cosmos.Hardware { protected readonly MemoryBlock08 mMemory08; public TextScreen() { + Cosmos.Debug.Debugger.Send("Cosmos.Hardware.TextScreen"); //Use Changeset 64921 //This gets called before at least one of the initializers. //1) This is a bug. diff --git a/source2/Users/Kudzu/Breakpoints/BreakpointsOS.cs b/source2/Users/Kudzu/Breakpoints/BreakpointsOS.cs index 4e0ec4c25..acfb306b0 100644 --- a/source2/Users/Kudzu/Breakpoints/BreakpointsOS.cs +++ b/source2/Users/Kudzu/Breakpoints/BreakpointsOS.cs @@ -6,6 +6,10 @@ using Sys = Cosmos.System; namespace BreakpointsKernel { public class BreakpointsOS : Sys.Kernel { + public BreakpointsOS() + { + Debugger.Send("BreakpointsKernel.BreakpointOS..ctor()"); + } protected override void BeforeRun() { Console.WriteLine("Test"); Debugger.Send("Hello from Cosmos!");