// func now() (sec int64, nsec int32) TEXT time·now(SB),NOSPLIT,$16 // Be careful. We're calling a function with gcc calling convention here. // We're guaranteed 128 bytes on entry, and we've taken 16, and the // call uses another 8. // That leaves 104 for the gettime code to use. Hope that's enough! MOVQ runtime·__vdso_clock_gettime_sym(SB), AX CMPQ AX, $0 JEQ fallback MOVL $0, DI // CLOCK_REALTIME LEAQ 0(SP), SI CALL AX MOVQ 0(SP), AX // sec MOVQ 8(SP), DX // nsec MOVQ AX, sec+0(FP) MOVL DX, nsec+8(FP) RET fallback: LEAQ 0(SP), DI MOVQ $0, SI MOVQ runtime·__vdso_gettimeofday_sym(SB), AX CALL AX MOVQ 0(SP), AX // sec MOVL 8(SP), DX // usec IMULQ $1000, DX MOVQ AX, sec+0(FP) MOVL DX, nsec+8(FP) RET --
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...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
On Mon, Feb 1, 2016 at 8:11 PM, Brad Fitzpatrick <brad...@golang.org> wrote:
> I think that's how much of Go's stack is guaranteed to still be valid. Go's
> stacks are small and grow as needed, unlike C, but this code is calling with
> gcc calling convention from Go code, and the gettime code isn't going to
> grow Go's stack for it... it'll just corrupt things and probably crash if
> there's not enough space.
>
> I don't know where 128 comes from, though.
Every function is guaranteed to have at least 128 bytes on the stack
at function entry. This is used to simplify the stack overflow check
for functions with small stack frames. See _StackSmall in
runtime/stack.go.