mirror of
https://github.com/golang/go.git
synced 2025-11-11 22:21:06 +00:00
runtime: clean up naming of mcallable functions.
Introduce the mFunction type to represent an mcall/onM-able function. Name such functions using _m. LGTM=bradfitz R=bradfitz CC=golang-codereviews https://golang.org/cl/121320043
This commit is contained in:
parent
161ba662b1
commit
e359bea8ad
6 changed files with 36 additions and 26 deletions
|
|
@ -514,7 +514,7 @@ throw:
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
runtime·setFinalizer(void)
|
runtime·setFinalizer_m(void)
|
||||||
{
|
{
|
||||||
Eface obj, finalizer;
|
Eface obj, finalizer;
|
||||||
|
|
||||||
|
|
@ -531,13 +531,13 @@ runtime·setFinalizer(void)
|
||||||
|
|
||||||
// mcallable cache refill
|
// mcallable cache refill
|
||||||
void
|
void
|
||||||
runtime·mcacheRefill(void)
|
runtime·mcacheRefill_m(void)
|
||||||
{
|
{
|
||||||
runtime·MCache_Refill(g->m->mcache, (int32)g->m->scalararg[0]);
|
runtime·MCache_Refill(g->m->mcache, (int32)g->m->scalararg[0]);
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
runtime·largeAlloc(void)
|
runtime·largeAlloc_m(void)
|
||||||
{
|
{
|
||||||
uintptr npages, size;
|
uintptr npages, size;
|
||||||
MSpan *s;
|
MSpan *s;
|
||||||
|
|
|
||||||
|
|
@ -114,7 +114,7 @@ func gomallocgc(size uintptr, typ *_type, flags int) unsafe.Pointer {
|
||||||
v := s.freelist
|
v := s.freelist
|
||||||
if v == nil {
|
if v == nil {
|
||||||
mp.scalararg[0] = tinySizeClass
|
mp.scalararg[0] = tinySizeClass
|
||||||
onM(&mcacheRefill)
|
onM(&mcacheRefill_m)
|
||||||
s = c.alloc[tinySizeClass]
|
s = c.alloc[tinySizeClass]
|
||||||
v = s.freelist
|
v = s.freelist
|
||||||
}
|
}
|
||||||
|
|
@ -143,7 +143,7 @@ func gomallocgc(size uintptr, typ *_type, flags int) unsafe.Pointer {
|
||||||
v := s.freelist
|
v := s.freelist
|
||||||
if v == nil {
|
if v == nil {
|
||||||
mp.scalararg[0] = uint(sizeclass)
|
mp.scalararg[0] = uint(sizeclass)
|
||||||
onM(&mcacheRefill)
|
onM(&mcacheRefill_m)
|
||||||
s = c.alloc[sizeclass]
|
s = c.alloc[sizeclass]
|
||||||
v = s.freelist
|
v = s.freelist
|
||||||
}
|
}
|
||||||
|
|
@ -162,7 +162,7 @@ func gomallocgc(size uintptr, typ *_type, flags int) unsafe.Pointer {
|
||||||
} else {
|
} else {
|
||||||
mp.scalararg[0] = uint(size)
|
mp.scalararg[0] = uint(size)
|
||||||
mp.scalararg[1] = uint(flags)
|
mp.scalararg[1] = uint(flags)
|
||||||
onM(&largeAlloc)
|
onM(&largeAlloc_m)
|
||||||
s = (*mspan)(mp.ptrarg[0])
|
s = (*mspan)(mp.ptrarg[0])
|
||||||
mp.ptrarg[0] = nil
|
mp.ptrarg[0] = nil
|
||||||
x = unsafe.Pointer(uintptr(s.start << pageShift))
|
x = unsafe.Pointer(uintptr(s.start << pageShift))
|
||||||
|
|
@ -272,7 +272,7 @@ func profilealloc(mp *m, x unsafe.Pointer, size uintptr) {
|
||||||
}
|
}
|
||||||
mp.scalararg[0] = uint(size)
|
mp.scalararg[0] = uint(size)
|
||||||
mp.ptrarg[0] = x
|
mp.ptrarg[0] = x
|
||||||
onM(&mprofMalloc)
|
onM(&mprofMalloc_m)
|
||||||
}
|
}
|
||||||
|
|
||||||
// force = 1 - do GC regardless of current heap usage
|
// force = 1 - do GC regardless of current heap usage
|
||||||
|
|
@ -341,7 +341,7 @@ func gogc(force int32) {
|
||||||
} else {
|
} else {
|
||||||
mp.scalararg[1] = 0
|
mp.scalararg[1] = 0
|
||||||
}
|
}
|
||||||
onM(&mgc2)
|
onM(&gc_m)
|
||||||
}
|
}
|
||||||
|
|
||||||
// all done
|
// all done
|
||||||
|
|
@ -426,6 +426,6 @@ func SetFinalizer(obj interface{}, finalizer interface{}) {
|
||||||
mp.ptrarg[1] = e.data
|
mp.ptrarg[1] = e.data
|
||||||
mp.ptrarg[2] = unsafe.Pointer(ftyp)
|
mp.ptrarg[2] = unsafe.Pointer(ftyp)
|
||||||
mp.ptrarg[3] = f.data
|
mp.ptrarg[3] = f.data
|
||||||
onM(&setFinalizer)
|
onM(&setFinalizer_m)
|
||||||
releasem(mp)
|
releasem(mp)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1369,7 +1369,7 @@ mgc(G *gp)
|
||||||
}
|
}
|
||||||
|
|
||||||
void
|
void
|
||||||
runtime·mgc2(void)
|
runtime·gc_m(void)
|
||||||
{
|
{
|
||||||
struct gc_args a;
|
struct gc_args a;
|
||||||
G *gp;
|
G *gp;
|
||||||
|
|
|
||||||
|
|
@ -142,7 +142,7 @@ runtime·MProf_Malloc(void *p, uintptr size)
|
||||||
|
|
||||||
// Called by malloc to record a profiled block.
|
// Called by malloc to record a profiled block.
|
||||||
void
|
void
|
||||||
runtime·mprofMalloc(void)
|
runtime·mprofMalloc_m(void)
|
||||||
{
|
{
|
||||||
uintptr stk[32];
|
uintptr stk[32];
|
||||||
Bucket *b;
|
Bucket *b;
|
||||||
|
|
|
||||||
|
|
@ -10,10 +10,12 @@ import (
|
||||||
|
|
||||||
// these 4 functions are complicated enough that we will share
|
// these 4 functions are complicated enough that we will share
|
||||||
// the print logic with the C printf.
|
// the print logic with the C printf.
|
||||||
var printstring_m byte
|
var (
|
||||||
var printuint_m byte
|
printstring_m,
|
||||||
var printhex_m byte
|
printuint_m,
|
||||||
var printfloat_m byte
|
printhex_m,
|
||||||
|
printfloat_m mFunction
|
||||||
|
)
|
||||||
|
|
||||||
func printstring(s string) {
|
func printstring(s string) {
|
||||||
mp := acquirem()
|
mp := acquirem()
|
||||||
|
|
|
||||||
|
|
@ -44,21 +44,29 @@ func roundup(p unsafe.Pointer, n uintptr) unsafe.Pointer {
|
||||||
func acquirem() *m
|
func acquirem() *m
|
||||||
func releasem(mp *m)
|
func releasem(mp *m)
|
||||||
|
|
||||||
// in asm_*.s
|
// An mFunction represents a C function that runs on the M stack. It
|
||||||
func mcall(fn *byte)
|
// can be called from Go using mcall or onM. Through the magic of
|
||||||
func onM(fn *byte)
|
// linking, an mFunction variable and the corresponding C code entry
|
||||||
|
// point live at the same address.
|
||||||
|
type mFunction byte
|
||||||
|
|
||||||
// C routines that run on the M stack. Call these like
|
// in asm_*.s
|
||||||
// mcall(&mcacheRefill)
|
func mcall(fn *mFunction)
|
||||||
|
func onM(fn *mFunction)
|
||||||
|
|
||||||
|
// C functions that run on the M stack. Call these like
|
||||||
|
// mcall(&mcacheRefill_m)
|
||||||
// Arguments should be passed in m->scalararg[x] and
|
// Arguments should be passed in m->scalararg[x] and
|
||||||
// m->ptrarg[x]. Return values can be passed in those
|
// m->ptrarg[x]. Return values can be passed in those
|
||||||
// same slots.
|
// same slots.
|
||||||
var mcacheRefill byte
|
var (
|
||||||
var largeAlloc byte
|
mcacheRefill_m,
|
||||||
var mprofMalloc byte
|
largeAlloc_m,
|
||||||
var mgc2 byte
|
mprofMalloc_m,
|
||||||
var setFinalizer byte
|
gc_m,
|
||||||
var markallocated_m byte
|
setFinalizer_m,
|
||||||
|
markallocated_m mFunction
|
||||||
|
)
|
||||||
|
|
||||||
// memclr clears n bytes starting at ptr.
|
// memclr clears n bytes starting at ptr.
|
||||||
// in memclr_*.s
|
// in memclr_*.s
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue