소스 검색

Made precise GC optional (for platforms that are not (yet) prepared for this)

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@6760 8c9fc860-2736-0410-a75d-ab315db34111
felixf 9 년 전
부모
커밋
2e8032c62b
2개의 변경된 파일13개의 추가작업 그리고 9개의 파일을 삭제
  1. 1 1
      source/FoxCompiler.Mod
  2. 12 8
      source/FoxIntermediateBackend.Mod

+ 1 - 1
source/FoxCompiler.Mod

@@ -559,7 +559,7 @@ BEGIN
 	NEW(platforms,8);
 	(* platform definitions hard coded for the common cases -- maybe (parts of it) should be outsourced to a file ?*)
 	AddPlatform("Win32","-b=AMD --objectFile=Binary --symbolFile=Binary --objectFileExtensions=.Obw --symbolFileExtension=.Obw");
-	AddPlatform("Win32G","-b=AMD --objectFile=Generic --symbolFile=Textual --newObjectFile --mergeSections --objectFileExtension=.GofW --symbolFileExtension=.SymW");
+	AddPlatform("Win32G","-b=AMD --objectFile=Generic --symbolFile=Textual --newObjectFile --mergeSections --objectFileExtension=.GofW --symbolFileExtension=.SymW --preciseGC");
 	AddPlatform("Minos","-b=ARM --objectFile=Generic --newObjectFile --metaData=simple --objectFileExtension=.Goa --symbolFileExtension=.Sya");
 	AddPlatform("TRM","-b=TRM --objectFile=Generic --newObjectFile --metaData=simple --objectFileExtension=.GofT --symbolFileExtension=.SymT");
 	AddPlatform("TRMI","-b=TRM --objectFile=Intermediate --newObjectFile --metaData=simple --objectFileExtension=.IroT --symbolFileExtension=.IrsT");

+ 12 - 8
source/FoxIntermediateBackend.Mod

@@ -100,7 +100,6 @@ CONST
 		Size8Flag = 10; (* size = 8 *)
 		
 		ReflectionSupport = TRUE;
-		PreciseGCSupport = TRUE;
 		(* Solution for identifying procedure descriptors on the stack and for being able to differentiate "old school" stack frames from the underlying operating system stack frames:
 			push a procedure desriptor plus one to where the BP pointer would be located. The misalignment of the procedure descriptor makes it possible to identify that it is not
 			a base pointer but a procedure descriptor. The base pointer itself is in such cases located at BP + address size.
@@ -1571,7 +1570,7 @@ TYPE
 				ELSE
 					body := NIL;
 				END;
-				IF PreciseGCSupport & (body # NIL) & (body.code = NIL) THEN
+				IF backend.preciseGC & (body # NIL) & (body.code = NIL) THEN
 					Emit(Push(-1, one)) ;
 					procedureType.SetParametersOffset(1); 
 					ASSERT(system.GenerateParameterOffsets(procedure, procedure.level > 0));
@@ -1616,7 +1615,7 @@ TYPE
 				body := NIL;
 			END;
 
-			IF backend.cooperative OR PreciseGCSupport & (body # NIL) & (body.code = NIL) THEN
+			IF backend.cooperative OR  backend.preciseGC & (body # NIL) & (body.code = NIL) THEN
 				IntermediateCode.InitImmediate(op2,addressType, ToMemoryUnits(system, system.addressSize));
 				Emit(Add(position, sp, fp, op2));
 			ELSE
@@ -9100,7 +9099,7 @@ TYPE
 				result.op := basereg;
 				parametersSize := ProcedureParametersSize(system,scope(SyntaxTree.ProcedureScope).ownerProcedure);
 				IntermediateCode.AddOffset(result.op,ToMemoryUnits(system,addressType.sizeInBits)+parametersSize);
-				IF backend.cooperative OR PreciseGCSupport THEN
+				IF backend.cooperative OR backend.preciseGC THEN
 					IntermediateCode.AddOffset(result.op,ToMemoryUnits(system,addressType.sizeInBits));
 				END;
 				(* tag must be loaded when dereferencing SELF pointer *)
@@ -9306,13 +9305,13 @@ TYPE
 			IF scope # baseScope THEN
 				(* left := [fp+8] *)
 				IntermediateCode.InitMemory(right,addressType,fp,ToMemoryUnits(system,2*addressType.sizeInBits));
-				IF backend.cooperative OR PreciseGCSupport THEN IntermediateCode.AddOffset (right, ToMemoryUnits(system,addressType.sizeInBits)) END;
+				IF backend.cooperative OR backend.preciseGC THEN IntermediateCode.AddOffset (right, ToMemoryUnits(system,addressType.sizeInBits)) END;
 				ReuseCopy(left,right);
 				ReleaseIntermediateOperand(right);
 				scope := scope.outerScope; DEC(level);
 				(* { left := [left+8] } *)
 				IntermediateCode.InitMemory(right,addressType,left,ToMemoryUnits(system,2*addressType.sizeInBits));
-				IF backend.cooperative  OR PreciseGCSupport THEN IntermediateCode.AddOffset (right, ToMemoryUnits(system,addressType.sizeInBits)) END;
+				IF backend.cooperative  OR backend.preciseGC THEN IntermediateCode.AddOffset (right, ToMemoryUnits(system,addressType.sizeInBits)) END;
 				WHILE (scope # baseScope) & (scope IS SyntaxTree.ProcedureScope) DO
 					Emit(Mov(position,left,right));
 					scope := scope.outerScope; DEC(level);
@@ -10917,7 +10916,7 @@ TYPE
 				InitVariables(scope);
 				
 				
-				IF PreciseGCSupport & (x.code = NIL) & (~procedureType.noPAF) & ~procedure.isEntry THEN
+				IF backend.preciseGC & (x.code = NIL) & (~procedureType.noPAF) & ~procedure.isEntry THEN
 					GetCodeSectionNameForSymbol(procedure, name);
 					Basic.SuffixSegmentedName (name, Basic.MakeString ("@Descriptor"));
 					IntermediateCode.InitAddress(right, addressType, name, 0, 0);
@@ -12677,7 +12676,7 @@ TYPE
 					IF scope(SyntaxTree.ProcedureScope).ownerProcedure.type(SyntaxTree.ProcedureType).isDelegate THEN 
 						parametersSize := ProcedureParametersSize(module.system,scope(SyntaxTree.ProcedureScope).ownerProcedure);
 						INC(parametersSize,ToMemoryUnits(module.system,module.system.addressSize));
-						IF PreciseGCSupport THEN
+						IF implementationVisitor.backend.preciseGC THEN
 							INC(parametersSize,ToMemoryUnits(module.system,module.system.addressSize));
 						END;
 						Symbol(source, NIL, 0, parametersSize); INC(numberPointers);
@@ -13118,6 +13117,8 @@ TYPE
 		preregisterStatic-: BOOLEAN;
 		dump-: Basic.Writer;
 		cellsAreObjects: BOOLEAN;
+		preciseGC: BOOLEAN; 
+		
 		PROCEDURE &InitIntermediateBackend*;
 		BEGIN
 			simpleMetaData := FALSE;
@@ -13217,6 +13218,7 @@ TYPE
 			options.Add('o',"optimize", Options.Flag);
 			options.Add(0X,"preregisterStatic", Options.Flag);
 			options.Add(0X,"cellsAreObjects", Options.Flag);
+			options.Add(0X,"preciseGC", Options.Flag);
 		END DefineOptions;
 
 		PROCEDURE GetOptions(options: Options.Options);
@@ -13245,6 +13247,8 @@ TYPE
 			optimize := options.GetFlag("optimize");
 			preregisterStatic := options.GetFlag("preregisterStatic");
 			cellsAreObjects := options.GetFlag("cellsAreObjects");
+			preciseGC := options.GetFlag("preciseGC");
+
 		END GetOptions;
 
 		PROCEDURE DefaultSymbolFileFormat(): Formats.SymbolFileFormat;