image

was looking at this V8 design doc where it has a section for Constant Pool Entries

it says

Constant pools are used to store heap objects and small integers that are referenced as constants in generated bytecode. and

... Small integers and the strong referenced oddball type’s have bytecodes to load them directly and do not go into the constant pool.

So I am confused: are small integers pooled or not?

My understanding is that it is not worth it pooling small integers if sizeof(int) < sizeof(int *) - because it is cheaper to just copy the actual integer instead of copying the pointer that points to the integer in the constant pool. Also variables that hold integers can be optimised to be stored directly in CPU registers and skip being allocated in memory first.

Please correct me if I am wrong.