<div dir="ltr">Tim, John, Bert, et al,<div><br></div><div> if you look at e.g. resizing code in the platforms/iOS code (in e.g. platforms/iOS//vm/OSX/sqSqueakOSXOpenGLView.m) the code accesses the display bits by looking up the display object installed via primitiveBeDisplay in the specialObjectsArray:</div><div><br></div><div><div>- (void) performDraw: (CGRect)rect {</div><div> sqInt form = interpreterProxy->displayObject(); // Form</div><div><br></div><div> CGContextRef context = (CGContextRef)[[NSGraphicsContext currentContext] graphicsPort];</div><div> CGContextSaveGState(context);</div><div><br></div><div> int width = interpreterProxy->positive32BitValueOf(interpreterProxy->fetchPointerofObject(1, form));</div><div> int height = interpreterProxy->positive32BitValueOf(interpreterProxy->fetchPointerofObject(2, form));</div><div> sqInt formBits = interpreterProxy->fetchPointerofObject(0, form); // bits</div><div> void* bits = (void*)interpreterProxy->firstIndexableField(formBits); // bits</div><div> int bitSize = interpreterProxy->byteSizeOf(formBits);</div><div> int bytePerRow = 4*width;</div><div><br></div><div>This is really unsafe. If it gets called while the VM is compacting, or doing a become, then potentially boom!</div><div><br></div><div>Storing the display in the specialObjectsArray stops it form being GCed, but it doesn't stop it moving around, and it doesn't stop a become altering the location of the objects surrounding it, etc.</div><div><br></div><div>Surely a better approach is to inform the VM of the location, depth and extent of the bits via some ioSetDisplayBits function and then cacheing those values somewhere in the VM. Thoughts?</div><div><br></div><div>P.S. John McIntosh tells me that you, Tim R, may have written such code in the past.</div><div><br></div><div class="gmail_signature"><div dir="ltr"><div><span style="font-size:small;border-collapse:separate"><div>_,,,^..^,,,_<br></div><div>best, Eliot</div></span></div></div></div>
</div></div>