reefedjib at yahoo.com
Sat Oct 13 22:55:09 UTC 2007
On Oct 13, 2007, at 2:52 PM, tim Rowledge wrote:
> On 13-Oct-07, at 2:02 PM, Robert Withers wrote:
>> Ok, this gets me into the CompiledMethod, with which I have very
>> little experience. I did find that the 'source' toggle button in
>> a browser has a bytecodes option. It didn't help me much, seeing
>> the bytecodes. I am trying to find a way to invoke a bytecode
>> primitive from the image.
I will do my best to answer this seemingly innocuous, simple
question. The short answer is that I am reviving my efforts at
incorporating eventual references, a la SqueakElib, in the Squeak
image. This entails making the VM eventual safe.
The longer answer forgets all of the networking work I did, which I
managed to leverage into SSL and SSH. I want to allow some object
references to be eventual and thereby defer method evaluation to some
future time after invocation. This works ok for receivers that are
eventual (4 eventual + 5) -> promise that later evaluates #+ and
resolves to eventual(9). In this case, I intercept the msg send and
send it eventually.
The problem I perceive I have is when we have (4 + 5 eventual).
There is nothing that intercepts it. We can't have eventual
references which are used as arguments to indexed or named
primitives. I am trying to fix this. It's fuzzy, but there are
several issues I am working through here, which I have just now named
the intercept problem, the invocation problem, the inoculation problem.
The intercept problem: modify all bytecode/primitive functions to
check arguments on the stack for eventual references (ugh), if
eventual arg exists, contaminate the receiver as an eventual ref
(#becomeForward:), package the args and the primitiveIndex (call it
an EventualPrimitiveInvocation) and eventally send to an eventual
join of all eventual args + receiver. It runs when all eventual refs
are resolved. It gets fuzzy here, but the eventual contagion will
spread to all objects using an eventual ref to maintain message
order. Return a promise ref on the stack for the eventual result of
this future computation.
The invocation problem: the issue I am exploring in this email. I
need to unwrap local eventual refs (not remote eventual refs or
promises) to use as arguments. I need to invoke the bytecode/
primitive prim where interception occurred. I need to resolve the
promise created from the intercept.
The inoculation problem: when the system has finished eventual
sending to system contaminated eventual ref, then inoculate the ref
back to a non-eventual reference.
I hope this makes some sense.
>> So, for instance, given 2 SmallIntegers in hand, I want to run
>> bytecodePrimAdd without running #+.
> Err, given a bytecode named 'bytecodePrimAdd' what would you expect
> it to do? Why, it runs the same code that primitiveAdd does, modulo
> the bytecode version knowing that it will be inlined into the big
> bytecode loop. And oddly enough, that very fact means that if you
> *did* manage to invoke it by some devious magic, it would cause
> some interesting issue because you'd be affecting the in-loop
> values of stack pointer etc, which could cause all sorts of fun.
Ok, I am confused as to which gets called. #primitiveAdd is in the
primitive table as number 1, so I guess that shows up in the mcache
for primitiveIndex 1, and thus gets invoked. Is it right? I would
be happy to run #primitiveAdd, but wouldn't it also have fun with
affecting values of the stack pointer and such?
>> Is there a way to do this? I am digging through
>> #lookupInMethodCacheSel:class: at the moment to see how primitive
>> dispatch works.
> Why? What on earth are you doing? Message sending is designed to be
> atomic and trying to insert yourself in the middle is likely to go
> boom. You really are in danger of branching to the Halt and Catch
> Fire instruction...
I think I need a primitive of my own to marshall the stack args, so
method lookup and activate the primitive. On eventual ref
resolution, I can call a method with this primitiveIndex, where the
receiver is the EventualPrimitiveInvocation obj.
> tim Rowledge; tim at rowledge.org; http://www.rowledge.org/tim
> I came, I saw, I deleted all your files.
More information about the Squeak-dev