benilla-re systems structs docs

f_luaopen

function · lua · boundary

Address
0x6f6d70 · 354 bytes, up to 0x6f6ed1
Meaning
Builds the global state of a new Lua state: tables, string table, tag method names
Confidence
verified, proof two
Finding
lua/runtime#state-open-and-close

Finding: State open and close in lua: calls, states and the collector

lua_open (ui/luastate) runs f_luaopen in protected mode. It allocates the 192-byte global state and stores default_panic in it, calls stack_init (a stack of 45 slots and 8 call records), makes the default metatable (its own metatable), the globals table and the registry, sizes the string table at 32, runs luaT_init and luaX_init, fixes the not enough memory string and sets the first threshold to four times the block count. luaE_newthread makes a coroutine state. close_state closes the upvalues, sweeps every object, frees the stacks, calls the client's memory-pool teardown 0x6fb2f0 (0x6f6f54) and frees the global state. mallocstate, freestate, freestack and luaE_freethread allocate and free the records, and callallgcTM is the protected function that runs the last finalizers.

functionnamedecided by
0x6f6b10luaE_newthreadmallocstate (0x6f6b14), luaC_link type 8 (0x6f6b21), preinit_state (0x6f6b28), stack_init (0x6f6b37)
0x6f6b80mallocstateluaM_irealloc in lstate.c for 0x68 bytes (0x6f6b8d)
0x6f6ba0stack_inittwo luaM_irealloc in lstate.c for 0x2d0 and 0xc0 bytes (0x6f6bb8, 0x6f6be4)
0x6f6c90luaE_freethreadluaF_close (0x6f6c9b), freestack (0x6f6ca4), tail jmp to freestate (0x6f6caf)
0x6f6cc0freestateluaM_irealloc in lstate.c (0x6f6ccb)
0x6f6ce0freestacktwo luaM_irealloc in lstate.c (0x6f6cfd, 0x6f6d17)
0x6f6d70f_luaopenallocates 0xc0 bytes (0x6f6d88), panic store (0x6f6ddd), three luaH_new (0x6f6e3b, 0x6f6e62, 0x6f6e87), luaS_resize 32 (0x6f6e96), luaT_init (0x6f6e9d), threshold shl 2 (0x6f6ec8)
0x6f6ee0default_panicthree bytes: xor eax,eax; ret
0x6f6ef0close_stateluaF_close (0x6f6ef6), luaC_sweep (0x6f6f09), luaS_freeall (0x6f6f10), freestack (0x6f6f46), pool teardown 0x6fb2f0 (0x6f6f54), freestate (0x6f6f79)
0x6f6fe0callallgcTMtail jmp to luaC_callGCTM (0x6f6fe0)
0x6f7b40luaT_initloop over the name table (0x6f7b72), luaS_newlstr, limit 0xbc (0x6f7b8c), the fixed bit 0x10

The derivation is in the doc.

Callers 0

None by a direct call or jump.

Callees 8

Calls and jumps by a bare address, from tables/calls.tsv.