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
vm-dev@lists.squeakfoundation.org