Add fast-path dispatch for address-taken functions in ModuleClone#326
Open
Pavel-Durov wants to merge 9 commits intoykjit:mainfrom
Open
Add fast-path dispatch for address-taken functions in ModuleClone#326Pavel-Durov wants to merge 9 commits intoykjit:mainfrom
Pavel-Durov wants to merge 9 commits intoykjit:mainfrom
Conversation
Previously, functions whose address was taken were excluded from cloning entirely to preserve function pointer identity. This meant all indirect calls always went through the unoptimised body, even at runtime when no tracing was active. Address-taken functions are now cloned into `__yk_opt_<name>` as normal, but the original symbol is kept. A tracing-state dispatch check is prepended: when `__yk_thread_tracing_state == 0` (the common case) a call to the optimised clone is emitted; otherwise the original unoptimised body executes. This preserves function pointer identity while reducing overhead for indirect calls to a single load + branch in the non-tracing path. Functions that are still excluded from this optimisation: those containing the control point, and functions annotated `yk_outline` or `yk_indirect_inline`.
Previously, functions whose address was taken were excluded from cloning entirely to preserve function pointer identity. This meant all indirect calls always went through the unoptimised body, even at runtime when no tracing was active. Address-taken functions are now cloned into `__yk_opt_<name>` as normal, but the original symbol is kept. A tracing-state dispatch check is prepended: when `__yk_thread_tracing_state == 0` (the common case) a call to the optimised clone is emitted; otherwise the original unoptimised body executes. This preserves function pointer identity while reducing overhead for indirect calls to a single load + branch in the non-tracing path. Functions that are still excluded from this optimisation: those containing the control point, and functions annotated `yk_outline` or `yk_indirect_inline`.
Author
|
Will post haste diff when its complete, it takes ages for ykmicropython |
…urov/ykllvm-fork into opt-indirect-fn-notrace-fastpath
Author
|
Ready for another review :) |
Author
|
Sorry missed one thing! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously, functions whose address was taken were excluded from cloning entirely to preserve function pointer identity. This meant all indirect calls always went through the unoptimised body, even at runtime when no tracing was active.
Address-taken functions are now cloned into
__yk_opt_<name>as normal, but the original symbol is kept. A tracing-state dispatch check is prepended: when__yk_thread_tracing_state == 0(the common case) a call to the optimised clone is emitted; otherwise the original unoptimised body executes.This preserves function pointer identity while reducing overhead for indirect calls to a single load + branch in the non-tracing path.
Functions that are still excluded from this optimisation: those containing the control point, and functions annotated
yk_outlineoryk_indirect_inline.