[Vm-dev] Re: [Pharo-dev] Initial versions for OSWindow and Woden

Ronie Salgado roniesalg at gmail.com
Sat May 31 20:04:53 UTC 2014


Sorry about the missing VM source. I am uploading the changes into my
github repository: https://github.com/ronsaldo/pharo-vm

As for the details of loading a OSWindow into a Pharo image, there is a
fogbugz issue with all the required instructions.

Now, OSWindow relies heavily on NativeBoost, so as for Squeak integration
they would need to support it. Now, I am also working on a new FFI, which
will allows NB to have a better integration with the existing VM. With the
FFI iam working on, it should be possible to use NB for when machine code
generation is forbidden. In this project I am having discussions and
working with Igor, Esteban, Clement and Eliot.

Currently OSWindow is mostly for Pharo, but it should be possible to have
it for more Smalltalks.

As for the existing VM windows, we removed it completely for Linux with
Igor. In Pharo, we don't want to maintain that old code in C, because is
huge, really hard to understand and it has his limitations. For example,
with the old VM window we have to pass mouse wheel events as if there
keyboard presses. Windows and Mac OS X are next.

In OSWindow, we receive the raw events that SDL2 or an operating system
specific backend provide us. Later I will try it with a joystick.

------------------
-- VM Changes
----------------------

The SDL2Display plugin has the following code:

extern struct VirtualMachine* interpreterProxy;
extern void setIoProcessEventsHandler(void * handler);

static int inited = 0;
static int inputSemaphoreIndex = 0;

/**
 * Called by the VM heartbeat if installed, to check for the presence of
events.
 */
static void ioCheckForEvents() {
    if (inited) {
        SDL_PumpEvents();
        if (SDL_HasEvents(SDL_FIRSTEVENT, SDL_LASTEVENT)) {
            interpreterProxy->signalSemaphoreWithIndex(inputSemaphoreIndex);
        }
    }
}

void setSDL2InputSemaphoreIndex(int semaIndex) {
    inited = 1;
    inputSemaphoreIndex = semaIndex;
    setIoProcessEventsHandler(&ioCheckForEvents);
}


The only change needed for existing platform specific driver is to
implement:
extern void setIoProcessEventsHandler(void * handler);

In Windows, I just had to add:

/*sqWin32Window.c*/

/*Line 179*//**
 * HACK: Hook for SDL2.
 */
static void (*ioCheckForEventsHooks)(void);

EXPORT(void) setIoProcessEventsHandler(void * handler) {
    ioCheckForEventsHooks = (void (*)())handler;
}

/*Line 1586 */        /* HACK: for SDL2.*/
        if(ioCheckForEventsHooks)
            ioCheckForEventsHooks();


I called them hacks, because a proper way means killing that code. As for
the VM Windows code, it gives me the impression of being unnecessarily
complex and to also have performance issues. In my laptop in Linux it takes
about one minute to load NBOpenGL into a new image, but in Windows it takes
about one hour, in the same machine.

It could be my impression, but is window using multiples thread, one for IO
and another for the actual VM?

Greetings,
Ronie


2014-05-31 11:39 GMT-04:00 phil at highoctane.be <phil at highoctane.be>:

> Ronie,
>
> Throw the VM sources somewhere so that I can try this on CentOS. Glibc
> 2_15 issue...
>
> Phil
>
>
> On Sat, May 31, 2014 at 5:12 PM, Laurent Laffont <
> laurent.laffont at gmail.com> wrote:
>
>>  Hi,
>>
>>
>>
>> Seems to work well on my linux machine too (Arch 64). The main Pharo
>> window is better handled by KDE (don't know why, but nice side effect :)
>>
>>
>>
>> Laurent
>>
>>
>>
>> Le samedi 31 mai 2014, 05:54:52 Ronie Salgado a écrit :
>>
>> > Hello There,
>>
>> >
>>
>> > I have been working in OSWindow, which is a cross platform API for
>> dealing
>>
>> > with native operating system windows. This API requires using a custom
>> VM
>>
>> > and the library SDL2.
>>
>> >
>>
>> > With this API, even the main Pharo window is handled almost completely
>> in
>>
>> > image side using NativeBoost.
>>
>> >
>>
>> > The only support required from the VM is a small periodical check in the
>>
>> > heartbeat about the presence of events. This no more than 10 lines of
>> code.
>>
>> >
>>
>> > This is currently working very well in my Linux machine, so I need to
>> start
>>
>> > testing this stuff.
>>
>> >
>>
>> > For Windows, soon I will be building the custom VM. My last built was
>> very
>>
>> > dirty and I want to do something more clean.
>>
>> >
>>
>> > For Mac OS X, I don't have one for testing. But Alex is going allow me
>> to
>>
>> > borrow one for some time. So be patience.
>>
>> >
>>
>> > As for Woden, it is a new 3D graphics engine that I started making. This
>>
>> > one requires currently support of OSWindow and also shows some cool
>> stuffs.
>>
>> >
>>
>> > As for prebuilt versions of the VM with OSWindow support along with
>>
>> > preloaded images for both, OSWindow and Woden. And screenshots.
>>
>> >
>>
>> > Well, I am putting them here: http://ronie.cl/OSWindow/
>>
>> >
>>
>> > Greetings,
>>
>> > Ronie
>>
>>
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20140531/af8adf1b/attachment.htm


More information about the Vm-dev mailing list