Marcel Taeumel uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-mt.1202.mcz
==================== Summary ====================
Name: System-mt.1202
Author: mt
Time: 18 December 2020, 10:11:47.76906 am
UUID: 29ceed8f-1bbf-fa4f-89ee-8e8aaabe25ba
Ancestors: System-dtl.1201
Fixes logging output of DoItFirst for cases where stdio streams are unavailable such as on Windows via Squeak.exe (instead of SqueakConsole.exe).
=============== Diff against System-dtl.1201 ===============
Item was removed:
- ----- Method: DoItFirst>>print:to: (in category 'private') -----
- print: aString to: stream
- [ stream nextPutAll: aString; lf; flush ]
- on: Error
- do: [ Transcript cr; show: self class name , ' output: ', aString; flush.
- ^false ].
- ^true.
- !
Item was changed:
----- Method: DoItFirst>>printError: (in category 'private') -----
printError: aString
"Print to stdout if available, otherwise to the transcript. Answer true if
the stdio stream was used, false if output was redirected to transcript."
+ [ FileStream stderr nextPutAll: aString; lf; flush ]
+ on: Error
+ do: [ TranscriptStream forceUpdate: false. "Graphics not yet fully initialized."
+ Transcript cr; show: self class name , ' error: ', aString; flush.
+ ^false ].
+ ^true.
- ^self print: aString to: FileStream stderr.
!
Item was changed:
----- Method: DoItFirst>>printOut: (in category 'private') -----
printOut: aString
"Print to stdout if available, otherwise to the transcript. Answer true if
the stdio stream was used, false if output was redirected to transcript."
+ [ FileStream stdout nextPutAll: aString; lf; flush ]
+ on: Error
+ do: [ TranscriptStream forceUpdate: false. "Graphics not yet fully initialized."
+ Transcript cr; show: self class name , ' output: ', aString; flush.
+ ^false ].
+ ^true.
- ^self print: aString to: FileStream stdout.
!
A new version of System was added to project The Inbox:
http://source.squeak.org/inbox/System-dtl.1197.mcz
==================== Summary ====================
Name: System-dtl.1197
Author: dtl
Time: 12 December 2020, 11:39:02.946469 pm
UUID: 98a9eb0b-d360-473f-a718-f1f7ae883ac7
Ancestors: System-mt.1196
Enable removal of preference for 'Read document at startup'.
Simplify code such that #readDocumentAtStartup is assumed always true and document specifiers begining with '-' are not treated as start documents. The actual preference setting is no longer referenced.
Assumptions: if the start document resource name starts with '-' then it is unlikely to be a document. For the case of the first argument appearing to be a document but the user wishing to use it otherwise, the '--' token (or any other argument beginning with '-') may be used in the command line to protect the argument from evaluation. This allows the traditional start document processing to work normally in the general case, and allows start document processing to be bypassed from the command line if desired. No preference setting is required.
The #readDocumentAtStartup may be removed in a future update.
=============== Diff against System-mt.1196 ===============
Item was changed:
----- Method: ProjectLauncher>>startUpAfterLogin (in category 'running') -----
startUpAfterLogin
| scriptName loader isUrl |
self setupFlaps.
+ Smalltalk firstArgMightBeDocument
+ ifTrue: [scriptName := Smalltalk documentPath.
- Preferences readDocumentAtStartup
- ifTrue: [scriptName := Smalltalk documentPath
- ifNil: [''].
scriptName := scriptName convertFromSystemString.
scriptName isEmpty
ifFalse: ["figure out if script name is a URL by itself"
isUrl := (scriptName asLowercase beginsWith: 'http://')
or: [(scriptName asLowercase beginsWith: 'file://')
or: [scriptName asLowercase beginsWith: 'ftp://']].
isUrl
ifFalse: [| encodedPath pathTokens |
"Allow for ../dir/scriptName arguments"
pathTokens := scriptName splitBy: FileDirectory slash.
pathTokens := pathTokens
collect: [:s | s encodeForHTTP].
encodedPath := pathTokens
reduce: [:acc :each | acc , FileDirectory slash , each].
scriptName := (FileDirectory default uri resolveRelativeURI: encodedPath) asString]]]
ifFalse: [scriptName := ''].
scriptName isEmptyOrNil
ifTrue: [^ Preferences eToyFriendly
ifTrue: [self currentWorld addGlobalFlaps]].
loader := CodeLoader new.
loader
loadSourceFiles: (Array with: scriptName).
(scriptName asLowercase endsWith: '.pr')
ifTrue: [self installProjectFrom: loader]
ifFalse: [loader installSourceFiles]!
Item was changed:
----- Method: SmalltalkImage>>arguments (in category 'command line') -----
arguments
"Answer an array with all the command line arguments.
+ This does not include imagePath, documentPath nor any option.
+ The '--' token on the command line indicates that remaining arguments should
+ be passed to the image without interpretation, and should not be treated as e.g.
+ specification of a start script."
+
- This does not include imagePath, documentPath nor any option."
-
"Smalltalk commandLine arguments"
+ | args |
- | args strm |
args := self rawArguments.
+ (args includes: '--' )
+ ifTrue: [ ^ args copyAfter: '--' ]
+ ifFalse: [ | rs | rs := args readStream.
+ rs next. "skip image name"
+ self firstArgMightBeDocument
+ ifTrue: [rs next "skip startup document name"].
+ ^ rs upToEnd ].
- (args includes: '--')
- ifTrue: [ ^args copyAfter: self imageArgumentsMarker ].
- strm := args readStream.
- strm atEnd ifFalse: [ strm next. "skip image name"
- (Preferences readDocumentAtStartup and: [ strm atEnd not ])
- ifTrue: [ strm next "skip startup document name" ]].
- ^ strm upToEnd.
!
Item was changed:
----- Method: SmalltalkImage>>documentPath (in category 'command line') -----
documentPath
"Answer the absolute path of the document passed to the VM or nil if none."
"Smalltalk commandLine documentPath"
+ ^ (self getSystemAttribute: 2) ifNil: [ '' ]
- ^ (self getSystemAttribute: 2)
- ifNotNil: [ :arg | arg = self imageArgumentsMarker
- ifTrue: [nil] ifFalse: [arg]].
-
!
Item was added:
+ ----- Method: SmalltalkImage>>firstArgMightBeDocument (in category 'private') -----
+ firstArgMightBeDocument
+ "If the first argument begins with '-' then it is unlikely to be a document specification"
+ ^ (self documentPath beginsWith: '-') not
+ !
Item was removed:
- ----- Method: SmalltalkImage>>imageArgumentsMarker (in category 'command line') -----
- imageArgumentsMarker
- "The '--' token on the command line indicates that remaining arguments should
- be passed to the image without interpretation, and should not be treated as e.g.
- specification of a start script."
-
- ^ '--'!
Marcel Taeumel uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-mt.1200.mcz
==================== Summary ====================
Name: System-mt.1200
Author: mt
Time: 17 December 2020, 6:27:01.501895 pm
UUID: 0ff20c8c-9b07-c546-a2fe-c8310bc4c019
Ancestors: System-mt.1199
One more tweak for SpaceTally: It does not make sense to reuse the set of seen objects when enumerating the classes. Only reuse a set when enumerating each class' instances. Now the order of classes provided for #spaceTally: does not matter anymore.
=============== Diff against System-mt.1199 ===============
Item was changed:
----- Method: SpaceTally>>computeSpaceUsage (in category 'class analysis') -----
computeSpaceUsage
- | seenObjects |
- seenObjects := self depth > 0 ifTrue: [IdentitySet new].
results
do: [ :entry |
| class instanceSpaceAndCount |
class := self class environment at: entry analyzedClassName.
Smalltalk garbageCollectMost.
+ instanceSpaceAndCount := self spaceForInstancesOf: class depth: self depth.
- instanceSpaceAndCount := self spaceForInstancesOf: class depth: self depth seen: seenObjects.
entry
codeSize: class spaceUsed;
instanceCount: instanceSpaceAndCount second;
spaceForInstances: instanceSpaceAndCount first;
depthOfSpace: self depth ]
displayingProgress: 'Taking statistics...'!
Marcel Taeumel uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-mt.1199.mcz
==================== Summary ====================
Name: System-mt.1199
Author: mt
Time: 17 December 2020, 6:15:09.310895 pm
UUID: 00f96e57-9bc5-d044-bcb7-2dd90b55507b
Ancestors: System-mt.1198
Fixes SpaceTally. Only enumerate objects in variable classes, not bytes or words. Thus, avoid to create LargePositiveIntegers while counting.
=============== Diff against System-mt.1198 ===============
Item was changed:
Object subclass: #SpaceTally
instanceVariableNames: 'results depth'
classVariableNames: ''
poolDictionaries: ''
category: 'System-Tools'!
!SpaceTally commentStamp: '<historical>' prior: 0!
I'm responsible to help getting information about system space usage. The information I compute is represented by a spaceTallyItem.
Here are some examples to inspect:
SpaceTally new spaceTally: (Array with: TextMorph with: Point).
SpaceTally new systemWideSpaceTally.
SpaceTally new depth: 2; spaceTally: (PackageInfo named: #Morphic) classes.
SpaceTally new depth: 1; spaceTally: (PackageInfo named: #Monticello) classes. "Includes cached source code"
+ SpaceTally new spaceForInstancesOf: Form depth: 1. "Includes footprint for bitmaps"!
- SpaceTally new spaceForInstancesOf: Form depth: 2. "Includes bitmaps and large integers"!
Item was changed:
----- Method: SpaceTally>>spaceForInstance:depth:seen: (in category 'instance size') -----
spaceForInstance: anObject depth: anInteger seen: seenObjectsOrNil
| ctxt class basicSize depth total |
seenObjectsOrNil ifNotNil: [
(seenObjectsOrNil ifAbsentAdd: anObject) ifFalse: [^ 0]].
ctxt := thisContext.
class := ctxt objectClass: anObject.
basicSize := 0.
total := class isVariable
ifTrue: [class byteSizeOfInstanceOfSize: (basicSize := ctxt objectSize: anObject)]
ifFalse: [class isImmediateClass ifTrue: [0] ifFalse: [class byteSizeOfInstance]].
(depth := anInteger - 1) >= 0 ifTrue: [
anObject isCompiledCode
ifTrue: [
anObject literalsDo: [:literal |
total := total + (self spaceForInstance: literal depth: depth seen: seenObjectsOrNil)]]
ifFalse: [
+ (class instSpec between: 2 and: 4) ifTrue: [ "only indexable objects, no bytes etc."
+ 1 to: basicSize do: [:index |
+ total := total + (self spaceForInstance: (ctxt object: anObject basicAt: index) depth: depth seen: seenObjectsOrNil)]].
- 1 to: basicSize do: [:index |
- total := total + (self spaceForInstance: (ctxt object: anObject basicAt: index) depth: depth seen: seenObjectsOrNil)].
1 to: class instSize do: [:index |
total := total + (self spaceForInstance: (ctxt object: anObject instVarAt: index) depth: depth seen: seenObjectsOrNil)]]].
^ total!
Item was changed:
----- Method: SpaceTally>>spaceForInstancesOf:depth:seen: (in category 'instance size') -----
spaceForInstancesOf: aClass depth: anInteger seen: seenObjects
"Answer a pair of the number of bytes consumed by all instances of the given class, including their object headers, and the number of instances. Follow each instance's fields up to the given depth. Beware of cycles to shared objects, which will tamper the resulting numbers.
SpaceTally new spaceForInstancesOf: Form depth: 0. --- Same as #spaceForInstancesOf:
SpaceTally new spaceForInstancesOf: Form depth: 1. --- Includes memory footprint for bits etc.
- SpaceTally new spaceForInstancesOf: Form depth: 2. --- Also includes LargePositiveIntegers in bitmaps ;-)
"
| instances total |
instances := aClass allInstances.
instances isEmpty ifTrue: [^#(0 0)].
total := 0.
instances do: [:each | total := total + (self spaceForInstance: each depth: anInteger seen: seenObjects)].
^{ total. instances size }!
A new version of System was added to project The Inbox:
http://source.squeak.org/inbox/System-mt.1175.mcz
==================== Summary ====================
Name: System-mt.1175
Author: mt
Time: 29 September 2020, 1:16:45.233157 pm
UUID: f0acc060-a48b-2c4f-8b56-aaf2f55601b4
Ancestors: System-topa.1174
Adds a way to compute a space tally for objects up to a certain depth.
Questions:
- Is the interface (i.e. "depth" and "seen") OK?
- Is the use of IdentitySet OK?
- Can we speed this up somehow?
- Do we need depth-messages for the "class analysis" protocol, too?
=============== Diff against System-topa.1174 ===============
Item was added:
+ ----- Method: SpaceTally>>spaceForInstance:depth: (in category 'instance size') -----
+ spaceForInstance: anObject depth: anInteger
+
+ ^ self spaceForInstance: anObject depth: anInteger seen: IdentitySet new!
Item was added:
+ ----- Method: SpaceTally>>spaceForInstance:depth:seen: (in category 'instance size') -----
+ spaceForInstance: anObject depth: anInteger seen: someObjects
+
+ | class depth total |
+ (someObjects includes: anObject) ifTrue: [^ 0].
+ someObjects add: anObject.
+ class := anObject class.
+ depth := anInteger - 1.
+ total := class isVariable
+ ifTrue: [class byteSizeOfInstanceOfSize: anObject basicSize]
+ ifFalse: [class isImmediateClass ifTrue: [0] ifFalse: [class byteSizeOfInstance]].
+ depth >= 0 ifTrue: [
+ anObject isCompiledCode
+ ifTrue: [
+ anObject literalsDo: [:literal |
+ total := total + (self spaceForInstance: literal depth: depth seen: someObjects)]]
+ ifFalse: [
+ 1 to: anObject basicSize do: [:index |
+ total := total + (self spaceForInstance: (anObject basicAt: index) depth: depth seen: someObjects)].
+ 1 to: class instSize do: [:index |
+ total := total + (self spaceForInstance: (anObject instVarAt: index) depth: depth seen: someObjects)]]].
+ ^ total!
Item was added:
+ ----- Method: SpaceTally>>spaceForInstancesOf:depth: (in category 'instance size') -----
+ spaceForInstancesOf: aClass depth: aNumber
+ "Answer a pair of the number of bytes consumed by all instances of the given class, including their object headers, and the number of instances. Follow each instance's fields up to the given depth. Beware of cycles to shared objects, which will tamper the resulting numbers.
+
+ SpaceTally new spaceForInstancesOf: Form depth: 0. --- Same as #spaceForInstanecsOf:
+ SpaceTally new spaceForInstancesOf: Form depth: 1. --- Includes memory footprint for bits etc.
+ SpaceTally new spaceForInstancesOf: Form depth: 2. --- Also includes LargePositiveIntegers in bitmaps ;-)
+ "
+
+ | instances total sub depth |
+ instances := aClass allInstances.
+ instances isEmpty ifTrue: [^#(0 0)].
+ total := 0.
+ instances do: [:each | total := total + (self spaceForInstance: each depth: aNumber)].
+ ^{ total. instances size }!
Marcel Taeumel uploaded a new version of System to project The Trunk:
http://source.squeak.org/trunk/System-mt.1175.mcz
==================== Summary ====================
Name: System-mt.1175
Author: mt
Time: 29 September 2020, 1:16:45.233157 pm
UUID: f0acc060-a48b-2c4f-8b56-aaf2f55601b4
Ancestors: System-topa.1174
Adds a way to compute a space tally for objects up to a certain depth.
Questions:
- Is the interface (i.e. "depth" and "seen") OK?
- Is the use of IdentitySet OK?
- Can we speed this up somehow?
- Do we need depth-messages for the "class analysis" protocol, too?
=============== Diff against System-topa.1174 ===============
Item was added:
+ ----- Method: SpaceTally>>spaceForInstance:depth: (in category 'instance size') -----
+ spaceForInstance: anObject depth: anInteger
+
+ ^ self spaceForInstance: anObject depth: anInteger seen: IdentitySet new!
Item was added:
+ ----- Method: SpaceTally>>spaceForInstance:depth:seen: (in category 'instance size') -----
+ spaceForInstance: anObject depth: anInteger seen: someObjects
+
+ | class depth total |
+ (someObjects includes: anObject) ifTrue: [^ 0].
+ someObjects add: anObject.
+ class := anObject class.
+ depth := anInteger - 1.
+ total := class isVariable
+ ifTrue: [class byteSizeOfInstanceOfSize: anObject basicSize]
+ ifFalse: [class isImmediateClass ifTrue: [0] ifFalse: [class byteSizeOfInstance]].
+ depth >= 0 ifTrue: [
+ anObject isCompiledCode
+ ifTrue: [
+ anObject literalsDo: [:literal |
+ total := total + (self spaceForInstance: literal depth: depth seen: someObjects)]]
+ ifFalse: [
+ 1 to: anObject basicSize do: [:index |
+ total := total + (self spaceForInstance: (anObject basicAt: index) depth: depth seen: someObjects)].
+ 1 to: class instSize do: [:index |
+ total := total + (self spaceForInstance: (anObject instVarAt: index) depth: depth seen: someObjects)]]].
+ ^ total!
Item was added:
+ ----- Method: SpaceTally>>spaceForInstancesOf:depth: (in category 'instance size') -----
+ spaceForInstancesOf: aClass depth: aNumber
+ "Answer a pair of the number of bytes consumed by all instances of the given class, including their object headers, and the number of instances. Follow each instance's fields up to the given depth. Beware of cycles to shared objects, which will tamper the resulting numbers.
+
+ SpaceTally new spaceForInstancesOf: Form depth: 0. --- Same as #spaceForInstanecsOf:
+ SpaceTally new spaceForInstancesOf: Form depth: 1. --- Includes memory footprint for bits etc.
+ SpaceTally new spaceForInstancesOf: Form depth: 2. --- Also includes LargePositiveIntegers in bitmaps ;-)
+ "
+
+ | instances total sub depth |
+ instances := aClass allInstances.
+ instances isEmpty ifTrue: [^#(0 0)].
+ total := 0.
+ instances do: [:each | total := total + (self spaceForInstance: each depth: aNumber)].
+ ^{ total. instances size }!