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

Minor patches -- on the way to the precise GC

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@6717 8c9fc860-2736-0410-a75d-ab315db34111
felixf 9 лет назад
Родитель
Сommit
2e2984ce9f
4 измененных файлов с 37 добавлено и 25 удалено
  1. 2 2
      source/FoxIntermediateBackend.Mod
  2. 10 8
      source/Generic.Reflection.Mod
  3. 5 1
      source/ModuleParser.Mod
  4. 20 14
      source/Win32.Objects.Mod

+ 2 - 2
source/FoxIntermediateBackend.Mod

@@ -12343,10 +12343,10 @@ TYPE
 				Symbol(section,procedureSection, procedureSection.validPAFEnter,0);
 				Info(section,"pcStatementEnd");
 				Symbol(section, procedureSection, procedureSection.validPAFExit,0);
-				Info(section,"pointer to offsets array");
-				Symbol(section, section,section.pc+1,0);
 				patchProcedurePC := section.pc;
 				Size(section, 0);
+				Info(section,"pointer to offsets array");
+				Symbol(section, section,section.pc+1,0);
 				Info(section,"offsets array");
 				procedure := procedureSection.symbol(SyntaxTree.Procedure);
 				PointerArray(section, procedure.procedureScope, numberPointers);

+ 10 - 8
source/Generic.Reflection.Mod

@@ -58,16 +58,16 @@ CONST
 	sfTypeMathTensor* = 28X;
 	sfTypeDelegate* = 29X; 
 	sfTypeENUM* = 2AX;
-	sfTypeCELL = 2BX;
-	sfTypePORT = 2CX;
+	sfTypeCELL* = 2BX;
+	sfTypePORT* = 2CX;
 	
-	sfIN = 0X;
-	sfOUT = 1X;
+	sfIN* = 0X;
+	sfOUT* = 1X;
 	
 	(* variable / parameter addressing modes *)
-	sfAbsolute = 0X; (* global vars *)
-	sfRelative = 1X; (* variables, value parameters *)
-	sfIndirect = 2X; (* var parameters *) 
+	sfAbsolute* = 0X; (* global vars *)
+	sfRelative* = 1X; (* variables, value parameters *)
+	sfIndirect* = 2X; (* var parameters *) 
 
 	sfScopeBegin* = 0F0X;
 	sfScopeEnd* = 0F1X; 
@@ -653,7 +653,7 @@ CONST
 			RETURN; 
 		END;
 		WHILE (refs[offset] = sfVariable) DO
-			IF find.minLevel <= level THEN
+			IF find.minLevel <= level+1 THEN
 				FindInVariable(refs, offset, level+1, find);
 				IF find.found THEN RETURN END;
 			ELSE
@@ -1080,3 +1080,5 @@ TYPE
 BEGIN
 	modes := " rdy run awl awc awe rip";   (* 4 characters per mode from Objects.Ready to Objects.Terminated *)
 END Reflection.
+
+

+ 5 - 1
source/ModuleParser.Mod

@@ -716,11 +716,15 @@ TYPE
 				IF symbol.token # FoxScanner.RightBrace THEN
 					LOOP
 						Check(FoxScanner.Identifier);
-						IF symbol.token = FoxScanner.LeftParenthesis THEN
+						IF (symbol.token = FoxScanner.LeftParenthesis) THEN
 							NextSymbol;
 							NEW (ignore);
 							ConstExprP	 (FoxScanner.RightParenthesis, -1, ignore);
 							Check (FoxScanner.RightParenthesis);
+						ELSIF  (symbol.token = FoxScanner.Equal) THEN
+							NextSymbol;
+							NEW (ignore);
+							ConstExprP	 (FoxScanner.RightBrace, FoxScanner.Comma, ignore);
 						END;
 						IF symbol.token # FoxScanner.Comma THEN EXIT END;
 						NextSymbol;

+ 20 - 14
source/Win32.Objects.Mod

@@ -178,7 +178,7 @@ TYPE
 			res := Kernel32.GetThreadContext( handle, state );
 
 			ASSERT ( res # 0, 1004 );
-			sp := state.SP;  bp := state.BP; pc := state.PC;
+			sp := state.SP;  bp := state.BP; pc := state.PC; curbp := 0;
 
 			(* stack garbage collection *)
 
@@ -190,7 +190,8 @@ TYPE
 					Heaps.RegisterCandidates( sp, stackBottom - sp );
 				END;
 			ELSIF Heaps.GCType = Heaps.MetaDataForStackGC THEN
-				first := TRUE; curbp := bp;
+				first := TRUE; curbp := 0;
+
 				WHILE (bp # Heaps.NilVal) & (sp <= bp) & (bp < stackBottom)  DO
 					FindPointers(bp, pc, d0, d1);
  					IF first THEN
@@ -212,6 +213,8 @@ TYPE
  							ELSE
  								SYSTEM.GET(state.SP + AddressSize, pc);		(* matching pc is at 4 bytes after stack pointer, pushed base pointer is at stack pointer position *)
 							END;
+							curbp := bp;
+							SYSTEM.GET(curbp, bp);
  						ELSE
  							(* regular case: bp and pc were synchronized *)
  							curbp := bp;
@@ -230,31 +233,29 @@ TYPE
 			END
 		END FindRoots;
 
+
+	END Process;
+
 		PROCEDURE FindPointers(bp, pc : ADDRESS; VAR diff0, diff1: SIZE);
-		(*
-		VAR procDesc: Modules.ProcedureDescPointer; startIndex, i: LONGINT; ptr : ADDRESS; success: BOOLEAN;
-		*)
+		VAR procDesc: Modules.ProcedureDescPointer; startIndex, i: LONGINT; ptr : ADDRESS;
 		BEGIN
-			(*! adapt me
 			diff0 := InitDiff; diff1 := InitDiff;
 			procDesc := Modules.FindProc(pc, Modules.procedureDescriptors);
-			IF success THEN
+			IF procDesc # NIL THEN
 				diff0 := pc - procDesc.pcFrom;
-				diff1 := pc - procDesc.pcStatementEnd;
-				IF (LEN(procDescs.offsets) > 0) & (pc >= procDesc.pcStatementBegin) & (pc <= procDescs.pcStatementEnd) THEN
-					FOR i := 0 TO procDescs.noPtr - 1 DO
-						SYSTEM.GET(bp + Modules.ptrOffsets[startIndex + i], ptr);
+				diff1 := pc - procDesc.pcLimit;
+				IF (LEN(procDesc.offsets) > 0) & (pc >= procDesc.pcValid) & (pc <= procDesc.pcEnd) THEN
+					FOR i := 0 TO LEN(procDesc.offsets) - 1 DO
+						ptr := bp + procDesc.offsets[i];
 						IF ptr # Heaps.NilVal THEN
 							Heaps.Mark(SYSTEM.VAL(ANY, ptr))
 						END
 					END
 				END
 			END
-			*)
 		END FindPointers;
 
-	END Process;
-
+TYPE
 	ExceptionHandler* = PROCEDURE(	VAR context: Kernel32.Context;
 										VAR excpRec: Kernel32.ExceptionRecord;
 										VAR handled: BOOLEAN);
@@ -1402,3 +1403,8 @@ o if process is not running, at least state.ESP is valid, and between stack.adr
 o when releasing the Ready lock, make sure the process state is up to date
 *)
 
+SystemTools.ShowStacks ~
+
+Heaps.SetMetaData 
+
+StaticLinker.Link --fileFormat=PE32 --fileName=A2GC.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 ~