Skip to content

Conversation

@isildur-g
Copy link

call to one of the dispatched functions, we determine the correct target and replace a static func ptr to point to the correct target. on subsequent calls
we directly call the target. It's a bit messy and
while it eliminates the branching and ifunc indirection at runtime, it still involves a second function call and copying of a stack frame etc. The macros are
a fair bit uglier now but one needs to be able to
specify both the full arg list of a given function, as well as specify only the names of the args, to
macro out the invocation of the passthrough call.
The extra router function could be merged into the resolve function, but i wanted to leave that more
or less untouched for the first review.

src/dispatcher.c Outdated
CONNECT_DISPATCH_2(hs_error_t, hs_scan, const hs_database_t *db, const char *data,
unsigned length, unsigned flags, hs_scratch_t *scratch,
match_event_handler onEvent, void *userCtx);
CONNECT_ARGS_3(hs_error_t, hs_scan, db, data, length, flags, scratch, onEvent, userCtx);
Copy link

Choose a reason for hiding this comment

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

it would be great if those macros could be unified in one. Also, can you try to remove those pragmas and see if it causes a problem?

@markos markos linked an issue Apr 4, 2024 that may be closed by this pull request
@markos markos added the enhancement New feature or request label Apr 4, 2024
@markos markos added this to the 5.4.12 milestone Apr 4, 2024
@isildur-g isildur-g closed this Apr 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor Dispatcher to use function table instead of macro

2 participants