The Inbox: Kernel-mha.498.mcz

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

The Inbox: Kernel-mha.498.mcz

commits-2
A new version of Kernel was added to project The Inbox:
http://source.squeak.org/inbox/Kernel-mha.498.mcz

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

Name: Kernel-mha.498
Author: mha
Time: 21 September 2010, 1:53:02.882 pm
UUID: 9c6916b4-1b76-424e-9a7c-9837a84c01e6
Ancestors: Kernel-nice.497

attempted cleanup of CompiledMethod's closures protocol

=============== Diff against Kernel-nice.497 ===============

Item was added:
+ InstructionClient subclass: #ClosureExtractor
+ instanceVariableNames: 'action scanner'
+ classVariableNames: ''
+ poolDictionaries: ''
+ category: 'Kernel-Methods'!
+
+ !ClosureExtractor commentStamp: 'mha 9/21/2010 11:16' prior: 0!
+ A ClosureExtractor is a utility class that is used to extract all BlockClosures from a CompiledMethod. It inherits from InstructionClient and understands only one single message, namely that corresponding to the push closure bytecode instruction. Being sent this message, a ClosureExtractor will create a BlockClosure instance and evaluate the block it holds as an instance variable with that closure as parameter.!

Item was added:
+ ----- Method: ClosureExtractor classSide>>withAction:andScanner: (in category 'instance creation') -----
+ withAction: aBlock andScanner: anInstructionStream
+ "The passed block must accept one value, which will be a BlockClosure."
+ ^ self new action: aBlock; scanner: anInstructionStream!

Item was added:
+ ----- Method: ClosureExtractor>>action (in category 'accessing') -----
+ action
+ ^ action!

Item was added:
+ ----- Method: ClosureExtractor>>action: (in category 'accessing') -----
+ action: aBlock
+ action := aBlock!

Item was added:
+ ----- Method: ClosureExtractor>>pushClosureCopyNumCopiedValues:numArgs:blockSize: (in category 'instruction decoding') -----
+ pushClosureCopyNumCopiedValues: numCopied numArgs: numArgs blockSize: blockSize
+
+ "Create a BlockClosure corresponding to the closure bytecode
+ and execute the action block with it. The created BlockClosure is only a pseudo value,
+ it is not populated with meaningful context and argument information."
+
+ action value:
+ (BlockClosure
+ outerContext: (MethodContext
+ sender: thisContext
+ receiver: self
+ method: scanner method
+ arguments: (Array new: scanner method numArgs))
+ startpc: scanner pc
+ numArgs: numArgs
+ copiedValues: (Array new: numCopied))!

Item was added:
+ ----- Method: ClosureExtractor>>scanner (in category 'accessing') -----
+ scanner
+ ^ scanner!

Item was added:
+ ----- Method: ClosureExtractor>>scanner: (in category 'accessing') -----
+ scanner: anInstructionStream
+ scanner := anInstructionStream!

Item was changed:
  ----- Method: CompiledMethod>>embeddedBlockMethods (in category 'closures') -----
  embeddedBlockMethods
 
+ | bms extractor scanner |
+ bms := OrderedCollection new.
+ scanner := InstructionStream on: self.
+ extractor := ClosureExtractor withAction: [ :c | bms add: c ] andScanner: scanner.
+ [ scanner pc <= self endPC ] whileTrue: [ scanner interpretNextInstructionFor: extractor ].
+ ^ bms!
- | set |
- set := OrderedCollection new.
- 1 to: self numLiterals do: [:i |  | lit |
- lit := self literalAt: i.
- (lit isKindOf: CompiledMethod) ifTrue: [
- set add: lit.
- ] ifFalse: [(lit isKindOf: BlockClosure) ifTrue: [
- set add: lit method.
- ]].
- ].
- ^ set!

Item was removed:
- ----- Method: CompiledMethod>>isBlockMethod (in category 'closures') -----
- isBlockMethod
- "Is this a sub-method (embedded block's method) of another method. If so the last literal points to its outer method"
-
- ^ (self header bitAnd: 1 << 29) ~= 0!

Item was removed:
- ----- Method: CompiledMethod>>isBlockMethod: (in category 'closures') -----
- isBlockMethod: bool
- "Use the sign bit in the header to mark methods that are sub-methods of an outer method. The outer method will be held in my last literal."
-
- self objectAt: 1 put: (bool
- ifTrue: [self header bitOr: 1 << 29]
- ifFalse: [self header bitAnd: (1 << 29) bitInvert])!

Item was removed:
- ----- Method: CompiledMethod>>isClosureCompiled: (in category 'closures') -----
- isClosureCompiled: bool
- "Use the sign bit in the header to mark methods that have been compiled using the new closure compiler (Parser2)."
-
- self objectAt: 1 put: (bool
- ifTrue: [(self header bitOr: 1 << 30) as31BitSmallInt]
- ifFalse: [(self header bitAnd: (1 << 30) bitInvert) as31BitSmallInt])!

Item was removed:
- ----- Method: CompiledMethod>>remoteReturns (in category 'closures') -----
- remoteReturns
- "For closure methods only"
-
- ^ self messages includes: #privRemoteReturnTo:!

Item was removed:
- ----- Method: CompiledMethod>>searchImageForHomeMethod (in category 'closures') -----
- searchImageForHomeMethod
-
- SystemNavigation default allObjectsDo: [:obj |
- obj class == CompiledMethod ifTrue: [
- (obj pointsTo: self) ifTrue: [^ obj searchImageForHomeMethod]
- ] ifFalse: [obj class == BlockClosure ifTrue: [
- (obj method == self and: [obj size = 0])
- ifTrue: [^ obj searchImageForHomeMethod]
- ]]
- ].
- ^ self  "must be a loner block method"!