<body><div id="__MailbirdStyleContent" style="font-size: 10pt;font-family: Arial;color: #000000;text-align: left" dir="ltr">
Hi Dave.<div><br></div><div>> <span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px">Provide vmParameterAt:default: to handle primitive failure on reading VM parameters.</span></div><div><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px"><br></span></div><div><span style="font-family: Arial, Helvetica, sans-serif;font-size: 13px">Hmm... #vmParameterAt:ifAbsent: would be "more idiomatic"?</span></div><div><br></div><div>Best,</div><div>Marcel</div><div class="mb_sig"></div><blockquote class='history_container' type='cite' style='border-left-style:solid;border-width:1px; margin-top:20px; margin-left:0px;padding-left:10px;'>
<p style='color: #AAAAAA; margin-top: 10px;'>Am 28.12.2020 16:50:22 schrieb commits@source.squeak.org <commits@source.squeak.org>:</p><div style='font-family:Arial,Helvetica,sans-serif'>David T. Lewis uploaded a new version of System to project The Inbox:<br>http://source.squeak.org/inbox/System-dtl.1209.mcz<br><br>==================== Summary ====================<br><br>Name: System-dtl.1209<br>Author: dtl<br>Time: 28 December 2020, 10:50:06.875257 am<br>UUID: 25efba24-561f-4c53-97d9-95438edfce90<br>Ancestors: System-eem.1207<br><br>Provide vmParameterAt:default: to handle primitive failure on reading VM parameters.<br>Supply default parameter values to mock possibly missing elements in the parameters array.<br>Remove two unnecessary isRunningCog checks and an ifNotNil:<br>Remove inappropriate halt in sendMouseWheelEvents:<br>Let supportsMultipleBytecodeSets and supportsReadOnlyObjects work on any VM.<br><br>=============== Diff against System-eem.1207 ===============<br><br>Item was changed:<br> ----- Method: SmalltalkImage>>isRunningCog (in category 'system attributes') -----<br> isRunningCog<br> "Answers if we're running on a Cog VM (JIT or StackInterpreter)"<br> <br>+ ^(self vmParameterAt: 42 default: nil)<br>- ^(self vmParameterAt: 42)<br> ifNil: [false]<br> ifNotNil: [:numStackPages| numStackPages > 0]!<br><br>Item was changed:<br> ----- Method: SmalltalkImage>>isRunningCogit (in category 'system attributes') -----<br> isRunningCogit<br> "Answers if we're running on the Cog JIT"<br> <br>+ ^(self vmParameterAt: 46 default: nil)<br>- ^(self vmParameterAt: 46)<br> ifNil: [false]<br> ifNotNil: [:machineCodeZoneSize| machineCodeZoneSize > 0]!<br><br>Item was changed:<br> ----- Method: SmalltalkImage>>lowSpaceThreshold (in category 'memory space') -----<br> lowSpaceThreshold <br> "Answer the low space threshold. When the amount of free memory (after garbage collection)<br> falls below this limit, the system is in serious danger of completely exhausting memory and<br> crashing. This limit should be made high enough to allow the user open a debugger to diagnose<br> a problem or to save the image. In a stack-based VM such as Cog contexts for activations in<br> the stack zone will have to be created as the debugger opens, requiring additional headroom."<br> <br> | slotsForDebugger slotsForContextsOnStackPages |<br> slotsForDebugger := 65536. "Arbitrary guess"<br> slotsForContextsOnStackPages :=<br>+ (self vmParameterAt: 42 default: nil)<br>- (self vmParameterAt: 42)<br> ifNil: [0]<br> ifNotNil:<br> [:numStackPages| | headerSize numActivationsPerPage maxContextSize |<br> numActivationsPerPage := 40. "Design goal of the Cog & Stack VMs"<br> headerSize := 8 / self wordSize. "64-bits for Spur"<br> maxContextSize := thisContext class instSize + CompiledMethod fullFrameSize + headerSize.<br> numStackPages * numActivationsPerPage * maxContextSize].<br> ^slotsForDebugger + slotsForContextsOnStackPages * self wordSize!<br><br>Item was changed:<br> ----- Method: SmalltalkImage>>maxExternalSemaphores (in category 'vm parameters') -----<br> maxExternalSemaphores<br>+ "The size of table where external semaphores are registered. Only in Cog,<br>+ other VMs are expected to answer nil if present in the parameters array."<br>+ ^self vmParameterAt: 49 default: nil!<br>- "The size of table where external semaphores are registered. Only in Cog"<br>- self isRunningCog ifFalse: [^nil].<br>- ^self vmParameterAt: 49!<br><br>Item was changed:<br> ----- Method: SmalltalkImage>>maxExternalSemaphores: (in category 'vm parameters') -----<br> maxExternalSemaphores: aSize<br> "Changes the size of table where external semaphores are registered. <br> The size can only grow, and will always be the next power of two larger than the parameter.<br> <br> Setting this at any time other than start-up can potentially lose requests.<br> i.e. during the realloc new storage is allocated,<br> the old contents are copied and then pointers are switched. <br> Requests occurring during copying won't be seen if they occur to indices already copied. <br> The intended use is to set the table to some adequate maximum at start-up"<br> <br>- self isRunningCog ifFalse: [^0].<br> "The vm-header field is a short, maximum 64k entries. Well, on most platforms anyways "<br> (aSize < 0 or: [aSize > 16rFFFF]) ifTrue: [^self error: 'maxExternalSemaphores: is limited to 16rFFFF'].<br>+ ^[self vmParameterAt: 49 put: aSize] on: Error do: [0].!<br>- ^self vmParameterAt: 49 put: aSize!<br><br>Item was changed:<br> ----- Method: SmalltalkImage>>processPreemptionYields (in category 'system attributes') -----<br> processPreemptionYields<br> "Answer whether the VM causes a process to yield on process preemption,<br> i.e. to put a preempted process at the back of its run queue. If the parameter<br> is unavailable (non-Cog VMs) or bit 2 (4) is 0 then preemption yields."<br> <br>+ ^((self vmParameterAt: 48 default: [^true]) allMask: 4) not<br>+ !<br>- ^(([self vmParameterAt: 48]<br>- on: Error<br>- do: [:ex| ^true]) allMask: 4) not!<br><br>Item was changed:<br> ----- Method: SmalltalkImage>>sendMouseWheelEvents (in category 'system attributes') -----<br> sendMouseWheelEvents<br> "The Cog VM can be instructed to deliver mouse wheel events as mouse wheel events.<br> By default mouse wheel events are mapped to arrow events.<br> This flag persists across snapshots, stored in the image header."<br> <br>+ ^(self vmParameterAt: 48 default: 0) anyMask: 32!<br>- ^(self vmParameterAt: 48) anyMask: 32!<br><br>Item was changed:<br> ----- Method: SmalltalkImage>>supportsMultipleBytecodeSets (in category 'system attributes') -----<br> supportsMultipleBytecodeSets<br> "Answer whether the VM supports multiple bytecodeSets."<br> "SmalltalkImage current supportsMultipleBytecodeSets"<br> <br>+ ^(self vmParameterAt: 65 default: nil)<br>- ^(self vmParameterAt: 65)<br> ifNil: [false]<br> ifNotNil:<br> [:param| "In older VMs this is a boolean answering the vm-internal MULTIPLE_BYTECODE_SETS define"<br> param isInteger "In newer VMs it is a set of integer flags, bit 0 of which is the vm-internal MULTIPLE_BYTECODE_SETS define"<br> ifTrue: [param anyMask: 1]<br> ifFalse: [param]]!<br><br>Item was changed:<br> ----- Method: SmalltalkImage>>supportsQueueingFinalization (in category 'system attributes') -----<br> supportsQueueingFinalization<br> "Answer whether the VM queues individual weak arrays for finalization, instead<br> of signalling the finalization semaphore once for all arrays and having the<br> WeakRegistry mechanism finalize all weak arrays, whether they need to or not."<br> "SmalltalkImage current supportsQueueingFinalization"<br> <br>+ ^(self vmParameterAt: 48 default: 0) anyMask: 16!<br>- ^(self vmParameterAt: 48) anyMask: 16!<br><br>Item was changed:<br> ----- Method: SmalltalkImage>>supportsReadOnlyObjects (in category 'system attributes') -----<br> supportsReadOnlyObjects<br> "Answer whether the VM observes the per-object read-only flag and consequently aborts<br> writes to inst vars of, and fails primitives that attempt to modify, read-only objects."<br> "SmalltalkImage current supportsReadOnlyObjects"<br> <br>+ ^(self vmParameterAt: 65 default: nil)<br>- ^(self vmParameterAt: 65)<br> ifNil: [false]<br> ifNotNil:<br> [:param| "In older VMs this is a boolean answering the vm-internal MULTIPLE_BYTECODE_SETS define"<br> param isInteger "In newer VMs it is a set of integer flags, bit 1 of which is the vm-internal IMMUTABILITY define"<br> ifTrue: [param anyMask: 2]<br> ifFalse: [false]]!<br><br>Item was added:<br>+ ----- Method: SmalltalkImage>>vmParameterAt:default: (in category 'vm parameters') -----<br>+ vmParameterAt: parameterIndex default: defaultValueOrBlock<br>+ "Answer a VM parameter or defaultValueOrBlock value if out of range."<br>+ <primitive: 254=""><br>+ ^defaultValueOrBlock value!<br><br>Item was changed:<br> ----- Method: SmalltalkImage>>wordSize (in category 'image') -----<br> wordSize<br> "Answer the size in bytes of an object pointer or word in the object memory.<br> The value does not change for a given image, but may be modified by a SystemTracer<br> when converting the image to another format. The value is cached in WordSize to<br> avoid the performance overhead of repeatedly consulting the VM."<br> <br> "Smalltalk wordSize"<br> <br>+ ^ WordSize ifNil: [WordSize := self vmParameterAt: 40 default: 4]!<br>- ^ WordSize ifNil: [WordSize := [self vmParameterAt: 40] on: Error do: [4]]!<br><br><br></primitive:></div></blockquote>
</div></body>