Bert Freudenberg uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-bf.710.mcz
==================== Summary ====================
Name: Kernel-bf.710
Author: bf
Time: 4 September 2012, 1:54:08.616 pm
UUID: 772d3014-9910-4231-bee1-36d35938014d
Ancestors: Kernel-ul.709
For printing Time, do not use Floats. E.g., '6:27:08.649' asTime was printed as '6:27:08.649000000000001 am' due to converting to floating point for printing, when the representation itself uses precise numbers (nanoseconds). This fix introduces Integer>>printOn:asFixedPoint: which might not be the best idea; if some other dialect has an existing method that does something similar we should use that selector.
=============== Diff against Kernel-ul.709 ===============
Item was added:
+ ----- Method: Integer>>printOn:asFixedPoint: (in category 'printing') -----
+ printOn: aStream asFixedPoint: base
+ "assume I am a fixedpoint decimal scaled by base"
+ "String streamContents: [:s | 1234 printOn: s asFixedPoint: 1000]"
+
+ | b n |
+ self < 0 ifTrue: [aStream nextPut: $-.
+ ^self negated printOn: aStream asFixedPoint: base].
+ b := base.
+ n := self.
+ [aStream print: n // b.
+ (n := n \\ b) = 0] whileFalse: [
+ b = base ifTrue: [aStream nextPut: $.].
+ b := b // 10].
+ !
Item was changed:
----- Method: Time>>print24:showSeconds:on: (in category 'printing') -----
print24: hr24 showSeconds: showSeconds on: aStream
"Format is 'hh:mm:ss' or 'h:mm:ss am' or, if showSeconds is false, 'hh:mm' or 'h:mm am'"
| h m s |
h := self hour. m := self minute. s := self second.
hr24
ifTrue:
[ h < 10 ifTrue: [ aStream nextPutAll: '0' ].
h printOn: aStream ]
ifFalse:
[ h > 12
ifTrue: [h - 12 printOn: aStream]
ifFalse:
[h < 1
ifTrue: [ 12 printOn: aStream ]
ifFalse: [ h printOn: aStream ]]].
aStream nextPutAll: (m < 10 ifTrue: [':0'] ifFalse: [':']).
m printOn: aStream.
showSeconds ifTrue:
[ aStream nextPutAll: (s < 10 ifTrue: [':0'] ifFalse: [':']).
self nanoSecond = 0
ifTrue: [s asInteger printOn: aStream]
+ ifFalse: [s asInteger * NanosInSecond + self nanoSecond asInteger
+ printOn: aStream asFixedPoint: NanosInSecond]].
- ifFalse: [(s + (self nanoSecond / NanosInSecond) asFloat) printOn: aStream]].
hr24 ifFalse:
[ aStream nextPutAll: (h < 12 ifTrue: [' am'] ifFalse: [' pm']) ].
!
Bert Freudenberg uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-bf.710.mcz
==================== Summary ====================
Name: Kernel-bf.710
Author: bf
Time: 4 September 2012, 1:54:08.616 pm
UUID: 772d3014-9910-4231-bee1-36d35938014d
Ancestors: Kernel-ul.709
For printing Time, do not use Floats. E.g., '6:27:08.649' asTime was printed as '6:27:08.649000000000001 am' due to converting to floating point for printing, when the representation itself uses precise numbers (nanoseconds). This fix introduces Integer>>printOn:asFixedPoint: which might not be the best idea; if some other dialect has an existing method that does something similar we should use that selector.
=============== Diff against Kernel-ul.709 ===============
Item was added:
+ ----- Method: Integer>>printOn:asFixedPoint: (in category 'printing') -----
+ printOn: aStream asFixedPoint: base
+ "assume I am a fixedpoint decimal scaled by base"
+ "String streamContents: [:s | 1234 printOn: s asFixedPoint: 1000]"
+
+ | b n |
+ self < 0 ifTrue: [aStream nextPut: $-.
+ ^self negated printOn: aStream asFixedPoint: base].
+ b := base.
+ n := self.
+ [aStream print: n // b.
+ (n := n \\ b) = 0] whileFalse: [
+ b = base ifTrue: [aStream nextPut: $.].
+ b := b // 10].
+ !
Item was changed:
----- Method: Time>>print24:showSeconds:on: (in category 'printing') -----
print24: hr24 showSeconds: showSeconds on: aStream
"Format is 'hh:mm:ss' or 'h:mm:ss am' or, if showSeconds is false, 'hh:mm' or 'h:mm am'"
| h m s |
h := self hour. m := self minute. s := self second.
hr24
ifTrue:
[ h < 10 ifTrue: [ aStream nextPutAll: '0' ].
h printOn: aStream ]
ifFalse:
[ h > 12
ifTrue: [h - 12 printOn: aStream]
ifFalse:
[h < 1
ifTrue: [ 12 printOn: aStream ]
ifFalse: [ h printOn: aStream ]]].
aStream nextPutAll: (m < 10 ifTrue: [':0'] ifFalse: [':']).
m printOn: aStream.
showSeconds ifTrue:
[ aStream nextPutAll: (s < 10 ifTrue: [':0'] ifFalse: [':']).
self nanoSecond = 0
ifTrue: [s asInteger printOn: aStream]
+ ifFalse: [s asInteger * NanosInSecond + self nanoSecond asInteger
+ printOn: aStream asFixedPoint: NanosInSecond]].
- ifFalse: [(s + (self nanoSecond / NanosInSecond) asFloat) printOn: aStream]].
hr24 ifFalse:
[ aStream nextPutAll: (h < 12 ifTrue: [' am'] ifFalse: [' pm']) ].
!
Bert Freudenberg uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-bf.710.mcz
==================== Summary ====================
Name: Kernel-bf.710
Author: bf
Time: 4 September 2012, 1:54:08.616 pm
UUID: 772d3014-9910-4231-bee1-36d35938014d
Ancestors: Kernel-ul.709
For printing Time, do not use Floats. E.g., '6:27:08.649' asTime was printed as '6:27:08.649000000000001 am' due to converting to floating point for printing, when the representation itself uses precise numbers (nanoseconds). This fix introduces Integer>>printOn:asFixedPoint: which might not be the best idea; if some other dialect has an existing method that does something similar we should use that selector.
=============== Diff against Kernel-ul.709 ===============
Item was added:
+ ----- Method: Integer>>printOn:asFixedPoint: (in category 'printing') -----
+ printOn: aStream asFixedPoint: base
+ "assume I am a fixedpoint decimal scaled by base"
+ "String streamContents: [:s | 1234 printOn: s asFixedPoint: 1000]"
+
+ | b n |
+ self < 0 ifTrue: [aStream nextPut: $-.
+ ^self negated printOn: aStream asFixedPoint: base].
+ b := base.
+ n := self.
+ [aStream print: n // b.
+ (n := n \\ b) = 0] whileFalse: [
+ b = base ifTrue: [aStream nextPut: $.].
+ b := b // 10].
+ !
Item was changed:
----- Method: Time>>print24:showSeconds:on: (in category 'printing') -----
print24: hr24 showSeconds: showSeconds on: aStream
"Format is 'hh:mm:ss' or 'h:mm:ss am' or, if showSeconds is false, 'hh:mm' or 'h:mm am'"
| h m s |
h := self hour. m := self minute. s := self second.
hr24
ifTrue:
[ h < 10 ifTrue: [ aStream nextPutAll: '0' ].
h printOn: aStream ]
ifFalse:
[ h > 12
ifTrue: [h - 12 printOn: aStream]
ifFalse:
[h < 1
ifTrue: [ 12 printOn: aStream ]
ifFalse: [ h printOn: aStream ]]].
aStream nextPutAll: (m < 10 ifTrue: [':0'] ifFalse: [':']).
m printOn: aStream.
showSeconds ifTrue:
[ aStream nextPutAll: (s < 10 ifTrue: [':0'] ifFalse: [':']).
self nanoSecond = 0
ifTrue: [s asInteger printOn: aStream]
+ ifFalse: [s asInteger * NanosInSecond + self nanoSecond asInteger
+ printOn: aStream asFixedPoint: NanosInSecond]].
- ifFalse: [(s + (self nanoSecond / NanosInSecond) asFloat) printOn: aStream]].
hr24 ifFalse:
[ aStream nextPutAll: (h < 12 ifTrue: [' am'] ifFalse: [' pm']) ].
!
Levente Uzonyi uploaded a new version of Tools to project The Trunk:
http://source.squeak.org/trunk/Tools-ul.422.mcz
==================== Summary ====================
Name: Tools-ul.422
Author: ul
Time: 3 September 2012, 11:54:59.7 am
UUID: 5abcf237-40bb-2143-85a6-595721d615c2
Ancestors: Tools-dtl.421
PointerExplorer enhancements:
- weak-only referers are shown at the end of the list and their identityHash is surrounded by parentheses
- refering contexts created by the explorer invocation from a workspace are not listed
=============== Diff against Tools-dtl.421 ===============
Item was changed:
----- Method: PointerExplorerWrapper>>contents (in category 'accessing') -----
contents
+ "Return the wrappers with the objects holding references to item. Eldest objects come first, weak only referencers are at the end and have parentheses around their identity hash."
+
+ | objects weakOnlyReferences |
+ objects := item inboundPointersExcluding: { self. model }.
+ weakOnlyReferences := OrderedCollection new.
+ objects removeAllSuchThat: [ :each |
+ each class == self class
+ or: [ each class == PointerExplorer
+ or: [ (each class == MethodContext
+ and: [ each receiver class == PointerExplorer ] )
+ or: [ (each pointsOnlyWeaklyTo: item)
+ ifTrue: [ weakOnlyReferences add: each. true ]
+ ifFalse: [ false ] ] ] ] ].
+ ^(objects replace: [ :each |
+ self class with: each name: each identityHash asString model: item ])
+ addAll: (weakOnlyReferences replace: [ :each |
+ self class with: each name: '(', each identityHash asString, ')' model: item ]);
+ yourself!
- | objects |
- objects := Utilities pointersTo: item except: (Array with: self).
- ^(objects reject: [:ea | ea class = self class or: [ea class = PointerExplorer]])
- collect: [:ea| self class with: ea name: ea identityHash asString model: item]!
Levente Uzonyi uploaded a new version of Tools to project The Trunk:
http://source.squeak.org/trunk/Tools-ul.422.mcz
==================== Summary ====================
Name: Tools-ul.422
Author: ul
Time: 3 September 2012, 11:54:59.7 am
UUID: 5abcf237-40bb-2143-85a6-595721d615c2
Ancestors: Tools-dtl.421
PointerExplorer enhancements:
- weak-only referers are shown at the end of the list and their identityHash is surrounded by parentheses
- refering contexts created by the explorer invocation from a workspace are not listed
=============== Diff against Tools-dtl.421 ===============
Item was changed:
----- Method: PointerExplorerWrapper>>contents (in category 'accessing') -----
contents
+ "Return the wrappers with the objects holding references to item. Eldest objects come first, weak only referencers are at the end and have parentheses around their identity hash."
+
+ | objects weakOnlyReferences |
+ objects := item inboundPointersExcluding: { self. model }.
+ weakOnlyReferences := OrderedCollection new.
+ objects removeAllSuchThat: [ :each |
+ each class == self class
+ or: [ each class == PointerExplorer
+ or: [ (each class == MethodContext
+ and: [ each receiver class == PointerExplorer ] )
+ or: [ (each pointsOnlyWeaklyTo: item)
+ ifTrue: [ weakOnlyReferences add: each. true ]
+ ifFalse: [ false ] ] ] ] ].
+ ^(objects replace: [ :each |
+ self class with: each name: each identityHash asString model: item ])
+ addAll: (weakOnlyReferences replace: [ :each |
+ self class with: each name: '(', each identityHash asString, ')' model: item ]);
+ yourself!
- | objects |
- objects := Utilities pointersTo: item except: (Array with: self).
- ^(objects reject: [:ea | ea class = self class or: [ea class = PointerExplorer]])
- collect: [:ea| self class with: ea name: ea identityHash asString model: item]!
Levente Uzonyi uploaded a new version of Tools to project The Trunk:
http://source.squeak.org/trunk/Tools-ul.422.mcz
==================== Summary ====================
Name: Tools-ul.422
Author: ul
Time: 3 September 2012, 11:54:59.7 am
UUID: 5abcf237-40bb-2143-85a6-595721d615c2
Ancestors: Tools-dtl.421
PointerExplorer enhancements:
- weak-only referers are shown at the end of the list and their identityHash is surrounded by parentheses
- refering contexts created by the explorer invocation from a workspace are not listed
=============== Diff against Tools-dtl.421 ===============
Item was changed:
----- Method: PointerExplorerWrapper>>contents (in category 'accessing') -----
contents
+ "Return the wrappers with the objects holding references to item. Eldest objects come first, weak only referencers are at the end and have parentheses around their identity hash."
+
+ | objects weakOnlyReferences |
+ objects := item inboundPointersExcluding: { self. model }.
+ weakOnlyReferences := OrderedCollection new.
+ objects removeAllSuchThat: [ :each |
+ each class == self class
+ or: [ each class == PointerExplorer
+ or: [ (each class == MethodContext
+ and: [ each receiver class == PointerExplorer ] )
+ or: [ (each pointsOnlyWeaklyTo: item)
+ ifTrue: [ weakOnlyReferences add: each. true ]
+ ifFalse: [ false ] ] ] ] ].
+ ^(objects replace: [ :each |
+ self class with: each name: each identityHash asString model: item ])
+ addAll: (weakOnlyReferences replace: [ :each |
+ self class with: each name: '(', each identityHash asString, ')' model: item ]);
+ yourself!
- | objects |
- objects := Utilities pointersTo: item except: (Array with: self).
- ^(objects reject: [:ea | ea class = self class or: [ea class = PointerExplorer]])
- collect: [:ea| self class with: ea name: ea identityHash asString model: item]!
Levente Uzonyi uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-ul.709.mcz
==================== Summary ====================
Name: Kernel-ul.709
Author: ul
Time: 4 September 2012, 12:42:11.196 am
UUID: 359e6dd2-5981-ae43-a5bd-c687dd1d5614
Ancestors: Kernel-eem.708
Various changes:
- improved Object >> #inboundPointersExcluding:. Better results (less noise) and performance. Uses a marker object instead of 0.
- introduced ProtoObject >> #pointsOnlyWeaklyTo: which returns true if the receiver only has a weak reference to the argument, otherwise false. The reason why it's in ProtoObject is that #pointsTo: is there too. Implementation from Pharo by Igor Stasenko.
- added Process >> #environmentAt:ifAbsentPut: which is useful for direct manipulation of the environment of Processes
- introduced Behavior >> #isCompact and changed two methods which can use this method directly
=============== Diff against Kernel-eem.708 ===============
Item was changed:
----- Method: Behavior>>becomeCompact (in category 'private') -----
becomeCompact
"Here are the restrictions on compact classes in order for export segments to work: A compact class index may not be reused. If a class was compact in a release of Squeak, no other class may use that index. The class might not be compact later, and there should be nil in its place in the array."
| cct index |
self isWeak ifTrue:[^ self halt: 'You must not make a weak class compact'].
cct := Smalltalk compactClassesArray.
+ (self isCompact or: [cct includes: self])
- (self indexIfCompact > 0 or: [cct includes: self])
ifTrue: [^ self halt: self name , 'is already compact'].
index := cct indexOf: nil
ifAbsent: [^ self halt: 'compact class table is full'].
"Install this class in the compact class table"
cct at: index put: self.
"Update instspec so future instances will be compact"
format := format + (index bitShift: 11).
"Make up new instances and become old ones into them"
self updateInstancesFrom: self.
"Purge any old instances"
Smalltalk garbageCollect.!
Item was changed:
----- Method: Behavior>>becomeCompactSimplyAt: (in category 'private') -----
becomeCompactSimplyAt: index
"Make me compact, but don't update the instances. For importing segments."
"Here are the restrictions on compact classes in order for export segments to work: A compact class index may not be reused. If a class was compact in a release of Squeak, no other class may use that index. The class might not be compact later, and there should be nil in its place in the array."
| cct |
self isWeak ifTrue:[^ self halt: 'You must not make a weak class compact'].
cct := Smalltalk compactClassesArray.
+ (self isCompact or: [cct includes: self])
- (self indexIfCompact > 0 or: [cct includes: self])
ifTrue: [^ self halt: self name , 'is already compact'].
(cct at: index) ifNotNil: [^ self halt: 'compact table slot already in use'].
"Install this class in the compact class table"
cct at: index put: self.
"Update instspec so future instances will be compact"
format := format + (index bitShift: 11).
"Caller must convert the instances"
!
Item was added:
+ ----- Method: Behavior>>isCompact (in category 'testing') -----
+ isCompact
+
+ ^self indexIfCompact ~= 0!
Item was changed:
----- Method: Object>>inboundPointersExcluding: (in category 'tracing') -----
inboundPointersExcluding: objectsToExclude
+ "Answer a list of all objects in the system that hold a reference to me, excluding those in the collection of objectsToExclude."
- "Answer a list of all objects in the system that point to me, excluding those in the collection of objectsToExclude. I do my best to avoid creating any temporary objects that point to myself, especially method and block contexts. Adapted from PointerFinder class >> #pointersTo:except:"
+ | pointers object objectsToAlwaysExclude |
- | anObj pointers objectsToAlwaysExclude |
Smalltalk garbageCollect.
+ pointers := OrderedCollection new.
+ "SystemNavigation >> #allObjectsDo: is inlined here with a slight modification: the marker object is pointers. This gives better results, because the value of pointers, it's inner objects and transient method contexts will not be iterated over."
+ object := self someObject.
+ [ object == pointers ] whileFalse: [
+ (object isInMemory and: [ object pointsTo: self ]) ifTrue: [
+ pointers add: object ].
+ object := object nextObject ].
- "big collection shouldn't grow, so it's contents array is always the same"
- pointers := OrderedCollection new: 1000.
-
- "#allObjectsDo: and #pointsTo: are expanded inline to keep spurious
- method and block contexts out of the results"
- anObj := self someObject.
- [0 == anObj] whileFalse: [ "We must use #== here, to avoid leaving the loop when anObj is another number that's equal to 0 (e.g. 0.0)."
- anObj isInMemory
- ifTrue: [((anObj instVarsInclude: self)
- or: [anObj class == self])
- ifTrue: [pointers add: anObj]].
- anObj := anObj nextObject].
-
objectsToAlwaysExclude := {
- pointers collector.
thisContext.
thisContext sender.
thisContext sender sender.
objectsToExclude.
}.
+ ^pointers removeAllSuchThat: [ :ea |
-
- ^ pointers removeAllSuchThat: [:ea |
(objectsToAlwaysExclude identityIncludes: ea)
+ or: [ objectsToExclude identityIncludes: ea ] ]!
- or: [objectsToExclude identityIncludes: ea]]!
Item was added:
+ ----- Method: Process>>environmentAt:ifAbsentPut: (in category 'process specific') -----
+ environmentAt: key ifAbsentPut: aBlock
+
+ ^(env ifNil: [ env := Dictionary new ]) at: key ifAbsentPut: aBlock.!
Item was added:
+ ----- Method: ProtoObject>>pointsOnlyWeaklyTo: (in category 'tracing') -----
+ pointsOnlyWeaklyTo: anObject
+ "Assume, we already know that receiver points to an object, answer true if receiver points only weakly to it."
+
+ self class isWeak ifFalse: [ ^false ].
+ 1 to: self class instSize do: [ :i |
+ (self instVarAt: i) == anObject ifTrue: [ ^false ] ].
+ ^true!
Levente Uzonyi uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-ul.709.mcz
==================== Summary ====================
Name: Kernel-ul.709
Author: ul
Time: 4 September 2012, 12:42:11.196 am
UUID: 359e6dd2-5981-ae43-a5bd-c687dd1d5614
Ancestors: Kernel-eem.708
Various changes:
- improved Object >> #inboundPointersExcluding:. Better results (less noise) and performance. Uses a marker object instead of 0.
- introduced ProtoObject >> #pointsOnlyWeaklyTo: which returns true if the receiver only has a weak reference to the argument, otherwise false. The reason why it's in ProtoObject is that #pointsTo: is there too. Implementation from Pharo by Igor Stasenko.
- added Process >> #environmentAt:ifAbsentPut: which is useful for direct manipulation of the environment of Processes
- introduced Behavior >> #isCompact and changed two methods which can use this method directly
=============== Diff against Kernel-eem.708 ===============
Item was changed:
----- Method: Behavior>>becomeCompact (in category 'private') -----
becomeCompact
"Here are the restrictions on compact classes in order for export segments to work: A compact class index may not be reused. If a class was compact in a release of Squeak, no other class may use that index. The class might not be compact later, and there should be nil in its place in the array."
| cct index |
self isWeak ifTrue:[^ self halt: 'You must not make a weak class compact'].
cct := Smalltalk compactClassesArray.
+ (self isCompact or: [cct includes: self])
- (self indexIfCompact > 0 or: [cct includes: self])
ifTrue: [^ self halt: self name , 'is already compact'].
index := cct indexOf: nil
ifAbsent: [^ self halt: 'compact class table is full'].
"Install this class in the compact class table"
cct at: index put: self.
"Update instspec so future instances will be compact"
format := format + (index bitShift: 11).
"Make up new instances and become old ones into them"
self updateInstancesFrom: self.
"Purge any old instances"
Smalltalk garbageCollect.!
Item was changed:
----- Method: Behavior>>becomeCompactSimplyAt: (in category 'private') -----
becomeCompactSimplyAt: index
"Make me compact, but don't update the instances. For importing segments."
"Here are the restrictions on compact classes in order for export segments to work: A compact class index may not be reused. If a class was compact in a release of Squeak, no other class may use that index. The class might not be compact later, and there should be nil in its place in the array."
| cct |
self isWeak ifTrue:[^ self halt: 'You must not make a weak class compact'].
cct := Smalltalk compactClassesArray.
+ (self isCompact or: [cct includes: self])
- (self indexIfCompact > 0 or: [cct includes: self])
ifTrue: [^ self halt: self name , 'is already compact'].
(cct at: index) ifNotNil: [^ self halt: 'compact table slot already in use'].
"Install this class in the compact class table"
cct at: index put: self.
"Update instspec so future instances will be compact"
format := format + (index bitShift: 11).
"Caller must convert the instances"
!
Item was added:
+ ----- Method: Behavior>>isCompact (in category 'testing') -----
+ isCompact
+
+ ^self indexIfCompact ~= 0!
Item was changed:
----- Method: Object>>inboundPointersExcluding: (in category 'tracing') -----
inboundPointersExcluding: objectsToExclude
+ "Answer a list of all objects in the system that hold a reference to me, excluding those in the collection of objectsToExclude."
- "Answer a list of all objects in the system that point to me, excluding those in the collection of objectsToExclude. I do my best to avoid creating any temporary objects that point to myself, especially method and block contexts. Adapted from PointerFinder class >> #pointersTo:except:"
+ | pointers object objectsToAlwaysExclude |
- | anObj pointers objectsToAlwaysExclude |
Smalltalk garbageCollect.
+ pointers := OrderedCollection new.
+ "SystemNavigation >> #allObjectsDo: is inlined here with a slight modification: the marker object is pointers. This gives better results, because the value of pointers, it's inner objects and transient method contexts will not be iterated over."
+ object := self someObject.
+ [ object == pointers ] whileFalse: [
+ (object isInMemory and: [ object pointsTo: self ]) ifTrue: [
+ pointers add: object ].
+ object := object nextObject ].
- "big collection shouldn't grow, so it's contents array is always the same"
- pointers := OrderedCollection new: 1000.
-
- "#allObjectsDo: and #pointsTo: are expanded inline to keep spurious
- method and block contexts out of the results"
- anObj := self someObject.
- [0 == anObj] whileFalse: [ "We must use #== here, to avoid leaving the loop when anObj is another number that's equal to 0 (e.g. 0.0)."
- anObj isInMemory
- ifTrue: [((anObj instVarsInclude: self)
- or: [anObj class == self])
- ifTrue: [pointers add: anObj]].
- anObj := anObj nextObject].
-
objectsToAlwaysExclude := {
- pointers collector.
thisContext.
thisContext sender.
thisContext sender sender.
objectsToExclude.
}.
+ ^pointers removeAllSuchThat: [ :ea |
-
- ^ pointers removeAllSuchThat: [:ea |
(objectsToAlwaysExclude identityIncludes: ea)
+ or: [ objectsToExclude identityIncludes: ea ] ]!
- or: [objectsToExclude identityIncludes: ea]]!
Item was added:
+ ----- Method: Process>>environmentAt:ifAbsentPut: (in category 'process specific') -----
+ environmentAt: key ifAbsentPut: aBlock
+
+ ^(env ifNil: [ env := Dictionary new ]) at: key ifAbsentPut: aBlock.!
Item was added:
+ ----- Method: ProtoObject>>pointsOnlyWeaklyTo: (in category 'tracing') -----
+ pointsOnlyWeaklyTo: anObject
+ "Assume, we already know that receiver points to an object, answer true if receiver points only weakly to it."
+
+ self class isWeak ifFalse: [ ^false ].
+ 1 to: self class instSize do: [ :i |
+ (self instVarAt: i) == anObject ifTrue: [ ^false ] ].
+ ^true!
Levente Uzonyi uploaded a new version of Kernel to project The Trunk:
http://source.squeak.org/trunk/Kernel-ul.709.mcz
==================== Summary ====================
Name: Kernel-ul.709
Author: ul
Time: 4 September 2012, 12:42:11.196 am
UUID: 359e6dd2-5981-ae43-a5bd-c687dd1d5614
Ancestors: Kernel-eem.708
Various changes:
- improved Object >> #inboundPointersExcluding:. Better results (less noise) and performance. Uses a marker object instead of 0.
- introduced ProtoObject >> #pointsOnlyWeaklyTo: which returns true if the receiver only has a weak reference to the argument, otherwise false. The reason why it's in ProtoObject is that #pointsTo: is there too. Implementation from Pharo by Igor Stasenko.
- added Process >> #environmentAt:ifAbsentPut: which is useful for direct manipulation of the environment of Processes
- introduced Behavior >> #isCompact and changed two methods which can use this method directly
=============== Diff against Kernel-eem.708 ===============
Item was changed:
----- Method: Behavior>>becomeCompact (in category 'private') -----
becomeCompact
"Here are the restrictions on compact classes in order for export segments to work: A compact class index may not be reused. If a class was compact in a release of Squeak, no other class may use that index. The class might not be compact later, and there should be nil in its place in the array."
| cct index |
self isWeak ifTrue:[^ self halt: 'You must not make a weak class compact'].
cct := Smalltalk compactClassesArray.
+ (self isCompact or: [cct includes: self])
- (self indexIfCompact > 0 or: [cct includes: self])
ifTrue: [^ self halt: self name , 'is already compact'].
index := cct indexOf: nil
ifAbsent: [^ self halt: 'compact class table is full'].
"Install this class in the compact class table"
cct at: index put: self.
"Update instspec so future instances will be compact"
format := format + (index bitShift: 11).
"Make up new instances and become old ones into them"
self updateInstancesFrom: self.
"Purge any old instances"
Smalltalk garbageCollect.!
Item was changed:
----- Method: Behavior>>becomeCompactSimplyAt: (in category 'private') -----
becomeCompactSimplyAt: index
"Make me compact, but don't update the instances. For importing segments."
"Here are the restrictions on compact classes in order for export segments to work: A compact class index may not be reused. If a class was compact in a release of Squeak, no other class may use that index. The class might not be compact later, and there should be nil in its place in the array."
| cct |
self isWeak ifTrue:[^ self halt: 'You must not make a weak class compact'].
cct := Smalltalk compactClassesArray.
+ (self isCompact or: [cct includes: self])
- (self indexIfCompact > 0 or: [cct includes: self])
ifTrue: [^ self halt: self name , 'is already compact'].
(cct at: index) ifNotNil: [^ self halt: 'compact table slot already in use'].
"Install this class in the compact class table"
cct at: index put: self.
"Update instspec so future instances will be compact"
format := format + (index bitShift: 11).
"Caller must convert the instances"
!
Item was added:
+ ----- Method: Behavior>>isCompact (in category 'testing') -----
+ isCompact
+
+ ^self indexIfCompact ~= 0!
Item was changed:
----- Method: Object>>inboundPointersExcluding: (in category 'tracing') -----
inboundPointersExcluding: objectsToExclude
+ "Answer a list of all objects in the system that hold a reference to me, excluding those in the collection of objectsToExclude."
- "Answer a list of all objects in the system that point to me, excluding those in the collection of objectsToExclude. I do my best to avoid creating any temporary objects that point to myself, especially method and block contexts. Adapted from PointerFinder class >> #pointersTo:except:"
+ | pointers object objectsToAlwaysExclude |
- | anObj pointers objectsToAlwaysExclude |
Smalltalk garbageCollect.
+ pointers := OrderedCollection new.
+ "SystemNavigation >> #allObjectsDo: is inlined here with a slight modification: the marker object is pointers. This gives better results, because the value of pointers, it's inner objects and transient method contexts will not be iterated over."
+ object := self someObject.
+ [ object == pointers ] whileFalse: [
+ (object isInMemory and: [ object pointsTo: self ]) ifTrue: [
+ pointers add: object ].
+ object := object nextObject ].
- "big collection shouldn't grow, so it's contents array is always the same"
- pointers := OrderedCollection new: 1000.
-
- "#allObjectsDo: and #pointsTo: are expanded inline to keep spurious
- method and block contexts out of the results"
- anObj := self someObject.
- [0 == anObj] whileFalse: [ "We must use #== here, to avoid leaving the loop when anObj is another number that's equal to 0 (e.g. 0.0)."
- anObj isInMemory
- ifTrue: [((anObj instVarsInclude: self)
- or: [anObj class == self])
- ifTrue: [pointers add: anObj]].
- anObj := anObj nextObject].
-
objectsToAlwaysExclude := {
- pointers collector.
thisContext.
thisContext sender.
thisContext sender sender.
objectsToExclude.
}.
+ ^pointers removeAllSuchThat: [ :ea |
-
- ^ pointers removeAllSuchThat: [:ea |
(objectsToAlwaysExclude identityIncludes: ea)
+ or: [ objectsToExclude identityIncludes: ea ] ]!
- or: [objectsToExclude identityIncludes: ea]]!
Item was added:
+ ----- Method: Process>>environmentAt:ifAbsentPut: (in category 'process specific') -----
+ environmentAt: key ifAbsentPut: aBlock
+
+ ^(env ifNil: [ env := Dictionary new ]) at: key ifAbsentPut: aBlock.!
Item was added:
+ ----- Method: ProtoObject>>pointsOnlyWeaklyTo: (in category 'tracing') -----
+ pointsOnlyWeaklyTo: anObject
+ "Assume, we already know that receiver points to an object, answer true if receiver points only weakly to it."
+
+ self class isWeak ifFalse: [ ^false ].
+ 1 to: self class instSize do: [ :i |
+ (self instVarAt: i) == anObject ifTrue: [ ^false ] ].
+ ^true!