The Inbox: System-dtl.1209.mcz

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

The Inbox: System-dtl.1209.mcz

commits-2
David T. Lewis uploaded a new version of System to project The Inbox:
http://source.squeak.org/inbox/System-dtl.1209.mcz

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

Name: System-dtl.1209
Author: dtl
Time: 28 December 2020, 10:50:06.875257 am
UUID: 25efba24-561f-4c53-97d9-95438edfce90
Ancestors: System-eem.1207

Provide vmParameterAt:default: to handle primitive failure on reading VM parameters.
Supply default parameter values to mock possibly missing elements in the parameters array.
Remove two unnecessary isRunningCog checks and an ifNotNil:
Remove inappropriate halt in sendMouseWheelEvents:
Let supportsMultipleBytecodeSets and supportsReadOnlyObjects work on any VM.

=============== Diff against System-eem.1207 ===============

Item was changed:
  ----- Method: SmalltalkImage>>isRunningCog (in category 'system attributes') -----
  isRunningCog
  "Answers if we're running on a Cog VM (JIT or StackInterpreter)"
 
+ ^(self vmParameterAt: 42 default: nil)
- ^(self vmParameterAt: 42)
  ifNil: [false]
  ifNotNil: [:numStackPages| numStackPages > 0]!

Item was changed:
  ----- Method: SmalltalkImage>>isRunningCogit (in category 'system attributes') -----
  isRunningCogit
  "Answers if we're running on the Cog JIT"
 
+ ^(self vmParameterAt: 46 default: nil)
- ^(self vmParameterAt: 46)
  ifNil: [false]
  ifNotNil: [:machineCodeZoneSize| machineCodeZoneSize > 0]!

Item was changed:
  ----- Method: SmalltalkImage>>lowSpaceThreshold (in category 'memory space') -----
  lowSpaceThreshold
  "Answer the low space threshold. When the amount of free memory (after garbage collection)
  falls below this limit, the system is in serious danger of completely exhausting memory and
  crashing. This limit should be made high enough to allow the user open a debugger to diagnose
  a problem or to save the image.  In a stack-based VM such as Cog contexts for activations in
  the stack zone will have to be created as the debugger opens, requiring additional headroom."
 
  | slotsForDebugger slotsForContextsOnStackPages |
  slotsForDebugger := 65536. "Arbitrary guess"
  slotsForContextsOnStackPages :=
+ (self vmParameterAt: 42 default: nil)
- (self vmParameterAt: 42)
  ifNil: [0]
  ifNotNil:
  [:numStackPages| | headerSize numActivationsPerPage maxContextSize |
  numActivationsPerPage := 40. "Design goal of the Cog & Stack VMs"
  headerSize := 8 / self wordSize. "64-bits for Spur"
  maxContextSize := thisContext class instSize + CompiledMethod fullFrameSize + headerSize.
  numStackPages * numActivationsPerPage * maxContextSize].
  ^slotsForDebugger + slotsForContextsOnStackPages * self wordSize!

Item was changed:
  ----- Method: SmalltalkImage>>maxExternalSemaphores (in category 'vm parameters') -----
  maxExternalSemaphores
+ "The size of table where external semaphores are registered. Only in Cog,
+ other VMs are expected to answer nil if present in the parameters array."
+ ^self vmParameterAt: 49 default: nil!
- "The size of table where external semaphores are registered. Only in Cog"
- self isRunningCog ifFalse: [^nil].
- ^self vmParameterAt: 49!

Item was changed:
  ----- Method: SmalltalkImage>>maxExternalSemaphores: (in category 'vm parameters') -----
  maxExternalSemaphores: aSize
  "Changes the size of table where external semaphores are registered.
  The size can only grow, and will always be the next power of two larger than the parameter.
 
  Setting this at any time other than start-up can potentially lose requests.
  i.e. during the realloc new storage is allocated,
  the old contents are copied and then pointers are switched.
  Requests occurring during copying won't be seen if they occur to indices already copied.
  The intended use is to set the table to some adequate maximum at start-up"
 
- self isRunningCog ifFalse: [^0].
  "The vm-header field is a short, maximum 64k entries. Well, on most platforms anyways "
  (aSize < 0 or: [aSize > 16rFFFF]) ifTrue: [^self error: 'maxExternalSemaphores: is limited to 16rFFFF'].
+ ^[self vmParameterAt: 49 put: aSize] on: Error do: [0].!
- ^self vmParameterAt: 49 put: aSize!

Item was changed:
  ----- Method: SmalltalkImage>>processPreemptionYields (in category 'system attributes') -----
  processPreemptionYields
  "Answer whether the VM causes a process to yield on process preemption,
  i.e. to put a preempted process at the back of its run queue.  If the parameter
  is unavailable (non-Cog VMs) or bit 2 (4) is 0 then preemption yields."
 
+ ^((self vmParameterAt: 48 default: [^true]) allMask: 4) not
+ !
- ^(([self vmParameterAt: 48]
- on: Error
- do: [:ex| ^true]) allMask: 4) not!

Item was changed:
  ----- Method: SmalltalkImage>>sendMouseWheelEvents (in category 'system attributes') -----
  sendMouseWheelEvents
  "The Cog VM can be instructed to deliver mouse wheel events as mouse wheel events.
  By default mouse wheel events are mapped to arrow events.
  This flag persists across snapshots, stored in the image header."
 
+ ^(self vmParameterAt: 48 default: 0) anyMask: 32!
- ^(self vmParameterAt: 48) anyMask: 32!

Item was changed:
  ----- Method: SmalltalkImage>>supportsMultipleBytecodeSets (in category 'system attributes') -----
  supportsMultipleBytecodeSets
  "Answer whether the VM supports multiple bytecodeSets."
  "SmalltalkImage current supportsMultipleBytecodeSets"
 
+ ^(self vmParameterAt: 65 default: nil)
- ^(self vmParameterAt: 65)
  ifNil: [false]
  ifNotNil:
  [:param| "In older VMs this is a boolean answering the vm-internal MULTIPLE_BYTECODE_SETS define"
  param isInteger "In newer VMs it is a set of integer flags, bit 0 of which is the vm-internal MULTIPLE_BYTECODE_SETS define"
  ifTrue: [param anyMask: 1]
  ifFalse: [param]]!

Item was changed:
  ----- Method: SmalltalkImage>>supportsQueueingFinalization (in category 'system attributes') -----
  supportsQueueingFinalization
  "Answer whether the VM queues individual weak arrays for finalization, instead
  of signalling the finalization semaphore once for all arrays and having the
  WeakRegistry mechanism finalize all weak arrays, whether they need to or not."
  "SmalltalkImage current supportsQueueingFinalization"
 
+ ^(self vmParameterAt: 48 default: 0) anyMask: 16!
- ^(self vmParameterAt: 48) anyMask: 16!

Item was changed:
  ----- Method: SmalltalkImage>>supportsReadOnlyObjects (in category 'system attributes') -----
  supportsReadOnlyObjects
  "Answer whether the VM observes the per-object read-only flag and consequently aborts
  writes to inst vars of, and fails primitives that attempt to modify, read-only objects."
  "SmalltalkImage current supportsReadOnlyObjects"
 
+ ^(self vmParameterAt: 65 default: nil)
- ^(self vmParameterAt: 65)
  ifNil: [false]
  ifNotNil:
  [:param| "In older VMs this is a boolean answering the vm-internal MULTIPLE_BYTECODE_SETS define"
  param isInteger "In newer VMs it is a set of integer flags, bit 1 of which is the vm-internal IMMUTABILITY define"
  ifTrue: [param anyMask: 2]
  ifFalse: [false]]!

Item was added:
+ ----- Method: SmalltalkImage>>vmParameterAt:default: (in category 'vm parameters') -----
+ vmParameterAt: parameterIndex default: defaultValueOrBlock
+ "Answer a VM parameter or defaultValueOrBlock value if out of range."
+ <primitive: 254>
+ ^defaultValueOrBlock value!

Item was changed:
  ----- Method: SmalltalkImage>>wordSize (in category 'image') -----
  wordSize
  "Answer the size in bytes of an object pointer or word in the object memory.
  The value does not change for a given image, but may be modified by a SystemTracer
  when converting the image to another format. The value is cached in WordSize to
  avoid the performance overhead of repeatedly consulting the VM."
 
  "Smalltalk wordSize"
 
+ ^ WordSize ifNil: [WordSize := self vmParameterAt: 40 default: 4]!
- ^ WordSize ifNil: [WordSize := [self vmParameterAt: 40] on: Error do: [4]]!


Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: System-dtl.1209.mcz

marcel.taeumel
Hi Dave.

Provide vmParameterAt:default: to handle primitive failure on reading VM parameters.

Hmm... #vmParameterAt:ifAbsent: would be "more idiomatic"?

Best,
Marcel

Am 28.12.2020 16:50:22 schrieb [hidden email] <[hidden email]>:

David T. Lewis uploaded a new version of System to project The Inbox:
http://source.squeak.org/inbox/System-dtl.1209.mcz

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

Name: System-dtl.1209
Author: dtl
Time: 28 December 2020, 10:50:06.875257 am
UUID: 25efba24-561f-4c53-97d9-95438edfce90
Ancestors: System-eem.1207

Provide vmParameterAt:default: to handle primitive failure on reading VM parameters.
Supply default parameter values to mock possibly missing elements in the parameters array.
Remove two unnecessary isRunningCog checks and an ifNotNil:
Remove inappropriate halt in sendMouseWheelEvents:
Let supportsMultipleBytecodeSets and supportsReadOnlyObjects work on any VM.

=============== Diff against System-eem.1207 ===============

Item was changed:
----- Method: SmalltalkImage>>isRunningCog (in category 'system attributes') -----
isRunningCog
"Answers if we're running on a Cog VM (JIT or StackInterpreter)"

+ ^(self vmParameterAt: 42 default: nil)
- ^(self vmParameterAt: 42)
ifNil: [false]
ifNotNil: [:numStackPages| numStackPages > 0]!

Item was changed:
----- Method: SmalltalkImage>>isRunningCogit (in category 'system attributes') -----
isRunningCogit
"Answers if we're running on the Cog JIT"

+ ^(self vmParameterAt: 46 default: nil)
- ^(self vmParameterAt: 46)
ifNil: [false]
ifNotNil: [:machineCodeZoneSize| machineCodeZoneSize > 0]!

Item was changed:
----- Method: SmalltalkImage>>lowSpaceThreshold (in category 'memory space') -----
lowSpaceThreshold
"Answer the low space threshold. When the amount of free memory (after garbage collection)
falls below this limit, the system is in serious danger of completely exhausting memory and
crashing. This limit should be made high enough to allow the user open a debugger to diagnose
a problem or to save the image. In a stack-based VM such as Cog contexts for activations in
the stack zone will have to be created as the debugger opens, requiring additional headroom."

| slotsForDebugger slotsForContextsOnStackPages |
slotsForDebugger := 65536. "Arbitrary guess"
slotsForContextsOnStackPages :=
+ (self vmParameterAt: 42 default: nil)
- (self vmParameterAt: 42)
ifNil: [0]
ifNotNil:
[:numStackPages| | headerSize numActivationsPerPage maxContextSize |
numActivationsPerPage := 40. "Design goal of the Cog & Stack VMs"
headerSize := 8 / self wordSize. "64-bits for Spur"
maxContextSize := thisContext class instSize + CompiledMethod fullFrameSize + headerSize.
numStackPages * numActivationsPerPage * maxContextSize].
^slotsForDebugger + slotsForContextsOnStackPages * self wordSize!

Item was changed:
----- Method: SmalltalkImage>>maxExternalSemaphores (in category 'vm parameters') -----
maxExternalSemaphores
+ "The size of table where external semaphores are registered. Only in Cog,
+ other VMs are expected to answer nil if present in the parameters array."
+ ^self vmParameterAt: 49 default: nil!
- "The size of table where external semaphores are registered. Only in Cog"
- self isRunningCog ifFalse: [^nil].
- ^self vmParameterAt: 49!

Item was changed:
----- Method: SmalltalkImage>>maxExternalSemaphores: (in category 'vm parameters') -----
maxExternalSemaphores: aSize
"Changes the size of table where external semaphores are registered.
The size can only grow, and will always be the next power of two larger than the parameter.

Setting this at any time other than start-up can potentially lose requests.
i.e. during the realloc new storage is allocated,
the old contents are copied and then pointers are switched.
Requests occurring during copying won't be seen if they occur to indices already copied.
The intended use is to set the table to some adequate maximum at start-up"

- self isRunningCog ifFalse: [^0].
"The vm-header field is a short, maximum 64k entries. Well, on most platforms anyways "
(aSize < 0 or: [aSize > 16rFFFF]) ifTrue: [^self error: 'maxExternalSemaphores: is limited to 16rFFFF'].
+ ^[self vmParameterAt: 49 put: aSize] on: Error do: [0].!
- ^self vmParameterAt: 49 put: aSize!

Item was changed:
----- Method: SmalltalkImage>>processPreemptionYields (in category 'system attributes') -----
processPreemptionYields
"Answer whether the VM causes a process to yield on process preemption,
i.e. to put a preempted process at the back of its run queue. If the parameter
is unavailable (non-Cog VMs) or bit 2 (4) is 0 then preemption yields."

+ ^((self vmParameterAt: 48 default: [^true]) allMask: 4) not
+ !
- ^(([self vmParameterAt: 48]
- on: Error
- do: [:ex| ^true]) allMask: 4) not!

Item was changed:
----- Method: SmalltalkImage>>sendMouseWheelEvents (in category 'system attributes') -----
sendMouseWheelEvents
"The Cog VM can be instructed to deliver mouse wheel events as mouse wheel events.
By default mouse wheel events are mapped to arrow events.
This flag persists across snapshots, stored in the image header."

+ ^(self vmParameterAt: 48 default: 0) anyMask: 32!
- ^(self vmParameterAt: 48) anyMask: 32!

Item was changed:
----- Method: SmalltalkImage>>supportsMultipleBytecodeSets (in category 'system attributes') -----
supportsMultipleBytecodeSets
"Answer whether the VM supports multiple bytecodeSets."
"SmalltalkImage current supportsMultipleBytecodeSets"

+ ^(self vmParameterAt: 65 default: nil)
- ^(self vmParameterAt: 65)
ifNil: [false]
ifNotNil:
[:param| "In older VMs this is a boolean answering the vm-internal MULTIPLE_BYTECODE_SETS define"
param isInteger "In newer VMs it is a set of integer flags, bit 0 of which is the vm-internal MULTIPLE_BYTECODE_SETS define"
ifTrue: [param anyMask: 1]
ifFalse: [param]]!

Item was changed:
----- Method: SmalltalkImage>>supportsQueueingFinalization (in category 'system attributes') -----
supportsQueueingFinalization
"Answer whether the VM queues individual weak arrays for finalization, instead
of signalling the finalization semaphore once for all arrays and having the
WeakRegistry mechanism finalize all weak arrays, whether they need to or not."
"SmalltalkImage current supportsQueueingFinalization"

+ ^(self vmParameterAt: 48 default: 0) anyMask: 16!
- ^(self vmParameterAt: 48) anyMask: 16!

Item was changed:
----- Method: SmalltalkImage>>supportsReadOnlyObjects (in category 'system attributes') -----
supportsReadOnlyObjects
"Answer whether the VM observes the per-object read-only flag and consequently aborts
writes to inst vars of, and fails primitives that attempt to modify, read-only objects."
"SmalltalkImage current supportsReadOnlyObjects"

+ ^(self vmParameterAt: 65 default: nil)
- ^(self vmParameterAt: 65)
ifNil: [false]
ifNotNil:
[:param| "In older VMs this is a boolean answering the vm-internal MULTIPLE_BYTECODE_SETS define"
param isInteger "In newer VMs it is a set of integer flags, bit 1 of which is the vm-internal IMMUTABILITY define"
ifTrue: [param anyMask: 2]
ifFalse: [false]]!

Item was added:
+ ----- Method: SmalltalkImage>>vmParameterAt:default: (in category 'vm parameters') -----
+ vmParameterAt: parameterIndex default: defaultValueOrBlock
+ "Answer a VM parameter or defaultValueOrBlock value if out of range."
+
+ ^defaultValueOrBlock value!

Item was changed:
----- Method: SmalltalkImage>>wordSize (in category 'image') -----
wordSize
"Answer the size in bytes of an object pointer or word in the object memory.
The value does not change for a given image, but may be modified by a SystemTracer
when converting the image to another format. The value is cached in WordSize to
avoid the performance overhead of repeatedly consulting the VM."

"Smalltalk wordSize"

+ ^ WordSize ifNil: [WordSize := self vmParameterAt: 40 default: 4]!
- ^ WordSize ifNil: [WordSize := [self vmParameterAt: 40] on: Error do: [4]]!




Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: System-dtl.1209.mcz

Eliot Miranda-2


On Jan 5, 2021, at 4:18 AM, Marcel Taeumel <[hidden email]> wrote:


Hi Dave.

Provide vmParameterAt:default: to handle primitive failure on reading VM parameters.

Hmm... #vmParameterAt:ifAbsent: would be "more idiomatic"?

or vmParameterAt:ifFail:

No matter which selector I like this very much.  It’s a good idea Dave.  Just upload to trunk what you like best.


Best,
Marcel

Am 28.12.2020 16:50:22 schrieb [hidden email] <[hidden email]>:

David T. Lewis uploaded a new version of System to project The Inbox:
http://source.squeak.org/inbox/System-dtl.1209.mcz

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

Name: System-dtl.1209
Author: dtl
Time: 28 December 2020, 10:50:06.875257 am
UUID: 25efba24-561f-4c53-97d9-95438edfce90
Ancestors: System-eem.1207

Provide vmParameterAt:default: to handle primitive failure on reading VM parameters.
Supply default parameter values to mock possibly missing elements in the parameters array.
Remove two unnecessary isRunningCog checks and an ifNotNil:
Remove inappropriate halt in sendMouseWheelEvents:
Let supportsMultipleBytecodeSets and supportsReadOnlyObjects work on any VM.

=============== Diff against System-eem.1207 ===============

Item was changed:
----- Method: SmalltalkImage>>isRunningCog (in category 'system attributes') -----
isRunningCog
"Answers if we're running on a Cog VM (JIT or StackInterpreter)"

+ ^(self vmParameterAt: 42 default: nil)
- ^(self vmParameterAt: 42)
ifNil: [false]
ifNotNil: [:numStackPages| numStackPages > 0]!

Item was changed:
----- Method: SmalltalkImage>>isRunningCogit (in category 'system attributes') -----
isRunningCogit
"Answers if we're running on the Cog JIT"

+ ^(self vmParameterAt: 46 default: nil)
- ^(self vmParameterAt: 46)
ifNil: [false]
ifNotNil: [:machineCodeZoneSize| machineCodeZoneSize > 0]!

Item was changed:
----- Method: SmalltalkImage>>lowSpaceThreshold (in category 'memory space') -----
lowSpaceThreshold
"Answer the low space threshold. When the amount of free memory (after garbage collection)
falls below this limit, the system is in serious danger of completely exhausting memory and
crashing. This limit should be made high enough to allow the user open a debugger to diagnose
a problem or to save the image. In a stack-based VM such as Cog contexts for activations in
the stack zone will have to be created as the debugger opens, requiring additional headroom."

| slotsForDebugger slotsForContextsOnStackPages |
slotsForDebugger := 65536. "Arbitrary guess"
slotsForContextsOnStackPages :=
+ (self vmParameterAt: 42 default: nil)
- (self vmParameterAt: 42)
ifNil: [0]
ifNotNil:
[:numStackPages| | headerSize numActivationsPerPage maxContextSize |
numActivationsPerPage := 40. "Design goal of the Cog & Stack VMs"
headerSize := 8 / self wordSize. "64-bits for Spur"
maxContextSize := thisContext class instSize + CompiledMethod fullFrameSize + headerSize.
numStackPages * numActivationsPerPage * maxContextSize].
^slotsForDebugger + slotsForContextsOnStackPages * self wordSize!

Item was changed:
----- Method: SmalltalkImage>>maxExternalSemaphores (in category 'vm parameters') -----
maxExternalSemaphores
+ "The size of table where external semaphores are registered. Only in Cog,
+ other VMs are expected to answer nil if present in the parameters array."
+ ^self vmParameterAt: 49 default: nil!
- "The size of table where external semaphores are registered. Only in Cog"
- self isRunningCog ifFalse: [^nil].
- ^self vmParameterAt: 49!

Item was changed:
----- Method: SmalltalkImage>>maxExternalSemaphores: (in category 'vm parameters') -----
maxExternalSemaphores: aSize
"Changes the size of table where external semaphores are registered.
The size can only grow, and will always be the next power of two larger than the parameter.

Setting this at any time other than start-up can potentially lose requests.
i.e. during the realloc new storage is allocated,
the old contents are copied and then pointers are switched.
Requests occurring during copying won't be seen if they occur to indices already copied.
The intended use is to set the table to some adequate maximum at start-up"

- self isRunningCog ifFalse: [^0].
"The vm-header field is a short, maximum 64k entries. Well, on most platforms anyways "
(aSize < 0 or: [aSize > 16rFFFF]) ifTrue: [^self error: 'maxExternalSemaphores: is limited to 16rFFFF'].
+ ^[self vmParameterAt: 49 put: aSize] on: Error do: [0].!
- ^self vmParameterAt: 49 put: aSize!

Item was changed:
----- Method: SmalltalkImage>>processPreemptionYields (in category 'system attributes') -----
processPreemptionYields
"Answer whether the VM causes a process to yield on process preemption,
i.e. to put a preempted process at the back of its run queue. If the parameter
is unavailable (non-Cog VMs) or bit 2 (4) is 0 then preemption yields."

+ ^((self vmParameterAt: 48 default: [^true]) allMask: 4) not
+ !
- ^(([self vmParameterAt: 48]
- on: Error
- do: [:ex| ^true]) allMask: 4) not!

Item was changed:
----- Method: SmalltalkImage>>sendMouseWheelEvents (in category 'system attributes') -----
sendMouseWheelEvents
"The Cog VM can be instructed to deliver mouse wheel events as mouse wheel events.
By default mouse wheel events are mapped to arrow events.
This flag persists across snapshots, stored in the image header."

+ ^(self vmParameterAt: 48 default: 0) anyMask: 32!
- ^(self vmParameterAt: 48) anyMask: 32!

Item was changed:
----- Method: SmalltalkImage>>supportsMultipleBytecodeSets (in category 'system attributes') -----
supportsMultipleBytecodeSets
"Answer whether the VM supports multiple bytecodeSets."
"SmalltalkImage current supportsMultipleBytecodeSets"

+ ^(self vmParameterAt: 65 default: nil)
- ^(self vmParameterAt: 65)
ifNil: [false]
ifNotNil:
[:param| "In older VMs this is a boolean answering the vm-internal MULTIPLE_BYTECODE_SETS define"
param isInteger "In newer VMs it is a set of integer flags, bit 0 of which is the vm-internal MULTIPLE_BYTECODE_SETS define"
ifTrue: [param anyMask: 1]
ifFalse: [param]]!

Item was changed:
----- Method: SmalltalkImage>>supportsQueueingFinalization (in category 'system attributes') -----
supportsQueueingFinalization
"Answer whether the VM queues individual weak arrays for finalization, instead
of signalling the finalization semaphore once for all arrays and having the
WeakRegistry mechanism finalize all weak arrays, whether they need to or not."
"SmalltalkImage current supportsQueueingFinalization"

+ ^(self vmParameterAt: 48 default: 0) anyMask: 16!
- ^(self vmParameterAt: 48) anyMask: 16!

Item was changed:
----- Method: SmalltalkImage>>supportsReadOnlyObjects (in category 'system attributes') -----
supportsReadOnlyObjects
"Answer whether the VM observes the per-object read-only flag and consequently aborts
writes to inst vars of, and fails primitives that attempt to modify, read-only objects."
"SmalltalkImage current supportsReadOnlyObjects"

+ ^(self vmParameterAt: 65 default: nil)
- ^(self vmParameterAt: 65)
ifNil: [false]
ifNotNil:
[:param| "In older VMs this is a boolean answering the vm-internal MULTIPLE_BYTECODE_SETS define"
param isInteger "In newer VMs it is a set of integer flags, bit 1 of which is the vm-internal IMMUTABILITY define"
ifTrue: [param anyMask: 2]
ifFalse: [false]]!

Item was added:
+ ----- Method: SmalltalkImage>>vmParameterAt:default: (in category 'vm parameters') -----
+ vmParameterAt: parameterIndex default: defaultValueOrBlock
+ "Answer a VM parameter or defaultValueOrBlock value if out of range."
+
+ ^defaultValueOrBlock value!

Item was changed:
----- Method: SmalltalkImage>>wordSize (in category 'image') -----
wordSize
"Answer the size in bytes of an object pointer or word in the object memory.
The value does not change for a given image, but may be modified by a SystemTracer
when converting the image to another format. The value is cached in WordSize to
avoid the performance overhead of repeatedly consulting the VM."

"Smalltalk wordSize"

+ ^ WordSize ifNil: [WordSize := self vmParameterAt: 40 default: 4]!
- ^ WordSize ifNil: [WordSize := [self vmParameterAt: 40] on: Error do: [4]]!





Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: System-dtl.1209.mcz

David T. Lewis
On Tue, Jan 05, 2021 at 09:06:16AM -0800, Eliot Miranda wrote:

>
>
> > On Jan 5, 2021, at 4:18 AM, Marcel Taeumel <[hidden email]> wrote:
> >
> > ???
> > Hi Dave.
> >
> > > Provide vmParameterAt:default: to handle primitive failure on reading VM parameters.
> >
> > Hmm... #vmParameterAt:ifAbsent: would be "more idiomatic"?
>
> or vmParameterAt:ifFail:
>
> No matter which selector I like this very much.  It???s a good idea Dave.  Just upload to trunk what you like best.
>

Thanks, I will follow up in the next day or so.

The inbox submission had an embarrassing error, so I already moved
it to treated. I'll tidy it up and resubmit to trunk.

Dave

Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: System-dtl.1209.mcz

David T. Lewis
In reply to this post by marcel.taeumel
On Tue, Jan 05, 2021 at 01:17:50PM +0100, Marcel Taeumel wrote:
> Hi Dave.
>
> >??Provide vmParameterAt:default: to handle primitive failure on reading VM parameters.
>
> Hmm... #vmParameterAt:ifAbsent: would be "more idiomatic"?
>

I was not sure about this either. It tried "ifAbsent" and "onError"
but ifAbsent sounded too much like collection behavior, and onError
just looked strange. In the end I decided that what we are really
trying to do is supply a default in the case of a VM that does not know
about a VM parameter, so that's how I ended up with vmParameterAt:default:

Dave


Reply | Threaded
Open this post in threaded view
|

Re: The Inbox: System-dtl.1209.mcz

codefrau
On Tue, Jan 5, 2021 at 9:24 AM David T. Lewis <[hidden email]> wrote:
On Tue, Jan 05, 2021 at 01:17:50PM +0100, Marcel Taeumel wrote:
> Hi Dave.
>
> >??Provide vmParameterAt:default: to handle primitive failure on reading VM parameters.
>
> Hmm... #vmParameterAt:ifAbsent: would be "more idiomatic"?
>

I was not sure about this either. It tried "ifAbsent" and "onError"
but ifAbsent sounded too much like collection behavior, and onError
just looked strange. In the end I decided that what we are really
trying to do is supply a default in the case of a VM that does not know
about a VM parameter, so that's how I ended up with vmParameterAt:default:

Dave

I had the same reaction though, especially since you allow passing a block which is evaluated only if the primitive fails.

Maybe thinking of it as being equivalent to 

   Smalltalk getVMParameters at: index ifAbsent: [...]

would make the "... ifAbsent:" more palatable?

Vanessa