[Vm-dev] Question about trampoline usage

Eliot Miranda eliot.miranda at gmail.com
Mon Aug 15 19:36:21 UTC 2022

Hi Angel,

> On Aug 15, 2022, at 10:02 AM, Angel Yan <angelyan96 at gmail.com> wrote:
> As I had suspected, it turned out to be a silly mistake on my part. Apparently, I need to call the trampoline using CallRT instead of Call because of method relocations? That seems to explain the symptoms I've seen.

I apologize for not responding sooner.  When I read your message I thought for a few days and the only thing I could think of was not saving the relevant registers.  (This would matter if a trampoline were called at an arbitrary point where registers were live on return from the trampoline). I did t think about method relocation at all.  I’m really glad you figured it out. I’m sorry I was g of more help.

>> On Wed, Aug 10, 2022 at 12:46 AM Angel Yan <angelyan96 at gmail.com> wrote:
>> Hi
>> I'm doing some work on the cog vm for which I need to instrument cogged bytecodes to collect runtime information and my plan is to do this via trampolines. The idea is to update the Cogit such that calls to the relevant trampolines are generated before or after the usual machine code that is generated for these bytecodes.
>> As a first test, I added a dummy trampoline that just prints a message to stdout and updated the machine code translation of a bytecode to generate a call to said trampoline at the beginning. For this I:
>> 1. Updated StackToRegisterMappingCogit class>>#numTrampolines.
>> 2. Added a ceDummyTrampoline inst var to StackToRegisterMappingCogit.
>> 3. Updated StackToRegisterMappingCogit to generate the dummy trampoline.
>>     StackToRegisterMappingCogit>>#generateRunTimeTrampolines
>>         super generateRunTimeTrampolines.
>>         ceDummyTrampoline := self genTrampolineFor: #dummyTrampoline:
>>             called: 'ceDummyTrampoline'
>>              regsToSave: CallerSavedRegisterMask.
>> 4. Added the dummy trampoline method in the CoInterpreter.
>>     CoInterpreter>>#dummyTrampoline
>>         <api>
>>         self cCode: 'printf("dummy trampoline\n");'.
>> 5. Instrumented a bytecode.
>>     StackToRegisterMappingCogit>>#genStoreAndPopReceiverVariableBytecode
>>         self Call: ceDummyTrampoline.
>>         ^super genStoreAndPopReceiverVariableBytecode.
>> 6. Generated and compiled a new vm with VMMaker generateSqueakSpurCog64VM.
>> With the newly compiled vm I'm able to open an image and I can see the message from the trampoline being printed to stdout, however, it quickly crashes when I start doing things in the UI. These are some of the behaviors I've observed:
>> * The vm does not seem to crash as long as I do simple things like moving around the cursor, opening context menus and dragging collapsed windows, however, it quickly -but not always immediately- crashes when I start opening windows.
>> * The chances of a window crashing the vm increases with time. e.g. I'm able to open a browser if I do it as soon as I open the image, but not if I wait 5 seconds.
>> * Some windows are more likely to crash the vm than others. e.g. I'm able to open multiple workspaces and transcripts before the vm crashes, but at most one browser.
>> * The vm outputs a crash dump sometimes, but not always.
>> I've attached to this message some of the crash dumps I've gotten.
>> Any help will be greatly appreciated. I've tried debugging using the simulator and gdb but was not able to get very far as I don't know how to best troubleshoot these types of errors. Suggestions in this regard are welcome as well.
>> Thanks!
>> Regards
>> Angel
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20220815/86d9b3e3/attachment.html>

More information about the Vm-dev mailing list