[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[dotgnu-pnet-commits] libjit ChangeLog include/jit/jit.h include/jit/...
From: |
Aleksey Demakov |
Subject: |
[dotgnu-pnet-commits] libjit ChangeLog include/jit/jit.h include/jit/... |
Date: |
Thu, 29 May 2008 21:03:31 +0000 |
CVSROOT: /sources/dotgnu-pnet
Module name: libjit
Changes by: Aleksey Demakov <avd> 08/05/29 21:03:31
Modified files:
. : ChangeLog
include/jit : jit.h Makefile.am
jit : Makefile.am jit-except.c
Added files:
include/jit : jit-unwind.h
jit : jit-unwind.c
Log message:
add unwinding interface
CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/libjit/ChangeLog?cvsroot=dotgnu-pnet&r1=1.381&r2=1.382
http://cvs.savannah.gnu.org/viewcvs/libjit/include/jit/jit.h?cvsroot=dotgnu-pnet&r1=1.4&r2=1.5
http://cvs.savannah.gnu.org/viewcvs/libjit/include/jit/Makefile.am?cvsroot=dotgnu-pnet&r1=1.7&r2=1.8
http://cvs.savannah.gnu.org/viewcvs/libjit/include/jit/jit-unwind.h?cvsroot=dotgnu-pnet&rev=1.1
http://cvs.savannah.gnu.org/viewcvs/libjit/jit/Makefile.am?cvsroot=dotgnu-pnet&r1=1.25&r2=1.26
http://cvs.savannah.gnu.org/viewcvs/libjit/jit/jit-except.c?cvsroot=dotgnu-pnet&r1=1.9&r2=1.10
http://cvs.savannah.gnu.org/viewcvs/libjit/jit/jit-unwind.c?cvsroot=dotgnu-pnet&rev=1.1
Patches:
Index: ChangeLog
===================================================================
RCS file: /sources/dotgnu-pnet/libjit/ChangeLog,v
retrieving revision 1.381
retrieving revision 1.382
diff -u -b -r1.381 -r1.382
--- ChangeLog 29 May 2008 18:53:00 -0000 1.381
+++ ChangeLog 29 May 2008 21:03:30 -0000 1.382
@@ -4,7 +4,14 @@
type.
* include/jit/jit-except.h, include/jit/jit-common.h: move
- JIT_NO_OFFSET from jit-except.h to jit-common.h
+ JIT_NO_OFFSET from jit-except.h to jit-common.h.
+
+ * include/jit/jit-unwind.h, jit/jit-unwind.c: new files.
+ * include/jit/jit.h, include/jit/Makefile.am: add jit-unwind.h.
+ * jit/Makefile.am: add jit-unwind.c.
+
+ * jit/jit-except.c (jit_exception_get_stack_trace): re-implement
+ using unwind routines.
2008-05-28 Juan Jesus Garcia de Soria <address@hidden>
Index: include/jit/jit.h
===================================================================
RCS file: /sources/dotgnu-pnet/libjit/include/jit/jit.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -b -r1.4 -r1.5
--- include/jit/jit.h 24 Jan 2008 20:12:50 -0000 1.4
+++ include/jit/jit.h 29 May 2008 21:03:30 -0000 1.5
@@ -36,11 +36,12 @@
#include <jit/jit-function.h>
#include <jit/jit-init.h>
#include <jit/jit-insn.h>
+#include <jit/jit-intrinsic.h>
#include <jit/jit-meta.h>
#include <jit/jit-objmodel.h>
#include <jit/jit-opcode.h>
#include <jit/jit-type.h>
-#include <jit/jit-intrinsic.h>
+#include <jit/jit-unwind.h>
#include <jit/jit-util.h>
#include <jit/jit-value.h>
#include <jit/jit-walk.h>
Index: include/jit/Makefile.am
===================================================================
RCS file: /sources/dotgnu-pnet/libjit/include/jit/Makefile.am,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -b -r1.7 -r1.8
--- include/jit/Makefile.am 13 Apr 2008 16:14:15 -0000 1.7
+++ include/jit/Makefile.am 29 May 2008 21:03:30 -0000 1.8
@@ -3,7 +3,8 @@
BUILT_SOURCES = jit-arch.h
libjitincludedir = $(includedir)/jit
-libjitinclude_HEADERS = jit.h \
+libjitinclude_HEADERS = \
+ jit.h \
jit-arch.h \
jit-apply.h \
jit-block.h \
@@ -25,6 +26,7 @@
jit-opcode.h \
jit-plus.h \
jit-type.h \
+ jit-unwind.h \
jit-util.h \
jit-value.h \
jit-walk.h
Index: jit/Makefile.am
===================================================================
RCS file: /sources/dotgnu-pnet/libjit/jit/Makefile.am,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -b -r1.25 -r1.26
--- jit/Makefile.am 4 Mar 2008 20:36:17 -0000 1.25
+++ jit/Makefile.am 29 May 2008 21:03:30 -0000 1.26
@@ -71,6 +71,7 @@
jit-thread.c \
jit-thread.h \
jit-type.c \
+ jit-unwind.c \
jit-value.c \
jit-walk.c
Index: jit/jit-except.c
===================================================================
RCS file: /sources/dotgnu-pnet/libjit/jit/jit-except.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -b -r1.9 -r1.10
--- jit/jit-except.c 24 Jan 2008 20:12:51 -0000 1.9
+++ jit/jit-except.c 29 May 2008 21:03:30 -0000 1.10
@@ -305,32 +305,32 @@
@*/
jit_stack_trace_t jit_exception_get_stack_trace(void)
{
- jit_stack_trace_t trace = 0;
- unsigned int size = 0;
-#if JIT_APPLY_BROKEN_FRAME_BUILTINS != 0
- jit_thread_control_t control;
- jit_backtrace_t top;
- jit_backtrace_t item;
+ jit_stack_trace_t trace;
+ unsigned int size;
+ jit_unwind_context_t unwind;
/* Count the number of items in the current thread's call stack */
- control = _jit_thread_get_control();
- if(!control)
+ size = 0;
+ if(jit_unwind_init(&unwind, NULL))
{
- return 0;
+ do
+ {
+ size++;
}
- size = 0;
- top = control->backtrace_head;
- item = top;
- while(item != 0)
+ while(jit_unwind_next_pc(&unwind));
+ jit_unwind_free(&unwind);
+ }
+
+ /* Bail out if the stack is not available */
+ if(size == 0)
{
- ++size;
- item = item->parent;
+ return 0;
}
/* Allocate memory for the stack trace */
- trace = (jit_stack_trace_t)jit_malloc
- (sizeof(struct jit_stack_trace) +
- size * sizeof(void *) - sizeof(void *));
+ trace = (jit_stack_trace_t) jit_malloc(sizeof(struct jit_stack_trace)
+ + size * sizeof(void *)
+ - sizeof(void *));
if(!trace)
{
return 0;
@@ -339,43 +339,22 @@
/* Populate the stack trace with the items we counted earlier */
size = 0;
- item = top;
- while(item != 0)
+ if(jit_unwind_init(&unwind, NULL))
{
- trace->items[size] = item->pc;
- ++size;
- item = item->parent;
- }
-#else
- void *frame = jit_get_current_frame();
-
- /* Count the number of items in the current thread's call stack */
- while(frame != 0)
+ do
{
- frame = jit_get_next_frame_address(frame);
- ++size;
+ trace->items[size] = jit_unwind_get_pc(&unwind);
+ size++;
}
-
- /* Allocate memory for the stack trace */
- trace = (jit_stack_trace_t)jit_malloc
- (sizeof(struct jit_stack_trace) +
- size * sizeof(void *) - sizeof(void *));
- if(!trace)
+ while(jit_unwind_next_pc(&unwind));
+ jit_unwind_free(&unwind);
+ }
+ else
{
+ jit_free(trace);
return 0;
}
- trace->size = size;
- /* Populate the stack trace with the items we counted earlier */
- size = 0;
- frame = jit_get_current_frame();
- while(frame != 0)
- {
- trace->items[size] = jit_get_return_address(frame);
- frame = jit_get_next_frame_address(frame);
- ++size;
- }
-#endif
return trace;
}
@@ -469,7 +448,7 @@
}
}
}
- return JIT_CACHE_NO_OFFSET;
+ return JIT_NO_OFFSET;
}
/*@
Index: include/jit/jit-unwind.h
===================================================================
RCS file: include/jit/jit-unwind.h
diff -N include/jit/jit-unwind.h
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ include/jit/jit-unwind.h 29 May 2008 21:03:30 -0000 1.1
@@ -0,0 +1,59 @@
+/*
+ * jit-unwind.h - Routines for performing stack unwinding.
+ *
+ * Copyright (C) 2008 Southern Storm Software, Pty Ltd.
+ *
+ * This file is part of the libjit library.
+ *
+ * The libjit library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation, either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * The libjit library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the libjit library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#ifndef _JIT_UNWIND_H
+#define _JIT_UNWIND_H
+
+#include <jit/jit-common.h>
+#include <jit/jit-arch.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct
+{
+ void *frame;
+ void *cache;
+ jit_context_t context;
+#ifdef _JIT_ARCH_UNWIND_DATA
+ _JIT_ARCH_UNWIND_DATA
+#endif
+} jit_unwind_context_t;
+
+int jit_unwind_init(jit_unwind_context_t *unwind, jit_context_t context);
+void jit_unwind_free(jit_unwind_context_t *unwind);
+
+int jit_unwind_next(jit_unwind_context_t *unwind);
+int jit_unwind_next_pc(jit_unwind_context_t *unwind);
+void *jit_unwind_get_pc(jit_unwind_context_t *unwind);
+
+int jit_unwind_jump(jit_unwind_context_t *unwind, void *pc);
+
+jit_function_t jit_unwind_get_function(jit_unwind_context_t *unwind);
+unsigned int jit_unwind_get_offset(jit_unwind_context_t *unwind);
+
+#ifdef __cplusplus
+};
+#endif
+
+#endif /* _JIT_UNWIND_H */
Index: jit/jit-unwind.c
===================================================================
RCS file: jit/jit-unwind.c
diff -N jit/jit-unwind.c
--- /dev/null 1 Jan 1970 00:00:00 -0000
+++ jit/jit-unwind.c 29 May 2008 21:03:30 -0000 1.1
@@ -0,0 +1,212 @@
+/*
+ * jit-unwind.c - Routines for performing stack unwinding.
+ *
+ * Copyright (C) 2008 Southern Storm Software, Pty Ltd.
+ *
+ * This file is part of the libjit library.
+ *
+ * The libjit library is free software: you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public License
+ * as published by the Free Software Foundation, either version 2.1 of
+ * the License, or (at your option) any later version.
+ *
+ * The libjit library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
+ *
+ * You should have received a copy of the GNU Lesser General Public
+ * License along with the libjit library. If not, see
+ * <http://www.gnu.org/licenses/>.
+ */
+
+#include "jit-internal.h"
+#include "jit-cache.h"
+#include "jit-rules.h"
+#include "jit-apply-rules.h"
+#include <jit/jit-unwind.h>
+#include <jit/jit-walk.h>
+
+int
+jit_unwind_init(jit_unwind_context_t *unwind, jit_context_t context)
+{
+#if defined(JIT_BACKENED_INTERP) || JIT_APPLY_BROKEN_FRAME_BUILTINS != 0
+ jit_thread_control_t control;
+
+ control = _jit_thread_get_control();
+ if(!control)
+ {
+ return 0;
+ }
+
+ unwind->frame = control->backtrace_head;
+#elif JIT_FAST_GET_CURRENT_FRAME != 0
+ unwind->frame = jit_get_next_frame_address(jit_get_current_frame());
+#else
+ unwind->frame = jit_get_frame_address(1);
+#endif
+
+ unwind->context = context;
+ unwind->cache = 0;
+
+#ifdef _JIT_ARCH_UNWIND_INIT
+ _JIT_ARCH_UNWIND_INIT(unwind);
+#endif
+
+ return (unwind->frame != 0);
+}
+
+void
+jit_unwind_free(jit_unwind_context_t *unwind)
+{
+#ifdef _JIT_ARCH_UNWIND_FREE
+ _JIT_ARCH_UNWIND_FREE(unwind);
+#endif
+}
+
+int
+jit_unwind_next(jit_unwind_context_t *unwind)
+{
+#if defined(_JIT_ARCH_UNWIND_NEXT) || defined(_JIT_ARCH_UNWIND_NEXT_PRE)
+ jit_function_t func;
+#endif
+
+ if(!unwind || !unwind->frame)
+ {
+ return 0;
+ }
+
+ unwind->cache = 0;
+
+#if defined(JIT_BACKENED_INTERP) || JIT_APPLY_BROKEN_FRAME_BUILTINS != 0
+ unwind->frame = ((jit_backtrace_t) unwind->frame)->parent;
+ return (unwind->frame != 0);
+#else
+
+#ifdef _JIT_ARCH_UNWIND_NEXT_PRE
+ func = jit_unwind_get_function(unwind);
+ if(func)
+ {
+ _JIT_ARCH_UNWIND_NEXT_PRE(unwind, func);
+ }
+#endif
+
+ unwind->frame = jit_get_next_frame_address(unwind->frame);
+ if(!unwind->frame)
+ {
+ return 0;
+ }
+
+#ifdef _JIT_ARCH_UNWIND_NEXT
+ func = jit_unwind_get_function(unwind);
+ if(func)
+ {
+ _JIT_ARCH_UNWIND_NEXT(unwind, func);
+ }
+#endif
+
+ return 1;
+#endif
+}
+
+int
+jit_unwind_next_pc(jit_unwind_context_t *unwind)
+{
+ if(!unwind || !unwind->frame)
+ {
+ return 0;
+ }
+
+ unwind->cache = 0;
+
+#if defined(JIT_BACKENED_INTERP) || JIT_APPLY_BROKEN_FRAME_BUILTINS != 0
+ unwind->frame = ((jit_backtrace_t) unwind->frame)->parent;
+#else
+ unwind->frame = jit_get_next_frame_address(unwind->frame);
+#endif
+ return (unwind->frame != 0);
+}
+
+void *
+jit_unwind_get_pc(jit_unwind_context_t *unwind)
+{
+ if(!unwind || !unwind->frame)
+ {
+ return 0;
+ }
+
+#if defined(JIT_BACKENED_INTERP) || JIT_APPLY_BROKEN_FRAME_BUILTINS != 0
+ return ((jit_backtrace_t) unwind->frame)->pc;
+#else
+ return jit_get_return_address(unwind->frame);
+#endif
+}
+
+int
+jit_unwind_jump(jit_unwind_context_t *unwind, void *pc)
+{
+#ifdef _JIT_ARCH_UNWIND_JUMP
+ if(!unwind || !unwind->frame || !pc)
+ {
+ return 0;
+ }
+
+ return _JIT_ARCH_UNWIND_JUMP(unwind, pc);
+#else
+ return 0;
+#endif
+}
+
+jit_function_t
+jit_unwind_get_function(jit_unwind_context_t *unwind)
+{
+ if(!unwind || !unwind->frame || !unwind->context)
+ {
+ return 0;
+ }
+
+ if(!unwind->cache)
+ {
+ jit_cache_t cache = _jit_context_get_cache(unwind->context);
+ void *pc = jit_unwind_get_pc(unwind);
+ unwind->cache = (jit_function_t)
+ _jit_cache_get_method(cache, pc, NULL);
+ }
+
+ return (jit_function_t) unwind->cache;
+}
+
+unsigned int
+jit_unwind_get_offset(jit_unwind_context_t *unwind)
+{
+ jit_function_t func;
+ jit_cache_t cache;
+ void *pc, *start;
+
+ if(!unwind || !unwind->frame || !unwind->context)
+ {
+ return JIT_NO_OFFSET;
+ }
+
+ pc = jit_unwind_get_pc(unwind);
+ if(!pc)
+ {
+ return JIT_NO_OFFSET;
+ }
+
+ func = jit_unwind_get_function(unwind);
+ if(!func)
+ {
+ return JIT_NO_OFFSET;
+ }
+
+ cache = _jit_context_get_cache(unwind->context);
+
+#ifdef JIT_PROLOG_SIZE
+ start = _jit_cache_get_start_method(cache, func->entry_point);
+#else
+ start = func->entry_point;
+#endif
+
+ return _jit_cache_get_bytecode(cache, start, pc - start, 0);
+}
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [dotgnu-pnet-commits] libjit ChangeLog include/jit/jit.h include/jit/...,
Aleksey Demakov <=