diff --git a/Docs/Kernel/Memory.md b/Docs/Kernel/Memory.md
index 844b3747c..89a799f3b 100644
--- a/Docs/Kernel/Memory.md
+++ b/Docs/Kernel/Memory.md
@@ -1 +1,104 @@
-On initialization of the kernel, a GlobalInformationTable is setup. This contains the address of the first DataLookupEntry
\ No newline at end of file
+# Layout
+
+```
+F..F
+
+Stack
+ Currently only one stack as we don't have threads yet. Stack resides at top of RAM and grows down.
+ In future each process will have its own stack in DATA. And Stack master section will be eliminated.
+....
+
+Data
+ -Heap
+ Global heap for all processes since compiler enforces references.
+
+Text
+ All sections are fixed in size and are stacked.
+ -Syslinux Boot Code
+ -Cosmos Boot Code
+ -Kernel
+ -Apps (Monolithic currently, will move to DATA later)
+ -Legacy GDT
+ -IDT
+ -Page Tables
+
+0..0
+```
+
+```
+MM API
+-Allocate new item
+-Add/remove ref
+-Lock/unlock an item
+-Force a compact
+
+Implicit
+-Get pointer
+
+Internal
+-Compact
+-Relocate items
+
+Properties
+-Ref count
+-Lock status
+-Size
+
+Handles
+-Use indirect pointers via a lookup table. Handle is ptr to table. Global table to save space.
+ -No way to compact tables?
+ -use linked list of tables to allow some compaction?
+ -Allocate tables to processes so they will go away 100% when process goes way since its not fully shrinkable.
+ -Keep in data space in future?
+ -Small tables increase compaction opportunities
+-Points to actual data
+-Properties are before pointer
+-In atomic ops (IL emit groups) - pointer can be grabbed and stored
+```
+
+# OLD BELOW THIS POINT
+
+On initialization of the kernel, a GlobalInformationTable is setup. This contains the address of the first DataLookupEntry
+
+# The Memory Manager
+
+The manager will init itself if there are no blocks. The manager is modeled after a double LinkedList and is not a List.
+
+# Memory Layout
+The layout does not have a preset list or table but rather every item has meta data linking the next and previous item. This allows for a robust system.
+
+The data layout is as follows:
+
+````
+Block|Block|Block etc.
+
+Block =
+
+Meta Data|Data
+
+Meta data =
+4 bytes (preveus block address start)|4 bytes (next block address start)|4 bytes (curent[this] block size)| 4 bytes (curent[this] block flag)
+```
+BlockFlags :
+
+```
+Allocated = 0,
+Free = 1,
+```
+
+the final layout looks like this:
+
+```
+4 bytes|4 bytes|4 bytes|4 bytes | (size of Block) bytes | 4 bytes|4 bytes|4 bytes | 4 bytes | (size of Block) bytes | etc
+
+```
+Note:
+this means the smallest size an Block can occupy is 17 bytes, 16 bytes for the header and 1 for the smallest data type a byte.
+
+# Usage
+
+### Allocation
+ Allocating a block happens by finding the first free block and split it (if necessary).
+
+## Deallocation
+ Freeing a block is easy set its flag (in the metadata) to free.
diff --git a/Docs/Kernel/MemoryManager.md b/Docs/Kernel/MemoryManager.md
deleted file mode 100644
index e42bca00b..000000000
--- a/Docs/Kernel/MemoryManager.md
+++ /dev/null
@@ -1,42 +0,0 @@
-# The Memory Manager
-
-The manager will init itself if there are no blocks. The manager is modeled after a double LinkedList and is not a List.
-
-# Memory Layout
-The layout does not have a preset list or table but rather every item has meta data linking the next and previous item. This allows for a robust system.
-
-The data layout is as follows:
-
-````
-Block|Block|Block etc.
-
-Block =
-
-Meta Data|Data
-
-Meta data =
-4 bytes (preveus block address start)|4 bytes (next block address start)|4 bytes (curent[this] block size)| 4 bytes (curent[this] block flag)
-```
-BlockFlags :
-
-```
-Allocated = 0,
-Free = 1,
-```
-
-the final layout looks like this:
-
-```
-4 bytes|4 bytes|4 bytes|4 bytes | (size of Block) bytes | 4 bytes|4 bytes|4 bytes | 4 bytes | (size of Block) bytes | etc
-
-```
-Note:
-this means the smallest size an Block can occupy is 17 bytes, 16 bytes for the header and 1 for the smallest data type a byte.
-
-# Usage
-
-### Allocation
- Allocating a block happens by finding the first free block and split it (if necessary).
-
-## Deallocation
- Freeing a block is easy set its flag (in the metadata) to free.
diff --git a/Users/Matthijs/DebugCompiler/DebugCompiler.csproj b/Users/Matthijs/DebugCompiler/DebugCompiler.csproj
index 75c537ca5..7aea80881 100644
--- a/Users/Matthijs/DebugCompiler/DebugCompiler.csproj
+++ b/Users/Matthijs/DebugCompiler/DebugCompiler.csproj
@@ -14,13 +14,14 @@
512
+ {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
SAK
SAK
SAK
SAK
- x86
+ AnyCPU
true
full
false
diff --git a/source/Cosmos.Core.Memory.Test/CRAM.cs b/source/Cosmos.Core.Memory.Test/CRAM.cs
new file mode 100644
index 000000000..0fbb7e5f1
--- /dev/null
+++ b/source/Cosmos.Core.Memory.Test/CRAM.cs
@@ -0,0 +1,10 @@
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+
+namespace Cosmos.Core.Memory.Test {
+ static public class CRAM {
+ }
+}
diff --git a/source/Cosmos.Core.Memory.Test/Cosmos.Core.Memory.Test.csproj b/source/Cosmos.Core.Memory.Test/Cosmos.Core.Memory.Test.csproj
new file mode 100644
index 000000000..16647507d
--- /dev/null
+++ b/source/Cosmos.Core.Memory.Test/Cosmos.Core.Memory.Test.csproj
@@ -0,0 +1,84 @@
+
+
+
+ Debug
+ AnyCPU
+ {901EA2C4-5E9C-44E8-B6D2-3B23DEE6D61B}
+ Library
+ Properties
+ Cosmos.Core.Memory.Test
+ Cosmos.Core.Memory.Test
+ v4.5.2
+ 512
+ {3AC096D0-A1C2-E12C-1390-A8335801FDAB};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}
+ 10.0
+ $(MSBuildExtensionsPath32)\Microsoft\VisualStudio\v$(VisualStudioVersion)
+ $(ProgramFiles)\Common Files\microsoft shared\VSTT\$(VisualStudioVersion)\UITestExtensionPackages
+ False
+ UnitTest
+
+
+ true
+ full
+ false
+ bin\Debug\
+ DEBUG;TRACE
+ prompt
+ 4
+
+
+ pdbonly
+ true
+ bin\Release\
+ TRACE
+ prompt
+ 4
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ False
+
+
+ False
+
+
+ False
+
+
+ False
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/source/Cosmos.Core.Memory.Test/Properties/AssemblyInfo.cs b/source/Cosmos.Core.Memory.Test/Properties/AssemblyInfo.cs
new file mode 100644
index 000000000..2d449f074
--- /dev/null
+++ b/source/Cosmos.Core.Memory.Test/Properties/AssemblyInfo.cs
@@ -0,0 +1,36 @@
+using System.Reflection;
+using System.Runtime.CompilerServices;
+using System.Runtime.InteropServices;
+
+// General Information about an assembly is controlled through the following
+// set of attributes. Change these attribute values to modify the information
+// associated with an assembly.
+[assembly: AssemblyTitle("Cosmos.Core.Memory.Test")]
+[assembly: AssemblyDescription("")]
+[assembly: AssemblyConfiguration("")]
+[assembly: AssemblyCompany("")]
+[assembly: AssemblyProduct("Cosmos.Core.Memory.Test")]
+[assembly: AssemblyCopyright("Copyright © 2016")]
+[assembly: AssemblyTrademark("")]
+[assembly: AssemblyCulture("")]
+
+// Setting ComVisible to false makes the types in this assembly not visible
+// to COM components. If you need to access a type in this assembly from
+// COM, set the ComVisible attribute to true on that type.
+[assembly: ComVisible(false)]
+
+// The following GUID is for the ID of the typelib if this project is exposed to COM
+[assembly: Guid("901ea2c4-5e9c-44e8-b6d2-3b23dee6d61b")]
+
+// Version information for an assembly consists of the following four values:
+//
+// Major Version
+// Minor Version
+// Build Number
+// Revision
+//
+// You can specify all the values or you can default the Build and Revision Numbers
+// by using the '*' as shown below:
+// [assembly: AssemblyVersion("1.0.*")]
+[assembly: AssemblyVersion("1.0.0.0")]
+[assembly: AssemblyFileVersion("1.0.0.0")]
diff --git a/source/Cosmos.Core.Memory.Test/UnitTest1.cs b/source/Cosmos.Core.Memory.Test/UnitTest1.cs
new file mode 100644
index 000000000..1c0956971
--- /dev/null
+++ b/source/Cosmos.Core.Memory.Test/UnitTest1.cs
@@ -0,0 +1,11 @@
+using System;
+using Microsoft.VisualStudio.TestTools.UnitTesting;
+
+namespace Cosmos.Core.Memory.Test {
+ [TestClass]
+ public class UnitTest1 {
+ [TestMethod]
+ public void TestMethod1() {
+ }
+ }
+}
diff --git a/source/Cosmos.IL2CPU/IL/Stsfld.cs b/source/Cosmos.IL2CPU/IL/Stsfld.cs
index bfea84073..9ce509d81 100644
--- a/source/Cosmos.IL2CPU/IL/Stsfld.cs
+++ b/source/Cosmos.IL2CPU/IL/Stsfld.cs
@@ -23,7 +23,7 @@ namespace Cosmos.IL2CPU.X86.IL
SysReflection.FieldInfo xField = xOpCode.Value;
// call cctor:
var xCctor = (xField.DeclaringType.GetConstructors(BindingFlags.Static | BindingFlags.NonPublic) ?? new ConstructorInfo[0]).SingleOrDefault();
- if (xCctor != null)
+ if (xCctor != null && xCctor.DeclaringType != aMethod.MethodBase.DeclaringType)
{
new CPUx86.Call { DestinationLabel = LabelName.Get(xCctor) };
ILOp.EmitExceptionLogic(Assembler, aMethod, aOpCode, true, null, ".AfterCCTorExceptionCheck");
diff --git a/source/Cosmos.sln b/source/Cosmos.sln
index caaa3355f..e4dabd26f 100644
--- a/source/Cosmos.sln
+++ b/source/Cosmos.sln
@@ -249,6 +249,8 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cosmos.Compiler.Tests.Metho
EndProject
Project("{471EC4BB-E47E-4229-A789-D1F5F83B52D4}") = "Cosmos.Compiler.Tests.MethodTestsBoot", "..\Tests\Cosmos.Compiler.Tests.MethodTests\Cosmos.Compiler.Tests.MethodTestsBoot.Cosmos", "{0FEE977D-AE52-4381-B513-71C5C1982ED4}"
EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Cosmos.Core.Memory.Test", "Cosmos.Core.Memory.Test\Cosmos.Core.Memory.Test.csproj", "{901EA2C4-5E9C-44E8-B6D2-3B23DEE6D61B}"
+EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
@@ -1105,6 +1107,18 @@ Global
{0FEE977D-AE52-4381-B513-71C5C1982ED4}.Release|x64.Build.0 = Debug|x86
{0FEE977D-AE52-4381-B513-71C5C1982ED4}.Release|x86.ActiveCfg = Debug|x86
{0FEE977D-AE52-4381-B513-71C5C1982ED4}.Release|x86.Build.0 = Debug|x86
+ {901EA2C4-5E9C-44E8-B6D2-3B23DEE6D61B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {901EA2C4-5E9C-44E8-B6D2-3B23DEE6D61B}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {901EA2C4-5E9C-44E8-B6D2-3B23DEE6D61B}.Debug|x64.ActiveCfg = Debug|Any CPU
+ {901EA2C4-5E9C-44E8-B6D2-3B23DEE6D61B}.Debug|x64.Build.0 = Debug|Any CPU
+ {901EA2C4-5E9C-44E8-B6D2-3B23DEE6D61B}.Debug|x86.ActiveCfg = Debug|Any CPU
+ {901EA2C4-5E9C-44E8-B6D2-3B23DEE6D61B}.Debug|x86.Build.0 = Debug|Any CPU
+ {901EA2C4-5E9C-44E8-B6D2-3B23DEE6D61B}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {901EA2C4-5E9C-44E8-B6D2-3B23DEE6D61B}.Release|Any CPU.Build.0 = Release|Any CPU
+ {901EA2C4-5E9C-44E8-B6D2-3B23DEE6D61B}.Release|x64.ActiveCfg = Release|Any CPU
+ {901EA2C4-5E9C-44E8-B6D2-3B23DEE6D61B}.Release|x64.Build.0 = Release|Any CPU
+ {901EA2C4-5E9C-44E8-B6D2-3B23DEE6D61B}.Release|x86.ActiveCfg = Release|Any CPU
+ {901EA2C4-5E9C-44E8-B6D2-3B23DEE6D61B}.Release|x86.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
@@ -1204,5 +1218,6 @@ Global
{C1D525C4-B072-4F2F-94BF-4862E6727C4B} = {9637A680-F8E9-4925-A4E4-00045205EC04}
{FE8B9F39-7C96-4866-9A18-386735895CEE} = {F104F6BC-EF8E-4408-A786-D570D7565231}
{0FEE977D-AE52-4381-B513-71C5C1982ED4} = {F104F6BC-EF8E-4408-A786-D570D7565231}
+ {901EA2C4-5E9C-44E8-B6D2-3B23DEE6D61B} = {9637A680-F8E9-4925-A4E4-00045205EC04}
EndGlobalSection
EndGlobal