Hi Eliot. If I compile a StackVM, and I just press the left arrow in a code pane of a OB windows, in a pharo image, I get an asser that fails:<br>(oop & 1) 19202<br><br>Sorry I bother with these asserts, but I am trying to solve the crashes I have and I think starting for the asserts is a good idea.<br>
<br>The assert that fails is in primitiveClosureValue() the part:<br><br>blockClosure = longAt(GIV(stackPointer) + (GIV(argumentCount) * BytesPerWord));<br> /* begin quickFetchInteger:ofObject: */<br> oop = longAt((blockClosure + BaseHeaderSize) + (ClosureNumArgsIndex << ShiftForWord));<br>
assert((oop & 1));<br> numArgs = (oop >> 1);<br> if (!(GIV(argumentCount) == numArgs)) {<br> /* begin primitiveFail */<br> if (GIV(primFailCode) == 0) {<br> GIV(primFailCode) = 1;<br>
}<br> return;<br> } <br><br><br>numArgs results to be a large number (using #printNum: was 718613205), and if I try to do a #printOop: I got a " 0x55aa55aa0x55aa55aa is not on the heap" <br>
<br>Now, of course, the "if (!(GIV(argumentCount) == numArgs)) " fails.<br><br>What it is funny is that I did a #printOop: of blockClosure instVar, and this is what I get: 0x1f59b578: a(n) Association<br><br>Association? WTF ? so...I guess something weird is happening. I continue debugging it..and I noticed that:<br>
<br>- Several classes were called in addition to Association,like Character. These seems to be compact classes and implement #value and #value: ;)<br>- Both, #bytecodePrimValue and #bytecodePrimValueWithArg were not calling #primitiveClosureValue. So, "isBlock" was false...<br>
<br>I tried modifying #bytecodePrimValueWithArg and #bytecodePrimValue this line:<br><br>isBlock := objectMemory is: rcvr instanceOf: <span style="background-color: rgb(255, 255, 51);">ClassBlockClosure</span> compactClassIndex: ClassBlockClosureCompactIndex.<br>
<br>to this one:<br><br>isBlock := objectMemory is: rcvr instanceOf: <span style="background-color: rgb(255, 255, 51);">(self splObj: ClassBlockClosure)</span> compactClassIndex: ClassBlockClosureCompactIndex.<br><br>
WIth this change, at least, the assert doesn't fail anymore. I made progress (maybe). But still, for normal closures, "isBlock" seems to be false. So.....all block values are being managed as a normal send ????<br>
<br>Now, I don't understand why ClassBlockClosureCompactIndex is 0. I think this may be the problem. Why it is not 12? (in Pharo Smalltalk compactClassesArray at: 12 ->>> BlockClosure.)<br>I notice that ObjectMemory >> initializeCompactClassIndices does:<br>
<br> ClassBlockClosureCompactIndex := 0 "12". "Prospective. Currently TranslatedMethod class"<br><br><br>Notice that this ZERO changes the sematic of #is: oop instanceOf: classOop compactClassIndex: compactClassIndex<br>
called from the #bytecodePrimValue and bytecodePrimValueWithArg<br><br>Finally, I changed the mentioned line to this:<br><br>isBlock := objectMemory is: rcvr instanceOf:<span style="background-color: rgb(255, 255, 102);"> (self splObj: ClassBlockClosure) compactClassIndex: 12.</span><br>
<br>and finally, with block closures, it is calling the primitive, and for Association it doesn't fail the assert. ahh and the image doesn't crash ;)<br><br>I don't know if this is a bug, if my solution was ok, nor it impact. Please let me know.<br>
<br>Cheers<br><br>Mariano<br><br><br><br><br>