method loading
authorClaus Gittinger <cg@exept.de>
Wed, 06 Dec 1995 13:42:24 +0100
changeset 156 2bf6dc265509
parent 155 1884c71a2507
child 157 d7f68808a258
method loading
BCompiler.st
ByteCodeCompiler.st
ObjFLoader.st
ObjectFileLoader.st
--- a/BCompiler.st	Wed Dec 06 11:50:20 1995 +0100
+++ b/BCompiler.st	Wed Dec 06 13:42:24 1995 +0100
@@ -1594,7 +1594,7 @@
 
     |stFileName stream handle address flags command oFileName soFileName 
      initName newMethod ok status className sep class stcPath 
-     errorStream errorMessages eMsg|
+     errorStream errorMessages eMsg m|
 
     ObjectFileLoader isNil ifTrue:[^ #Error].
     STCCompilation == #never ifTrue:[^ #Error].
@@ -1775,20 +1775,24 @@
 
 "/    ('init at ' , address printString) printNL.
 
-    ObjectFileLoader 
+    m := ObjectFileLoader 
 	callInitFunctionAt:address 
 	specialInit:true
 	forceOld:true 
 	interruptable:false
 	argument:2
 	identifyAs:handle
-	returnsObject:false.
+	returnsObject:true.
 
     "
      did it work ?
     "
     newMethod := aClass compiledMethodAt:selector.
     newMethod notNil ifTrue:[
+	m ~~ newMethod ifTrue:[
+	    'BCOMPILER: oops - loaded method installed itself elsewhere' errorPrintNL.
+	].
+
 	newMethod source:aString.
 	aClass updateRevisionString.
 	aClass addChangeRecordForMethod:newMethod.
@@ -1856,7 +1860,7 @@
     "
 
     "Modified: 14.9.1995 / 22:33:04 / claus"
-    "Modified: 29.10.1995 / 19:58:56 / cg"
+    "Modified: 6.12.1995 / 13:16:17 / cg"
 !
 
 trappingStubMethodFor:aString inCategory:cat
@@ -1886,5 +1890,5 @@
 !ByteCodeCompiler class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libcomp/Attic/BCompiler.st,v 1.51 1995-12-06 10:49:57 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/Attic/BCompiler.st,v 1.52 1995-12-06 12:41:56 cg Exp $'
 ! !
--- a/ByteCodeCompiler.st	Wed Dec 06 11:50:20 1995 +0100
+++ b/ByteCodeCompiler.st	Wed Dec 06 13:42:24 1995 +0100
@@ -1594,7 +1594,7 @@
 
     |stFileName stream handle address flags command oFileName soFileName 
      initName newMethod ok status className sep class stcPath 
-     errorStream errorMessages eMsg|
+     errorStream errorMessages eMsg m|
 
     ObjectFileLoader isNil ifTrue:[^ #Error].
     STCCompilation == #never ifTrue:[^ #Error].
@@ -1775,20 +1775,24 @@
 
 "/    ('init at ' , address printString) printNL.
 
-    ObjectFileLoader 
+    m := ObjectFileLoader 
 	callInitFunctionAt:address 
 	specialInit:true
 	forceOld:true 
 	interruptable:false
 	argument:2
 	identifyAs:handle
-	returnsObject:false.
+	returnsObject:true.
 
     "
      did it work ?
     "
     newMethod := aClass compiledMethodAt:selector.
     newMethod notNil ifTrue:[
+	m ~~ newMethod ifTrue:[
+	    'BCOMPILER: oops - loaded method installed itself elsewhere' errorPrintNL.
+	].
+
 	newMethod source:aString.
 	aClass updateRevisionString.
 	aClass addChangeRecordForMethod:newMethod.
@@ -1856,7 +1860,7 @@
     "
 
     "Modified: 14.9.1995 / 22:33:04 / claus"
-    "Modified: 29.10.1995 / 19:58:56 / cg"
+    "Modified: 6.12.1995 / 13:16:17 / cg"
 !
 
 trappingStubMethodFor:aString inCategory:cat
@@ -1886,5 +1890,5 @@
 !ByteCodeCompiler class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libcomp/ByteCodeCompiler.st,v 1.51 1995-12-06 10:49:57 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/ByteCodeCompiler.st,v 1.52 1995-12-06 12:41:56 cg Exp $'
 ! !
--- a/ObjFLoader.st	Wed Dec 06 11:50:20 1995 +0100
+++ b/ObjFLoader.st	Wed Dec 06 13:42:24 1995 +0100
@@ -828,16 +828,16 @@
 loadMethodObjectFile:aFileName
     "load an object file (.o-file) for a single method into the image; 
      This does a slightly different initialization.
-     Return false on error, true if ok."
-
-    |handle initAddr initName idx|
+     Return the loaded method; nil on error"
+
+    |handle initAddr initName idx m|
 
     "
      load the objectfile
     "
     handle := self loadDynamicObject:aFileName.
     handle isNil ifTrue:[
-	^ false
+	^ nil
     ].
 
     initName := aFileName asString.
@@ -861,26 +861,27 @@
 	    ].
 
 	    self unloadDynamicObject:handle.
-	    ^ false
+	    ^ nil
 	]
     ].
 
-    self
+    m := self
 	callInitFunctionAt:initAddr 
 	specialInit:true
 	forceOld:true 
 	interruptable:false
 	argument:2
 	identifyAs:handle
-	returnsObject:false.
-
-    ^ true
+	returnsObject:true.
+
+    ^ m
 
     "Created: 5.12.1995 / 20:59:46 / cg"
+    "Modified: 6.12.1995 / 13:13:44 / cg"
 !
 
 reloadAllRememberedObjectFiles
-    |oldDummyMethod where|
+    |oldDummyMethod where m|
 
     PreviouslyLoadedObjects notNil ifTrue:[
 	PreviouslyLoadedObjects keysAndValuesDo:[:fileName :handle |
@@ -890,10 +891,18 @@
 	    ] ifFalse:[
 		handle isMethodHandle ifTrue:[
 		    oldDummyMethod := handle method.
-		    where := oldDummyMethod who.
-		    self loadMethodObjectFile:fileName.
-		    where notNil ifTrue:[
-			((where at:1) compiledMethodAt:(where at:2)) source:(oldDummyMethod source)
+		    oldDummyMethod isNil ifTrue:[
+			('OBJFLOADER: ignore obsolete (already collected) method in ' , fileName) infoPrintNL
+		    ] ifFalse:[
+			where := oldDummyMethod who.
+			m := self loadMethodObjectFile:fileName.
+			where notNil ifTrue:[
+			    m == ((where at:1) compiledMethodAt:(where at:2)) ifFalse:[
+				'OBJFLOADER: oops - loaded method installed wrong' errorPrintNL.
+			    ].
+			    handle method:m.
+			    m source:(oldDummyMethod source)
+			]
 		    ]
 		] ifFalse:[
 		    self halt.
@@ -902,6 +911,8 @@
 	].
 	PreviouslyLoadedObjects := nil
     ]
+
+    "Modified: 6.12.1995 / 13:23:07 / cg"
 !
 
 revalidateAllObjectFiles
@@ -2825,6 +2836,6 @@
 !ObjectFileLoader class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libcomp/Attic/ObjFLoader.st,v 1.61 1995-12-06 10:50:20 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/Attic/ObjFLoader.st,v 1.62 1995-12-06 12:42:24 cg Exp $'
 ! !
 ObjectFileLoader initialize!
--- a/ObjectFileLoader.st	Wed Dec 06 11:50:20 1995 +0100
+++ b/ObjectFileLoader.st	Wed Dec 06 13:42:24 1995 +0100
@@ -828,16 +828,16 @@
 loadMethodObjectFile:aFileName
     "load an object file (.o-file) for a single method into the image; 
      This does a slightly different initialization.
-     Return false on error, true if ok."
-
-    |handle initAddr initName idx|
+     Return the loaded method; nil on error"
+
+    |handle initAddr initName idx m|
 
     "
      load the objectfile
     "
     handle := self loadDynamicObject:aFileName.
     handle isNil ifTrue:[
-	^ false
+	^ nil
     ].
 
     initName := aFileName asString.
@@ -861,26 +861,27 @@
 	    ].
 
 	    self unloadDynamicObject:handle.
-	    ^ false
+	    ^ nil
 	]
     ].
 
-    self
+    m := self
 	callInitFunctionAt:initAddr 
 	specialInit:true
 	forceOld:true 
 	interruptable:false
 	argument:2
 	identifyAs:handle
-	returnsObject:false.
-
-    ^ true
+	returnsObject:true.
+
+    ^ m
 
     "Created: 5.12.1995 / 20:59:46 / cg"
+    "Modified: 6.12.1995 / 13:13:44 / cg"
 !
 
 reloadAllRememberedObjectFiles
-    |oldDummyMethod where|
+    |oldDummyMethod where m|
 
     PreviouslyLoadedObjects notNil ifTrue:[
 	PreviouslyLoadedObjects keysAndValuesDo:[:fileName :handle |
@@ -890,10 +891,18 @@
 	    ] ifFalse:[
 		handle isMethodHandle ifTrue:[
 		    oldDummyMethod := handle method.
-		    where := oldDummyMethod who.
-		    self loadMethodObjectFile:fileName.
-		    where notNil ifTrue:[
-			((where at:1) compiledMethodAt:(where at:2)) source:(oldDummyMethod source)
+		    oldDummyMethod isNil ifTrue:[
+			('OBJFLOADER: ignore obsolete (already collected) method in ' , fileName) infoPrintNL
+		    ] ifFalse:[
+			where := oldDummyMethod who.
+			m := self loadMethodObjectFile:fileName.
+			where notNil ifTrue:[
+			    m == ((where at:1) compiledMethodAt:(where at:2)) ifFalse:[
+				'OBJFLOADER: oops - loaded method installed wrong' errorPrintNL.
+			    ].
+			    handle method:m.
+			    m source:(oldDummyMethod source)
+			]
 		    ]
 		] ifFalse:[
 		    self halt.
@@ -902,6 +911,8 @@
 	].
 	PreviouslyLoadedObjects := nil
     ]
+
+    "Modified: 6.12.1995 / 13:23:07 / cg"
 !
 
 revalidateAllObjectFiles
@@ -2825,6 +2836,6 @@
 !ObjectFileLoader class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libcomp/ObjectFileLoader.st,v 1.61 1995-12-06 10:50:20 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/ObjectFileLoader.st,v 1.62 1995-12-06 12:42:24 cg Exp $'
 ! !
 ObjectFileLoader initialize!