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

[for the future] Maybe use int_fast16_t instead of int16_t in the VM? #597

Open
jpellegrini opened this issue Aug 28, 2023 · 0 comments
Open

Comments

@jpellegrini
Copy link
Contributor

Hi @egallesio !

I'm not sure if it would actually make a difference, but... "Theoretically", it could make the VM faster. The "fast" size for int_fast16_t is not the same as int16_t, at least in two architectures that I use.

#include <stdio.h>
#include <stdint.h>
int main() {
  printf("int_fast8_t  %ld -> %ld\n", sizeof(int8_t),  sizeof(int_fast8_t));
  printf("int_fast16_t %ld -> %ld\n", sizeof(int16_t), sizeof(int_fast16_t));
  printf("int_fast32_t %ld -> %ld\n", sizeof(int32_t), sizeof(int_fast32_t));
  printf("int_fast64_t %ld -> %ld\n", sizeof(int64_t), sizeof(int_fast64_t));
}

On an amd64 machine I get

int_fast8_t  1 -> 1
int_fast16_t 2 -> 8
int_fast32_t 4 -> 8
int_fast64_t 8 -> 8

On a mipsel wireless router,

int_fast8_t  1 -> 1
int_fast16_t 2 -> 4
int_fast32_t 4 -> 4
int_fast64_t 8 -> 8

Of course, I tried to just change the types and... STklos crashed when compiling (Well, I supposed it wouldn't be as simple as that).

But theoretically, the bytecode files wouldn't need to be changed. We can store the bytes as usual, and read them into int_fast16_t variables instead of int16_t...

Anyway -- not urgent, of course!

@jpellegrini jpellegrini changed the title [for the future] Maybe use int_fast16_t instead of int_16 in the VM? [for the future] Maybe use int_fast16_t instead of int16_t in the VM? Aug 28, 2023
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

No branches or pull requests

1 participant