Skip to content

Optimize hook dispatch codegen - #110

Merged
jkivilin merged 3 commits into
masterfrom
optimize-hook-dispatch-codegen
May 18, 2026
Merged

Optimize hook dispatch codegen#110
jkivilin merged 3 commits into
masterfrom
optimize-hook-dispatch-codegen

Conversation

@jkivilin

Copy link
Copy Markdown
Member

Summary

  • Clear hook_list_tables_updated flag immediately after capture in the pre-plugin loop, matching the existing post-plugin loop pattern and preventing unnecessary find_plugin_after_rebuild lookups during re-entrant dispatch
  • Use pre-increment -1-based reentry_index instead of post-increment 0-based reentry_count for better x86 codegen (inc+jnz / dec+js vs load-compare-increment)
  • Skip copy_meta_globals save/restore on the outermost (non-reentrant) call where there are no previous meta globals to preserve

Test plan

  • All existing unit tests pass (35 suites, ~800+ tests)
  • Re-entrancy integration tests pass

jkivilin added 3 commits May 18, 2026 08:14
Matches the pattern already used in the post-plugin loop (line 192-193).
Prevents re-entrant inner calls from seeing a stale flag and doing
unnecessary find_plugin_after_rebuild lookups.
Change reentry tracking from 0-based post-increment counter to
-1-based pre-increment index. Pre-increment + compare-to-zero
generates inc+jnz on x86 instead of load-compare-increment from
post-increment. Exit uses dec+js instead of dec+jnz.
Move copy_meta_globals into the reentry branch — the outermost call
has no previous meta globals to save or restore, so the copies are
wasted work on the non-reentrant fast path.
@jkivilin
jkivilin merged commit 88a8bee into master May 18, 2026
11 checks passed
@jkivilin
jkivilin deleted the optimize-hook-dispatch-codegen branch August 25, 2026 17:36
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.

1 participant