OSDN Git Service

runtime: More efficient implementation of trampolines.
[pf3gnuchains/gcc-fork.git] / libgo / runtime / runtime.h
index 3e75b15..94f8911 100644 (file)
@@ -7,7 +7,6 @@
 #include "config.h"
 
 #include "go-assert.h"
-#include <setjmp.h>
 #include <signal.h>
 #include <stdio.h>
 #include <stdlib.h>
@@ -15,6 +14,7 @@
 #include <sys/types.h>
 #include <sys/stat.h>
 #include <fcntl.h>
+#include <unistd.h>
 #include <pthread.h>
 #include <semaphore.h>
 #include <ucontext.h>
@@ -71,6 +71,8 @@ typedef       struct  __go_panic_stack        Panic;
 typedef struct __go_func_type          FuncType;
 typedef struct __go_map_type           MapType;
 
+typedef struct  Traceback      Traceback;
+
 /*
  * per-cpu declaration.
  */
@@ -128,7 +130,7 @@ struct      G
        void*   gcnext_segment;
        void*   gcnext_sp;
        void*   gcinitial_sp;
-       jmp_buf gcregs;
+       ucontext_t gcregs;
        byte*   entry;          // initial function
        G*      alllink;        // on allg
        void*   param;          // passed parameter on wakeup
@@ -143,14 +145,16 @@ struct    G
        M*      m;              // for debuggers, but offset not hard-coded
        M*      lockedm;
        M*      idlem;
-       // int32        sig;
+       int32   sig;
        int32   writenbuf;
        byte*   writebuf;
-       // uintptr      sigcode0;
-       // uintptr      sigcode1;
+       uintptr sigcode0;
+       uintptr sigcode1;
        // uintptr      sigpc;
        uintptr gopc;   // pc of go statement that created this goroutine
 
+       Traceback* traceback;
+
        ucontext_t      context;
        void*           stack_context[10];
 };
@@ -274,6 +278,7 @@ int32       runtime_ncpu;
  * common functions and data
  */
 int32  runtime_findnull(const byte*);
+void   runtime_dump(byte*, int32);
 
 /*
  * very low level c-called
@@ -285,10 +290,18 @@ void      runtime_goenvs(void);
 void   runtime_goenvs_unix(void);
 void   runtime_throw(const char*) __attribute__ ((noreturn));
 void   runtime_panicstring(const char*) __attribute__ ((noreturn));
+void   runtime_prints(const char*);
+void   runtime_printf(const char*, ...);
 void*  runtime_mal(uintptr);
 void   runtime_schedinit(void);
 void   runtime_initsig(void);
 void   runtime_sigenable(uint32 sig);
+int32  runtime_gotraceback(void);
+void   runtime_goroutineheader(G*);
+void   runtime_goroutinetrailer(G*);
+void   runtime_traceback();
+void   runtime_tracebackothers(G*);
+void   runtime_printtrace(uintptr*, int32);
 String runtime_gostringnocopy(const byte*);
 void*  runtime_mstart(void*);
 G*     runtime_malg(int32, byte**, size_t*);
@@ -368,9 +381,35 @@ void __wrap_rtems_task_variable_add(void **);
 #endif
 
 /*
+ * Names generated by gccgo.
+ */
+#define runtime_printbool      __go_print_bool
+#define runtime_printfloat     __go_print_double
+#define runtime_printint       __go_print_int64
+#define runtime_printiface     __go_print_interface
+#define runtime_printeface     __go_print_empty_interface
+#define runtime_printstring    __go_print_string
+#define runtime_printpointer   __go_print_pointer
+#define runtime_printuint      __go_print_uint64
+#define runtime_printslice     __go_print_slice
+#define runtime_printcomplex   __go_print_complex
+
+/*
  * runtime go-called
  */
-void   runtime_panic(Eface);
+void   runtime_printbool(_Bool);
+void   runtime_printfloat(double);
+void   runtime_printint(int64);
+void   runtime_printiface(Iface);
+void   runtime_printeface(Eface);
+void   runtime_printstring(String);
+void   runtime_printpc(void*);
+void   runtime_printpointer(void*);
+void   runtime_printuint(uint64);
+void   runtime_printhex(uint64);
+void   runtime_printslice(Slice);
+void   runtime_printcomplex(__complex double);
+
 struct __go_func_type;
 void reflect_call(const struct __go_func_type *, const void *, _Bool, _Bool,
                  void **, void **)
@@ -378,7 +417,7 @@ void reflect_call(const struct __go_func_type *, const void *, _Bool, _Bool,
 
 /* Functions.  */
 #define runtime_panic __go_panic
-#define runtime_printf printf
+#define runtime_write(d, v, n) write((d), (v), (n))
 #define runtime_malloc(s) __go_alloc(s)
 #define runtime_free(p) __go_free(p)
 #define runtime_strcmp(s1, s2) __builtin_strcmp((s1), (s2))
@@ -426,6 +465,8 @@ void        runtime_newErrorString(String, Eface*)
 /*
  * wrapped for go users
  */
+bool   runtime_isInf(float64 f, int32 sign);
+#define runtime_isNaN(f) __builtin_isnan(f)
 void   runtime_semacquire(uint32 volatile *);
 void   runtime_semrelease(uint32 volatile *);
 int32  runtime_gomaxprocsfunc(int32 n);
@@ -434,6 +475,8 @@ void        runtime_osyield(void);
 void   runtime_LockOSThread(void) __asm__("runtime.LockOSThread");
 void   runtime_UnlockOSThread(void) __asm__("runtime.UnlockOSThread");
 
+bool   runtime_showframe(const unsigned char*);
+
 uintptr        runtime_memlimit(void);
 
 // If appropriate, ask the operating system to control whether this
@@ -447,6 +490,7 @@ uintptr     runtime_memlimit(void);
 void   runtime_setprof(bool);
 
 void   runtime_time_scan(void (*)(byte*, int64));
+void   runtime_trampoline_scan(void (*)(byte *, int64));
 
 void   runtime_setsig(int32, bool, bool);
 #define runtime_setitimer setitimer
@@ -468,3 +512,5 @@ void        __go_register_gc_roots(struct root_list*);
 // This will be 0 when using split stacks, as in that case
 // the stacks are allocated by the splitstack library.
 extern uintptr runtime_stacks_sys;
+
+extern _Bool __go_file_line (uintptr, String*, String*, int *);