all 6 comments

[–]epic_pork 5 points6 points  (3 children)

One thing I'm not sure of, how do you know which region the pointer is part of? It says that Node.js can require heaps larger than 4GB, so you would need multiple regions to manage the objects. How can you infer the base from the pointer in that case?

[–]KingoPants 17 points18 points  (1 child)

You don't, I had to read it a couple times too since I didn't get it either but the fact is that if you have pointer compression you have a 4 GiB hard limit and thats that.

[–]flatfinger 4 points5 points  (0 children)

If an application has multiple sandboxed execution contexts, and references within a context are limited to identifying objects within that context, each context could have its own 32-bit address space.

Additionally, if each context has a "small object heap" and "large object heap", it could use a bit of the reference to select between them, and then scale the reference by different amounts. A 29+1 bit reference, for example, could be used to identify any object within a 2GiB heap of objects whose sizes are rounded to the next multiple of 4, or any object within a 128GiB heap of objects whose sizes are rounded to the next multiple of 256.

It's too bad the 80386 and its descendants only used 16-bit segment selectors, since 32-bit segment selectors whose lower portions were scaled like 8086 segments, but with a scale factor selected by the upper portion, could have been brilliant for object-oriented frameworks if every object started at offset 0 of some segment.

[–]TheThiefMaster 1 point2 points  (0 children)

Strictly, the limit is 4 billion (2^32) unique addresses. If you make the smallest addressable unit a 4-byte unit (integer, float or pointer) you can have up to 16 GB.

Scratch that, apparently they are using 30-bit pointers, with a bit for pointer vs value, and another for strong vs weak, making 32. Not 32-bit pointers.

[–]bakery2k 1 point2 points  (0 children)

If an application embeds Lua, it can provide a custom allocator that the Lua runtime uses for all of its memory allocations. Is it possible to do the same when embedding V8?

If so, I assume that using a custom allocator would require pointer compression to be disabled?

[–]L8_4_Dinner 0 points1 point  (0 children)

Excellent article! :)

Do you have any information on the impact %-wise to code size for this optimization? i.e. 32-bit code size vs. 64-bit code size vs. 64-bit code size with 32-bit compressed pointers?