Browse Source

can boot with GC on -- but GC still runs into problems (metadata corrupt, probably)

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@7460 8c9fc860-2736-0410-a75d-ab315db34111
felixf 7 years ago
parent
commit
e669c6e42f

+ 1 - 1
source/FoxCompiler.Mod

@@ -549,7 +549,7 @@ BEGIN
 	(* platform definitions hard coded for the common cases -- maybe (parts of it) should be outsourced to a file ?*)
 	(* platform definitions hard coded for the common cases -- maybe (parts of it) should be outsourced to a file ?*)
 	DoAddPlatform("Win32","-b=AMD --objectFile=Binary --symbolFile=Binary --objectFileExtension=.Obw --symbolFileExtension=.Obw");
 	DoAddPlatform("Win32","-b=AMD --objectFile=Binary --symbolFile=Binary --objectFileExtension=.Obw --symbolFileExtension=.Obw");
 	DoAddPlatform("Win32G","-b=AMD --objectFile=Generic --symbolFile=Textual --newObjectFile --mergeSections --objectFileExtension=.GofW --symbolFileExtension=.SymW --preciseGC --trackLeave --writeBarriers");
 	DoAddPlatform("Win32G","-b=AMD --objectFile=Generic --symbolFile=Textual --newObjectFile --mergeSections --objectFileExtension=.GofW --symbolFileExtension=.SymW --preciseGC --trackLeave --writeBarriers");
-	DoAddPlatform("Win64G","-b=AMD --bits=64 --objectFile=Generic --newObjectFile  --symbolFile=Textual  --objectFileExtension=.GofWw --symbolFileExtension=.SymWw --traceModule=Trace");
+	DoAddPlatform("Win64G","-b=AMD --bits=64 --objectFile=Generic --newObjectFile  --symbolFile=Textual  --objectFileExtension=.GofWw --symbolFileExtension=.SymWw --preciseGC");
 	DoAddPlatform("Win32C","-b=AMD --cooperative --objectFile=Generic --newObjectFile --traceModule=Trace --objectFileExtension=.GofCW --symbolFileExtension=.SymCW");
 	DoAddPlatform("Win32C","-b=AMD --cooperative --objectFile=Generic --newObjectFile --traceModule=Trace --objectFileExtension=.GofCW --symbolFileExtension=.SymCW");
 	DoAddPlatform("ARM","-b=ARM --objectFile=Generic --newObjectFile --metaData=simple --objectFileExtension=.Goa --symbolFileExtension=.Sya");
 	DoAddPlatform("ARM","-b=ARM --objectFile=Generic --newObjectFile --metaData=simple --objectFileExtension=.Goa --symbolFileExtension=.Sya");
 	DoAddPlatform("Minos","-b=ARM --objectFile=Minos"); 
 	DoAddPlatform("Minos","-b=ARM --objectFile=Minos"); 

+ 2 - 1
source/FoxIntermediateBackend.Mod

@@ -13088,12 +13088,13 @@ TYPE
 			Address(moduleSection,0);
 			Address(moduleSection,0);
 			Info(moduleSection, "exTable*: ExceptionTable");
 			Info(moduleSection, "exTable*: ExceptionTable");
 			Symbol(moduleSection,exceptionSection,exceptionSectionOffset,0);
 			Symbol(moduleSection,exceptionSection,exceptionSectionOffset,0);
-			IF module.system.addressType.sizeInBits = 64 THEN Longint(moduleSection, 0); END; (* padding -> alignment *)
 			Info(moduleSection,"internal: POINTER TO ARRAY OF Pointer");
 			Info(moduleSection,"internal: POINTER TO ARRAY OF Pointer");
 			Symbol(moduleSection, modulePointerSection, modulePointerSectionOffset, 0);
 			Symbol(moduleSection, modulePointerSection, modulePointerSectionOffset, 0);
 			Info(moduleSection, "crc*: LONGINT");
 			Info(moduleSection, "crc*: LONGINT");
 			patchCRC:= moduleSection.pc;
 			patchCRC:= moduleSection.pc;
 			Longint(moduleSection, 0); (*!  must be implemented *)
 			Longint(moduleSection, 0); (*!  must be implemented *)
+
+			IF module.system.addressType.sizeInBits = 64 THEN Longint(moduleSection, 0); END; (* padding *)
 			Info(moduleSection, "body*: ADDRESS");
 			Info(moduleSection, "body*: ADDRESS");
 			Symbol(moduleSection, bodyProc, 0,0);
 			Symbol(moduleSection, bodyProc, 0,0);
 			Info(moduleSection, "module flags");
 			Info(moduleSection, "module flags");

BIN
source/Oberon.System.Mod


+ 0 - 4
source/Win64.Machine.Mod

@@ -538,20 +538,16 @@ BEGIN
 		Trace.String("removing "); Trace.String(traceName); Trace.Ln;
 		Trace.String("removing "); Trace.String(traceName); Trace.Ln;
 		(*Trace.Char := LogChar;*)
 		(*Trace.Char := LogChar;*)
 		res := Kernel32.CloseHandle(hout);
 		res := Kernel32.CloseHandle(hout);
-		TRACE(res); 
 		IF res = 0 THEN
 		IF res = 0 THEN
 			res := Kernel32.GetLastError();
 			res := Kernel32.GetLastError();
 			Trace.String("could not close "); Trace.String("; res = "); Trace.Int(res,1); Trace.Ln;
 			Trace.String("could not close "); Trace.String("; res = "); Trace.Int(res,1); Trace.Ln;
 		END;
 		END;
 		res := Kernel32.DeleteFile(traceName);
 		res := Kernel32.DeleteFile(traceName);
-		TRACE(res); 
 		IF res = 0 THEN
 		IF res = 0 THEN
 			res := Kernel32.GetLastError();
 			res := Kernel32.GetLastError();
 			Trace.String("could not delete "); Trace.String(traceName); Trace.String("; res = "); Trace.Int(res,1); Trace.Ln;
 			Trace.String("could not delete "); Trace.String(traceName); Trace.String("; res = "); Trace.Int(res,1); Trace.Ln;
 		END;
 		END;
-		TRACE(res);
 	END;
 	END;
-	TRACE(traceName);
 END RemoveTraceFile;
 END RemoveTraceFile;
 
 
 PROCEDURE ToExecutablePath(CONST name: ARRAY OF CHAR; VAR fullName: ARRAY OF CHAR);
 PROCEDURE ToExecutablePath(CONST name: ARRAY OF CHAR; VAR fullName: ARRAY OF CHAR);

+ 13 - 28
source/Win64.Objects.Mod

@@ -6,7 +6,7 @@ IMPORT SYSTEM, Trace, Kernel32, Machine, Modules, Heaps;
 
 
 CONST
 CONST
 	HandleExcp = TRUE;   (* FALSE -> we asume that it is done correctly by Traps *)
 	HandleExcp = TRUE;   (* FALSE -> we asume that it is done correctly by Traps *)
-	TraceVerbose = FALSE;
+	TraceVerbose = TRUE;
 	StrongChecks = FALSE;  defaultStackSize = 0;
 	StrongChecks = FALSE;  defaultStackSize = 0;
 	TraceOpenClose = FALSE;
 	TraceOpenClose = FALSE;
 
 
@@ -135,7 +135,7 @@ TYPE
 		sseAdr: LONGINT;
 		sseAdr: LONGINT;
 		*)
 		*)
 		condition-: Condition;   (* awaited process' condition *)
 		condition-: Condition;   (* awaited process' condition *)
-		condFP-: LONGINT;   (* awaited process' condition's context *)
+		condFP-: ADDRESS;   (* awaited process' condition's context *)
 		mode-: LONGINT;   (* process state *)  (* only changed inside Objects lock ??? *)
 		mode-: LONGINT;   (* process state *)  (* only changed inside Objects lock ??? *)
 		procID-: LONGINT;   (* processor ID where running,  exported for compatibilty , useless in WinAos *)
 		procID-: LONGINT;   (* processor ID where running,  exported for compatibilty , useless in WinAos *)
 		waitingOn-: ProtectedObject;   (* obj this process is waiting on (for lock or condition) *)
 		waitingOn-: ProtectedObject;   (* obj this process is waiting on (for lock or condition) *)
@@ -163,13 +163,13 @@ TYPE
 
 
 		PROCEDURE FindRoots;   (* override, called while GC, replaces Threads.CheckStacks *)
 		PROCEDURE FindRoots;   (* override, called while GC, replaces Threads.CheckStacks *)
 		VAR sp: ADDRESS; res: Kernel32.BOOL; pc, bp: ADDRESS;
 		VAR sp: ADDRESS; res: Kernel32.BOOL; pc, bp: ADDRESS;
-			n,adr: ADDRESS; desc {UNTRACED}: Modules.ProcedureDescPointer; i: LONGINT; p {UNTRACED}: ANY;
-			context: Kernel32.Wow64Context;
+			n,adr: ADDRESS; desc {UNTRACED}: Modules.ProcedureDescPointer; p {UNTRACED}: ANY; i: SIZE;
 			a0,a1, obp, osb, osbp, opc, gbp: ADDRESS;
 			a0,a1, obp, osb, osbp, opc, gbp: ADDRESS;
 			O: ANY; ID: LONGINT;
 			O: ANY; ID: LONGINT;
 			mod {UNTRACED}: Modules.Module;
 			mod {UNTRACED}: Modules.Module;
 			proc {UNTRACED}: Modules.ProcedureDescPointer;
 			proc {UNTRACED}: Modules.ProcedureDescPointer;
 			modName: ARRAY 128 OF CHAR;
 			modName: ARRAY 128 OF CHAR;
+			mode0,mode1: LONGINT;
 		BEGIN
 		BEGIN
 			O := obj; ID := id;
 			O := obj; ID := id;
 			IF (handle = 0) OR (mode = Terminated) OR (mode < Ready) (* procedure Wrapper not yet started *)
 			IF (handle = 0) OR (mode = Terminated) OR (mode < Ready) (* procedure Wrapper not yet started *)
@@ -180,26 +180,11 @@ TYPE
 			IF CurrentProcess() = SELF THEN
 			IF CurrentProcess() = SELF THEN
 				sp := Machine.CurrentSP();  bp :=Machine.CurrentBP(); pc := Machine.CurrentPC(); 
 				sp := Machine.CurrentSP();  bp :=Machine.CurrentBP(); pc := Machine.CurrentPC(); 
 			ELSE
 			ELSE
-				IF mode # Suspended THEN
-					IF isWow64 THEN 
-						res := Kernel32.Wow64SuspendThread(handle);
-					ELSE
-						res := Kernel32.SuspendThread(handle);
-					END;
-					ASSERT(res # -1);
-				END;
-
+				res := Kernel32.SuspendThread(handle); (* can suspend a suspended thread -- no problem at all *)
 				state.ContextFlags := SYSTEM.VAL(LONGINT, Kernel32.ContextControl + Kernel32.ContextInteger);
 				state.ContextFlags := SYSTEM.VAL(LONGINT, Kernel32.ContextControl + Kernel32.ContextInteger);
 				res := Kernel32.GetThreadContext( handle, state );
 				res := Kernel32.GetThreadContext( handle, state );
-				
-				context.ContextFlags := SYSTEM.VAL(LONGINT, Kernel32.ContextControl + Kernel32.ContextInteger);
-				IF isWow64 THEN 
-					res := Kernel32.Wow64GetThreadContext( handle, context );
-				ELSE
-					res := Kernel32.GetThreadContext( handle, context );
-				END;
-				ASSERT(res # 0);
-				sp :=  context.SP; bp := context.BP; pc := context.PC;
+
+				sp :=  state.SP; bp := state.BP; pc := state.PC;
 				
 				
 				mod := Modules.ThisModuleByAdr0(pc);
 				mod := Modules.ThisModuleByAdr0(pc);
 				IF mod # NIL THEN
 				IF mod # NIL THEN
@@ -220,9 +205,9 @@ TYPE
 			(* stack garbage collection *)
 			(* stack garbage collection *)
 
 
 			IF Heaps.GCType= Heaps.HeuristicStackInspectionGC THEN
 			IF Heaps.GCType= Heaps.HeuristicStackInspectionGC THEN
-				Heaps.Candidate( context.RDI );  Heaps.Candidate( context.RSI );
-				Heaps.Candidate( context.RBX ); Heaps.Candidate( context.RDX );
-				Heaps.Candidate( context.RCX ); Heaps.Candidate( context.RAX );
+				Heaps.Candidate( state.RDI );  Heaps.Candidate( state.RSI );
+				Heaps.Candidate( state.RBX ); Heaps.Candidate( state.RDX );
+				Heaps.Candidate( state.RCX ); Heaps.Candidate( state.RAX );
 				IF (stackBottom # 0) & (sp # 0) THEN
 				IF (stackBottom # 0) & (sp # 0) THEN
 					Heaps.RegisterCandidates( sp, stackBottom - sp );
 					Heaps.RegisterCandidates( sp, stackBottom - sp );
 				END;
 				END;
@@ -232,6 +217,7 @@ TYPE
 						SYSTEM.GET(bp, n);
 						SYSTEM.GET(bp, n);
 						IF ODD(n) THEN (* procedure descriptor at bp *)
 						IF ODD(n) THEN (* procedure descriptor at bp *)
 							desc := SYSTEM.VAL(Modules.ProcedureDescPointer, n-1);
 							desc := SYSTEM.VAL(Modules.ProcedureDescPointer, n-1);
+							WriteType(desc); Trace.Ln;
 							IF desc # NIL THEN
 							IF desc # NIL THEN
 								a0 := ADDRESSOF(desc.offsets);
 								a0 := ADDRESSOF(desc.offsets);
 								a1 :=  SYSTEM.VAL(ADDRESS, desc.offsets);
 								a1 :=  SYSTEM.VAL(ADDRESS, desc.offsets);
@@ -254,7 +240,7 @@ TYPE
 				END; 
 				END; 
 			END;
 			END;
 			
 			
-			IF (CurrentProcess() # SELF) & (mode # Suspended) THEN
+			IF (CurrentProcess() # SELF) (* & (mode # Suspended) *) THEN
 				res := Kernel32.ResumeThread(handle);
 				res := Kernel32.ResumeThread(handle);
 				ASSERT(res # -1);
 				ASSERT(res # -1);
 			END;
 			END;
@@ -504,7 +490,7 @@ BEGIN (* {t # NIL & t.next = NIL & t.prev = NIL} *)
 END Put;
 END Put;
 
 
 (* starting address of user stack for current thread, called stack top in TIB.H *)
 (* starting address of user stack for current thread, called stack top in TIB.H *)
-PROCEDURE -StackBottom*( ): LONGINT;
+PROCEDURE -StackBottom*( ): ADDRESS;
 CODE {SYSTEM.i386}
 CODE {SYSTEM.i386}
 	DB	064H
 	DB	064H
 	DB	08BH
 	DB	08BH
@@ -1371,7 +1357,6 @@ BEGIN
 	
 	
 	
 	
 	(* determine whether it is WOW64 environment *)
 	(* determine whether it is WOW64 environment *)
-	TRACE(Kernel32.Wow64GetThreadContext); 
 	(*
 	(*
 	isWow64 := (Kernel32.Wow64GetThreadContext # NIL) & (Kernel32.Wow64GetThreadContext(Kernel32.GetCurrentThread(),lpContext) # 0); 
 	isWow64 := (Kernel32.Wow64GetThreadContext # NIL) & (Kernel32.Wow64GetThreadContext(Kernel32.GetCurrentThread(),lpContext) # 0); 
 	TRACE("Objects 5"); 
 	TRACE("Objects 5");