Nicolas Cellier uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-nice.377.mcz ==================== Summary ==================== Name: Kernel-nice.377 Author: nice Time: 15 January 2010, 11:15:25.577 pm UUID: 9795d8b5-764d-4087-934b-5f540004008b Ancestors: Kernel-bf.376 add #selectorsAndMethodsDo: and use it to fast up some operations This is 4x faster than class selectorsDo: [:s | class compiledMethodAt: s] =============== Diff against Kernel-bf.376 =============== Item was changed: ----- Method: Behavior>>spaceUsed (in category 'private') ----- spaceUsed "Answer a rough estimate of number of bytes used by this class and its metaclass. Does not include space used by class variables." | space | space := 0. + self methodsDo: [:method | - self selectorsDo: [:sel | | method | space := space + 16. "dict and org'n space" - method := self compiledMethodAt: sel. space := space + (method size + 6 "hdr + avg pad"). method literals do: [:lit | (lit isMemberOf: Array) ifTrue: [space := space + ((lit size + 1) * 4)]. (lit isMemberOf: Float) ifTrue: [space := space + 12]. (lit isMemberOf: ByteString) ifTrue: [space := space + (lit size + 6)]. (lit isMemberOf: LargeNegativeInteger) ifTrue: [space := space + ((lit size + 1) * 4)]. (lit isMemberOf: LargePositiveInteger) ifTrue: [space := space + ((lit size + 1) * 4)]]]. ^ space! Item was changed: ----- Method: Behavior>>selectorsAndMethodsDo: (in category 'accessing method dictionary') ----- + selectorsAndMethodsDo: selectorAndMethodBlock + "Evaluate the two argument selectorAndMethodBlock for all the selector/method pairs in my method dictionary." - selectorsAndMethodsDo: aBlock - "Evaluate selectorBlock for all the message selectors in my method dictionary." + ^ self methodDict keysAndValuesDo: selectorAndMethodBlock! - ^ self methodDict keysAndValuesDo: aBlock! Item was changed: ----- Method: Behavior>>recompileChanges (in category 'compiling') ----- recompileChanges "Compile all the methods that are in the changes file. This validates sourceCode and variable references and forces methods to use the current bytecode set" + self selectorsAndMethodsDo: + [:sel :m | m fileIndex > 1 ifTrue: - self selectorsDo: - [:sel | (self compiledMethodAt: sel) fileIndex > 1 ifTrue: [self recompile: sel from: self]]! Item was changed: ----- Method: InstructionPrinter class>>printClass: (in category 'printing') ----- printClass: class "Create a file whose name is the argument followed by '.bytes'. Store on the file the symbolic form of the compiled methods of the class." | file | file := FileStream newFileNamed: class name , '.bytes'. + class selectorsAndMethodsDo: + [:sel :m | - class selectorsDo: - [:sel | file cr; nextPutAll: sel; cr. + (self on: m) printInstructionsOn: file]. - (self on: (class compiledMethodAt: sel)) printInstructionsOn: file]. file close "InstructionPrinter printClass: Parser." ! |
Free forum by Nabble | Edit this page |