Commit 99a08262 authored by Russ Cox's avatar Russ Cox

runtime: mark sysAlloc nosplit

sysAlloc is the only mem function called from Go.

LGTM=iant, khr
R=golang-codereviews, khr, 0intro, iant
CC=dvyukov, golang-codereviews, r
https://golang.org/cl/139210043
parent db58ab96
...@@ -7,7 +7,9 @@ ...@@ -7,7 +7,9 @@
#include "defs_GOOS_GOARCH.h" #include "defs_GOOS_GOARCH.h"
#include "os_GOOS.h" #include "os_GOOS.h"
#include "malloc.h" #include "malloc.h"
#include "../../cmd/ld/textflag.h"
#pragma textflag NOSPLIT
void* void*
runtime·sysAlloc(uintptr n, uint64 *stat) runtime·sysAlloc(uintptr n, uint64 *stat)
{ {
......
...@@ -7,12 +7,14 @@ ...@@ -7,12 +7,14 @@
#include "defs_GOOS_GOARCH.h" #include "defs_GOOS_GOARCH.h"
#include "os_GOOS.h" #include "os_GOOS.h"
#include "malloc.h" #include "malloc.h"
#include "textflag.h"
enum enum
{ {
ENOMEM = 12, ENOMEM = 12,
}; };
#pragma textflag NOSPLIT
void* void*
runtime·sysAlloc(uintptr n, uint64 *stat) runtime·sysAlloc(uintptr n, uint64 *stat)
{ {
......
...@@ -7,12 +7,14 @@ ...@@ -7,12 +7,14 @@
#include "defs_GOOS_GOARCH.h" #include "defs_GOOS_GOARCH.h"
#include "os_GOOS.h" #include "os_GOOS.h"
#include "malloc.h" #include "malloc.h"
#include "textflag.h"
enum enum
{ {
ENOMEM = 12, ENOMEM = 12,
}; };
#pragma textflag NOSPLIT
void* void*
runtime·sysAlloc(uintptr n, uint64 *stat) runtime·sysAlloc(uintptr n, uint64 *stat)
{ {
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "defs_GOOS_GOARCH.h" #include "defs_GOOS_GOARCH.h"
#include "os_GOOS.h" #include "os_GOOS.h"
#include "malloc.h" #include "malloc.h"
#include "../../cmd/ld/textflag.h"
enum enum
{ {
...@@ -57,6 +58,7 @@ mmap_fixed(byte *v, uintptr n, int32 prot, int32 flags, int32 fd, uint32 offset) ...@@ -57,6 +58,7 @@ mmap_fixed(byte *v, uintptr n, int32 prot, int32 flags, int32 fd, uint32 offset)
return p; return p;
} }
#pragma textflag NOSPLIT
void* void*
runtime·sysAlloc(uintptr n, uint64 *stat) runtime·sysAlloc(uintptr n, uint64 *stat)
{ {
......
...@@ -7,12 +7,14 @@ ...@@ -7,12 +7,14 @@
#include "defs_GOOS_GOARCH.h" #include "defs_GOOS_GOARCH.h"
#include "os_GOOS.h" #include "os_GOOS.h"
#include "malloc.h" #include "malloc.h"
#include "../../cmd/ld/textflag.h"
enum enum
{ {
Debug = 0, Debug = 0,
}; };
#pragma textflag NOSPLIT
void* void*
runtime·sysAlloc(uintptr n, uint64 *stat) runtime·sysAlloc(uintptr n, uint64 *stat)
{ {
......
...@@ -7,12 +7,14 @@ ...@@ -7,12 +7,14 @@
#include "defs_GOOS_GOARCH.h" #include "defs_GOOS_GOARCH.h"
#include "os_GOOS.h" #include "os_GOOS.h"
#include "malloc.h" #include "malloc.h"
#include "../../cmd/ld/textflag.h"
enum enum
{ {
ENOMEM = 12, ENOMEM = 12,
}; };
#pragma textflag NOSPLIT
void* void*
runtime·sysAlloc(uintptr n, uint64 *stat) runtime·sysAlloc(uintptr n, uint64 *stat)
{ {
......
...@@ -7,12 +7,14 @@ ...@@ -7,12 +7,14 @@
#include "defs_GOOS_GOARCH.h" #include "defs_GOOS_GOARCH.h"
#include "os_GOOS.h" #include "os_GOOS.h"
#include "malloc.h" #include "malloc.h"
#include "../../cmd/ld/textflag.h"
enum enum
{ {
ENOMEM = 12, ENOMEM = 12,
}; };
#pragma textflag NOSPLIT
void* void*
runtime·sysAlloc(uintptr n, uint64 *stat) runtime·sysAlloc(uintptr n, uint64 *stat)
{ {
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "arch_GOARCH.h" #include "arch_GOARCH.h"
#include "malloc.h" #include "malloc.h"
#include "os_GOOS.h" #include "os_GOOS.h"
#include "../../cmd/ld/textflag.h"
extern byte runtime·end[]; extern byte runtime·end[];
static byte *bloc = { runtime·end }; static byte *bloc = { runtime·end };
...@@ -32,17 +33,40 @@ brk(uintptr nbytes) ...@@ -32,17 +33,40 @@ brk(uintptr nbytes)
bloc = (byte*)bl + nbytes; bloc = (byte*)bl + nbytes;
runtime·unlock(&memlock); runtime·unlock(&memlock);
return (void*)bl; return (void*)bl;
} }
void* static void
runtime·sysAlloc(uintptr nbytes, uint64 *stat) sysalloc(void)
{ {
uintptr nbytes;
uint64 *stat;
void *p; void *p;
nbytes = g->m->scalararg[0];
stat = g->m->ptrarg[0];
g->m->scalararg[0] = 0;
g->m->ptrarg[0] = nil;
p = brk(nbytes); p = brk(nbytes);
if(p != nil) if(p != nil)
runtime·xadd64(stat, nbytes); runtime·xadd64(stat, nbytes);
g->m->ptrarg[0] = p;
}
#pragma textflag NOSPLIT
void*
runtime·sysAlloc(uintptr nbytes, uint64 *stat)
{
void (*fn)(void);
void *p;
g->m->scalararg[0] = nbytes;
g->m->ptrarg[0] = stat;
fn = sysalloc;
runtime·onM(&fn);
p = g->m->ptrarg[0];
g->m->ptrarg[0] = nil;
return p; return p;
} }
......
...@@ -7,12 +7,14 @@ ...@@ -7,12 +7,14 @@
#include "defs_GOOS_GOARCH.h" #include "defs_GOOS_GOARCH.h"
#include "os_GOOS.h" #include "os_GOOS.h"
#include "malloc.h" #include "malloc.h"
#include "../../cmd/ld/textflag.h"
enum enum
{ {
ENOMEM = 12, ENOMEM = 12,
}; };
#pragma textflag NOSPLIT
void* void*
runtime·sysAlloc(uintptr n, uint64 *stat) runtime·sysAlloc(uintptr n, uint64 *stat)
{ {
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "os_GOOS.h" #include "os_GOOS.h"
#include "defs_GOOS_GOARCH.h" #include "defs_GOOS_GOARCH.h"
#include "malloc.h" #include "malloc.h"
#include "../../cmd/ld/textflag.h"
enum { enum {
MEM_COMMIT = 0x1000, MEM_COMMIT = 0x1000,
...@@ -25,6 +26,7 @@ extern void *runtime·VirtualAlloc; ...@@ -25,6 +26,7 @@ extern void *runtime·VirtualAlloc;
extern void *runtime·VirtualFree; extern void *runtime·VirtualFree;
extern void *runtime·VirtualProtect; extern void *runtime·VirtualProtect;
#pragma textflag NOSPLIT
void* void*
runtime·sysAlloc(uintptr n, uint64 *stat) runtime·sysAlloc(uintptr n, uint64 *stat)
{ {
......
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