Commit e359bea8 authored by Keith Randall's avatar Keith Randall

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
parent 161ba662
......@@ -514,7 +514,7 @@ throw:
}
void
runtime·setFinalizer(void)
runtime·setFinalizer_m(void)
{
Eface obj, finalizer;
......@@ -531,13 +531,13 @@ runtime·setFinalizer(void)
// mcallable cache refill
void
runtime·mcacheRefill(void)
runtime·mcacheRefill_m(void)
{
runtime·MCache_Refill(g->m->mcache, (int32)g->m->scalararg[0]);
}
void
runtime·largeAlloc(void)
runtime·largeAlloc_m(void)
{
uintptr npages, size;
MSpan *s;
......
......@@ -114,7 +114,7 @@ func gomallocgc(size uintptr, typ *_type, flags int) unsafe.Pointer {
v := s.freelist
if v == nil {
mp.scalararg[0] = tinySizeClass
onM(&mcacheRefill)
onM(&mcacheRefill_m)
s = c.alloc[tinySizeClass]
v = s.freelist
}
......@@ -143,7 +143,7 @@ func gomallocgc(size uintptr, typ *_type, flags int) unsafe.Pointer {
v := s.freelist
if v == nil {
mp.scalararg[0] = uint(sizeclass)
onM(&mcacheRefill)
onM(&mcacheRefill_m)
s = c.alloc[sizeclass]
v = s.freelist
}
......@@ -162,7 +162,7 @@ func gomallocgc(size uintptr, typ *_type, flags int) unsafe.Pointer {
} else {
mp.scalararg[0] = uint(size)
mp.scalararg[1] = uint(flags)
onM(&largeAlloc)
onM(&largeAlloc_m)
s = (*mspan)(mp.ptrarg[0])
mp.ptrarg[0] = nil
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.ptrarg[0] = x
onM(&mprofMalloc)
onM(&mprofMalloc_m)
}
// force = 1 - do GC regardless of current heap usage
......@@ -341,7 +341,7 @@ func gogc(force int32) {
} else {
mp.scalararg[1] = 0
}
onM(&mgc2)
onM(&gc_m)
}
// all done
......@@ -426,6 +426,6 @@ func SetFinalizer(obj interface{}, finalizer interface{}) {
mp.ptrarg[1] = e.data
mp.ptrarg[2] = unsafe.Pointer(ftyp)
mp.ptrarg[3] = f.data
onM(&setFinalizer)
onM(&setFinalizer_m)
releasem(mp)
}
......@@ -1369,7 +1369,7 @@ mgc(G *gp)
}
void
runtime·mgc2(void)
runtime·gc_m(void)
{
struct gc_args a;
G *gp;
......
......@@ -142,7 +142,7 @@ runtime·MProf_Malloc(void *p, uintptr size)
// Called by malloc to record a profiled block.
void
runtime·mprofMalloc(void)
runtime·mprofMalloc_m(void)
{
uintptr stk[32];
Bucket *b;
......
......@@ -10,10 +10,12 @@ import (
// these 4 functions are complicated enough that we will share
// the print logic with the C printf.
var printstring_m byte
var printuint_m byte
var printhex_m byte
var printfloat_m byte
var (
printstring_m,
printuint_m,
printhex_m,
printfloat_m mFunction
)
func printstring(s string) {
mp := acquirem()
......
......@@ -44,21 +44,29 @@ func roundup(p unsafe.Pointer, n uintptr) unsafe.Pointer {
func acquirem() *m
func releasem(mp *m)
// An mFunction represents a C function that runs on the M stack. It
// can be called from Go using mcall or onM. Through the magic of
// linking, an mFunction variable and the corresponding C code entry
// point live at the same address.
type mFunction byte
// in asm_*.s
func mcall(fn *byte)
func onM(fn *byte)
func mcall(fn *mFunction)
func onM(fn *mFunction)
// C routines that run on the M stack. Call these like
// mcall(&mcacheRefill)
// C functions that run on the M stack. Call these like
// mcall(&mcacheRefill_m)
// Arguments should be passed in m->scalararg[x] and
// m->ptrarg[x]. Return values can be passed in those
// same slots.
var mcacheRefill byte
var largeAlloc byte
var mprofMalloc byte
var mgc2 byte
var setFinalizer byte
var markallocated_m byte
var (
mcacheRefill_m,
largeAlloc_m,
mprofMalloc_m,
gc_m,
setFinalizer_m,
markallocated_m mFunction
)
// memclr clears n bytes starting at ptr.
// in memclr_*.s
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment