[Vm-dev] run-time cost of the lookup in the Mac threaded GUI scheme

Eliot Miranda eliot.miranda at gmail.com
Fri Jun 10 16:58:22 UTC 2011


Hi John,  Hi All,

    I'm in Mac OS platform land right now and have become alarmed, possibly
unnecessarily, about the run-time cost of the lookup in the Mac threaded GUI
scheme, e.g. in the following

    void *giLocker;
    int return_value=0;

    giLocker = interpreterProxy->ioLoadFunctionFrom("getUIToLock", "");
    if (giLocker != 0) {
        sqInt foo[7];
        foo[0] = 4;
        foo[1] = (sqInt) MoveWindow;
        foo[2] = (sqInt) windowHandleFromIndex(windowIndex);
        foo[3] = x;
        foo[4] = y;
        foo[5] = true;
        foo[6] = 0;
        ((sqInt (*) (void *)) giLocker)(foo);
        return_value = interpreterProxy->positive32BitIntegerFor(foo[6]);
    }

isn't the lookup in ioLoadFunctionFrom expensive?  Shouldn't we instead be
writing

static void *giLocker = 0;

...
int myfunc()
{
    int return_value=0;

    if (!guiLocker)
        giLocker = interpreterProxy->ioLoadFunctionFrom("getUIToLock", "");
    if (giLocker) {
        sqInt foo[7];
        foo[0] = 4;
        foo[1] = (sqInt) MoveWindow;
        foo[2] = (sqInt) windowHandleFromIndex(windowIndex);
        foo[3] = x;
        foo[4] = y;
        foo[5] = true;
        foo[6] = 0;
        ((sqInt (*) (void *)) giLocker)(foo);
        return_value = interpreterProxy->positive32BitIntegerFor(foo[6]);
    }

?

And if not, why not?

best
Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20110610/ba652e81/attachment.htm


More information about the Vm-dev mailing list