Search code examples
google-chromepointersv8

how v8 encodes pointers in memory


V8 version 10.7.0 (candidate)

I have created an array of elements from several objects

enter image description here

with v8 builtin functions, use "%DebugPrint" to get pointer to array object

enter image description here

I look in memory for the address of the array object "0x000001BE0010BC5D",

enter image description here

and I see that the first address corresponds to the map of the object the map address is encrypted

I would love to know how to decode the address manually


Solution

  • It's not encrypted, it's compressed. So it helps to print 32-bit values in your disassembler; in this case that'd be 0x002c3b51 for the array's map (lower half of the 64-bit value that you printed). Since all objects live on the same heap, you can manually decompress that address by adding the same upper-32-bits prefix that the array's address has, i.e. 0x000001be. So the map's full address is 0x000001be002c3b51 (as you can already see in your second screenshot).

    The upper half of that first 64-bit value is the compressed version of the array's second field, to its "properties" backing store.

    Side note: please learn how to post code as code, not as screenshots.