[squeak-dev] The Trunk: Kernel-Igor.Stasenko.341.mcz

commits at source.squeak.org commits at source.squeak.org
Tue Dec 22 21:01:18 UTC 2009

Igor Stasenko uploaded a new version of Kernel to project The Trunk:

==================== Summary ====================

Name: Kernel-Igor.Stasenko.341
Author: Igor.Stasenko
Time: 22 December 2009, 10:57:21 am
UUID: 164fdcb7-0f83-ce49-8e4d-db607a365d78
Ancestors: Kernel-ul.340

- adding support of embedding source code in trailer

=============== Diff against Kernel-ul.340 ===============

Item was changed:
  ----- Method: CompiledMethod>>getSourceFor:in: (in category 'source code management') -----
  getSourceFor: selector in: class
  	"Retrieve or reconstruct the source code for this method."
  	| trailer source |
  	trailer := self trailer.
  	trailer tempNames ifNotNil: [:namesString | 
  		"Magic sources -- decompile with temp names"
  		^ ((class decompilerClass new withTempNames: namesString)
  				decompile: selector in: class method: self)
+ 	trailer sourceCode ifNotNil: [:code | ^ code ].
  	trailer hasSourcePointer ifFalse: [
  		"No source pointer -- decompile without temp names"
  		^ (class decompilerClass new decompile: selector in: class method: self)
  	"Situation normal;  read the sourceCode from the file"
  	source := [self getSourceFromFile]
  				on: Error
  		"An error can happen here if, for example, the changes file has been truncated by an aborted download.  The present solution is to ignore the error and fall back on the decompiler.  A more thorough solution should probably trigger a systematic invalidation of all source pointers past the end of the changes file.  Consider that, as time goes on, the changes file will eventually grow large enough to cover the lost code, and then instead of falling into this error case, random source code will get returned."
  				do: [ :ex | ex return: nil].
  		ifNotNil: [
  			| sourceSelector |
  			"I think this is something to do with the traits system.  It would be ncie if someone
  			 documented this.  It looks like an egregious hack to me. eem 9/5/2009 09:04"
  			(class isAliasSelector: selector)
  				ifFalse: [ source ]
  				ifTrue: [ "Only alias selectors need this replacement"
  					 sourceSelector := Parser parserClass new parseSelector: source.
  					 sourceSelector = selector
  						ifTrue: [ source ]
  						ifFalse: [ self replace: sourceSelector with: selector in: source ] ] ]
  		ifNil: [
  			"Something really wrong -- decompile blind (no temps)"
  			 (class decompilerClass new decompile: selector in: class method: self)

Item was changed:
  ----- Method: CompiledMethodTrailer>>sourceCode: (in category 'accessing') -----
  sourceCode: aString
  	"Embed the source code into compiled method trailer, 
  	pick best compression method"
  	| temp |
  	self clear.
  	kind := #EmbeddedSourceQCompress.
+ 	data := aString asString. "add Text support in future?"
- 	data := aString.
  	self encode.
  	temp := encodedData.
  	kind := #EmbeddedSourceZip.
  	self encode.
  	encodedData size > temp size ifTrue: [
  		encodedData := temp.
  		kind := #EmbeddedSourceQCompress.
  		size := encodedData size.

Item was added:
+ ----- Method: CompiledMethod>>dropSourcePointer (in category 'source code management') -----
+ dropSourcePointer
+ 	self trailer hasSourcePointer ifTrue: [
+ 		self becomeForward: 
+ 			(self copyWithTrailerBytes: 
+ 				(CompiledMethodTrailer new sourceCode: self getSource))]
+ !

More information about the Squeak-dev mailing list