3 ms·
In Java, it was mostly a no brainer: Objects were already aligned on 16byte boundaries, the extra shift is mostly free on modern hardware, and the optimizer is
by hyperman1 8y ago
In Java, it was mostly a no brainer: Objects were already aligned on 16byte boundaries, the extra shift is mostly free on modern hardware, and the optimizer is smart enough to compute the base only once if multiple fields are accessed - the common situation.
But that's Java. In C, pointer casting makes it impossible to do this without help from the programmer: You simply can't stop the programmer to cast an invalid value to a pointer. In theory, a mode where char is 2, 4 or 8 physical bytes, but in practice, a lot of software would break.