Skip to content
Fedor Indutny edited this page Jan 28, 2014 · 1 revision

Boxing

Last bit:

  • non-zero - pointer
  • zero - small integer

Odd-balls

undefined, null are just a pointers to the non-movable heap with a value, known ahead of time during compilation.

Object structure

First word (quad- or double-) is a pointer to map, all next data is a map's body.

[map pointer] [body...]

Map has the same structure as an Object.

There are some special, pre-defined maps: Number, Function, Object, ...

Heap Number

[Number map] [8-byte floating point value]

Function

[Function map] [context] [Code]

String

[String map] [len] [len x bytes...]

Cons-String

[Cons-String map] [left] [right]

Regexp

TBD

Dense-Array

[Dense-Array map] [len] [len x pointers...]

Context

[Context map] [parent] [num] [num x pointers...]

Code

[Code map] [clen] [tlen] [rlen]
[clen x bytes...] # Actual machine code
[tlen x Type Info] # Various type info collected inside it
[rlen x Relocation Info] # Info for relocating stuff in code object and
                         # referencing other objects in heap

Stores generated machine code, allocated in exectuable heap.

Object and every other map

[Object map] [space-size] [space-size x bytes...]

Note that map does also serve as a prototype chain.

Type Info

A pointer-sized bitfield:

  • 0000000 - unknown
  • 0000010 - smi
  • 0000011 - heap number
  • 0000010 - number
  • 0000100 - string
  • 0001000 - function
  • 0010000 - dense-array
  • 0100000 - object

All stubs record their incoming types, making the info available at the CFG level.

Relocation Info

A pointer sized relative offset (from the start of assembly code section in Code object).

Frames

Every time the runtime is entered from C++ - following structure is pushed on-stack:

0x................ <- pointer to a previous runtime's stack
0xdeadbeefbadbadb0