by bcoates · 13y ago · 0 comments
Heap allocations are expensive even in non-GC languages.
You can get away from that with a sufficiently smart JIT turning a stable access to a known object into little more than a vtable dispatch. That's close to what V8 does with hidden classes on full cache hits (object map — its "hidden class" — + object "array" property both cached).
point.x
will generate the assembly: cmp [ebx,<hidden class offset>],<cached hidden class>
jne <inline cache miss>
mov eax,[ebx, <cached x offset>]
(where ebx is the previously loaded `point`)