[squeak-dev] The Trunk: System-dtl.666.mcz
commits at source.squeak.org
commits at source.squeak.org
Sun Feb 16 02:54:25 UTC 2014
David T. Lewis uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-dtl.666.mcz
==================== Summary ====================
Name: System-dtl.666
Author: dtl
Time: 15 February 2014, 9:53:14.979 pm
UUID: 098b856a-ecc5-498a-bceb-ef3457d3511e
Ancestors: System-dtl.665
Sending basicNew to CompiledMethod may crash the VM, so don't do that.
=============== Diff against System-dtl.665 ===============
Item was changed:
----- Method: SpaceTally>>spaceForInstancesOf: (in category 'instance size') -----
spaceForInstancesOf: aClass
"Answer the number of bytes consumed by all instances of the given class, including their object headers and the number of instances."
| smallHeaderSize instVarBytes isVariable bytesPerElement total lastInstance instance instanceCount |
instance := aClass someInstance ifNil: [ ^#(0 0) ].
smallHeaderSize := aClass isCompact ifTrue: [ 4 ] ifFalse: [ 8 ].
instVarBytes := aClass instSize * 4.
isVariable := aClass isVariable.
bytesPerElement := isVariable
ifFalse: [ 0 ]
ifTrue: [ aClass isBytes ifTrue: [ 1 ] ifFalse: [ 4 ] ].
total := 0.
instanceCount := 0.
"A modified version of #allInstancesDo: is inlined here. It avoids an infinite loop when another process is creating new instances of aClass."
self flag: #allInstancesDo:.
+ lastInstance :=
+ aClass == CompiledMethod "CompiledMethod has special format, see its class comment"
+ ifTrue: [aClass new]
+ ifFalse: [aClass basicNew].
- lastInstance := aClass basicNew.
[ instance == lastInstance ] whileFalse: [
| contentBytes headerBytes |
contentBytes := instVarBytes + (isVariable
ifFalse: [ 0 ]
ifTrue: [ instance basicSize * bytesPerElement ]).
headerBytes := contentBytes > 255
ifTrue: [ 12 ]
ifFalse: [ smallHeaderSize ].
total := total + headerBytes + (contentBytes roundUpTo: 4).
instanceCount := instanceCount + 1.
instance := instance nextInstance ].
^{ total. instanceCount }!
More information about the Squeak-dev
mailing list
|