0x7CFE / llst

LLVM powered Little Smalltalk.
Other
93 stars 10 forks source link

Fast block return #78

Closed 0x7CFE closed 8 years ago

0x7CFE commented 9 years ago

Original implementation uses exception API to perform far jump to dispatch BlockReturn instruction. This work OK but is terribly slow. I mean REALLY slow, 10 times slower than the software implementation and 40 times slower than implementation proposed here.

Current pull request implements BlockReturn using MRV technique to return several values in registers instead of stack. In our case result object is returned in eax whereas target context in edx (on x86 of course). Cascade block return is handled by simply propagating these two registers unchanged from inner stack frame to outer and so on. Typical overhead is one cmp or test instruction per message send and one ret instruction per frame.

We use use -freg-struct-return technique which is uncommon in UNIX world and it's calling conventions, but is fully supported in GCC and clang depending on a compiler version.

More portable implementation should pass return value using the stack (sret in terms of LLVM) but this will be slower and will not handle cascade return in a straightforward way.

coveralls commented 8 years ago

Coverage Status

Coverage remained the same at 61.248% when pulling 8d869d80e54174b229727bcb4117b4bdccdaa1ee on feature/32/fast_block_return into 9b72b7ba60f2873c3ff348eeef2f87bdc56cbc1b on develop.

coveralls commented 8 years ago

Coverage Status

Coverage remained the same at 61.248% when pulling 08cebd8059f68bf17598998592d994da7999b22c on feature/32/fast_block_return into 9b72b7ba60f2873c3ff348eeef2f87bdc56cbc1b on develop.

coveralls commented 8 years ago

Coverage Status

Coverage decreased (-0.2%) to 61.084% when pulling 8e5a29d97c46210c5b9aaa7ae387abeff9bee455 on feature/32/fast_block_return into 97ce220ca5b82d7a61c3fc114d7851606cf6666a on develop.

coveralls commented 8 years ago

Coverage Status

Coverage decreased (-0.2%) to 61.084% when pulling 8095eaf9f11b71ba3f87aefe975d8a5ae6a6177f on feature/32/fast_block_return into 97ce220ca5b82d7a61c3fc114d7851606cf6666a on develop.

coveralls commented 8 years ago

Coverage Status

Coverage increased (+0.6%) to 61.836% when pulling 63d3012e79f9e44552ae46cece777b250957ce56 on feature/32/fast_block_return into 97ce220ca5b82d7a61c3fc114d7851606cf6666a on develop.

coveralls commented 8 years ago

Coverage Status

Coverage increased (+0.4%) to 61.656% when pulling 7e8f1fac1366956d2e629548b1f4f633070fa18c on feature/32/fast_block_return into 97ce220ca5b82d7a61c3fc114d7851606cf6666a on develop.

coveralls commented 8 years ago

Coverage Status

Coverage remained the same at 61.248% when pulling a134dc19fb64e30dc310f2b32154c5a25309e63e on feature/32/fast_block_return into 97ce220ca5b82d7a61c3fc114d7851606cf6666a on develop.

kpp commented 8 years ago

WTF, Дима. Я как бэ комменты оставил

0x7CFE commented 8 years ago

Изменения по твоим комментариям надо оформить отдельным PR поверх develop. Текущая ситуация тормозила дальнейшее развитие. К сожалению, у меня сейчас нет времени на полноценное оформление исходников. В конце концов, develop — это нестабильная ветка.