]> Cypherpunks repositories - gostls13.git/commitdiff
runtime: clean up naming of mcallable functions.
authorKeith Randall <khr@golang.org>
Wed, 6 Aug 2014 21:33:57 +0000 (14:33 -0700)
committerKeith Randall <khr@golang.org>
Wed, 6 Aug 2014 21:33:57 +0000 (14:33 -0700)
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

src/pkg/runtime/malloc.c
src/pkg/runtime/malloc.go
src/pkg/runtime/mgc0.c
src/pkg/runtime/mprof.goc
src/pkg/runtime/print.go
src/pkg/runtime/stubs.go

index d56d0dcf314f7c421bd2ec5c9d8c29b5e5e70668..951117622f0f0f2894247925e4790d53f0e9fd8e 100644 (file)
@@ -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;
index dedcea94a6f12ea54fe6ce567bb2c989772fb9fc..81769573c98a03ff6f4a99f3ef47cdea73b8d490 100644 (file)
@@ -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)
 }
index e7955151ce09a75a52e4ff2ec75087763836c1b9..01e055cf04e809d2150f4915e8417593a552bbcf 100644 (file)
@@ -1369,7 +1369,7 @@ mgc(G *gp)
 }
 
 void
-runtime·mgc2(void)
+runtime·gc_m(void)
 {
        struct gc_args a;
        G *gp;
index 69187f2a741e4a4da770fa97a94739d7812aa6f5..053781193e8613be9c478fd7bd5c0f39a90a6479 100644 (file)
@@ -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;
index 904af5d3338bd68f830442bfeec6d3fb1736ede6..4b94417c6ec4d3bc6cb32473b24130529f05cd3e 100644 (file)
@@ -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()
index 30638d1af8a9e999d96d4dc2e8e3931e9be25f3b..8a2fc8a97e87a3acf1773c5abce90deb005ac567 100644 (file)
@@ -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