Save 64 bytes from most Linux/amd64 interpreter frames. (mono/mono#15926)
authorJay Krell <jaykrell@microsoft.com>
Wed, 31 Jul 2019 12:20:03 +0000 (05:20 -0700)
committerAlexander Köplinger <alex.koeplinger@outlook.com>
Wed, 31 Jul 2019 12:20:03 +0000 (14:20 +0200)
commit6b79d8f398ab347a4c2228da7864cb18201646d5
tree4ffbb3a813721b8089a167e22ca56b060769fb8a
parent421215847e7003be256160029abb485d08dab6db
Save 64 bytes from most Linux/amd64 interpreter frames. (mono/mono#15926)

 Probably same on all 64bit architectures. half on 32bit.

before:
```
0000000000003ce0 <interp_exec_method_full>:
    3ce0: 55                    push   %rbp
    3ce1: 48 89 e5              mov    %rsp,%rbp
    3ce4: 41 57                 push   %r15
    3ce6: 41 56                 push   %r14
    3ce8: 41 55                 push   %r13
    3cea: 41 54                 push   %r12
    3cec: 49 89 f4              mov    %rsi,%r12
    3cef: 53                    push   %rbx
    3cf0: 48 89 fb              mov    %rdi,%rbx
    3cf3: 48 81 ec 78 01 00 00  sub    $0x178,%rsp
```

after:
```
0000000000003ce0 <interp_exec_method_full>:
    3ce0: 55                    push   %rbp
    3ce1: 48 89 e5              mov    %rsp,%rbp
    3ce4: 41 57                 push   %r15
    3ce6: 41 56                 push   %r14
    3ce8: 41 55                 push   %r13
    3cea: 41 54                 push   %r12
    3cec: 49 89 f4              mov    %rsi,%r12
    3cef: 53                    push   %rbx
    3cf0: 48 89 fb              mov    %rdi,%rbx
    3cf3: 48 81 ec 38 01 00 00  sub    $0x138,%rsp
```

It was 0x158 recently.

Some frames will be larger, i.e. dynamic + pinvoke.

Classic technique:
 pointer instead of struct
 initialized to null
 alloca it when needed and not null

A more detailed analysis might enable better, such as making
the parameter optional, and/or having the callee default it to its
local storage.

Commit migrated from https://github.com/mono/mono/commit/e0335d357056f9017f7c170ed41f5cb7e3e32399
src/mono/mono/mini/interp/interp.c