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

tim Rowledge tim at rowledge.org
Tue May 2 00:25:52 UTC 2017

Err, yeah, that’s old stuff. So far as I can dredge up from long-term storage RISC OS has not likely problem with this because I have to copy the bits from the Display to the window backing store with a transform (ARGB-> 0BGR)  which means I couldn’t simply extract pixels at any time other than ioShowWindow(). The cost is two copies of the Display bitmap sitting around, which is a bit painful.

This is presumably an issue when a vm has threads for event handling of assorted OS stuff like window changes? Isn’t this something that pinning is supposed to help? And surely the BitMap is just about certain to be in old space?
> On 01-05-2017, at 3:50 PM, Eliot Miranda <eliot.miranda at gmail.com> wrote:
> 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

tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
Strange OpCodes: WK: Write to Keyboard

More information about the Vm-dev mailing list