<div dir="ltr"><div style>I was looking at the following primitiveFileRead because I wanted to extract some code. I do not see why objects should move during the primitive execution... And I do not see why is this check only made in this primitive (and the threadedFFI ones...).</div>
<div style><br></div><div style>Does someone have a clue?</div><div style><br></div><div style>Thanks,</div><div style>Guille</div><div><br></div><div>primitiveFileRead</div><div><span class="" style="white-space:pre">        </span>&lt;export: true&gt;</div>
<div><span class="" style="white-space:pre">        </span>| retryCount count startIndex array file elementSize bytesRead |</div><div><span class="" style="white-space:pre">        </span>&lt;var: &#39;file&#39; type: #&#39;SQFile *&#39;&gt;</div>
<div><span class="" style="white-space:pre">        </span>&lt;var: &#39;count&#39; type: #&#39;size_t&#39;&gt;</div><div><span class="" style="white-space:pre">        </span>&lt;var: &#39;startIndex&#39; type: #&#39;size_t&#39;&gt;</div>
<div><span class="" style="white-space:pre">        </span>&lt;var: &#39;elementSize&#39; type: #&#39;size_t&#39;&gt;</div><div><br></div><div><span class="" style="white-space:pre">        </span>retryCount<span class="" style="white-space:pre">        </span>:= 0.</div>
<div><span class="" style="white-space:pre">        </span>count<span class="" style="white-space:pre">                </span>:= interpreterProxy positive32BitValueOf: (interpreterProxy stackValue: 0).</div><div><span class="" style="white-space:pre">        </span>startIndex<span class="" style="white-space:pre">        </span>:= interpreterProxy positive32BitValueOf: (interpreterProxy stackValue: 1).</div>
<div> </div><div><span class="" style="white-space:pre">        </span>[array<span class="" style="white-space:pre">                </span>:= interpreterProxy stackValue: 2.</div><div><span class="" style="white-space:pre">        </span> file<span class="" style="white-space:pre">                        </span>:= self fileValueOf: (interpreterProxy stackValue: 3).</div>
<div><br></div><div><span class="" style="white-space:pre">        </span> (interpreterProxy failed</div><div><span class="" style="white-space:pre">        </span> &quot;buffer can be any indexable words or bytes object except CompiledMethod&quot;</div>
<div><span class="" style="white-space:pre">        </span> or: [(interpreterProxy isWordsOrBytes: array) not]) ifTrue:</div><div><span class="" style="white-space:pre">                </span>[^interpreterProxy primitiveFailFor: PrimErrBadArgument].</div>
<div><br></div><div><span class="" style="white-space:pre">        </span> elementSize := (interpreterProxy isWords: array) ifTrue: [4] ifFalse: [1].</div><div><span class="" style="white-space:pre">        </span> (startIndex &gt;= 1</div>
<div><span class="" style="white-space:pre">        </span>  and: [(startIndex + count - 1) &lt;= (interpreterProxy slotSizeOf: array)]) ifFalse:</div><div><span class="" style="white-space:pre">                </span>[^interpreterProxy primitiveFailFor: PrimErrBadIndex].</div>
<div><br></div><div><span class="" style="white-space:pre">        </span> &quot;Note: adjust startIndex for zero-origin indexing&quot;</div><div><span class="" style="white-space:pre">        </span> bytesRead := self</div><div><span class="" style="white-space:pre">                                        </span>sqFile: file</div>
<div><span class="" style="white-space:pre">                                        </span>Read: count * elementSize</div><div><span class="" style="white-space:pre">                                        </span>Into: (self cCoerce: (interpreterProxy firstIndexableField: array) to: #&#39;char *&#39;)</div>
<div><span class="" style="white-space:pre">                                        </span>At: (startIndex - 1) * elementSize.</div><div><span class="" style="white-space:pre">        </span> <b>interpreterProxy primitiveFailureCode = PrimErrObjectMayMove</b></div>
<div><b><span class="" style="white-space:pre">        </span> and: [(retryCount := retryCount + 1) &lt;= 2] &quot;Two objects, the file and the array can move&quot;</b>] whileTrue:</div><div><span class="" style="white-space:pre">                </span>[interpreterProxy</div>
<div><span class="" style="white-space:pre">                        </span>tenuringIncrementalGC;</div><div><span class="" style="white-space:pre">                        </span>primitiveFailFor: PrimNoErr].</div><div><span class="" style="white-space:pre">        </span>interpreterProxy failed ifFalse:</div>
<div><span class="" style="white-space:pre">                </span>[interpreterProxy</div><div><span class="" style="white-space:pre">                        </span>pop: 5 &quot;pop rcvr, file, array, startIndex, count&quot;</div><div><span class="" style="white-space:pre">                        </span>thenPush:(interpreterProxy integerObjectOf: bytesRead // elementSize)  &quot;push # of elements read&quot;]</div>
</div>