2009-03-30 01:01:07 -06:00
|
|
|
// Copyright 2009 The Go Authors. All rights reserved.
|
|
|
|
// Use of this source code is governed by a BSD-style
|
|
|
|
// license that can be found in the LICENSE file.
|
|
|
|
|
2009-06-17 16:15:55 -06:00
|
|
|
#include "386/asm.h"
|
|
|
|
|
2009-03-30 01:01:07 -06:00
|
|
|
TEXT _rt0_386(SB),7,$0
|
|
|
|
// copy arguments forward on an even stack
|
|
|
|
MOVL 0(SP), AX // argc
|
|
|
|
LEAL 4(SP), BX // argv
|
|
|
|
SUBL $128, SP // plenty of scratch
|
2009-10-03 11:37:12 -06:00
|
|
|
ANDL $~15, SP
|
2009-03-30 01:01:07 -06:00
|
|
|
MOVL AX, 120(SP) // save argc, argv away
|
|
|
|
MOVL BX, 124(SP)
|
|
|
|
|
2009-10-03 11:37:12 -06:00
|
|
|
// if there is an initcgo, call it to let it
|
|
|
|
// initialize and to set up GS. if not,
|
|
|
|
// we set up GS ourselves.
|
|
|
|
MOVL initcgo(SB), AX
|
|
|
|
TESTL AX, AX
|
|
|
|
JZ 3(PC)
|
|
|
|
CALL AX
|
|
|
|
JMP ok
|
|
|
|
|
2009-09-22 17:28:32 -06:00
|
|
|
// set up %gs
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
CALL runtime·ldt0setup(SB)
|
2009-03-30 01:01:07 -06:00
|
|
|
|
|
|
|
// store through it, to make sure it works
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
CMPL runtime·isplan9(SB), $1
|
2010-10-18 10:32:55 -06:00
|
|
|
JEQ ok
|
2010-01-06 18:58:55 -07:00
|
|
|
get_tls(BX)
|
|
|
|
MOVL $0x123, g(BX)
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
MOVL runtime·tls0(SB), AX
|
2009-03-30 01:01:07 -06:00
|
|
|
CMPL AX, $0x123
|
|
|
|
JEQ ok
|
2009-10-03 11:37:12 -06:00
|
|
|
MOVL AX, 0 // abort
|
2009-03-30 01:01:07 -06:00
|
|
|
ok:
|
|
|
|
// set up m and g "registers"
|
2010-01-06 18:58:55 -07:00
|
|
|
get_tls(BX)
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
LEAL runtime·g0(SB), CX
|
2010-01-06 18:58:55 -07:00
|
|
|
MOVL CX, g(BX)
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
LEAL runtime·m0(SB), AX
|
2010-01-06 18:58:55 -07:00
|
|
|
MOVL AX, m(BX)
|
2009-03-30 01:01:07 -06:00
|
|
|
|
|
|
|
// save m->g0 = g0
|
2009-06-17 16:15:55 -06:00
|
|
|
MOVL CX, m_g0(AX)
|
2009-03-30 01:01:07 -06:00
|
|
|
|
|
|
|
// create istack out of the OS stack
|
|
|
|
LEAL (-8192+104)(SP), AX // TODO: 104?
|
2009-06-17 16:15:55 -06:00
|
|
|
MOVL AX, g_stackguard(CX)
|
|
|
|
MOVL SP, g_stackbase(CX)
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
CALL runtime·emptyfunc(SB) // fault if stack check is wrong
|
2009-03-30 01:01:07 -06:00
|
|
|
|
|
|
|
// convention is D is always cleared
|
|
|
|
CLD
|
|
|
|
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
CALL runtime·check(SB)
|
2009-03-30 01:01:07 -06:00
|
|
|
|
|
|
|
// saved argc, argv
|
|
|
|
MOVL 120(SP), AX
|
|
|
|
MOVL AX, 0(SP)
|
|
|
|
MOVL 124(SP), AX
|
|
|
|
MOVL AX, 4(SP)
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
CALL runtime·args(SB)
|
|
|
|
CALL runtime·osinit(SB)
|
|
|
|
CALL runtime·schedinit(SB)
|
2009-03-30 01:01:07 -06:00
|
|
|
|
|
|
|
// create a new goroutine to start program
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
PUSHL $runtime·mainstart(SB) // entry
|
2009-06-17 16:15:55 -06:00
|
|
|
PUSHL $0 // arg size
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
CALL runtime·newproc(SB)
|
2009-03-30 01:01:07 -06:00
|
|
|
POPL AX
|
|
|
|
POPL AX
|
|
|
|
|
|
|
|
// start this M
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
CALL runtime·mstart(SB)
|
2009-03-30 01:01:07 -06:00
|
|
|
|
|
|
|
INT $3
|
|
|
|
RET
|
|
|
|
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
TEXT runtime·mainstart(SB),7,$0
|
2009-03-30 01:01:07 -06:00
|
|
|
CALL main·init(SB)
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
CALL runtime·initdone(SB)
|
2009-03-30 01:01:07 -06:00
|
|
|
CALL main·main(SB)
|
|
|
|
PUSHL $0
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
CALL runtime·exit(SB)
|
2009-03-30 01:01:07 -06:00
|
|
|
POPL AX
|
|
|
|
INT $3
|
|
|
|
RET
|
|
|
|
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
TEXT runtime·breakpoint(SB),7,$0
|
2009-09-22 17:28:32 -06:00
|
|
|
INT $3
|
2009-03-30 01:01:07 -06:00
|
|
|
RET
|
|
|
|
|
2009-06-17 16:15:55 -06:00
|
|
|
/*
|
|
|
|
* go-routine
|
|
|
|
*/
|
2009-03-30 01:01:07 -06:00
|
|
|
|
2009-06-17 16:15:55 -06:00
|
|
|
// uintptr gosave(Gobuf*)
|
|
|
|
// save state in Gobuf; setjmp
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
TEXT runtime·gosave(SB), 7, $0
|
2009-06-17 16:15:55 -06:00
|
|
|
MOVL 4(SP), AX // gobuf
|
|
|
|
LEAL 4(SP), BX // caller's SP
|
|
|
|
MOVL BX, gobuf_sp(AX)
|
|
|
|
MOVL 0(SP), BX // caller's PC
|
|
|
|
MOVL BX, gobuf_pc(AX)
|
2010-01-06 18:58:55 -07:00
|
|
|
get_tls(CX)
|
|
|
|
MOVL g(CX), BX
|
2009-06-17 16:15:55 -06:00
|
|
|
MOVL BX, gobuf_g(AX)
|
|
|
|
MOVL $0, AX // return 0
|
2009-03-30 01:01:07 -06:00
|
|
|
RET
|
|
|
|
|
2009-06-17 16:15:55 -06:00
|
|
|
// void gogo(Gobuf*, uintptr)
|
|
|
|
// restore state from Gobuf; longjmp
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
TEXT runtime·gogo(SB), 7, $0
|
2009-06-17 16:15:55 -06:00
|
|
|
MOVL 8(SP), AX // return 2nd arg
|
|
|
|
MOVL 4(SP), BX // gobuf
|
|
|
|
MOVL gobuf_g(BX), DX
|
|
|
|
MOVL 0(DX), CX // make sure g != nil
|
2010-01-06 18:58:55 -07:00
|
|
|
get_tls(CX)
|
|
|
|
MOVL DX, g(CX)
|
2009-06-17 16:15:55 -06:00
|
|
|
MOVL gobuf_sp(BX), SP // restore SP
|
|
|
|
MOVL gobuf_pc(BX), BX
|
|
|
|
JMP BX
|
|
|
|
|
|
|
|
// void gogocall(Gobuf*, void (*fn)(void))
|
|
|
|
// restore state from Gobuf but then call fn.
|
|
|
|
// (call fn, returning to state in Gobuf)
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
TEXT runtime·gogocall(SB), 7, $0
|
2009-06-17 16:15:55 -06:00
|
|
|
MOVL 8(SP), AX // fn
|
|
|
|
MOVL 4(SP), BX // gobuf
|
|
|
|
MOVL gobuf_g(BX), DX
|
2010-01-06 18:58:55 -07:00
|
|
|
get_tls(CX)
|
|
|
|
MOVL DX, g(CX)
|
2009-06-17 16:15:55 -06:00
|
|
|
MOVL 0(DX), CX // make sure g != nil
|
|
|
|
MOVL gobuf_sp(BX), SP // restore SP
|
|
|
|
MOVL gobuf_pc(BX), BX
|
|
|
|
PUSHL BX
|
|
|
|
JMP AX
|
|
|
|
POPL BX // not reached
|
|
|
|
|
|
|
|
/*
|
|
|
|
* support for morestack
|
|
|
|
*/
|
|
|
|
|
|
|
|
// Called during function prolog when more stack is needed.
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
TEXT runtime·morestack(SB),7,$0
|
2009-06-17 16:15:55 -06:00
|
|
|
// Cannot grow scheduler stack (m->g0).
|
2010-01-06 18:58:55 -07:00
|
|
|
get_tls(CX)
|
|
|
|
MOVL m(CX), BX
|
2009-06-17 16:15:55 -06:00
|
|
|
MOVL m_g0(BX), SI
|
2010-01-06 18:58:55 -07:00
|
|
|
CMPL g(CX), SI
|
2009-06-17 16:15:55 -06:00
|
|
|
JNE 2(PC)
|
|
|
|
INT $3
|
|
|
|
|
|
|
|
// frame size in DX
|
|
|
|
// arg size in AX
|
|
|
|
// Save in m.
|
|
|
|
MOVL DX, m_moreframe(BX)
|
|
|
|
MOVL AX, m_moreargs(BX)
|
|
|
|
|
|
|
|
// Called from f.
|
|
|
|
// Set m->morebuf to f's caller.
|
|
|
|
MOVL 4(SP), DI // f's caller's PC
|
|
|
|
MOVL DI, (m_morebuf+gobuf_pc)(BX)
|
|
|
|
LEAL 8(SP), CX // f's caller's SP
|
|
|
|
MOVL CX, (m_morebuf+gobuf_sp)(BX)
|
2009-07-08 19:16:09 -06:00
|
|
|
MOVL CX, (m_morefp)(BX)
|
2010-01-06 18:58:55 -07:00
|
|
|
get_tls(CX)
|
|
|
|
MOVL g(CX), SI
|
2009-06-17 16:15:55 -06:00
|
|
|
MOVL SI, (m_morebuf+gobuf_g)(BX)
|
|
|
|
|
|
|
|
// Set m->morepc to f's PC.
|
|
|
|
MOVL 0(SP), AX
|
|
|
|
MOVL AX, m_morepc(BX)
|
|
|
|
|
|
|
|
// Call newstack on m's scheduling stack.
|
|
|
|
MOVL m_g0(BX), BP
|
2010-01-06 18:58:55 -07:00
|
|
|
MOVL BP, g(CX)
|
2010-12-07 15:19:36 -07:00
|
|
|
MOVL (m_sched+gobuf_sp)(BX), AX
|
|
|
|
MOVL -4(AX), BX // fault if CALL would, before smashing SP
|
|
|
|
MOVL AX, SP
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
CALL runtime·newstack(SB)
|
2009-06-17 16:15:55 -06:00
|
|
|
MOVL $0, 0x1003 // crash if newstack returns
|
2009-03-30 01:01:07 -06:00
|
|
|
RET
|
|
|
|
|
2009-07-08 19:16:09 -06:00
|
|
|
// Called from reflection library. Mimics morestack,
|
|
|
|
// reuses stack growth code to create a frame
|
|
|
|
// with the desired args running the desired function.
|
|
|
|
//
|
|
|
|
// func call(fn *byte, arg *byte, argsize uint32).
|
|
|
|
TEXT reflect·call(SB), 7, $0
|
2010-01-06 18:58:55 -07:00
|
|
|
get_tls(CX)
|
|
|
|
MOVL m(CX), BX
|
2009-07-08 19:16:09 -06:00
|
|
|
|
|
|
|
// Save our caller's state as the PC and SP to
|
|
|
|
// restore when returning from f.
|
|
|
|
MOVL 0(SP), AX // our caller's PC
|
|
|
|
MOVL AX, (m_morebuf+gobuf_pc)(BX)
|
|
|
|
LEAL 4(SP), AX // our caller's SP
|
|
|
|
MOVL AX, (m_morebuf+gobuf_sp)(BX)
|
2010-01-06 18:58:55 -07:00
|
|
|
MOVL g(CX), AX
|
2009-07-08 19:16:09 -06:00
|
|
|
MOVL AX, (m_morebuf+gobuf_g)(BX)
|
|
|
|
|
|
|
|
// Set up morestack arguments to call f on a new stack.
|
2010-03-29 22:48:22 -06:00
|
|
|
// We set f's frame size to 1, as a hint to newstack
|
|
|
|
// that this is a call from reflect·call.
|
|
|
|
// If it turns out that f needs a larger frame than
|
|
|
|
// the default stack, f's usual stack growth prolog will
|
|
|
|
// allocate a new segment (and recopy the arguments).
|
2009-07-08 19:16:09 -06:00
|
|
|
MOVL 4(SP), AX // fn
|
|
|
|
MOVL 8(SP), DX // arg frame
|
|
|
|
MOVL 12(SP), CX // arg size
|
|
|
|
|
|
|
|
MOVL AX, m_morepc(BX) // f's PC
|
|
|
|
MOVL DX, m_morefp(BX) // argument frame pointer
|
|
|
|
MOVL CX, m_moreargs(BX) // f's argument size
|
2010-03-29 22:48:22 -06:00
|
|
|
MOVL $1, m_moreframe(BX) // f's frame size
|
2009-07-08 19:16:09 -06:00
|
|
|
|
|
|
|
// Call newstack on m's scheduling stack.
|
|
|
|
MOVL m_g0(BX), BP
|
2010-01-06 18:58:55 -07:00
|
|
|
get_tls(CX)
|
|
|
|
MOVL BP, g(CX)
|
2009-07-08 19:16:09 -06:00
|
|
|
MOVL (m_sched+gobuf_sp)(BX), SP
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
CALL runtime·newstack(SB)
|
2009-07-08 19:16:09 -06:00
|
|
|
MOVL $0, 0x1103 // crash if newstack returns
|
|
|
|
RET
|
|
|
|
|
|
|
|
|
2009-06-17 16:15:55 -06:00
|
|
|
// Return point when leaving stack.
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
TEXT runtime·lessstack(SB), 7, $0
|
2009-06-17 16:15:55 -06:00
|
|
|
// Save return value in m->cret
|
2010-01-06 18:58:55 -07:00
|
|
|
get_tls(CX)
|
|
|
|
MOVL m(CX), BX
|
2009-06-17 16:15:55 -06:00
|
|
|
MOVL AX, m_cret(BX)
|
|
|
|
|
|
|
|
// Call oldstack on m's scheduling stack.
|
|
|
|
MOVL m_g0(BX), DX
|
2010-01-06 18:58:55 -07:00
|
|
|
MOVL DX, g(CX)
|
2009-06-17 16:15:55 -06:00
|
|
|
MOVL (m_sched+gobuf_sp)(BX), SP
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
CALL runtime·oldstack(SB)
|
2009-06-17 16:15:55 -06:00
|
|
|
MOVL $0, 0x1004 // crash if oldstack returns
|
2009-03-30 01:01:07 -06:00
|
|
|
RET
|
|
|
|
|
2009-06-17 16:15:55 -06:00
|
|
|
|
2009-03-30 01:01:07 -06:00
|
|
|
// bool cas(int32 *val, int32 old, int32 new)
|
|
|
|
// Atomically:
|
|
|
|
// if(*val == old){
|
|
|
|
// *val = new;
|
|
|
|
// return 1;
|
|
|
|
// }else
|
|
|
|
// return 0;
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
TEXT runtime·cas(SB), 7, $0
|
2009-03-30 01:01:07 -06:00
|
|
|
MOVL 4(SP), BX
|
|
|
|
MOVL 8(SP), AX
|
|
|
|
MOVL 12(SP), CX
|
|
|
|
LOCK
|
|
|
|
CMPXCHGL CX, 0(BX)
|
|
|
|
JZ 3(PC)
|
|
|
|
MOVL $0, AX
|
|
|
|
RET
|
|
|
|
MOVL $1, AX
|
|
|
|
RET
|
|
|
|
|
2010-01-06 18:58:55 -07:00
|
|
|
// bool casp(void **p, void *old, void *new)
|
|
|
|
// Atomically:
|
|
|
|
// if(*p == old){
|
|
|
|
// *p = new;
|
|
|
|
// return 1;
|
|
|
|
// }else
|
|
|
|
// return 0;
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
TEXT runtime·casp(SB), 7, $0
|
2010-01-06 18:58:55 -07:00
|
|
|
MOVL 4(SP), BX
|
|
|
|
MOVL 8(SP), AX
|
|
|
|
MOVL 12(SP), CX
|
|
|
|
LOCK
|
|
|
|
CMPXCHGL CX, 0(BX)
|
|
|
|
JZ 3(PC)
|
|
|
|
MOVL $0, AX
|
|
|
|
RET
|
|
|
|
MOVL $1, AX
|
|
|
|
RET
|
|
|
|
|
2009-06-03 00:02:12 -06:00
|
|
|
// void jmpdefer(fn, sp);
|
|
|
|
// called from deferreturn.
|
2009-03-30 01:01:07 -06:00
|
|
|
// 1. pop the caller
|
|
|
|
// 2. sub 5 bytes from the callers return
|
|
|
|
// 3. jmp to the argument
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
TEXT runtime·jmpdefer(SB), 7, $0
|
2009-06-03 00:02:12 -06:00
|
|
|
MOVL 4(SP), AX // fn
|
|
|
|
MOVL 8(SP), BX // caller sp
|
|
|
|
LEAL -4(BX), SP // caller sp after CALL
|
|
|
|
SUBL $5, (SP) // return to CALL again
|
|
|
|
JMP AX // but first run the deferred function
|
2009-03-30 01:01:07 -06:00
|
|
|
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
TEXT runtime·memclr(SB),7,$0
|
2009-03-30 01:01:07 -06:00
|
|
|
MOVL 4(SP), DI // arg 1 addr
|
|
|
|
MOVL 8(SP), CX // arg 2 count
|
|
|
|
ADDL $3, CX
|
|
|
|
SHRL $2, CX
|
|
|
|
MOVL $0, AX
|
|
|
|
CLD
|
|
|
|
REP
|
|
|
|
STOSL
|
|
|
|
RET
|
|
|
|
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
TEXT runtime·getcallerpc(SB),7,$0
|
2009-03-30 01:01:07 -06:00
|
|
|
MOVL x+0(FP),AX // addr of first arg
|
|
|
|
MOVL -4(AX),AX // get calling pc
|
|
|
|
RET
|
|
|
|
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
TEXT runtime·setcallerpc(SB),7,$0
|
2009-03-30 01:01:07 -06:00
|
|
|
MOVL x+0(FP),AX // addr of first arg
|
|
|
|
MOVL x+4(FP), BX
|
|
|
|
MOVL BX, -4(AX) // set calling pc
|
|
|
|
RET
|
|
|
|
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
TEXT runtime·getcallersp(SB), 7, $0
|
2010-04-05 13:51:09 -06:00
|
|
|
MOVL sp+0(FP), AX
|
|
|
|
RET
|
|
|
|
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
TEXT runtime·ldt0setup(SB),7,$16
|
2009-03-30 01:01:07 -06:00
|
|
|
// set up ldt 7 to point at tls0
|
|
|
|
// ldt 1 would be fine on Linux, but on OS X, 7 is as low as we can go.
|
2009-09-22 17:28:32 -06:00
|
|
|
// the entry number is just a hint. setldt will set up GS with what it used.
|
2009-03-30 01:01:07 -06:00
|
|
|
MOVL $7, 0(SP)
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
LEAL runtime·tls0(SB), AX
|
2009-03-30 01:01:07 -06:00
|
|
|
MOVL AX, 4(SP)
|
|
|
|
MOVL $32, 8(SP) // sizeof(tls array)
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
CALL runtime·setldt(SB)
|
2009-03-30 01:01:07 -06:00
|
|
|
RET
|
|
|
|
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
TEXT runtime·emptyfunc(SB),0,$0
|
2009-03-30 01:01:07 -06:00
|
|
|
RET
|
|
|
|
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
TEXT runtime·abort(SB),7,$0
|
2009-03-30 01:01:07 -06:00
|
|
|
INT $0x3
|
2009-10-03 11:37:12 -06:00
|
|
|
|
|
|
|
// runcgo(void(*fn)(void*), void *arg)
|
2009-10-12 11:26:38 -06:00
|
|
|
// Call fn(arg) on the scheduler stack,
|
|
|
|
// aligned appropriately for the gcc ABI.
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
TEXT runtime·runcgo(SB),7,$16
|
2009-10-03 11:37:12 -06:00
|
|
|
MOVL fn+0(FP), AX
|
|
|
|
MOVL arg+4(FP), BX
|
|
|
|
MOVL SP, CX
|
2009-10-12 11:26:38 -06:00
|
|
|
|
|
|
|
// Figure out if we need to switch to m->g0 stack.
|
2010-01-06 18:58:55 -07:00
|
|
|
get_tls(DI)
|
|
|
|
MOVL m(DI), DX
|
2009-10-12 11:26:38 -06:00
|
|
|
MOVL m_g0(DX), SI
|
2010-01-06 18:58:55 -07:00
|
|
|
CMPL g(DI), SI
|
2009-10-12 11:26:38 -06:00
|
|
|
JEQ 2(PC)
|
|
|
|
MOVL (m_sched+gobuf_sp)(DX), SP
|
|
|
|
|
|
|
|
// Now on a scheduling stack (a pthread-created stack).
|
|
|
|
SUBL $16, SP
|
2009-10-03 11:37:12 -06:00
|
|
|
ANDL $~15, SP // alignment for gcc ABI
|
2010-04-09 14:30:35 -06:00
|
|
|
MOVL g(DI), BP
|
|
|
|
MOVL BP, 8(SP)
|
|
|
|
MOVL SI, g(DI)
|
2009-10-03 11:37:12 -06:00
|
|
|
MOVL CX, 4(SP)
|
|
|
|
MOVL BX, 0(SP)
|
|
|
|
CALL AX
|
2010-01-13 10:08:39 -07:00
|
|
|
|
2010-04-09 14:30:35 -06:00
|
|
|
// Back; switch to original g and stack, re-establish
|
2010-01-13 10:08:39 -07:00
|
|
|
// "DF is clear" invariant.
|
|
|
|
CLD
|
2010-04-09 14:30:35 -06:00
|
|
|
get_tls(DI)
|
|
|
|
MOVL 8(SP), SI
|
|
|
|
MOVL SI, g(DI)
|
2009-10-03 11:37:12 -06:00
|
|
|
MOVL 4(SP), SP
|
|
|
|
RET
|
|
|
|
|
2010-04-09 14:30:35 -06:00
|
|
|
// runcgocallback(G *g1, void* sp, void (*fn)(void))
|
|
|
|
// Switch to g1 and sp, call fn, switch back. fn's arguments are on
|
|
|
|
// the new stack.
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
TEXT runtime·runcgocallback(SB),7,$32
|
2010-04-09 14:30:35 -06:00
|
|
|
MOVL g1+0(FP), DX
|
|
|
|
MOVL sp+4(FP), AX
|
|
|
|
MOVL fn+8(FP), BX
|
|
|
|
|
|
|
|
// We are running on m's scheduler stack. Save current SP
|
|
|
|
// into m->sched.sp so that a recursive call to runcgo doesn't
|
|
|
|
// clobber our stack, and also so that we can restore
|
|
|
|
// the SP when the call finishes. Reusing m->sched.sp
|
|
|
|
// for this purpose depends on the fact that there is only
|
|
|
|
// one possible gosave of m->sched.
|
|
|
|
get_tls(CX)
|
|
|
|
MOVL DX, g(CX)
|
|
|
|
MOVL m(CX), CX
|
|
|
|
MOVL SP, (m_sched+gobuf_sp)(CX)
|
|
|
|
|
|
|
|
// Set new SP, call fn
|
|
|
|
MOVL AX, SP
|
|
|
|
CALL BX
|
|
|
|
|
|
|
|
// Restore old g and SP, return
|
|
|
|
get_tls(CX)
|
|
|
|
MOVL m(CX), DX
|
|
|
|
MOVL m_g0(DX), BX
|
|
|
|
MOVL BX, g(CX)
|
|
|
|
MOVL (m_sched+gobuf_sp)(DX), SP
|
|
|
|
RET
|
|
|
|
|
2009-12-08 19:19:30 -07:00
|
|
|
// check that SP is in range [g->stackbase, g->stackguard)
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
TEXT runtime·stackcheck(SB), 7, $0
|
2010-01-06 18:58:55 -07:00
|
|
|
get_tls(CX)
|
2010-03-30 11:53:16 -06:00
|
|
|
MOVL g(CX), AX
|
|
|
|
CMPL g_stackbase(AX), SP
|
|
|
|
JHI 2(PC)
|
|
|
|
INT $3
|
|
|
|
CMPL SP, g_stackguard(AX)
|
|
|
|
JHI 2(PC)
|
|
|
|
INT $3
|
2009-12-08 19:19:30 -07:00
|
|
|
RET
|
|
|
|
|
runtime: ,s/[a-zA-Z0-9_]+/runtime·&/g, almost
Prefix all external symbols in runtime by runtime·,
to avoid conflicts with possible symbols of the same
name in linked-in C libraries. The obvious conflicts
are printf, malloc, and free, but hide everything to
avoid future pain.
The symbols left alone are:
** known to cgo **
_cgo_free
_cgo_malloc
libcgo_thread_start
initcgo
ncgocall
** known to linker **
_rt0_$GOARCH
_rt0_$GOARCH_$GOOS
text
etext
data
end
pclntab
epclntab
symtab
esymtab
** known to C compiler **
_divv
_modv
_div64by32
etc (arch specific)
Tested on darwin/386, darwin/amd64, linux/386, linux/amd64.
Built (but not tested) for freebsd/386, freebsd/amd64, linux/arm, windows/386.
R=r, PeterGo
CC=golang-dev
https://golang.org/cl/2899041
2010-11-04 12:00:19 -06:00
|
|
|
GLOBL runtime·tls0(SB), $32
|