changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent:
authorStefan Vogel <sv@exept.de>
Fri, 16 Apr 2010 19:36:24 +0200
changeset 2350 16caba266df4
parent 2349 92c8f42e973d
child 2351 4371af1faf81
changed: #compileToMachineCode:forClass:selector:inCategory:notifying:install:skipIfSame:silent: when replacing an existing method, unlink the old compiled code and unload the corresponding ObjectFileHandle.
STCCompilerInterface.st
--- a/STCCompilerInterface.st	Fri Apr 16 19:34:38 2010 +0200
+++ b/STCCompilerInterface.st	Fri Apr 16 19:36:24 2010 +0200
@@ -248,7 +248,7 @@
         handle isNil ifTrue:[
             OperatingSystem removeFile:moduleFileName.
             "catch, so that #CannotLoad processing is done"
-            Parser::ParseError catch:[
+            Parser parseErrorSignal catch:[
                 originator parseError:'dynamic load of machine code failed' position:1.
             ].
             ^ #CannotLoad
@@ -289,6 +289,8 @@
                 "/ see addMethod:... in ClassDescription
                 classToCompileFor changed:#methodDictionary with:(Array with:selector with:oldMethod).
                 Smalltalk changed:#methodInClass with:(Array with:classToCompileFor with:selector with:oldMethod).
+            ] ifFalse:[
+                oldMethod := nil.
             ].
 
             silent ifFalse:[
@@ -298,15 +300,22 @@
 
             handle method:newMethod.
 
-            "/ check for obsolete loaded objects and unload them
+            "/ check for obsolete compiled method code and unload the
+            "/ corresponding ObjectFileHandle.
+            "/ The old method with its source code is usually kept in the method history.
+            "/ and will be recompiled on an undo
 
             ObjectFileLoader loadedObjectHandlesDo:[:anotherHandle |
                 anotherHandle isMethodHandle ifTrue:[
-                    anotherHandle method isNil ifTrue:[
-                        ObjectFileLoader unloadObjectFile:anotherHandle pathName.
-                        OperatingSystem removeFile:anotherHandle pathName.
-                    ]
-                ]
+                    anotherHandle method == oldMethod ifTrue:[
+                        "break association betwen old method, code and handle"
+                        anotherHandle removeConnectedObjects.
+                    ].
+                    anotherHandle isObsolete ifTrue:[
+                        anotherHandle unload.
+                        anotherHandle removeUnusedObjectFile.
+                    ].
+                ].
             ].
             ^ newMethod.
         ].
@@ -791,11 +800,11 @@
 !STCCompilerInterface class methodsFor:'documentation'!
 
 version
-    ^ '$Header: /cvs/stx/stx/libcomp/STCCompilerInterface.st,v 1.14 2010-03-09 23:34:28 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/STCCompilerInterface.st,v 1.15 2010-04-16 17:36:24 stefan Exp $'
 !
 
 version_CVS
-    ^ '$Header: /cvs/stx/stx/libcomp/STCCompilerInterface.st,v 1.14 2010-03-09 23:34:28 cg Exp $'
+    ^ '$Header: /cvs/stx/stx/libcomp/STCCompilerInterface.st,v 1.15 2010-04-16 17:36:24 stefan Exp $'
 ! !
 
 STCCompilerInterface initialize!