Răsfoiți Sursa

Preparational notes fot the changes for a generational garbage collector

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@7316 8c9fc860-2736-0410-a75d-ab315db34111
felixf 7 ani în urmă
părinte
comite
da2c74b12a
3 a modificat fișierele cu 41 adăugiri și 6 ștergeri
  1. 16 4
      source/FoxIntermediateBackend.Mod
  2. 20 1
      source/Heaps.Mod
  3. 5 1
      source/Win32.Machine.Mod

+ 16 - 4
source/FoxIntermediateBackend.Mod

@@ -11211,6 +11211,7 @@ TYPE
 				BaseTypesTableOffset := -2; (* typeInfo and size field *)
 				MethodTableOffset := -TypeTags+BaseTypesTableOffset;
 				TypeRecordBaseOffset := TypeTags + 2; (* MPO, typeInfo *)
+				(* change this when Heaps.HeapBlock is modified *)
 				RecordBaseOffset := 8; 		
 			END;
 			SELF.simple := simple;
@@ -11262,25 +11263,34 @@ TYPE
 		PROCEDURE HeapBlock(CONST moduleName, typeName: ARRAY OF CHAR; section: IntermediateCode.Section; dataAdrOffset: LONGINT);
 		VAR offset: LONGINT; name: Basic.SegmentedName; symbol: SyntaxTree.Symbol;
 		BEGIN
+			(* change this when Heaps.HeapBlock is modified *)
 			INC(dataAdrOffset,6);
+			
 			Info(section,"headerAdr");
 			Address(section,0);
+			
 			Info(section,"typeDesc");
-
 			symbol := implementationVisitor.GetTypeDescriptor(moduleName,typeName, name);
 			offset := ToMemoryUnits(module.system,TypeRecordBaseOffset*module.system.addressSize);
 			NamedSymbol(section, name, symbol, 0, offset);
 
 			Info(section,"mark: LONGINT;");
 			Longint(section,-1);
-			IF module.system.addressType.sizeInBits = 64 THEN Longint(section, 0);END;
+			IF module.system.addressType.sizeInBits = 64 THEN Longint(section, 0); INC(dataAdrOffset); END;
 			
 			Info(section,"dataAdr-: ADDRESS");
 			Symbol(section,section, dataAdrOffset,0);
+			
 			Info(section,"size-: SIZE");
 			Address(section,0);
-			Info(section,"nextRealtime: HeapBlock;");
+			
+			Info(section,"nextMark: HeapBlock;");
 			Address(section,0);
+			
+(*
+			Info(section,"generation");
+			Longint(section,0);
+*)
 		END HeapBlock;
 		
 		PROCEDURE ProtectedHeapBlock(CONST moduleName, typeName: ARRAY OF CHAR; section: IntermediateCode.Section; dataAdrOffset: LONGINT);
@@ -12606,8 +12616,10 @@ TYPE
 				offset := 0;
 			ELSE
 				IF module.system.addressType.sizeInBits = 64 THEN 
+					(* change this when Heaps.HeapBlock is modified *)
 					offset := ToMemoryUnits(module.system, 18* module.system.addressSize) (* Module pointer offset -- cf. ModuleSection(), how to encode generically correct? *);
 				ELSE
+					(* change this when Heaps.HeapBlock is modified *)
 					offset := ToMemoryUnits(module.system, 22* module.system.addressSize) (* Module pointer offset -- cf. ModuleSection(), how to encode generically correct? *);
 				END;
 			END;
@@ -14510,7 +14522,7 @@ BEGIN
 END FoxIntermediateBackend.
 
 
-Compiler.Compile FoxIntermediateBackend.Mod ~
+Compiler.Compile -p=Win32G FoxIntermediateBackend.Mod ~
 
 #	Release.Build --path="/temp/obg/"  WinAosNewObjectFile ~
 #	StaticLinker.Link --fileFormat=PE32 --fileName=A2Z.exe --extension=GofW --displacement=401000H --path="/temp/obg/" Runtime Trace Kernel32 Machine Heaps Modules Objects Kernel KernelLog Streams Commands Files WinFS Clock Dates Reals Strings Diagnostics BitSets StringPool ObjectFile GenericLinker Reflection  GenericLoader  BootConsole ~

+ 20 - 1
source/Heaps.Mod

@@ -81,10 +81,12 @@ TYPE
 	HeapBlockDesc* = RECORD
 		heapBlock {FICTIVE =HeapBlockOffset}: ADDRESS; 
 		typeDesc {FICTIVE =TypeDescOffset}: POINTER {UNSAFE} TO StaticTypeDesc; 
+		(* when this is changed --> change constant in Machine too and provide changes in FoxIntermediateBackend where noted *)
 		mark: LONGINT;
 		dataAdr-: ADDRESS;
 		size-: SIZE;
 		nextMark {UNTRACED}: HeapBlock;
+		(*generation-: LONGINT;*)
 	END;
 
 	FreeBlock* = POINTER TO FreeBlockDesc;
@@ -1566,12 +1568,13 @@ BEGIN
 	Machine.GetStaticHeap(beginBlockAdr, endBlockAdr, freeBlockAdr);
 
 	(* the Type desciptor is generated by the compiler, therefore the linker does not have to patch anything any more *)
+	
 	freeBlockTag := SYSTEM.TYPECODE (FreeBlockDesc);
 	systemBlockTag := SYSTEM.TYPECODE (SystemBlockDesc);
 	recordBlockTag := SYSTEM.TYPECODE (RecordBlockDesc);
 	protRecBlockTag := SYSTEM.TYPECODE (ProtRecBlockDesc);
 	arrayBlockTag := SYSTEM.TYPECODE (ArrayBlockDesc);
-
+	
 	(* find last block in static heap *)
 	p := beginBlockAdr;
 	heapBlock := SYSTEM.VAL(HeapBlock, p + BlockHeaderSize);
@@ -1658,6 +1661,22 @@ TraceHeap:
 11.07.2008 	ug	new heap data structures and adaption to GC
 *)
 
+Co
+
+
+Compiler.Compile -p=Win32G
+Runtime.Mod Trace.Mod Generic.Win32.Kernel32.Mod Win32.Machine.Mod Heaps.Mod 
+Generic.Modules.Mod Win32.Objects.Mod Win32.Kernel.Mod KernelLog.Mod Plugins.Mod Streams.Mod Pipes.Mod 
+Commands.Mod I386.Reals.Mod Generic.Reflection.Mod TrapWriters.Mod CRC.Mod SystemVersion.Mod 
+Win32.Traps.Mod Win32.WinTrace.Mod Win32.StdIO.Mod Locks.Mod Win32.Clock.Mod Disks.Mod Files.Mod 
+Dates.Mod Strings.Mod UTF8Strings.Mod FileTrapWriter.Mod Caches.Mod DiskVolumes.Mod 
+OldDiskVolumes.Mod RAMVolumes.Mod DiskFS.Mod OldDiskFS.Mod OberonFS.Mod FATVolumes.Mod FATFiles.Mod 
+ISO9660Volumes.Mod ISO9660Files.Mod Win32.User32.Mod Win32.WinTrace.Mod Win32.ODBC.Mod 
+Win32.Shell32.Mod Win32.SQL.Mod Win32.WinFS.Mod RelativeFileSystem.Mod BitSets.Mod Diagnostics.Mod 
+StringPool.Mod ObjectFile.Mod GenericLinker.Mod GenericLoader.Mod BootConsole.Mod 
+
+~
+
 Compiler.Compile -p=Win32G --traceModule=Trace  Heaps.Mod ~
 StaticLinker.Link --fileFormat=PE32 --fileName=A2.exe --extension=GofW --displacement=401000H Runtime Trace Kernel32 Machine Heaps Modules Objects Kernel KernelLog Streams Commands FIles WinFS Clock Dates Reals Strings Diagnostics BitSets StringPool ObjectFile GenericLinker Reflection  GenericLoader  BootConsole ~
 FSTools.CloseFiles A2M.exe ~

+ 5 - 1
source/Win32.Machine.Mod

@@ -24,6 +24,7 @@ CONST
 	AddressSize = SIZEOF(ADDRESS);
 	StaticBlockSize = 32;		(* static heap block size *)
 	BlockHeaderSize = 2 * AddressSize;
+	(* change this when Heaps.HeapBlock is modified *)
 	RecordDescSize = 4 * AddressSize;  (* needs to be adapted in case Heaps.RecordBlockDesc is changed *)
 
 (** standard lock levels (in order) *)  (* also refer to Traps.Show *)
@@ -737,10 +738,14 @@ BEGIN
 	SYSTEM.PUT(beginBlockAdr,0);
 	SYSTEM.PUT(beginBlockAdr+AddressSize,0);
 	SYSTEM.PUT(beginBlockAdr+2*AddressSize,0);
+	(* change this when Heaps.HeapBlock is modified *)
 	SYSTEM.PUT(beginBlockAdr+3*AddressSize,beginBlockAdr+7*AddressSize);
 	SYSTEM.PUT(beginBlockAdr+4*AddressSize,endBlockAdr-beginBlockAdr);
 	SYSTEM.PUT(beginBlockAdr+5*AddressSize,beginBlockAdr+2*AddressSize);
 	SYSTEM.PUT(beginBlockAdr+6*AddressSize,0);
+	(*
+	SYSTEM.PUT(beginBlockAdr+7*AddressSize,0);
+	*)
 
 	memoryBlock := memBlock;
 END InitHeap;
@@ -1101,4 +1106,3 @@ BEGIN
 		Init
 	END;
 END Machine.
-