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

[DYNAREC] Optimized CALL/RET RAS for out of dynablock jumps #1909

Merged
merged 1 commit into from
Oct 7, 2024

Conversation

ksco
Copy link
Collaborator

@ksco ksco commented Oct 6, 2024

Related PR: #1907

For out of block jumps, instead of jump to the table directly, add one more jump to make the RAS optimization valid.

A simple benchmark as below shows this fixes the performance loss in out-of-block-jumps introduced in PR #1907, while keeps the in-block-jumps as fast.

#include <limits.h>

int foo(int a) {
  return a + a;
}

int bar(int a) {
  return a + 2;
}

int baz(int a) {
  return a + 3;
}

int indirect_version(int (*fn)(int), int (*fn2)(int), int (*fn3)(int)) {
  int i, b = 0;

  for (i = 0; i < INT_MAX >> 2; ++i) {
    b += fn(b) + fn2(b) - fn3(b);
  }

  return b;
}

int main(int argc, char *argv[]) {
  return indirect_version(&foo, &bar, &baz);
}

@ptitSeb ptitSeb merged commit 4c69bcd into ptitSeb:main Oct 7, 2024
46 checks passed
@ksco ksco deleted the callret2 branch October 7, 2024 20:01
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.

2 participants