[Vm-dev] Question about trampoline usage

Angel Yan angelyan96 at gmail.com
Mon Aug 15 17:01:44 UTC 2022


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.

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/5ab3823b/attachment.html>


More information about the Vm-dev mailing list