Hi all.

I have an asm function that is defined like this:

// func f(x *T1, y *T2)
TEXT ·f(SB), 0, $32-16
  NO_LOCAL_POINTERS
  // It does call a few Go functions, this is why
  // I need some frame space, to put their arguments there.
  MOVQ <arg1>, 0(SP)
  MOVQ <arg2>, 8(SP)
  CALL ·gofunc1(SB)
  MOVQ 16(SP), AX // Save result
  // ...more such calls, args take up to 32 bytes.
  RET

It has 2 pointer arguments and frame with size=32 bytes.
All that frame space is only used for function call arguments,
asm function itself does not spill data to the stack.

Arguments to Go functions can contain pointers.
All of them come from the 2 f() arguments (x and y).

So the question is: how safe it's to use NO_LOCAL_POINTERS here?

If NO_LOCAL_POINTERS is removed, I can't do a CALL, since runtime needs a 
stack map.

Note that the asm code is simplified, but all statements given above still 
hold: stack frame only
holds pointers that are reachable via f() arguments and it's only used to 
pass arguments to (normal) Go functions.

This sentence from the asm docs <https://golang.org/doc/asm#runtime> adds 
more confusion:

> Because stack resizing is implemented by moving the stack, the stack 
> pointer may change during any function call: even pointers to stack data 
> must not be kept in local variables. 
>

I'm not sure what it means by "local variables". When doing asm, you can 
only imagine local variables as stack-saved values.

I found this part of code 
<https://github.com/golang/go/blob/master/src/runtime/vlop_arm.s#L146> that 
gives some insights, but I can't make a reliable conclusion about my case 
out of that.

Thank you in advance. :)

-- 
You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/golang-nuts/a70f1cff-7b0e-452f-a105-7d84e7b5102b%40googlegroups.com.

Reply via email to