[Vm-dev] Question about trampoline usage

Angel Yan angelyan96 at gmail.com
Wed Aug 10 03:46:12 UTC 2022


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/20220810/19394c98/attachment-0001.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: crash.dump.2
Type: application/x-troff-man
Size: 9102 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20220810/19394c98/attachment-0002.man>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: crash.dump.1
Type: application/x-troff-man
Size: 14668 bytes
Desc: not available
URL: <http://lists.squeakfoundation.org/pipermail/vm-dev/attachments/20220810/19394c98/attachment-0003.man>


More information about the Vm-dev mailing list