The Trunk: System-dtl.1210.mcz

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

The Trunk: System-dtl.1210.mcz

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

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

Name: System-dtl.1210
Author: dtl
Time: 6 January 2021, 4:59:31.092128 pm
UUID: a704d749-4986-46f9-aa2f-faa8bb4ea5e1
Ancestors: System-eem.1207

Provide vmParameterAt:ifAbsent: to handle primitive failure on reading VM parameters.
Supply default parameter values to mock possibly missing elements in the parameters array.

=============== 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 ifAbsent: 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 ifAbsent: 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 ifAbsent: 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 ifAbsent: 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 ifAbsent: [^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 ifAbsent: 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 ifAbsent: 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 ifAbsent: 0) anyMask: 16!
- ^(self vmParameterAt: 48) anyMask: 16!

Item was changed:
  ----- Method: SmalltalkImage>>supportsQueueingFinalization: (in category 'system attributes') -----
  supportsQueueingFinalization: aBoolean
  "Determine 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.
  This flag persists across snapshots, stored in the image header."
  "SmalltalkImage current supportsQueueingFinalization: true"
 
+ self vmParameterAt: 48 put: ((self vmParameterAt: 48 ifAbsent: [^false]) bitClear: 16) + (aBoolean ifTrue: [16] ifFalse: [0])!
- self vmParameterAt: 48 put: ((self vmParameterAt: 48) bitClear: 16) + (aBoolean ifTrue: [16] ifFalse: [0])!

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 ifAbsent: 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:ifAbsent: (in category 'vm parameters') -----
+ vmParameterAt: parameterIndex ifAbsent: defaultValueOrBlock
+ "Answer a VM parameter or defaultValueOrBlock value if out of range."
+ ^ [self vmParameterAt: parameterIndex]
+ on: Error
+ do: [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 ifAbsent: 4]!
- ^ WordSize ifNil: [WordSize := [self vmParameterAt: 40] on: Error do: [4]]!