aboutsummaryrefslogtreecommitdiff
path: root/libgo/runtime/go-unwind.c
diff options
context:
space:
mode:
authorIan Lance Taylor <ian@gcc.gnu.org>2016-08-30 21:07:47 +0000
committerIan Lance Taylor <ian@gcc.gnu.org>2016-08-30 21:07:47 +0000
commit75791bab05ec4a45a5c6a4dccd7f824ea8f4487c (patch)
tree9c8130f09f3b1f343a58af6dd0f97f3a14f617c9 /libgo/runtime/go-unwind.c
parent7875b41f1d0137005d87cc5dd12b2a7df2f30c5e (diff)
downloadgcc-75791bab05ec4a45a5c6a4dccd7f824ea8f4487c.zip
gcc-75791bab05ec4a45a5c6a4dccd7f824ea8f4487c.tar.gz
gcc-75791bab05ec4a45a5c6a4dccd7f824ea8f4487c.tar.bz2
runtime: use -fgo-c-header to build C header file
Use the new -fgo-c-header option to build a header file for the Go runtime code in libgo/go/runtime, and use the new header file in the C runtime code in libgo/runtime. This will ensure that the Go code and C code share the same data structures as we convert the runtime from C to Go. The new file libgo/go/runtime/runtime2.go is copied from the Go 1.7 release, and then edited to remove unnecessary data structures and modify others for use with libgo. The new file libgo/go/runtime/mcache.go is an initial version of the same files in the Go 1.7 release, and will be replaced by the Go 1.7 file when we convert to the new memory allocator. The new file libgo/go/runtime/type.go describes the gccgo version of the reflection data structures, and replaces the Go 1.7 runtime file which describes the gc version of those structures. Using the new header file means changing a number of struct fields to use Go naming conventions (that is, no underscores) and to rename constants to have a leading underscore so that they are not exported from the Go package. These names were updated in the C code. The C code was also changed to drop the thread-local variable m, as was done some time ago in the gc sources. Now the m field is always accessed using g->m, where g is the single remaining thread-local variable. This in turn required some adjustments to set g->m correctly in all cases. Also pass the new -fgo-compiling-runtime option when compiling the runtime package, although that option doesn't do anything yet. Reviewed-on: https://go-review.googlesource.com/28051 From-SVN: r239872
Diffstat (limited to 'libgo/runtime/go-unwind.c')
-rw-r--r--libgo/runtime/go-unwind.c56
1 files changed, 27 insertions, 29 deletions
diff --git a/libgo/runtime/go-unwind.c b/libgo/runtime/go-unwind.c
index 87d9eb3..ea11e4e3 100644
--- a/libgo/runtime/go-unwind.c
+++ b/libgo/runtime/go-unwind.c
@@ -15,7 +15,6 @@
#include "runtime.h"
#include "go-alloc.h"
-#include "go-defer.h"
#include "go-panic.h"
/* The code for a Go exception. */
@@ -57,43 +56,42 @@ __go_check_defer (_Bool *frame)
/* Some other language has thrown an exception. We know there
are no defer handlers, so there is nothing to do. */
}
- else if (g->is_foreign)
+ else if (g->isforeign)
{
- struct __go_panic_stack *n;
- _Bool was_recovered;
+ Panic *n;
+ _Bool recovered;
/* Some other language has thrown an exception. We need to run
the local defer handlers. If they call recover, we stop
unwinding the stack here. */
- n = ((struct __go_panic_stack *)
- __go_alloc (sizeof (struct __go_panic_stack)));
+ n = (Panic *) __go_alloc (sizeof (Panic));
- n->__arg.__type_descriptor = NULL;
- n->__arg.__object = NULL;
- n->__was_recovered = 0;
- n->__is_foreign = 1;
- n->__next = g->panic;
- g->panic = n;
+ n->arg.__type_descriptor = NULL;
+ n->arg.__object = NULL;
+ n->recovered = 0;
+ n->isforeign = 1;
+ n->next = g->_panic;
+ g->_panic = n;
while (1)
{
- struct __go_defer_stack *d;
+ Defer *d;
void (*pfn) (void *);
- d = g->defer;
- if (d == NULL || d->__frame != frame || d->__pfn == NULL)
+ d = g->_defer;
+ if (d == NULL || d->frame != frame || d->pfn == 0)
break;
- pfn = d->__pfn;
- g->defer = d->__next;
+ pfn = (void (*) (void *)) d->pfn;
+ g->_defer = d->next;
- (*pfn) (d->__arg);
+ (*pfn) (d->arg);
if (runtime_m () != NULL)
runtime_freedefer (d);
- if (n->__was_recovered)
+ if (n->recovered)
{
/* The recover function caught the panic thrown by some
other language. */
@@ -101,11 +99,11 @@ __go_check_defer (_Bool *frame)
}
}
- was_recovered = n->__was_recovered;
- g->panic = n->__next;
+ recovered = n->recovered;
+ g->_panic = n->next;
__go_free (n);
- if (was_recovered)
+ if (recovered)
{
/* Just return and continue executing Go code. */
*frame = 1;
@@ -115,17 +113,17 @@ __go_check_defer (_Bool *frame)
/* We are panicing through this function. */
*frame = 0;
}
- else if (g->defer != NULL
- && g->defer->__pfn == NULL
- && g->defer->__frame == frame)
+ else if (g->_defer != NULL
+ && g->_defer->pfn == 0
+ && g->_defer->frame == frame)
{
- struct __go_defer_stack *d;
+ Defer *d;
/* This is the defer function which called recover. Simply
return to stop the stack unwind, and let the Go code continue
to execute. */
- d = g->defer;
- g->defer = d->__next;
+ d = g->_defer;
+ g->_defer = d->next;
if (runtime_m () != NULL)
runtime_freedefer (d);
@@ -432,7 +430,7 @@ PERSONALITY_FUNCTION (int version,
else
{
g->exception = ue_header;
- g->is_foreign = is_foreign;
+ g->isforeign = is_foreign;
}
_Unwind_SetGR (context, __builtin_eh_return_data_regno (0),