The Trunk: Kernel-ul.1010.mcz

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

The Trunk: Kernel-ul.1010.mcz

commits-2
Levente Uzonyi uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-ul.1010.mcz

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

Name: Kernel-ul.1010
Author: ul
Time: 2 April 2016, 8:59:33.195843 pm
UUID: b583a3a1-3df9-468c-8c26-2388bd519d52
Ancestors: Kernel-mt.1009

Behavior changes:
- when #flushCache is sent to a selector, then there's no need to send it to the corresponding method too.

SmallInteger changes:
- #decimalDigitLength shouldn't perform LargeInteger comparisons on 32-bit VMs
- do fewer computations in #printOn:base:length:padded:
- removed #destinationBuffer: which has no sender

=============== Diff against Kernel-mt.1009 ===============

Item was changed:
  ----- Method: Behavior>>basicAddSelector:withMethod: (in category 'adding/removing methods') -----
  basicAddSelector: selector withMethod: compiledMethod
  "Add the message selector with the corresponding compiled method to the
  receiver's method dictionary.
  Do this without sending system change notifications"
 
- | oldMethodOrNil |
- oldMethodOrNil := self lookupSelector: selector.
  self methodDict at: selector put: compiledMethod.
+ compiledMethod
+ methodClass: self;
+ selector: selector.
- compiledMethod methodClass: self.
- compiledMethod selector: selector.
 
+ "Now flush Squeak's method cache for this selector"
+ selector flushCache!
- "Now flush Squeak's method cache, either by selector or by method"
- oldMethodOrNil == nil ifFalse: [oldMethodOrNil flushCache].
- selector flushCache.!

Item was changed:
  ----- Method: Behavior>>basicRemoveSelector: (in category 'adding/removing methods') -----
  basicRemoveSelector: selector
  "Assuming that the argument, selector (a Symbol), is a message selector
  in my method dictionary, remove it and its method. Returns the old method
  if found, nil otherwise."
 
  | oldMethod |
  oldMethod := self methodDict at: selector ifAbsent: [^ nil].
  self methodDict removeKey: selector.
 
+ "Now flush Squeak's method cache for this selector"
- "Now flush Squeak's method cache, either by selector or by method"
- oldMethod flushCache.
  selector flushCache.
  ^oldMethod!

Item was changed:
  ----- Method: SmallInteger>>decimalDigitLength (in category 'printing') -----
  decimalDigitLength
  "Answer the number of digits printed out in base 10.
+ Note that this only works for positive SmallIntegers up to 63-bits."
- Note that this only works for positive SmallIntegers up to 64-bits."
 
+ self <= 99999999 "8" ifTrue: [
+ self <= 9999 "4" ifTrue: [
+ self <= 99 "2" ifTrue: [
+ self <= 9 "1" ifTrue: [ ^1].
+ ^2 ].
+ self <= 999 "3" ifTrue: [ ^3].
+ ^4 ].
+ self <= 999999 "6" ifTrue: [
+ self <= 99999 "5" ifTrue: [ ^5 ].
- self < 10000 ifTrue: [
- self < 100 ifTrue: [
- self < 10 ifTrue: [ ^1].
- ^2 ].
- self < 1000 ifTrue: [ ^3 ].
- ^4 ].
- self < 100000000 ifTrue: [
- self < 1000000 ifTrue: [
- self < 100000 ifTrue: [ ^5].
  ^6 ].
+ self <= 9999999 "7" ifTrue: [ ^7 ].
- self < 10000000 ifTrue: [ ^7 ].
  ^8 ].
+ self <= 1073741823 "10" ifTrue: [ "This is here only to avoid LargeInteger comparisons in 32-bit VMs"
+ self <= 999999999 "9" ifTrue: [ ^9 ].
+ ^10 ].
+ self <= 999999999999999 "15" ifTrue: [
+ self <= 9999999999999 "13" ifTrue: [
+ self <= 99999999999 "11" ifTrue: [
+ self <= 9999999999 "10" ifTrue: [ ^10 ].
+ ^11 ].
+ self <= 999999999999 "12" ifTrue: [ ^12 ].
+ ^13 ].
+ self <= 99999999999999 "14" ifTrue: [ ^14 ].
+ ^15 ].
+ self <= 99999999999999999 "17" ifTrue: [
+ self <= 9999999999999999 "16" ifTrue: [ ^16 ].
+ ^17 ].
+ self <= 999999999999999999 "18" ifTrue: [ ^18 ].
+ ^19 "(1 << 60 - 1) asString size"!
- self < 1000000000000 ifTrue: [
- self < 10000000000 ifTrue: [
- self < 1000000000 ifTrue: [ ^9 ].
- ^10 ].
- self < 100000000000 ifTrue: [ ^11 ].
- ^12 ].
- self < 10000000000000000 ifTrue: [
- self < 100000000000000 ifTrue: [
- self < 10000000000000 ifTrue: [ ^13 ].
- ^14 ].
- self < 1000000000000000 ifTrue: [ ^15 ].
- ^16 ].
- self < 1000000000000000000 ifTrue: [
- self < 100000000000000000 ifTrue: [ ^17 ].
- ^18 ].
- self < 10000000000000000000 ifTrue: [ ^19 ].
- ^20!

Item was removed:
- ----- Method: SmallInteger>>destinationBuffer: (in category 'printing') -----
- destinationBuffer:digitLength
-   ^ LargePositiveInteger new: digitLength.!

Item was changed:
  ----- Method: SmallInteger>>printOn:base:length:padded: (in category 'printing') -----
  printOn: stream base: base length: minimumLength padded: padWithZeroes
 
  | n numberOfDigits totalLength divisor |
  self < 0
  ifTrue: [
  n := self negated.
  totalLength := 1 ]
  ifFalse: [
  n := self.
  totalLength := 0 ].
  numberOfDigits := n numberOfDigitsInBase: base.
  totalLength := totalLength + numberOfDigits.
  padWithZeroes ifFalse: [
  [ totalLength < minimumLength ] whileTrue: [
  stream space.
  totalLength := totalLength + 1 ] ].
  self < 0 ifTrue: [ stream nextPut: $- ].
  padWithZeroes ifTrue: [
  [ totalLength < minimumLength ] whileTrue: [
  stream nextPut: $0.
  totalLength := totalLength + 1 ] ].
+ numberOfDigits > 1 ifTrue: [
+ divisor := base = 10
+ ifTrue: [ #(1 10 100 1000 10000 100000 1000000 10000000 100000000 1000000000 10000000000 100000000000 1000000000000 10000000000000 100000000000000 1000000000000000 10000000000000000 100000000000000000 1000000000000000000) at: numberOfDigits ]
+ ifFalse: [ base raisedToInteger: numberOfDigits - 1 ].
+ [ divisor > 1 ] whileTrue: [
+ | digit |
+ digit := n // divisor.
+ stream nextPut: ('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' at: digit + 1).
+ n := n - (digit * divisor).
+ divisor := divisor // base ] ].
+ ^stream nextPut: ('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' at: n + 1)!
- divisor := base = 10
- ifTrue: [ #(1 10 100 1000 10000 100000 1000000 10000000 100000000 1000000000 10000000000 100000000000 1000000000000 10000000000000 100000000000000 1000000000000000 10000000000000000 100000000000000000 1000000000000000000) at: numberOfDigits ]
- ifFalse: [ base raisedToInteger: numberOfDigits - 1 ].
- [ divisor > 0 ] whileTrue: [
- | digit |
- digit := n // divisor.
- stream nextPut: ('0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' at: digit + 1).
- n := n - (digit * divisor).
- divisor := divisor // base ]!