STCCompilerInterface.st
changeset 2350 16caba266df4
parent 2336 adaeb8836c48
child 2461 89458faaeeb3
equal deleted inserted replaced
2349:92c8f42e973d 2350:16caba266df4
   246 
   246 
   247         handle := ObjectFileLoader loadMethodObjectFile:moduleFileName.
   247         handle := ObjectFileLoader loadMethodObjectFile:moduleFileName.
   248         handle isNil ifTrue:[
   248         handle isNil ifTrue:[
   249             OperatingSystem removeFile:moduleFileName.
   249             OperatingSystem removeFile:moduleFileName.
   250             "catch, so that #CannotLoad processing is done"
   250             "catch, so that #CannotLoad processing is done"
   251             Parser::ParseError catch:[
   251             Parser parseErrorSignal catch:[
   252                 originator parseError:'dynamic load of machine code failed' position:1.
   252                 originator parseError:'dynamic load of machine code failed' position:1.
   253             ].
   253             ].
   254             ^ #CannotLoad
   254             ^ #CannotLoad
   255         ].
   255         ].
   256 
   256 
   287 
   287 
   288                 "/ kludge-sigh: must send change messages manually here (stc-loaded code does not do it)
   288                 "/ kludge-sigh: must send change messages manually here (stc-loaded code does not do it)
   289                 "/ see addMethod:... in ClassDescription
   289                 "/ see addMethod:... in ClassDescription
   290                 classToCompileFor changed:#methodDictionary with:(Array with:selector with:oldMethod).
   290                 classToCompileFor changed:#methodDictionary with:(Array with:selector with:oldMethod).
   291                 Smalltalk changed:#methodInClass with:(Array with:classToCompileFor with:selector with:oldMethod).
   291                 Smalltalk changed:#methodInClass with:(Array with:classToCompileFor with:selector with:oldMethod).
       
   292             ] ifFalse:[
       
   293                 oldMethod := nil.
   292             ].
   294             ].
   293 
   295 
   294             silent ifFalse:[
   296             silent ifFalse:[
   295                 Transcript showCR:('    compiled: ', aClass name,' ',selector,' - machine code')
   297                 Transcript showCR:('    compiled: ', aClass name,' ',selector,' - machine code')
   296             ].
   298             ].
   297             ObjectMemory flushCaches.
   299             ObjectMemory flushCaches.
   298 
   300 
   299             handle method:newMethod.
   301             handle method:newMethod.
   300 
   302 
   301             "/ check for obsolete loaded objects and unload them
   303             "/ check for obsolete compiled method code and unload the
       
   304             "/ corresponding ObjectFileHandle.
       
   305             "/ The old method with its source code is usually kept in the method history.
       
   306             "/ and will be recompiled on an undo
   302 
   307 
   303             ObjectFileLoader loadedObjectHandlesDo:[:anotherHandle |
   308             ObjectFileLoader loadedObjectHandlesDo:[:anotherHandle |
   304                 anotherHandle isMethodHandle ifTrue:[
   309                 anotherHandle isMethodHandle ifTrue:[
   305                     anotherHandle method isNil ifTrue:[
   310                     anotherHandle method == oldMethod ifTrue:[
   306                         ObjectFileLoader unloadObjectFile:anotherHandle pathName.
   311                         "break association betwen old method, code and handle"
   307                         OperatingSystem removeFile:anotherHandle pathName.
   312                         anotherHandle removeConnectedObjects.
   308                     ]
   313                     ].
   309                 ]
   314                     anotherHandle isObsolete ifTrue:[
       
   315                         anotherHandle unload.
       
   316                         anotherHandle removeUnusedObjectFile.
       
   317                     ].
       
   318                 ].
   310             ].
   319             ].
   311             ^ newMethod.
   320             ^ newMethod.
   312         ].
   321         ].
   313 
   322 
   314         OperatingSystem removeFile:moduleFileName.
   323         OperatingSystem removeFile:moduleFileName.
   789 ! !
   798 ! !
   790 
   799 
   791 !STCCompilerInterface class methodsFor:'documentation'!
   800 !STCCompilerInterface class methodsFor:'documentation'!
   792 
   801 
   793 version
   802 version
   794     ^ '$Header: /cvs/stx/stx/libcomp/STCCompilerInterface.st,v 1.14 2010-03-09 23:34:28 cg Exp $'
   803     ^ '$Header: /cvs/stx/stx/libcomp/STCCompilerInterface.st,v 1.15 2010-04-16 17:36:24 stefan Exp $'
   795 !
   804 !
   796 
   805 
   797 version_CVS
   806 version_CVS
   798     ^ '$Header: /cvs/stx/stx/libcomp/STCCompilerInterface.st,v 1.14 2010-03-09 23:34:28 cg Exp $'
   807     ^ '$Header: /cvs/stx/stx/libcomp/STCCompilerInterface.st,v 1.15 2010-04-16 17:36:24 stefan Exp $'
   799 ! !
   808 ! !
   800 
   809 
   801 STCCompilerInterface initialize!
   810 STCCompilerInterface initialize!