Hacker News new | ask | show | jobs
by efaref 1062 days ago
> Unless those are actually padded to 32 bits in the VM or something.

They are.

3 comments

To be fair, they're padded in a lot of machine code contexts as well, even if you don't explicitly write `int_fast16_t`.

And since Java doesn't expose pointer guts, struct padding is purely a runtime optimization concern, not a language concern.

Don't you mean `int_least16_t`?
No, the `least` typedefs are irrelevant aliases for the exact type these days (except supposedly some 32-bit-only DSPs exist though. But 9-bit computing has been obsolete for longer than most of us have been alive, despite talking about it).

The `fast` typedefs are effectively programmer-opted-in to promotion to register size or something. But compiler optimizations often do the same thing on a per-operation level (signed overflow is UB, unsigned overflow masking can be deferred for addition/subtraction/multiplication and bitwise ops (though some can change the mask)).

They're extended when they're locals or temporaries, but they behave like real 8- and 16- bit values in fields and array elements.
In interpreted mode. They can be optimized by the JIT compiler differently though.