[Vm-dev] Informing the VM that the display bits have changed via primitiveBeDisplay

Eliot Miranda eliot.miranda at gmail.com
Mon May 1 22:50:44 UTC 2017


Tim, John, Bert, et al,

    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:

- (void) performDraw: (CGRect)rect {
    sqInt form = interpreterProxy->displayObject(); // Form

    CGContextRef context = (CGContextRef)[[NSGraphicsContext
currentContext] graphicsPort];
    CGContextSaveGState(context);

    int width =
interpreterProxy->positive32BitValueOf(interpreterProxy->fetchPointerofObject(1,
form));
    int height =
interpreterProxy->positive32BitValueOf(interpreterProxy->fetchPointerofObject(2,
form));
    sqInt formBits = interpreterProxy->fetchPointerofObject(0, form);   //
bits
    void* bits = (void*)interpreterProxy->firstIndexableField(formBits); //
bits
    int bitSize = interpreterProxy->byteSizeOf(formBits);
    int bytePerRow = 4*width;

This is really unsafe.  If it gets called while the VM is compacting, or
doing a become, then potentially boom!

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.

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?

P.S.  John McIntosh tells me that you, Tim R, may have written such code in
the past.

_,,,^..^,,,_
best, Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20170501/94518104/attachment.html>


More information about the Vm-dev mailing list