From lgvidal at gmail.com Mon Jun 10 17:08:50 2019 From: lgvidal at gmail.com (lgvidal) Date: Mon, 10 Jun 2019 12:08:50 -0500 (CDT) Subject: [Vm-beginners] Calling VM C functions from cogged primitives Message-ID: <1560186530194-0.post@n4.nabble.com> 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 From eliot.miranda at gmail.com Mon Jun 10 22:45:52 2019 From: eliot.miranda at gmail.com (Eliot Miranda) Date: Mon, 10 Jun 2019 15:45:52 -0700 Subject: [Vm-beginners] Calling VM C functions from cogged primitives In-Reply-To: <1560186530194-0.post@n4.nabble.com> References: <1560186530194-0.post@n4.nabble.com> Message-ID: Hi Leandro, On Mon, Jun 10, 2019 at 10:08 AM lgvidal 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: