[Vm-dev] Push/pop considered harmful

Andreas Raab andreas.raab at gmx.de
Tue Mar 3 18:34:31 UTC 2009

Igor Stasenko wrote:
> But it seems that it disabled by default.
> Yes it would be nice to replace push/pops with single method, like
> #primitiveArgumentAt: index
> where index = 0 is receiver
> 1 .. n - rest of arguments.

I think that is a brilliant idea, right in line with what we were doing. 
Finally you can use left-to-right access to method args ;-)

> Another thing, that most primitives never check a number of arguments
> on stack. This is also a potential risk, when you calling primitive
> with wrong number of arguments from a language side.

Right. One thing we can do here is to add a check to primArgAt: that 
just fails the primitive if you try to access arguments that aren't 

> Apart from this, what you suppose to do with primitives who switching
> the active context (entering block closure,signaling semaphore,
> scheduling etc)?
> In this situation you shouldn't try to validate the stack pointer, as
> well as primitive return value is useless.

Yes. push and pop will still be there for internal use - it is only the 
plugins that will get updated. So anything that wants to munge the stack 
in such a way will have to be builtin VM primitive which seems fair to me.

   - Andreas

More information about the Vm-dev mailing list