Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fast block return #78

Merged
merged 5 commits into from
Jun 18, 2016
Merged

Fast block return #78

merged 5 commits into from
Jun 18, 2016

Conversation

0x7CFE
Copy link
Owner

@0x7CFE 0x7CFE commented May 2, 2015

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.

@@ -1996,7 +1996,7 @@ run2: rounds | mock |
self run: [ mock selfSend ] rounds: rounds text: 'Self dispatch'.

self run: [ mock invokeBlock: [nil] ] rounds: rounds text: 'Block invoke'.
self run: [ mock blockReturn ] rounds: rounds text: 'Block return'.
self run: [ 1 to: rounds do: [ :x | mock blockReturn ] ] rounds: 1 text: 'Block return'.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What is the difference?

@0x7CFE 0x7CFE force-pushed the feature/32/fast_block_return branch from 81ac69e to 8d869d8 Compare April 18, 2016 17:30
@coveralls
Copy link

Coverage Status

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

@coveralls
Copy link

Coverage Status

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

@0x7CFE 0x7CFE force-pushed the feature/32/fast_block_return branch 2 times, most recently from 8e5a29d to 8095eaf Compare April 24, 2016 07:46
@coveralls
Copy link

Coverage Status

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

@coveralls
Copy link

Coverage Status

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

@@ -127,13 +127,16 @@ if (USE_LLVM)
src/llstPass.cpp
src/llstDebuggingPass.cpp
)

add_library(trampoline "src/trampoline.cpp")
set_source_files_properties(src/trampoline.cpp PROPERTIES COMPILE_FLAGS "-freg-struct-return")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@coveralls
Copy link

Coverage Status

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

@coveralls
Copy link

Coverage Status

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

@0x7CFE 0x7CFE force-pushed the feature/32/fast_block_return branch from 7caca94 to 50aa7eb Compare May 21, 2016 12:00
@0x7CFE 0x7CFE force-pushed the feature/32/fast_block_return branch from e189b20 to a134dc1 Compare June 18, 2016 12:10
@coveralls
Copy link

coveralls commented Jun 18, 2016

Coverage Status

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

@0x7CFE 0x7CFE merged commit a134dc1 into develop Jun 18, 2016
@kpp
Copy link
Collaborator

kpp commented Jun 25, 2016

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

@0x7CFE
Copy link
Owner Author

0x7CFE commented Jun 25, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants