3. int func2(int arg1, char *arg2) {
char str[100];
/* some other expressions */
}
int func1() {
int foo = 0;
int bar = 3;
char* buzz = malloc(5);
func2(foo, buzz);
}
char* buzz (stack slot with
address)
int bar = 3
int foo = 3
Return address
Params of func1
Stack
4. int func2(int arg1, char *arg2) {
char str[100];
/* some other expressions */
}
int func1() {
int foo = 0;
int bar = 3;
char* buzz = malloc(5);
func2(foo, buzz);
}
str[99]
str[1] … str[98]
str[0];
Return address (line 10)
arg2 = buzz
arg1 = foo = 3
Data of func1
Stack
12. 32 Slots and extra properties
1. Object gets 32 slots
2. V8 trims unused slots later
3. Extra properties go separately
13. Elements
● Keys are array indices
● Elements may be represented as simple
array
● Unbox values, if numbers only
14. Map a.k.a Hidden Class
● Stores object layout ({ property: offset })
● Assignment order matters
● New map created for each object change
● Allows fast property lookup
15. Maps creation
function Foo(bar, buzz) {
this.bar = bar;
this.buzz = buzz;
}
const foo1 = new Foo(1, 2);
const foo2 = new Foo(3, 4);
foo1.some = 5;
{ } - C0
{ bar } - C1
{ bar, buzz } - C2
{ bar, buzz, some } - C3