FAQ
Hi,

To learn continuous stack in golang , i wrote a test program, like this:
package main

func f() int {
     sum := 0
     elements := make([]int, 1000)
     for _, e := range elements {
         sum += e
     }
     return sum
}

func main() {
     f()
}

check the compile code generated by go tool:

"".f t=1 size=160 value=0 args=0x8 locals=0x1f40
     0x0000 00000 (test.go:3) TEXT "".f(SB), $8000-8
     0x0000 00000 (test.go:3) MOVQ (TLS), CX
     0x0009 00009 (test.go:3) MOVQ 16(CX), SI
     0x000d 00013 (test.go:3) CMPQ SI, $-1314
     0x0014 00020 (test.go:3) JEQ 138
     .....
     0x008a 00138 (test.go:3) CALL runtime.morestack_noctxt(SB)
     .....

i am so confused by the CMPQ SI, $-1314, what does -1314 mean?

tx for replying.


--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Search Discussions

  • Ian Lance Taylor at Nov 11, 2015 at 1:27 am

    On Tue, Nov 10, 2015 at 5:22 PM, Kai Ding wrote:
    To learn continuous stack in golang , i wrote a test program, like this:
    package main
    "".f t=1 size=160 value=0 args=0x8 locals=0x1f40
    0x0000 00000 (test.go:3) TEXT "".f(SB), $8000-8
    0x0000 00000 (test.go:3) MOVQ (TLS), CX
    0x0009 00009 (test.go:3) MOVQ 16(CX), SI
    0x000d 00013 (test.go:3) CMPQ SI, $-1314
    0x0014 00020 (test.go:3) JEQ 138
    .....
    0x008a 00138 (test.go:3) CALL runtime.morestack_noctxt(SB)
    .....

    i am so confused by the CMPQ SI, $-1314, what does -1314 mean?
    See the value of _StackPreempt in runtime/stack.go (in Go 1.5 the file
    is runtime/stack1.go).

    Ian

    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.
  • Kai Ding at Nov 12, 2015 at 3:49 am
    Yeah, got it, great thanks.


    在 2015年11月11日星期三 UTC+8上午9:28:29,Ian Lance Taylor写道:
    On Tue, Nov 10, 2015 at 5:22 PM, Kai Ding <tracym...@gmail.com
    <javascript:>> wrote:
    To learn continuous stack in golang , i wrote a test program, like this:
    package main
    "".f t=1 size=160 value=0 args=0x8 locals=0x1f40
    0x0000 00000 (test.go:3) TEXT "".f(SB), $8000-8
    0x0000 00000 (test.go:3) MOVQ (TLS), CX
    0x0009 00009 (test.go:3) MOVQ 16(CX), SI
    0x000d 00013 (test.go:3) CMPQ SI, $-1314
    0x0014 00020 (test.go:3) JEQ 138
    .....
    0x008a 00138 (test.go:3) CALL runtime.morestack_noctxt(SB)
    .....

    i am so confused by the CMPQ SI, $-1314, what does -1314 mean?
    See the value of _StackPreempt in runtime/stack.go (in Go 1.5 the file
    is runtime/stack1.go).

    Ian
    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/d/optout.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedNov 11, '15 at 1:22a
activeNov 12, '15 at 3:49a
posts3
users2
websitegolang.org

2 users in discussion

Kai Ding: 2 posts Ian Lance Taylor: 1 post

People

Translate

site design / logo © 2022 Grokbase