Pārlūkot izejas kodu

Simplified

git-svn-id: https://svn.inf.ethz.ch/svn/lecturers/a2/trunk@6705 8c9fc860-2736-0410-a75d-ab315db34111
felixf 9 gadi atpakaļ
vecāks
revīzija
8bd804556b

+ 0 - 2
source/Decoder.Mod

@@ -1883,8 +1883,6 @@ VAR
 		header.refSize := LEN(module.refs);
 		header.constSize := 0;
 		header.exTableLen := LEN(module.exTable);
-		header.procs := module.noProcs;
-		header.maxPtrs := module.maxPtrs;
 		header.staticTdSize := LEN(module.typeInfo);
 		header.crc := module.crc;
 		header.name := module.name;

+ 3 - 20
source/FoxIntermediateBackend.Mod

@@ -12466,9 +12466,9 @@ TYPE
 		PROCEDURE Module(bodyProc: IntermediateCode.Section);
 		VAR
 			moduleSection, pointerSection, importSection, emptyArraySection, exceptionSection, commandsSection,
-			typeInfoSection, procTableSection, ptrTableSection, referenceSection : IntermediateCode.Section;
+			typeInfoSection, procTableSection,  referenceSection : IntermediateCode.Section;
 			emptyArraySectionOffset, pointerSectionOffset, importSectionOffset, numberPointers,
-			exceptionSectionOffset, commandsSectionOffset, typeInfoSectionOffset, procTableSectionOffset, ptrTableSectionOffset, maxPointers, numberProcs,temp,
+			exceptionSectionOffset, commandsSectionOffset, typeInfoSectionOffset, procTableSectionOffset, maxPointers, numberProcs,temp,
 			referenceSectionOffset	: LONGINT;
 			name: Basic.SegmentedName; offset: LONGINT;
 		BEGIN
@@ -12487,11 +12487,6 @@ TYPE
 			referenceSection := Block("Heaps","SystemBlockDesc",".@References",referenceSectionOffset);
 			References(referenceSection);
 			procTableSection := Block("Heaps","SystemBlockDesc",".@ProcTable",procTableSectionOffset);
-			(*IF ~implementationVisitor.backend.cooperative THEN
-				ptrTableSection := Block("Heaps","SystemBlockDesc",".@PtrTable",ptrTableSectionOffset);
-			ELSE*)
-				ptrTableSection := NIL;
-			(*END;*)
 			ProcedureDescriptorArray(procTableSection, numberProcs);
 			name := "Heaps.AnyPtr";
 			offset := ToMemoryUnits(module.system,TypeRecordBaseOffset*module.system.addressSize);
@@ -12529,12 +12524,6 @@ TYPE
 			Symbol(moduleSection,importSection,emptyArraySectionOffset,0);
 			Info(moduleSection, "procTable*: ProcTable");
 			Symbol(moduleSection,procTableSection,procTableSectionOffset,0);
-			Info(moduleSection, "ptrTable*: PtrTable");
-			IF ptrTableSection # NIL THEN
-				Symbol(moduleSection,ptrTableSection,ptrTableSectionOffset,0);
-			ELSE
-				Symbol(moduleSection,emptyArraySection,emptyArraySectionOffset,0);
-			END;
 			Info(moduleSection, "data*, code*, staticTypeDescs*, refs*: Bytes");
 			Symbol(moduleSection,emptyArraySection,emptyArraySectionOffset,0);
 			Symbol(moduleSection,emptyArraySection,emptyArraySectionOffset,0);
@@ -12546,13 +12535,7 @@ TYPE
 			Address(moduleSection,0);
 			Info(moduleSection, "exTable*: ExceptionTable");
 			Symbol(moduleSection,exceptionSection,exceptionSectionOffset,0);
-			Info(moduleSection, "noProcs*: LONGINT");
-			Longint(moduleSection,numberProcs);
-			IF module.system.addressType.sizeInBits = 64 THEN Longint(moduleSection, 0); END;
-			Info(moduleSection, "firstProc*: ADDRESS");
-			Address(moduleSection,0);
-			Info(moduleSection, "maxPtrs*: LONGINT");
-			Longint(moduleSection,maxPointers);
+			IF module.system.addressType.sizeInBits = 64 THEN Longint(moduleSection, 0); END; (* padding -> alignment *)
 			Info(moduleSection,"internal: POINTER TO ARRAY OF Pointer");
 			Symbol(moduleSection, modulePointerSection, modulePointerSectionOffset, 0);
 			Info(moduleSection, "crc*: LONGINT");

+ 19 - 41
source/Generic.Modules.Mod

@@ -63,8 +63,8 @@ TYPE
 	*)
 
 	TypeDesc* = POINTER TO RECORD 
-		descSize: LONGINT;
-		sentinel: LONGINT;	(* = MPO-4 *)
+		descSize-: LONGINT;
+		sentinel-: LONGINT;	(* = MPO-4 *)
 		tag-: ADDRESS; (* pointer to static type descriptor, only used by linker and loader *)
 		flags-: SET;
 		mod- {UNTRACED}: Module;	(* hint only, because module may have been freed (at Heaps.ModOfs) *)
@@ -102,16 +102,12 @@ TYPE
 			typeInfo*: POINTER TO ARRAY OF TypeDesc;	
 			module*: POINTER TO ARRAY OF Module; (* imported modules: for reference counting *)
 			procTable*: ProcedureDescs; (* information inserted by loader, removed after use in Publish *)
-			ptrTable*: ADDRESS;  (*! legacy, can be removed *)
 			data*, code*, staticTypeDescs* (* ug *), refs*: Bytes;
 			export*: ExportDesc;
 			term*: TerminationHandler;
 			exTable*: ExceptionTable;
-			noProcs*: LONGINT;	(*! legacy, can be removed *)
-			firstProc*: ADDRESS; (*! legacy, can be removed *)
-			maxPtrs*: LONGINT; (*! legacy, can be removed *)
 			(* internal pointer array: to protect internal data structures from being GCed *)
-			internal: POINTER TO ARRAY OF ANY;
+			internal-: POINTER TO ARRAY OF ANY;
 			crc*: LONGINT;
 			body*: PROCEDURE;
 
@@ -138,13 +134,11 @@ VAR
 	extension-: ARRAY MaxObjFormats, 8 OF CHAR;
 	loader: ARRAY MaxObjFormats OF LoaderProc;
 	numLoaders: LONGINT;
-	kernelProc*: ARRAY 11 OF ADDRESS;	(** kernel call addresses for loader *)
 
 	freeRoot*: Module;	(** list of freed modules (temporary) *)
 
 	(* the following two variables are initialized by Linker *)
 	root-: Module;	(** list of modules (read-only) *)
-	initBlock: ANY;	(* placeholder - anchor for module init code (initialized by linker) *)
 	shutdown*: LONGINT;	(** None, Reboot, PowerDown *)
 	trace: BOOLEAN;
 	register: RECORD
@@ -427,13 +421,25 @@ END Initialize;
 		END;
 	END MergeProcedureDescs;
 
+	(* remove sorted procedure descriptors from sorted global array *)
 	PROCEDURE RemoveProcedureDescs*(p: ProcedureDescs);
+	VAR i,j,k: LONGINT; n: ProcedureDescs;
+	BEGIN
+		IF ~mayAllocate THEN RETURN END; 
+		NEW(n, LEN(procedureDescriptors) - LEN(p));
+		i := 0; j := 0; k := 0; 
+		WHILE i < LEN(procedureDescriptors) DO 
+			IF (j < LEN(p)) & (procedureDescriptors[i] = p[j]) THEN INC(j);
+			ELSE n[k] := procedureDescriptors[i]; INC(k);
+			END;
+			INC(i); 
+		END;
+		procedureDescriptors := n;
 	END RemoveProcedureDescs;
 
 (** Load the module if it is not already loaded. *)	(* Algorithm J. Templ, ETHZ, 1994 *)
 PROCEDURE ThisModule*(CONST name: ARRAY OF CHAR; VAR res: LONGINT; VAR msg: ARRAY OF CHAR): Module;
-TYPE Body = PROCEDURE;
-VAR m, p: Module; fileName: ARRAY 64 OF CHAR; body: Body; new: BOOLEAN; i: LONGINT;
+VAR m, p: Module; fileName: ARRAY 64 OF CHAR; i: LONGINT;
 BEGIN
 	res := Ok; msg[0] := 0X; m := ModuleByName(name);
 	IF m = NIL THEN
@@ -770,15 +776,6 @@ BEGIN
 	RETURN m.init;
 END Initialized;
 
-(** Return the specified kernel procedure address. *)
-PROCEDURE GetKernelProc*(num: LONGINT): ADDRESS;
-VAR adr: ADDRESS;
-BEGIN
-	adr := kernelProc[253-num];
-	ASSERT(adr # 0);
-	RETURN adr
-END GetKernelProc;
-
 PROCEDURE Register- (module {UNTRACED}: Module);
 BEGIN {UNCOOPERATIVE, UNCHECKED}
 	(*TRACE(module.name);*)
@@ -824,7 +821,7 @@ BEGIN
 END PublishRegisteredModules;
 
 (* procedure that will be called last in a linked kernel *)
-PROCEDURE {FINAL, NOPAF} Main;
+PROCEDURE {FINAL, NOPAF} Main-;
 BEGIN
 	(*Machine.Init;*)
 	Trace.String("publish registered modules"); Trace.Ln;
@@ -833,30 +830,11 @@ END Main;
 
 PROCEDURE Init;
 VAR
-	newArr: PROCEDURE (VAR p: ANY; elemTag: ADDRESS; numElems, numDims: SIZE; isRealtime: BOOLEAN);
-	newSys: PROCEDURE (VAR p: ANY; size: SIZE; isRealtime: BOOLEAN);
-	newRec: PROCEDURE (VAR p: ANY; tag: ADDRESS; isRealtime: BOOLEAN);
-	getProcedure: PROCEDURE(CONST m, p : ARRAY OF CHAR; argTdAdr, retTdAdr : ADDRESS; VAR entryAdr : ADDRESS);
 	s: ARRAY 4 OF CHAR;
 	module: Module;
 BEGIN
-	(* root and initBlock are initialized by the linker *)
+	(* root is initialized by the linker *)
 	shutdown := None;
-	newArr := Heaps.NewArr;
-	newSys := Heaps.NewSys;
-	newRec := Heaps.NewRec;
-	getProcedure := GetProcedure;
-	kernelProc[0] := SYSTEM.VAL (ADDRESS, newRec);	(* 253 *)
-	kernelProc[1] := SYSTEM.VAL (ADDRESS, newSys);	(* 252 *)
-	kernelProc[2] := SYSTEM.VAL (ADDRESS, newArr);	(* 251 *)
-	kernelProc[3] := 0;	(* 250 *)
-	kernelProc[4] := 0;	(* 249 *)
-	kernelProc[5] := 0;	(* 248 *)
-	kernelProc[6] := 0;	(* 247 *)
-	kernelProc[7] := 0;	(* 246 *)
-	kernelProc[8] := 0;	(* 245 *)
-	kernelProc[9] := 0;	(* 244 *)
-	kernelProc[10] := SYSTEM.VAL(ADDRESS, getProcedure);	(* 243 *)
 	numLoaders := 0;
 	freeRoot := NIL;
 	Machine.GetConfig("TraceModules", s);

+ 0 - 1
source/GenericLoader.Mod

@@ -626,7 +626,6 @@ VAR
 				module.data := arrangement.data.bytes;
 				module.code := arrangement.code.bytes;
 
-				module.firstProc := arrangement.code.firstAddress;
 				module.sb := 0 (*arrangement.data.firstAddress*); (* zero is correct ! *)
 				module.body := SYSTEM.VAL(Body, arrangement.bodyAddress);
 				

+ 1 - 1
source/Linker1.Mod

@@ -657,7 +657,7 @@ BEGIN
 	FOR i := 0 TO LEN(link)-1 DO
 		ASSERT(link[i].mod = 0);	(* only fix local things *)
 		CASE link[i].entry OF
-			243..253: FixRelative(link[i].link, Modules.GetKernelProc(m, link[i].entry))
+			243..253: HALT(100); (*FixRelative(link[i].link, Modules.GetKernelProc(m, link[i].entry))*)
 			|254: FixEntry(link[i].link, fixupCounts)	(* local procedure address *)
 			|255: FixCase(link[i].link, caseTableSize)	(* case table *)
 			ELSE res := 3406; RETURN				(* unknown fixup type *)

+ 0 - 9
source/Objects.Mod

@@ -1715,10 +1715,6 @@ END Start;
 (* Initialize module. *)
 PROCEDURE Init; (* can not use NEW *)
 VAR
-	lock: PROCEDURE (obj: ProtectedObject; exclusive: BOOLEAN);
-	unlock: PROCEDURE (obj: ProtectedObject; dummy: BOOLEAN);
-	await: PROCEDURE (cond: Condition; slink: ADDRESS; obj: ProtectedObject; flags: SET);
-	create: PROCEDURE (body: Body; priority: LONGINT; flags: SET; obj: ProtectedObject);
 	i: LONGINT;
 BEGIN
 	ProcessorHLT := NIL;
@@ -1730,11 +1726,6 @@ BEGIN
 	FOR i := 0 TO NumIRQ-1 DO processingIRQ[i] := FALSE END;
 	nextProcessID := 0; Machine.ticks := 0;
 	traceProcess := NIL;
-	lock := Lock; unlock := Unlock; await := Await; create := CreateProcess;
-	Modules.kernelProc[3] := SYSTEM.VAL (ADDRESS, create);	(* 250 *)
-	Modules.kernelProc[4] := SYSTEM.VAL (ADDRESS, await);	(* 249 *)
-	Modules.kernelProc[6] := SYSTEM.VAL (ADDRESS, lock);	(* 247 *)
-	Modules.kernelProc[7] := SYSTEM.VAL (ADDRESS, unlock);	(* 246 *)
 	terminate := Terminate;
 	trap[0] := Halt;
 	trap[1] := HaltUnbreakable;

+ 1 - 1
source/SystemTools.Mod

@@ -98,7 +98,7 @@ BEGIN
 		m := Modules.root;
 		WHILE m # NIL DO
 			context.out.String(m.name);
-			IF options.GetFlag("base") THEN context.out.String(" base="); context.out.Hex(m.firstProc,-8) END;
+			(*IF options.GetFlag("base") THEN context.out.String(" base="); context.out.Hex(m.firstProc,-8) END;*)
 			IF options.GetFlag("crc") THEN context.out.String(" crc="); context.out.Hex(m.crc,-8); context.out.String("") END;
 			m := m.next;
 			IF m # NIL THEN

+ 1 - 10
source/Unix.Objects.Mod

@@ -749,16 +749,7 @@ TYPE
 	END Convert;
 
 	PROCEDURE Init;
-	BEGIN
-		Modules.kernelProc[0] := ADDRESSOF( Heaps.NewRec );
-		Modules.kernelProc[1] := ADDRESSOF( Heaps.NewSys );
-		Modules.kernelProc[2] := ADDRESSOF( Heaps.NewArr );
-		Modules.kernelProc[3] := ADDRESSOF( CreateProcess );	(* 250 *)
-		Modules.kernelProc[4] := ADDRESSOF( Await);				(* 249 *)
-		Modules.kernelProc[6] := ADDRESSOF( Lock);				(* 247 *)
-		Modules.kernelProc[7] := ADDRESSOF( Unlock);			(* 246 *)
-		Modules.kernelProc[10] := ADDRESSOF( Modules.GetProcedure );
-		
+	BEGIN		
 		Unix.Dlsym( 0, "mtxInit",		ADDRESSOF( mtxInit ) );
 		Unix.Dlsym( 0, "mtxDestroy",	ADDRESSOF( mtxDestroy ) );
 		Unix.Dlsym( 0, "mtxLock",		ADDRESSOF( mtxLock ) );

+ 0 - 5
source/Win32.Objects.Mod

@@ -1212,11 +1212,6 @@ BEGIN
 	numberOfProcessors := Machine.NumberOfProcessors();
 	lock := Lock; unlock := Unlock; await := Await; create := CreateProcess;
 
-	Modules.kernelProc[3] := SYSTEM.VAL(LONGINT, create);   (* 250 *)
-	Modules.kernelProc[4] := SYSTEM.VAL(LONGINT, await);   (* 249 *)
-	Modules.kernelProc[6] := SYSTEM.VAL(LONGINT, lock);   (* 247 *)
-	Modules.kernelProc[7] := SYSTEM.VAL(LONGINT, unlock);   (* 246 *)
-
 	NEW(t);  NEW(fn);
 
 	Machine.Acquire(Machine.Objects);