Calling VM C functions from cogged primitives

Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

Calling VM C functions from cogged primitives

lgvidal
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.

Is this the way to go or is there an easier way to call a VM C function from
a cogged primitive?
Is there any documentation on how to define and use a new trampoline?

Thanks in advance!
Leandro




--
Sent from: http://forum.world.st/Smalltalk-VM-Beginners-f3068605.html
_______________________________________________
VM-beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/vm-beginners
Reply | Threaded
Open this post in threaded view
|

Re: Calling VM C functions from cogged primitives

Eliot Miranda-2
Hi Leandro,

On Mon, Jun 10, 2019 at 10:08 AM lgvidal <[hidden email]> 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
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/vm-beginners


--
_,,,^..^,,,_
best, Eliot

_______________________________________________
VM-beginners mailing list
[hidden email]
http://lists.squeakfoundation.org/mailman/listinfo/vm-beginners