[Vm-beginners] Calling VM C functions from cogged primitives

Eliot Miranda eliot.miranda at gmail.com
Mon Jun 10 22:45:52 UTC 2019


Hi Leandro,

On Mon, Jun 10, 2019 at 10:08 AM lgvidal <lgvidal at gmail.com> wrote:

> Hello!
>
> We've been working with storing some object metadata on instance variable
> assignments (i.e. the assigned object's class). Doing so in the "Stack VM"
> meant adding some code to certain primitives, we now find ourselves failing
> to extend this functionality to the Cog VM (StackToRegisterMappingCogit).
>
> As a proof of concept, we decided to use non-inlined C versions of the
> methods we defined for the Stack VM in the cogged primitives. We tried
> defining a new trampoline (with 3 arguments and no return) for this and
> then
> generating calls to it from the cogged primitive generators, but to no
> avail.
>

Have you looked at the delivery of the #attemptToAssign:withIndex: message
used to report a read-only object modification error?  his code works and
has been in production in both the StackInterpreter and the Cogit for over
a year now.

Browse references to VMBasicConstants' #IMMUTABILITY class var, e.g.

self systemNavigation browseAllCallsOn: (VMBasicConstants bindingOf:
#IMMUTABILITY)


> Is this the way to go or is there an easier way to call a VM C function
> from
> a cogged primitive?
>

This is the way to go.  But it has to be done just so :-).  Follow the
scheme used for  #attemptToAssign:withIndex: and you should do OK.


> Is there any documentation on how to define and use a new trampoline?
>

No, only the examples in the system.  Some errors should be straight-toward
to fix; the various implementations of numTrampolines must compute a large
enough trampoline table.  Other errors, such as failure to provide a valid
continuation on returning from the "send back" may be more difficult.  I'm
here to help.


> Thanks in advance!
> Leandro
>
> --
> Sent from: http://forum.world.st/Smalltalk-VM-Beginners-f3068605.html
> _______________________________________________
> VM-beginners mailing list
> VM-beginners at lists.squeakfoundation.org
> http://lists.squeakfoundation.org/mailman/listinfo/vm-beginners
>


-- 
_,,,^..^,,,_
best, Eliot
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-beginners/attachments/20190610/0809f4ef/attachment.html>


More information about the VM-beginners mailing list