NO_LOCAL_POINTERS only applys pointers to heap?

NO_LOCAL_POINTERS is used to tell runtime there is no pointer in stack variables, thus when stack moves, gc will not try to update addresses in that call frame.

45 // NO_LOCAL_POINTERS indicates that the assembly function stores
46 // no pointers to heap objects in its local stack variables.
47 #define NO_LOCAL_POINTERS FUNCDATA $FUNCDATA_LocalsPointerMaps, runtime·no_pointers_stackmap(SB)

However, what if there is a pointer hold stack memory? moving stack obviously should update the pointer’s value.

And more, the commence in same file says

 24 // GO_ARGS, GO_RESULTS_INITIALIZED, and NO_LOCAL_POINTERS are macros
 25 // that communicate to the runtime information about the location and liveness
 26 // of pointers in an assembly function's arguments, results, and stack frame.
 27 // This communication is only required in assembly functions that make calls
 28 // to other functions that might be preempted or grow the stack.
 29 // NOSPLIT functions that make no calls do not need to use these macros.

Which seems indicating only memory moving only happens in stack; because if a heap moving happens, a ASM functions making no calls and holding a pointer to heap will absolutely need to be updated.

Which means the commence should replace heap to stack:
45 // NO_LOCAL_POINTERS indicates that the assembly function stores
46 // no pointers to STACK objects in its local stack variables?

This isn’t about updating pointers when moving the stack, it’s for garbage collection to know if there are any pointers in the stack frame referring to heap-allocated objects that should be kept alive.

Then why it is not needed if the function does not making callings?

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.