aboutsummaryrefslogtreecommitdiff
path: root/libgo/runtime
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2014-07-12 00:01:09 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2014-07-12 00:01:09 +0000
commit2fa39ad859e59a5ad5796e522a4842717b2f6e0c (patch)
tree783acf11ed4625d6499f731501d984f25fa103fc /libgo/runtime
parentca76ae5c35f58f0ea40f656d3e555f2c740cf4ec (diff)
downloadgcc-2fa39ad859e59a5ad5796e522a4842717b2f6e0c.zip
gcc-2fa39ad859e59a5ad5796e522a4842717b2f6e0c.tar.gz
gcc-2fa39ad859e59a5ad5796e522a4842717b2f6e0c.tar.bz2
runtime: Merge master revision 19185.
This revision renames several files in the runtime directory from .c to .goc. From-SVN: r212472
Diffstat (limited to 'libgo/runtime')
-rw-r--r--libgo/runtime/chan.goc (renamed from libgo/runtime/chan.c)299
-rw-r--r--libgo/runtime/chan.h75
-rw-r--r--libgo/runtime/cpuprof.goc (renamed from libgo/runtime/cpuprof.c)10
-rw-r--r--libgo/runtime/go-cgo.c16
-rw-r--r--libgo/runtime/go-getgoroot.c26
-rw-r--r--libgo/runtime/go-typestring.c17
-rw-r--r--libgo/runtime/goc2c.c17
-rw-r--r--libgo/runtime/lfstack.goc (renamed from libgo/runtime/lfstack.c)12
-rw-r--r--libgo/runtime/malloc.goc6
-rw-r--r--libgo/runtime/malloc.h1
-rw-r--r--libgo/runtime/mgc0.c11
-rw-r--r--libgo/runtime/parfor.c47
-rw-r--r--libgo/runtime/print.c2
-rw-r--r--libgo/runtime/proc.c56
-rw-r--r--libgo/runtime/rdebug.goc21
-rw-r--r--libgo/runtime/runtime.c23
-rw-r--r--libgo/runtime/runtime.h11
-rw-r--r--libgo/runtime/runtime1.goc62
-rw-r--r--libgo/runtime/string.goc9
19 files changed, 238 insertions, 483 deletions
diff --git a/libgo/runtime/chan.c b/libgo/runtime/chan.goc
index 2ef78eb..ebe0493 100644
--- a/libgo/runtime/chan.c
+++ b/libgo/runtime/chan.goc
@@ -2,87 +2,16 @@
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
+package runtime
#include "runtime.h"
#include "arch.h"
#include "go-type.h"
#include "race.h"
#include "malloc.h"
-
-typedef struct WaitQ WaitQ;
-typedef struct SudoG SudoG;
-typedef struct Select Select;
-typedef struct Scase Scase;
-
-typedef struct __go_type_descriptor Type;
-typedef struct __go_channel_type ChanType;
-
-struct SudoG
-{
- G* g;
- uint32* selectdone;
- SudoG* link;
- int64 releasetime;
- byte* elem; // data element
-};
-
-struct WaitQ
-{
- SudoG* first;
- SudoG* last;
-};
-
-// The garbage collector is assuming that Hchan can only contain pointers into the stack
-// and cannot contain pointers into the heap.
-struct Hchan
-{
- uintgo qcount; // total data in the q
- uintgo dataqsiz; // size of the circular q
- uint16 elemsize;
- uint8 elemalign;
- uint8 pad; // ensures proper alignment of the buffer that follows Hchan in memory
- bool closed;
- const Type* elemtype; // element type
- uintgo sendx; // send index
- uintgo recvx; // receive index
- WaitQ recvq; // list of recv waiters
- WaitQ sendq; // list of send waiters
- Lock;
-};
+#include "chan.h"
uint32 runtime_Hchansize = sizeof(Hchan);
-// Buffer follows Hchan immediately in memory.
-// chanbuf(c, i) is pointer to the i'th slot in the buffer.
-#define chanbuf(c, i) ((byte*)((c)+1)+(uintptr)(c)->elemsize*(i))
-
-enum
-{
- debug = 0,
-
- // Scase.kind
- CaseRecv,
- CaseSend,
- CaseDefault,
-};
-
-struct Scase
-{
- SudoG sg; // must be first member (cast to Scase)
- Hchan* chan; // chan
- uint16 kind;
- uint16 index; // index to return
- bool* receivedp; // pointer to received bool (recv2)
-};
-
-struct Select
-{
- uint16 tcase; // total count of scase[]
- uint16 ncase; // currently filled scase[]
- uint16* pollorder; // case poll order
- Hchan** lockorder; // channel lock order
- Scase scase[1]; // one per case (in order of appearance)
-};
-
static void dequeueg(WaitQ*);
static SudoG* dequeue(WaitQ*);
static void enqueue(WaitQ*, SudoG*);
@@ -120,21 +49,10 @@ makechan(ChanType *t, int64 hint)
return c;
}
-// For reflect
-// func makechan(typ *ChanType, size uint64) (chan)
-Hchan *reflect_makechan(ChanType *, uint64)
- __asm__ (GOSYM_PREFIX "reflect.makechan");
-
-Hchan *
-reflect_makechan(ChanType *t, uint64 size)
-{
- Hchan *c;
-
+func reflect.makechan(t *ChanType, size uint64) (c *Hchan) {
c = makechan(t, size);
- return c;
}
-// makechan(t *ChanType, hint int64) (hchan *chan any);
Hchan*
__go_new_channel(ChanType *t, uintptr hint)
{
@@ -487,8 +405,6 @@ runtime_chanrecv2(ChanType *t, Hchan* c, byte* v)
return received;
}
-// func selectnbsend(c chan any, elem *any) bool
-//
// compiler implements
//
// select {
@@ -506,17 +422,10 @@ runtime_chanrecv2(ChanType *t, Hchan* c, byte* v)
// ... bar
// }
//
-_Bool
-runtime_selectnbsend(ChanType *t, Hchan *c, byte *val)
-{
- bool res;
-
- res = chansend(t, c, val, false, runtime_getcallerpc(&t));
- return (_Bool)res;
+func selectnbsend(t *ChanType, c *Hchan, elem *byte) (selected bool) {
+ selected = chansend(t, c, elem, false, runtime_getcallerpc(&t));
}
-// func selectnbrecv(elem *any, c chan any) bool
-//
// compiler implements
//
// select {
@@ -534,17 +443,10 @@ runtime_selectnbsend(ChanType *t, Hchan *c, byte *val)
// ... bar
// }
//
-_Bool
-runtime_selectnbrecv(ChanType *t, byte *v, Hchan *c)
-{
- bool selected;
-
- selected = chanrecv(t, c, v, false, nil);
- return (_Bool)selected;
+func selectnbrecv(t *ChanType, elem *byte, c *Hchan) (selected bool) {
+ selected = chanrecv(t, c, elem, false, nil);
}
-// func selectnbrecv2(elem *any, ok *bool, c chan any) bool
-//
// compiler implements
//
// select {
@@ -562,76 +464,27 @@ runtime_selectnbrecv(ChanType *t, byte *v, Hchan *c)
// ... bar
// }
//
-_Bool
-runtime_selectnbrecv2(ChanType *t, byte *v, _Bool *received, Hchan *c)
-{
- bool selected;
+func selectnbrecv2(t *ChanType, elem *byte, received *bool, c *Hchan) (selected bool) {
bool r;
- r = false;
- selected = chanrecv(t, c, v, false, received == nil ? nil : &r);
+ selected = chanrecv(t, c, elem, false, received == nil ? nil : &r);
if(received != nil)
*received = r;
- return selected;
}
-// For reflect:
-// func chansend(c chan, val *any, nb bool) (selected bool)
-// where val points to the data to be sent.
-//
-// The "uintptr selected" is really "bool selected" but saying
-// uintptr gets us the right alignment for the output parameter block.
-
-_Bool reflect_chansend(ChanType *, Hchan *, byte *, _Bool)
- __asm__ (GOSYM_PREFIX "reflect.chansend");
-
-_Bool
-reflect_chansend(ChanType *t, Hchan *c, byte *val, _Bool nb)
-{
- bool selected;
-
- selected = chansend(t, c, val, !nb, runtime_getcallerpc(&t));
- return (_Bool)selected;
+func reflect.chansend(t *ChanType, c *Hchan, elem *byte, nb bool) (selected bool) {
+ selected = chansend(t, c, elem, !nb, runtime_getcallerpc(&t));
}
-// For reflect:
-// func chanrecv(c chan, nb bool, val *any) (selected, received bool)
-// where val points to a data area that will be filled in with the
-// received value. val must have the size and type of the channel element type.
-
-struct chanrecv_ret
-{
- _Bool selected;
- _Bool received;
-};
-
-struct chanrecv_ret reflect_chanrecv(ChanType *, Hchan *, _Bool, byte *val)
- __asm__ (GOSYM_PREFIX "reflect.chanrecv");
-
-struct chanrecv_ret
-reflect_chanrecv(ChanType *t, Hchan *c, _Bool nb, byte *val)
-{
- struct chanrecv_ret ret;
- bool selected;
- bool received;
-
+func reflect.chanrecv(t *ChanType, c *Hchan, nb bool, elem *byte) (selected bool, received bool) {
received = false;
- selected = chanrecv(t, c, val, !nb, &received);
- ret.selected = (_Bool)selected;
- ret.received = (_Bool)received;
- return ret;
+ selected = chanrecv(t, c, elem, !nb, &received);
}
static Select* newselect(int32);
-// newselect(size uint32) (sel *byte);
-
-void* runtime_newselect(int32) __asm__ (GOSYM_PREFIX "runtime.newselect");
-
-void*
-runtime_newselect(int32 size)
-{
- return (void*)newselect(size);
+func newselect(size int32) (sel *byte) {
+ sel = (byte*)newselect(size);
}
static Select*
@@ -666,19 +519,10 @@ newselect(int32 size)
// cut in half to give stack a chance to split
static void selectsend(Select *sel, Hchan *c, int index, void *elem);
-// selectsend(sel *byte, hchan *chan any, elem *any) (selected bool);
-
-void runtime_selectsend(Select *, Hchan *, void *, int32)
- __asm__ (GOSYM_PREFIX "runtime.selectsend");
-
-void
-runtime_selectsend(Select *sel, Hchan *c, void *elem, int32 index)
-{
+func selectsend(sel *Select, c *Hchan, elem *byte, index int32) {
// nil cases do not compete
- if(c == nil)
- return;
-
- selectsend(sel, c, index, elem);
+ if(c != nil)
+ selectsend(sel, c, index, elem);
}
static void
@@ -706,34 +550,16 @@ selectsend(Select *sel, Hchan *c, int index, void *elem)
// cut in half to give stack a chance to split
static void selectrecv(Select *sel, Hchan *c, int index, void *elem, bool*);
-// selectrecv(sel *byte, hchan *chan any, elem *any) (selected bool);
-
-void runtime_selectrecv(Select *, Hchan *, void *, int32)
- __asm__ (GOSYM_PREFIX "runtime.selectrecv");
-
-void
-runtime_selectrecv(Select *sel, Hchan *c, void *elem, int32 index)
-{
+func selectrecv(sel *Select, c *Hchan, elem *byte, index int32) {
// nil cases do not compete
- if(c == nil)
- return;
-
- selectrecv(sel, c, index, elem, nil);
+ if(c != nil)
+ selectrecv(sel, c, index, elem, nil);
}
-// selectrecv2(sel *byte, hchan *chan any, elem *any, received *bool) (selected bool);
-
-void runtime_selectrecv2(Select *, Hchan *, void *, bool *, int32)
- __asm__ (GOSYM_PREFIX "runtime.selectrecv2");
-
-void
-runtime_selectrecv2(Select *sel, Hchan *c, void *elem, bool *received, int32 index)
-{
+func selectrecv2(sel *Select, c *Hchan, elem *byte, received *bool, index int32) {
// nil cases do not compete
- if(c == nil)
- return;
-
- selectrecv(sel, c, index, elem, received);
+ if(c != nil)
+ selectrecv(sel, c, index, elem, received);
}
static void
@@ -762,13 +588,7 @@ selectrecv(Select *sel, Hchan *c, int index, void *elem, bool *received)
// cut in half to give stack a chance to split
static void selectdefault(Select*, int);
-// selectdefault(sel *byte) (selected bool);
-
-void runtime_selectdefault(Select *, int32) __asm__ (GOSYM_PREFIX "runtime.selectdefault");
-
-void
-runtime_selectdefault(Select *sel, int32 index)
-{
+func selectdefault(sel *Select, index int32) {
selectdefault(sel, index);
}
@@ -844,9 +664,7 @@ selparkcommit(G *gp, void *sel)
return true;
}
-void
-runtime_block(void)
-{
+func block() {
runtime_park(nil, nil, "select (no cases)"); // forever
}
@@ -854,11 +672,7 @@ static int selectgo(Select**);
// selectgo(sel *byte);
-int runtime_selectgo(Select *) __asm__ (GOSYM_PREFIX "runtime.selectgo");
-
-int
-runtime_selectgo(Select *sel)
-{
+func selectgo(sel *Select) (ret int32) {
return selectgo(&sel);
}
@@ -1196,22 +1010,7 @@ enum SelectDir {
SelectDefault,
};
-// func rselect(cases []runtimeSelect) (chosen int, recvOK bool)
-
-struct rselect_ret {
- intgo chosen;
- _Bool recvOK;
-};
-
-struct rselect_ret reflect_rselect(Slice)
- __asm__ (GOSYM_PREFIX "reflect.rselect");
-
-struct rselect_ret
-reflect_rselect(Slice cases)
-{
- struct rselect_ret ret;
- intgo chosen;
- bool recvOK;
+func reflect.rselect(cases Slice) (chosen int, recvOK bool) {
int32 i;
Select *sel;
runtimeSelect* rcase, *rc;
@@ -1242,29 +1041,15 @@ reflect_rselect(Slice cases)
}
chosen = (intgo)(uintptr)selectgo(&sel);
-
- ret.chosen = chosen;
- ret.recvOK = (_Bool)recvOK;
- return ret;
}
static void closechan(Hchan *c, void *pc);
-// closechan(sel *byte);
-void
-runtime_closechan(Hchan *c)
-{
+func closechan(c *Hchan) {
closechan(c, runtime_getcallerpc(&c));
}
-// For reflect
-// func chanclose(c chan)
-
-void reflect_chanclose(Hchan *) __asm__ (GOSYM_PREFIX "reflect.chanclose");
-
-void
-reflect_chanclose(Hchan *c)
-{
+func reflect.chanclose(c *Hchan) {
closechan(c, runtime_getcallerpc(&c));
}
@@ -1326,21 +1111,11 @@ __go_builtin_close(Hchan *c)
runtime_closechan(c);
}
-// For reflect
-// func chanlen(c chan) (len int)
-
-intgo reflect_chanlen(Hchan *) __asm__ (GOSYM_PREFIX "reflect.chanlen");
-
-intgo
-reflect_chanlen(Hchan *c)
-{
- intgo len;
-
+func reflect.chanlen(c *Hchan) (len int) {
if(c == nil)
len = 0;
else
len = c->qcount;
- return len;
}
intgo
@@ -1349,21 +1124,11 @@ __go_chan_len(Hchan *c)
return reflect_chanlen(c);
}
-// For reflect
-// func chancap(c chan) int
-
-intgo reflect_chancap(Hchan *) __asm__ (GOSYM_PREFIX "reflect.chancap");
-
-intgo
-reflect_chancap(Hchan *c)
-{
- intgo cap;
-
+func reflect.chancap(c *Hchan) (cap int) {
if(c == nil)
cap = 0;
else
cap = c->dataqsiz;
- return cap;
}
intgo
diff --git a/libgo/runtime/chan.h b/libgo/runtime/chan.h
new file mode 100644
index 0000000..70b0b9d
--- /dev/null
+++ b/libgo/runtime/chan.h
@@ -0,0 +1,75 @@
+// 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.
+
+typedef struct WaitQ WaitQ;
+typedef struct SudoG SudoG;
+typedef struct Select Select;
+typedef struct Scase Scase;
+
+typedef struct __go_type_descriptor Type;
+typedef struct __go_channel_type ChanType;
+
+struct SudoG
+{
+ G* g;
+ uint32* selectdone;
+ SudoG* link;
+ int64 releasetime;
+ byte* elem; // data element
+};
+
+struct WaitQ
+{
+ SudoG* first;
+ SudoG* last;
+};
+
+// The garbage collector is assuming that Hchan can only contain pointers into the stack
+// and cannot contain pointers into the heap.
+struct Hchan
+{
+ uintgo qcount; // total data in the q
+ uintgo dataqsiz; // size of the circular q
+ uint16 elemsize;
+ uint16 pad; // ensures proper alignment of the buffer that follows Hchan in memory
+ bool closed;
+ const Type* elemtype; // element type
+ uintgo sendx; // send index
+ uintgo recvx; // receive index
+ WaitQ recvq; // list of recv waiters
+ WaitQ sendq; // list of send waiters
+ Lock;
+};
+
+// Buffer follows Hchan immediately in memory.
+// chanbuf(c, i) is pointer to the i'th slot in the buffer.
+#define chanbuf(c, i) ((byte*)((c)+1)+(uintptr)(c)->elemsize*(i))
+
+enum
+{
+ debug = 0,
+
+ // Scase.kind
+ CaseRecv,
+ CaseSend,
+ CaseDefault,
+};
+
+struct Scase
+{
+ SudoG sg; // must be first member (cast to Scase)
+ Hchan* chan; // chan
+ uint16 kind;
+ uint16 index; // index to return
+ bool* receivedp; // pointer to received bool (recv2)
+};
+
+struct Select
+{
+ uint16 tcase; // total count of scase[]
+ uint16 ncase; // currently filled scase[]
+ uint16* pollorder; // case poll order
+ Hchan** lockorder; // channel lock order
+ Scase scase[1]; // one per case (in order of appearance)
+};
diff --git a/libgo/runtime/cpuprof.c b/libgo/runtime/cpuprof.goc
index a07029c..28ae9bb 100644
--- a/libgo/runtime/cpuprof.c
+++ b/libgo/runtime/cpuprof.goc
@@ -48,6 +48,7 @@
// in order to let the log closer set the high bit to indicate "EOF" safely
// in the situation when normally the goroutine "owns" handoff.
+package runtime
#include "runtime.h"
#include "arch.h"
#include "malloc.h"
@@ -435,13 +436,8 @@ breakflush:
return ret; // set to nil at top of function
}
-extern Slice runtime_CPUProfile(void)
- __asm__ (GOSYM_PREFIX "runtime.CPUProfile");
-
// CPUProfile returns the next cpu profile block as a []byte.
// The user documentation is in debug.go.
-Slice
-runtime_CPUProfile(void)
-{
- return getprofile(prof);
+func CPUProfile() (ret Slice) {
+ ret = getprofile(prof);
}
diff --git a/libgo/runtime/go-cgo.c b/libgo/runtime/go-cgo.c
index 9ba1ea7..2b7baa4 100644
--- a/libgo/runtime/go-cgo.c
+++ b/libgo/runtime/go-cgo.c
@@ -177,19 +177,3 @@ _cgo_panic (const char *p)
__go_panic (e);
}
-
-/* Return the number of CGO calls. */
-
-int64 runtime_NumCgoCall (void) __asm__ (GOSYM_PREFIX "runtime.NumCgoCall");
-
-int64
-runtime_NumCgoCall (void)
-{
- int64 ret;
- M* m;
-
- ret = 0;
- for (m = runtime_atomicloadp (&runtime_allm); m != NULL; m = m->alllink)
- ret += m->ncgocall;
- return ret;
-}
diff --git a/libgo/runtime/go-getgoroot.c b/libgo/runtime/go-getgoroot.c
deleted file mode 100644
index 1b52d44..0000000
--- a/libgo/runtime/go-getgoroot.c
+++ /dev/null
@@ -1,26 +0,0 @@
-/* go-getgoroot.c -- getgoroot function for runtime package.
-
- Copyright 2010 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. */
-
-#include <stdlib.h>
-
-#include "runtime.h"
-
-String getgoroot (void) __asm__ (GOSYM_PREFIX "runtime.getgoroot");
-
-String
-getgoroot ()
-{
- const char *p;
- String ret;
-
- p = getenv ("GOROOT");
- ret.str = (const byte *) p;
- if (ret.str == NULL)
- ret.len = 0;
- else
- ret.len = __builtin_strlen (p);
- return ret;
-}
diff --git a/libgo/runtime/go-typestring.c b/libgo/runtime/go-typestring.c
deleted file mode 100644
index 0a90e84..0000000
--- a/libgo/runtime/go-typestring.c
+++ /dev/null
@@ -1,17 +0,0 @@
-/* go-typestring.c -- the runtime.typestring function.
-
- Copyright 2010 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. */
-
-#include "runtime.h"
-#include "interface.h"
-#include "go-type.h"
-
-String typestring(struct __go_empty_interface) __asm__ (GOSYM_PREFIX "runtime.typestring");
-
-String
-typestring (struct __go_empty_interface e)
-{
- return *e.__type_descriptor->__reflection;
-}
diff --git a/libgo/runtime/goc2c.c b/libgo/runtime/goc2c.c
index 87db58f..68281c3 100644
--- a/libgo/runtime/goc2c.c
+++ b/libgo/runtime/goc2c.c
@@ -617,9 +617,22 @@ process_file(void)
package = read_package();
read_preprocessor_lines();
while (read_func_header(&name, &params, &rets)) {
- write_func_header(package, name, params, rets);
+ char *p;
+ char *pkg;
+ char *nm;
+
+ p = strchr(name, '.');
+ if (p == NULL) {
+ pkg = package;
+ nm = name;
+ } else {
+ pkg = name;
+ nm = p + 1;
+ *p = '\0';
+ }
+ write_func_header(pkg, nm, params, rets);
copy_body();
- write_func_trailer(package, name, rets);
+ write_func_trailer(pkg, nm, rets);
free(name);
free_params(params);
free_params(rets);
diff --git a/libgo/runtime/lfstack.c b/libgo/runtime/lfstack.goc
index 132783c..060a0cc 100644
--- a/libgo/runtime/lfstack.c
+++ b/libgo/runtime/lfstack.goc
@@ -4,6 +4,7 @@
// Lock-free stack.
+package runtime
#include "runtime.h"
#include "arch.h"
@@ -69,11 +70,10 @@ runtime_lfstackpop(uint64 *head)
}
}
-LFNode* runtime_lfstackpop2(uint64*)
- __asm__ (GOSYM_PREFIX "runtime.lfstackpop2");
+func lfstackpush_go(head *uint64, node *LFNode) {
+ runtime_lfstackpush(head, node);
+}
-LFNode*
-runtime_lfstackpop2(uint64 *head)
-{
- return runtime_lfstackpop(head);
+func lfstackpop_go(head *uint64) (node *LFNode) {
+ node = runtime_lfstackpop(head);
}
diff --git a/libgo/runtime/malloc.goc b/libgo/runtime/malloc.goc
index 798d875..9c8b8c1 100644
--- a/libgo/runtime/malloc.goc
+++ b/libgo/runtime/malloc.goc
@@ -905,10 +905,8 @@ runtime_mal(uintptr n)
return runtime_mallocgc(n, 0, 0);
}
-void *
-runtime_new(const Type *typ)
-{
- return runtime_mallocgc(typ->__size, (uintptr)typ | TypeInfo_SingleObject, typ->kind&KindNoPointers ? FlagNoScan : 0);
+func new(typ *Type) (ret *uint8) {
+ ret = runtime_mallocgc(typ->__size, (uintptr)typ | TypeInfo_SingleObject, typ->kind&KindNoPointers ? FlagNoScan : 0);
}
static void*
diff --git a/libgo/runtime/malloc.h b/libgo/runtime/malloc.h
index b5dc5a4..30fbb64 100644
--- a/libgo/runtime/malloc.h
+++ b/libgo/runtime/malloc.h
@@ -586,6 +586,7 @@ void runtime_gc_m_ptr(Eface*);
void runtime_gc_itab_ptr(Eface*);
void runtime_memorydump(void);
+int32 runtime_setgcpercent(int32);
void runtime_proc_scan(struct Workbuf**, void (*)(struct Workbuf**, Obj));
void runtime_time_scan(struct Workbuf**, void (*)(struct Workbuf**, Obj));
diff --git a/libgo/runtime/mgc0.c b/libgo/runtime/mgc0.c
index 10dd412..e67c5b9 100644
--- a/libgo/runtime/mgc0.c
+++ b/libgo/runtime/mgc0.c
@@ -1174,6 +1174,7 @@ scanblock(Workbuf *wbuf, bool keepworking)
#endif
default:
+ runtime_printf("runtime: invalid GC instruction %p at %p\n", pc[0], pc);
runtime_throw("scanblock: invalid GC instruction");
return;
}
@@ -2449,13 +2450,9 @@ runtime_debug_readGCStats(Slice *pauses)
pauses->__count = n+3;
}
-intgo runtime_debug_setGCPercent(intgo)
- __asm__("runtime_debug.setGCPercent");
-
-intgo
-runtime_debug_setGCPercent(intgo in)
-{
- intgo out;
+int32
+runtime_setgcpercent(int32 in) {
+ int32 out;
runtime_lock(&runtime_mheap);
if(gcpercent == GcpercentUnknown)
diff --git a/libgo/runtime/parfor.c b/libgo/runtime/parfor.c
index 9489d8d..386faea 100644
--- a/libgo/runtime/parfor.c
+++ b/libgo/runtime/parfor.c
@@ -33,18 +33,6 @@ runtime_parforalloc(uint32 nthrmax)
return desc;
}
-// For testing from Go
-// func parforalloc2(nthrmax uint32) *ParFor
-
-ParFor *runtime_parforalloc2(uint32)
- __asm__ (GOSYM_PREFIX "runtime.parforalloc2");
-
-ParFor *
-runtime_parforalloc2(uint32 nthrmax)
-{
- return runtime_parforalloc(nthrmax);
-}
-
void
runtime_parforsetup(ParFor *desc, uint32 nthr, uint32 n, void *ctx, bool wait, void (*body)(ParFor*, uint32))
{
@@ -78,18 +66,6 @@ runtime_parforsetup(ParFor *desc, uint32 nthr, uint32 n, void *ctx, bool wait, v
}
}
-// For testing from Go
-// func parforsetup2(desc *ParFor, nthr, n uint32, ctx *byte, wait bool, body func(*ParFor, uint32))
-
-void runtime_parforsetup2(ParFor *, uint32, uint32, void *, bool, void *)
- __asm__ (GOSYM_PREFIX "runtime.parforsetup2");
-
-void
-runtime_parforsetup2(ParFor *desc, uint32 nthr, uint32 n, void *ctx, bool wait, void *body)
-{
- runtime_parforsetup(desc, nthr, n, ctx, wait, *(void(**)(ParFor*, uint32))body);
-}
-
void
runtime_parfordo(ParFor *desc)
{
@@ -214,23 +190,10 @@ exit:
me->nsleep = 0;
}
-// For testing from Go
-// func parforiters(desc *ParFor, tid uintptr) (uintptr, uintptr)
-
-struct parforiters_ret {
- uintptr start;
- uintptr end;
-};
-
-struct parforiters_ret runtime_parforiters(ParFor *, uintptr)
- __asm__ (GOSYM_PREFIX "runtime.parforiters");
-
-struct parforiters_ret
-runtime_parforiters(ParFor *desc, uintptr tid)
+// For testing from Go.
+void
+runtime_parforiters(ParFor *desc, uintptr tid, uintptr *start, uintptr *end)
{
- struct parforiters_ret ret;
-
- ret.start = (uint32)desc->thr[tid].pos;
- ret.end = (uint32)(desc->thr[tid].pos>>32);
- return ret;
+ *start = (uint32)desc->thr[tid].pos;
+ *end = (uint32)(desc->thr[tid].pos>>32);
}
diff --git a/libgo/runtime/print.c b/libgo/runtime/print.c
index d00b638..f602e9a 100644
--- a/libgo/runtime/print.c
+++ b/libgo/runtime/print.c
@@ -320,7 +320,7 @@ runtime_printhex(uint64 v)
void
runtime_printpointer(void *p)
{
- runtime_printhex((uint64)(uintptr)p);
+ runtime_printhex((uintptr)p);
}
void
diff --git a/libgo/runtime/proc.c b/libgo/runtime/proc.c
index d213084..8e32f78a2 100644
--- a/libgo/runtime/proc.c
+++ b/libgo/runtime/proc.c
@@ -2456,26 +2456,6 @@ runtime_lockedOSThread(void)
return g->lockedm != nil && m->lockedg != nil;
}
-// for testing of callbacks
-
-_Bool runtime_golockedOSThread(void)
- __asm__ (GOSYM_PREFIX "runtime.golockedOSThread");
-
-_Bool
-runtime_golockedOSThread(void)
-{
- return runtime_lockedOSThread();
-}
-
-intgo runtime_NumGoroutine (void)
- __asm__ (GOSYM_PREFIX "runtime.NumGoroutine");
-
-intgo
-runtime_NumGoroutine()
-{
- return runtime_gcount();
-}
-
int32
runtime_gcount(void)
{
@@ -3321,13 +3301,10 @@ runtime_testSchedLocalQueueSteal(void)
}
}
-intgo runtime_debug_setMaxThreads(intgo)
- __asm__(GOSYM_PREFIX "runtime_debug.setMaxThreads");
-
-intgo
-runtime_debug_setMaxThreads(intgo in)
+int32
+runtime_setmaxthreads(int32 in)
{
- intgo out;
+ int32 out;
runtime_lock(&runtime_sched);
out = runtime_sched.maxmcount;
@@ -3370,30 +3347,3 @@ runtime_gcwaiting(void)
{
return runtime_sched.gcwaiting;
}
-
-// func runtime_procPin() int
-
-intgo sync_runtime_procPin(void)
- __asm__(GOSYM_PREFIX "sync.runtime_procPin");
-
-intgo
-sync_runtime_procPin()
-{
- M *mp;
-
- mp = m;
- // Disable preemption.
- mp->locks++;
- return mp->p->id;
-}
-
-// func runtime_procUnpin()
-
-void sync_runtime_procUnpin(void)
- __asm__ (GOSYM_PREFIX "sync.runtime_procUnpin");
-
-void
-sync_runtime_procUnpin(void)
-{
- m->locks--;
-}
diff --git a/libgo/runtime/rdebug.goc b/libgo/runtime/rdebug.goc
new file mode 100644
index 0000000..230e8fa
--- /dev/null
+++ b/libgo/runtime/rdebug.goc
@@ -0,0 +1,21 @@
+// Copyright 2013 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.
+
+package runtime_debug
+#include "runtime.h"
+#include "arch.h"
+#include "malloc.h"
+
+func setMaxStack(in int) (out int) {
+ out = runtime_maxstacksize;
+ runtime_maxstacksize = in;
+}
+
+func setGCPercent(in int) (out int) {
+ out = runtime_setgcpercent(in);
+}
+
+func setMaxThreads(in int) (out int) {
+ out = runtime_setmaxthreads(in);
+}
diff --git a/libgo/runtime/runtime.c b/libgo/runtime/runtime.c
index eb32a8d..1678a45 100644
--- a/libgo/runtime/runtime.c
+++ b/libgo/runtime/runtime.c
@@ -9,7 +9,6 @@
#include "runtime.h"
#include "array.h"
-#include "go-panic.h"
// The GOTRACEBACK environment variable controls the
// behavior of a Go program that is crashing and exiting.
@@ -221,15 +220,6 @@ runtime_tickspersecond(void)
return res;
}
-int64 runtime_pprof_runtime_cyclesPerSecond(void)
- __asm__ (GOSYM_PREFIX "runtime_pprof.runtime_cyclesPerSecond");
-
-int64
-runtime_pprof_runtime_cyclesPerSecond(void)
-{
- return runtime_tickspersecond();
-}
-
// Called to initialize a new m (including the bootstrap m).
// Called on the parent thread (main thread in case of bootstrap), can allocate memory.
void
@@ -341,19 +331,6 @@ runtime_timediv(int64 v, int32 div, int32 *rem)
uintptr runtime_maxstacksize = 1<<20; // enough until runtime.main sets it for real
-intgo runtime_debug_setMaxStack(intgo)
- __asm__ (GOSYM_PREFIX "runtime_debug.setMaxStack");
-
-intgo
-runtime_debug_setMaxStack(intgo in)
-{
- intgo out;
-
- out = runtime_maxstacksize;
- runtime_maxstacksize = in;
- return out;
-}
-
void memclrBytes(Slice)
__asm__ (GOSYM_PREFIX "runtime.memclrBytes");
diff --git a/libgo/runtime/runtime.h b/libgo/runtime/runtime.h
index 9d5e42f..6bd53a8 100644
--- a/libgo/runtime/runtime.h
+++ b/libgo/runtime/runtime.h
@@ -455,7 +455,7 @@ extern bool runtime_precisestack;
#define nelem(x) (sizeof(x)/sizeof((x)[0]))
#define nil ((void*)0)
#define USED(v) ((void) v)
-#define ROUND(x, n) (((x)+(n)-1)&~((n)-1)) /* all-caps to mark as macro: it evaluates n twice */
+#define ROUND(x, n) (((x)+(n)-1)&~(uintptr)((n)-1)) /* all-caps to mark as macro: it evaluates n twice */
byte* runtime_startup_random_data;
uint32 runtime_startup_random_data_len;
@@ -491,6 +491,7 @@ extern int8* runtime_goos;
extern int32 runtime_ncpu;
extern void (*runtime_sysargs)(int32, uint8**);
extern DebugVars runtime_debug;
+extern uintptr runtime_maxstacksize;
/*
* common functions and data
@@ -501,9 +502,6 @@ intgo runtime_findnull(const byte*);
intgo runtime_findnullw(const uint16*);
void runtime_dump(byte*, int32);
-/*
- * very low level c-called
- */
void runtime_gogo(G*);
struct __go_func_type;
void runtime_args(int32, byte**);
@@ -618,6 +616,7 @@ void runtime_crash(void);
void runtime_parsedebugvars(void);
void _rt0_go(void);
void* runtime_funcdata(Func*, int32);
+int32 runtime_setmaxthreads(int32);
void runtime_stoptheworld(void);
void runtime_starttheworld(void);
@@ -690,7 +689,8 @@ LFNode* runtime_lfstackpop(uint64 *head);
*/
ParFor* runtime_parforalloc(uint32 nthrmax);
void runtime_parforsetup(ParFor *desc, uint32 nthr, uint32 n, void *ctx, bool wait, void (*body)(ParFor*, uint32));
-void runtime_parfordo(ParFor *desc) __asm__ (GOSYM_PREFIX "runtime.parfordo");
+void runtime_parfordo(ParFor *desc);
+void runtime_parforiters(ParFor*, uintptr, uintptr*, uintptr*);
/*
* low level C-called
@@ -762,6 +762,7 @@ void runtime_procyield(uint32);
void runtime_osyield(void);
void runtime_lockOSThread(void);
void runtime_unlockOSThread(void);
+bool runtime_lockedOSThread(void);
bool runtime_showframe(String, bool);
void runtime_printcreatedby(G*);
diff --git a/libgo/runtime/runtime1.goc b/libgo/runtime/runtime1.goc
index 9ce8300..e643965 100644
--- a/libgo/runtime/runtime1.goc
+++ b/libgo/runtime/runtime1.goc
@@ -4,6 +4,8 @@
package runtime
#include "runtime.h"
+#include "arch.h"
+#include "go-type.h"
func GOMAXPROCS(n int) (ret int) {
ret = runtime_gomaxprocsfunc(n);
@@ -12,3 +14,63 @@ func GOMAXPROCS(n int) (ret int) {
func NumCPU() (ret int) {
ret = runtime_ncpu;
}
+
+func NumCgoCall() (ret int64) {
+ M *mp;
+
+ ret = 0;
+ for(mp=runtime_atomicloadp(&runtime_allm); mp; mp=mp->alllink)
+ ret += mp->ncgocall;
+}
+
+func newParFor(nthrmax uint32) (desc *ParFor) {
+ desc = runtime_parforalloc(nthrmax);
+}
+
+func parForSetup(desc *ParFor, nthr uint32, n uint32, ctx *byte, wait bool, body *byte) {
+ runtime_parforsetup(desc, nthr, n, ctx, wait, *(void(**)(ParFor*, uint32))body);
+}
+
+func parForDo(desc *ParFor) {
+ runtime_parfordo(desc);
+}
+
+func parForIters(desc *ParFor, tid uintptr) (start uintptr, end uintptr) {
+ runtime_parforiters(desc, tid, &start, &end);
+}
+
+func typestring(e Eface) (s String) {
+ s = *e.__type_descriptor->__reflection;
+}
+
+func golockedOSThread() (ret bool) {
+ ret = runtime_lockedOSThread();
+}
+
+func NumGoroutine() (ret int) {
+ ret = runtime_gcount();
+}
+
+func getgoroot() (out String) {
+ const byte *p;
+
+ p = runtime_getenv("GOROOT");
+ out = runtime_gostringnocopy(p);
+}
+
+func runtime_pprof.runtime_cyclesPerSecond() (res int64) {
+ res = runtime_tickspersecond();
+}
+
+func sync.runtime_procPin() (p int) {
+ M *mp;
+
+ mp = runtime_m();
+ // Disable preemption.
+ mp->locks++;
+ p = mp->p->id;
+}
+
+func sync.runtime_procUnpin() {
+ runtime_m()->locks--;
+}
diff --git a/libgo/runtime/string.goc b/libgo/runtime/string.goc
index a0e80cc..f656318 100644
--- a/libgo/runtime/string.goc
+++ b/libgo/runtime/string.goc
@@ -73,13 +73,8 @@ runtime_gostringnocopy(const byte *str)
return s;
}
-String runtime_cstringToGo(byte*)
- __asm__ (GOSYM_PREFIX "runtime.cstringToGo");
-
-String
-runtime_cstringToGo(byte *str)
-{
- return runtime_gostringnocopy(str);
+func cstringToGo(str *byte) (s String) {
+ s = runtime_gostringnocopy(str);
}
enum