zandaqo / structurae

Data structures for high-performance JavaScript applications.
MIT License
694 stars 21 forks source link

TypedArray storing js object? #12

Closed jinCN closed 4 years ago

jinCN commented 4 years ago

Is it possible to provide some kind of TypedArray to store value referencing to js object?

zandaqo commented 4 years ago

Although object references are internally encoded as 64 bit (or 32 bit) values, JavaScript does not expose them, we cannot get and operate on them the way we do with pointers in C, hence, we cannot store them in TypedArrays/ArrayBuffers. Performance-wise, an array of object references should perform as well as a hypothetical TypedArray with pointers, since internally both of them are arrays of fixed type values and engines are smart enough to understand that.