<div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote">On Tue, May 2, 2017 at 12:50 AM, Eliot Miranda <span dir="ltr"><<a href="mailto:eliot.miranda@gmail.com" target="_blank">eliot.miranda@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"> <br><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/<wbr>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-><wbr>displayObject(); // Form</div><div><br></div><div>    CGContextRef context = (CGContextRef)[[<wbr>NSGraphicsContext currentContext] graphicsPort];</div><div>    CGContextSaveGState(context);</div><div><br></div><div>    int width = interpreterProxy-><wbr>positive32BitValueOf(<wbr>interpreterProxy-><wbr>fetchPointerofObject(1, form));</div><div>    int height = interpreterProxy-><wbr>positive32BitValueOf(<wbr>interpreterProxy-><wbr>fetchPointerofObject(2, form));</div><div>    sqInt formBits = interpreterProxy-><wbr>fetchPointerofObject(0, form);   // bits</div><div>    void* bits = (void*)interpreterProxy-><wbr>firstIndexableField(formBits); // bits</div><div>    int bitSize = interpreterProxy->byteSizeOf(<wbr>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></div></blockquote><div><br></div><div>Wouldn't the display bits still be moved around during GC? Nothing the image can do about that.</div><div><br></div><div>You could cache the values in the beDisplay primitive, but I don't see how that would change anything.</div><div><br></div><div>The original VM was single-threaded so this was not an issue. Are you trying to make the GC concurrent? I bet there are many many places that would break ... Maybe you need to temporarily pin the involved objects?</div><div><br></div><div>- Bert - </div></div></div></div>