[squeak-dev] The Inbox: Kernel-mha.500.mcz
commits at source.squeak.org
commits at source.squeak.org
Thu Sep 23 08:33:38 UTC 2010
A new version of Kernel was added to project The Inbox:
http://source.squeak.org/inbox/Kernel-mha.500.mcz
==================== Summary ====================
Name: Kernel-mha.500
Author: mha
Time: 23 September 2010, 10:33:16.329 am
UUID: 6386ad34-1295-4277-a2a3-068faac074de
Ancestors: Kernel-mha.499, Kernel-nice.499
third attempt to clean up CompiledMethod's closures protocol:
* leaner implementation of containsBlockClosures using scanFor:
* corrected InstructionStream >> #scanFor: method comment
=============== Diff against Kernel-mha.499 ===============
Item was changed:
SystemOrganization addCategory: #'Kernel-Chronology'!
SystemOrganization addCategory: #'Kernel-Classes'!
SystemOrganization addCategory: #'Kernel-Methods'!
SystemOrganization addCategory: #'Kernel-Numbers'!
SystemOrganization addCategory: #'Kernel-Objects'!
SystemOrganization addCategory: #'Kernel-Processes'!
SystemOrganization addCategory: #'Kernel-Models'!
- SystemOrganization addCategory: #'Kernel-Tests-ClassBuilder'!
Item was removed:
- ----- Method: CompiledMethod>>allEmbeddedBlockMethods (in category 'closures') -----
- allEmbeddedBlockMethods
-
- | set |
- set := OrderedCollection new.
- 1 to: self numLiterals do: [:i | | lit |
- lit := self literalAt: i.
- (lit isKindOf: CompiledMethod) ifTrue: [
- set add: lit.
- set addAll: lit allEmbeddedBlockMethods.
- ] ifFalse: [(lit isKindOf: BlockClosure) ifTrue: [
- set add: lit method.
- set addAll: lit method allEmbeddedBlockMethods
- ]].
- ].
- ^ set!
Item was changed:
----- Method: CompiledMethod>>containsBlockClosures (in category 'closures') -----
containsBlockClosures
+ ^ self scanner scanFor: [ :bc | bc = 143 "push closure bytecode" ]!
-
- ^ self embeddedBlockMethods size > 0!
Item was added:
+ ----- Method: Float>>copySignTo: (in category 'mathematical functions') -----
+ copySignTo: aNumber
+ "Return a number with same magnitude as aNumber and same sign as self.
+ Implementation note: take care of Float negativeZero, which is considered as having a negative sign."
+
+ (self > 0 or: [(self at: 1) = 0]) ifTrue: [^ aNumber abs].
+ ^aNumber abs negated!
Item was changed:
+ ----- Method: Float>>sign (in category 'mathematical functions') -----
- ----- Method: Float>>sign (in category 'testing') -----
sign
"Answer 1 if the receiver is greater than 0, -1 if less than 0, else 0.
Handle IEEE-754 negative-zero by reporting a sign of -1"
self > 0 ifTrue: [^ 1].
(self < 0 or: [((self at: 1) bitShift: -31) = 1]) ifTrue: [^ -1].
^ 0!
Item was added:
+ ----- Method: Float>>sign: (in category 'mathematical functions') -----
+ sign: aNumber
+ "Return a Number with the same sign as aNumber and same magnitude as self.
+ Implementation is different from super to handle the special case of Float negativeZero."
+
+ (self = 0.0 and: [aNumber sign negative]) ifTrue: [^Float negativeZero].
+ ^aNumber copySignTo: self!
Item was changed:
----- Method: InstructionStream>>scanFor: (in category 'scanning') -----
scanFor: scanBlock
+ "Check all bytecode instructions with scanBlock, answer true if scanBlock answers true.
+ This can be used to, e.g., check whether a method contains 'push closure' bytecodes like this:
+ aMethod scanFor: [ :b | b = 143 ]"
- "Answer the index of the first bytecode for which scanBlock
- answers true when supplied with that bytecode."
| method end byte |
method := self method.
end := method endPC.
[pc <= end] whileTrue:
[(scanBlock value: (byte := method at: pc)) ifTrue:
[^true].
pc := self nextPc: byte].
^false!
Item was added:
+ ----- Method: Number>>copySignTo: (in category 'mathematical functions') -----
+ copySignTo: aNumber
+ "Return a number with same magnitude as aNumber and same sign as self."
+
+ ^ self positive
+ ifTrue: [aNumber abs]
+ ifFalse: [aNumber abs negated].!
Item was changed:
+ ----- Method: Number>>sign (in category 'mathematical functions') -----
- ----- Method: Number>>sign (in category 'testing') -----
sign
"Answer 1 if the receiver is greater than 0, -1 if less than 0, else 0."
self > 0 ifTrue: [^1].
self < 0 ifTrue: [^-1].
^0!
Item was changed:
+ ----- Method: Number>>sign: (in category 'mathematical functions') -----
- ----- Method: Number>>sign: (in category 'converting') -----
sign: aNumber
+ "Return a Number with the same sign as aNumber and same magnitude as self."
- "Return a Number with the same sign as aNumber"
+ ^ aNumber copySignTo: self!
- ^ aNumber positive ifTrue: [self abs] ifFalse: [self abs negated].!
More information about the Squeak-dev
mailing list
|