Просмотр исходного кода

Added module.flags (in order to know about compilation flags at runtime, as for example metadata presence for the garbage collector)
Implemented module CRC (based on intermediate code)
CAUTION -- these changes need a bootstrapped rebuild of the system

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@7242 8c9fc860-2736-0410-a75d-ab315db34111

felixf 8 лет назад
Родитель
Сommit
6480111191
2 измененных файлов с 31 добавлено и 5 удалено
  1. 19 1
      source/FoxIntermediateBackend.Mod
  2. 12 4
      source/Generic.Modules.Mod

+ 19 - 1
source/FoxIntermediateBackend.Mod

@@ -3,7 +3,7 @@ MODULE FoxIntermediateBackend; (** AUTHOR ""; PURPOSE ""; *)
 IMPORT Basic := FoxBasic, SyntaxTree := FoxSyntaxTree, SemanticChecker := FoxSemanticChecker, Backend := FoxBackend, Global := FoxGlobal,
 	Scanner := FoxScanner, IntermediateCode := FoxIntermediateCode, Sections := FoxSections, BinaryCode := FoxBinaryCode,  Printout := FoxPrintout,
 	SYSTEM, Diagnostics, Strings, Options, Streams, Compiler, Formats := FoxFormats, SymbolFileFormat := FoxTextualSymbolFile, D := Debugging,
-	FingerPrinter := FoxFingerPrinter, StringPool;
+	FingerPrinter := FoxFingerPrinter, StringPool, CRC;
 
 CONST
 		(* operand modes *)
@@ -11104,6 +11104,7 @@ TYPE
 		TypeRecordBaseOffset: LONGINT; (* offset of type zero offset (without method entries) *)
 		
 		patchInfoPC: LONGINT;
+		patchCRC: LONGINT;
 	CONST
 		EmptyBlockOffset = 2;
 		
@@ -12815,6 +12816,7 @@ TYPE
 			exceptionSectionOffset, commandsSectionOffset, typeInfoSectionOffset, procTableSectionOffset, maxPointers, numberProcs,temp,
 			referenceSectionOffset	: LONGINT;
 			name: Basic.SegmentedName; offset: LONGINT;
+			flags: SET; 
 		BEGIN
 			NewModuleInfo();
 			pointerSection := Block("Heaps","SystemBlockDesc",".@PointerArray",pointerSectionOffset);
@@ -12887,9 +12889,14 @@ TYPE
 			Info(moduleSection,"internal: POINTER TO ARRAY OF Pointer");
 			Symbol(moduleSection, modulePointerSection, modulePointerSectionOffset, 0);
 			Info(moduleSection, "crc*: LONGINT");
+			patchCRC:= moduleSection.pc;
 			Longint(moduleSection, 0); (*!  must be implemented *)
 			Info(moduleSection, "body*: ADDRESS");
 			Symbol(moduleSection, bodyProc, 0,0);
+			Info(moduleSection, "module flags");
+			flags := {};
+			IF  implementationVisitor.backend.preciseGC THEN INCL(flags,0) END;
+			Set( moduleSection, flags);
 
 			IF implementationVisitor.backend.cooperative THEN
 				PatchSymbol(moduleSection,MonitorOffset,moduleSection.name,NIL,moduleSection.pc,0);
@@ -12905,6 +12912,12 @@ TYPE
 				Address(moduleSection,0);
 			END;
 		END Module;
+		
+		PROCEDURE PatchCRC(crc: LONGINT);
+		BEGIN
+			PatchLongint(ModuleSection(), patchCRC, crc);
+		END PatchCRC;
+		
 
 		PROCEDURE PointerArray(source: IntermediateCode.Section; scope: SyntaxTree.Scope; VAR numberPointers: LONGINT);
 		VAR variable: SyntaxTree.Variable; pc: LONGINT; symbol: Sections.Section; parameter: SyntaxTree.Parameter; parametersSize: SIZE;
@@ -13405,6 +13418,7 @@ TYPE
 			module: Sections.Module;
 			name, platformName: SyntaxTree.IdentifierString;
 			meta: MetaDataGenerator; 
+			crc: CRC.CRC32Stream;
 		BEGIN
 			ResetError;
 			Global.GetSymbolName(x,name);
@@ -13427,6 +13441,10 @@ TYPE
 			GetDescription(platformName);
 			module.SetPlatformName(platformName);
 
+			NEW(crc);
+			module.allSections.Dump(crc);
+			meta.PatchCRC(crc.GetCRC());
+			
 			RETURN module
 		END GenerateIntermediate;
 

+ 12 - 4
source/Generic.Modules.Mod

@@ -28,6 +28,9 @@ CONST
 
 	TraceBoot=FALSE;
 
+	(* flags *)
+	PreciseGC* = 0;
+
 TYPE
 	(* definitions for object-model loader support *)
 	Name* = ARRAY 32 OF CHAR;
@@ -108,14 +111,15 @@ TYPE
 			internal-: POINTER TO ARRAY OF ANY;
 			crc*: LONGINT;
 			body*: PROCEDURE;
-
+			flags*: SET;	 (* e.g. compilation flags *)
+			
 		PROCEDURE FindRoots;	(* override *)
 		VAR i: LONGINT; ptr: ANY; false: BOOLEAN;
 		VAR name: Name;
 		BEGIN
 			name := SELF.name;
 			false := FALSE; IF false THEN BEGIN{EXCLUSIVE} END END; (* trick to make a module a protected record ... *)
-			IF published THEN	(* mark global pointers *)
+			IF published THEN	(* mark global pointers *)				
 				FOR i := 0 TO LEN(ptrAdr) - 1 DO
 					SYSTEM.GET (ptrAdr[i], ptr);
 					IF ptr # NIL THEN Heaps.Mark(ptr) END
@@ -190,7 +194,7 @@ END Append;
 
 (** Add a module to the pool of accessible modules, or return named module. *)
 PROCEDURE Publish*(VAR m: Module; VAR new: BOOLEAN);
-VAR n: Module; i: LONGINT;
+VAR n: Module; i: LONGINT; name: Name;
 BEGIN
 	Machine.Acquire(Machine.Modules);
 	n := root; WHILE (n # NIL) & (n.name # m.name) DO n := n.next END;
@@ -216,7 +220,11 @@ BEGIN
 
 		new := TRUE;
 	END;
-	Machine.Release(Machine.Modules)
+	Machine.Release(Machine.Modules);
+	IF (Heaps.GCType = Heaps.MetaDataForStackGC) & ~(PreciseGC IN m.flags) THEN
+		name := m.name;
+		HALT(100);
+	END;
 END Publish;
 
 PROCEDURE Initialize*(VAR module: Module);