* Enable gcj on ARM EABI
@ 2007-07-27 15:56 Andrew Haley
2007-09-04 18:06 ` Andrew Haley
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Haley @ 2007-07-27 15:56 UTC (permalink / raw)
To: gcc-patches, java-patches
Add soft-float support for ARM libffi.
Add EABI exception handling.
Stub backtraces -- just for the time being.
Andrew.
2007-07-27 Andrew Haley <aph@redhat.com>
* configure.ac (noconfigdirs): Remove target-libffi and
target-libjava.
2007-07-27 Andrew Haley <aph@redhat.com>
* gnu/classpath/natVMStackWalker.cc (GET_CALLING_CLASS): Stub for
ARM EABI.
* exception.cc (get_exception_header_from_ue): New.
(get_ttype_entry): ARM EABI version.
(PERSONALITY_FUNCTION): Add ARM EABI code.
* sysdep/arm/backtrace.h: New file.
* stacktrace.cc (_URC_NORMAL_STOP): New.
* configure.ac (extra_ldflags_libjava): Add libsupc++.la for ARM
EABI.
* configure.host (BACKTRACESPEC): Add arm/backtrace.h.
2007-07-27 Andrew Haley <aph@redhat.com>
* src/arm/sysv.S (ffi_closure_SYSV): Add soft-float.
Index: configure
===================================================================
--- configure (revision 126800)
+++ configure (working copy)
@@ -2236,8 +2236,8 @@
noconfigdirs="$noconfigdirs target-libffi target-qthreads"
;;
arm*-*-linux-gnueabi)
- noconfigdirs="$noconfigdirs target-libffi target-qthreads"
- noconfigdirs="$noconfigdirs target-libjava target-libobjc"
+ noconfigdirs="$noconfigdirs target-qthreads"
+ noconfigdirs="$noconfigdirs target-libobjc"
case ${with_newlib} in
no) noconfigdirs="$noconfigdirs target-newlib target-libgloss"
esac
Index: libffi/src/arm/sysv.S
===================================================================
--- libffi/src/arm/sysv.S (revision 126800)
+++ libffi/src/arm/sysv.S (working copy)
@@ -225,12 +225,28 @@
bl ffi_closure_SYSV_inner
cmp r0, #FFI_TYPE_INT
beq .Lretint
+
cmp r0, #FFI_TYPE_FLOAT
+#ifdef __SOFTFP__
+ beq .Lretint
+#else
beq .Lretfloat
+#endif
+
cmp r0, #FFI_TYPE_DOUBLE
+#ifdef __SOFTFP__
+ beq .Lretlonglong
+#else
beq .Lretdouble
+#endif
+
cmp r0, #FFI_TYPE_LONGDOUBLE
+#ifdef __SOFTFP__
+ beq .Lretlonglong
+#else
beq .Lretlongdouble
+#endif
+
cmp r0, #FFI_TYPE_SINT64
beq .Lretlonglong
.Lclosure_epilogue:
@@ -243,6 +259,8 @@
ldr r0, [sp]
ldr r1, [sp, #4]
b .Lclosure_epilogue
+
+#ifndef __SOFTFP__
.Lretfloat:
ldfs f0, [sp]
b .Lclosure_epilogue
@@ -252,6 +270,8 @@
.Lretlongdouble:
ldfd f0, [sp]
b .Lclosure_epilogue
+#endif
+
.ffi_closure_SYSV_end:
.size CNAME(ffi_closure_SYSV),.ffi_closure_SYSV_end-CNAME(ffi_closure_SYSV)
Index: libjava/configure.host
===================================================================
--- libjava/configure.host (revision 126800)
+++ libjava/configure.host (working copy)
@@ -86,6 +86,7 @@
arm*-linux*)
libgcj_interpreter=yes
sysdeps_dir=arm
+ fallback_backtrace_h=sysdep/arm/backtrace.h
;;
mips-tx39-*|mipstx39-unknown-*)
libgcj_flags="${libgcj_flags} -G 0"
Index: libjava/configure.ac
===================================================================
--- libjava/configure.ac (revision 126800)
+++ libjava/configure.ac (working copy)
@@ -787,6 +787,9 @@
# on Darwin -single_module speeds up loading of the dynamic libraries.
extra_ldflags_libjava=-Wl,-single_module
;;
+arm*linux*eabi)
+ extra_ldflags_libjava=../libstdc++-v3/libsupc++/libsupc++.la
+ ;;
esac
AC_SUBST(extra_ldflags_libjava)
Index: libjava/stacktrace.cc
===================================================================
--- libjava/stacktrace.cc (revision 126800)
+++ libjava/stacktrace.cc (working copy)
@@ -39,6 +39,10 @@
using namespace java::util;
using namespace gnu::gcj::runtime;
+#ifdef __ARM_EABI_UNWINDER__
+#define _URC_NORMAL_STOP _URC_FAILURE
+#endif
+
// Maps ncode values to their containing native class.
// NOTE: Currently this Map contradicts class GC for native classes. This map
// (and the "new class stack") will need to use WeakReferences in order to
Index: libjava/sysdep/arm/backtrace.h
===================================================================
--- libjava/sysdep/arm/backtrace.h (revision 0)
+++ libjava/sysdep/arm/backtrace.h (revision 0)
@@ -0,0 +1,46 @@
+// backtrace.h - Fallback backtrace implementation. default implementation.
+
+/* Copyright (C) 2005, 2006 Free Software Foundation
+
+ This file is part of libgcj.
+
+This software is copyrighted work licensed under the terms of the
+Libgcj License. Please consult the file "LIBGCJ_LICENSE" for
+details. */
+
+#ifndef __SYSDEP_BACKTRACE_H__
+#define __SYSDEP_BACKTRACE_H__
+
+#include <java-stack.h>
+
+extern "C"
+{
+/* Unwind through the call stack calling TRACE_FN with STATE for every stack
+ frame. Returns the reason why the unwinding was stopped. */
+#ifdef __ARM_EABI_UNWINDER__
+#undef _Unwind_GetIPInfo
+#define _Unwind_GetIPInfo(ctx,ip_before_insn) \
+ (*(ip_before_insn) = 1, (ctx)->ret_addr)
+
+#undef _Unwind_GetRegionStart
+#define _Unwind_GetRegionStart(ctx) \
+ 0
+
+#undef _Unwind_Backtrace
+#define _Unwind_Backtrace(trace_fn,state_ptr) \
+ (fallback_backtrace (trace_fn, state_ptr))
+
+#define _Unwind_FindEnclosingFunction(PC) \
+ (PC)
+
+_Unwind_Reason_Code
+fallback_backtrace (_Unwind_Reason_Code (*)(struct _Unwind_Context*, void*), _Jv_UnwindState *)
+#else
+_Unwind_Reason_Code
+fallback_backtrace (_Unwind_Trace_Fn, _Jv_UnwindState *)
+#endif
+{
+ return _URC_NO_REASON;
+}
+}
+#endif
Index: libjava/configure
===================================================================
--- libjava/configure (revision 126800)
+++ libjava/configure (working copy)
@@ -20370,6 +20370,9 @@
# on Darwin -single_module speeds up loading of the dynamic libraries.
extra_ldflags_libjava=-Wl,-single_module
;;
+arm*linux*eabi)
+ extra_ldflags_libjava=../libstdc++-v3/libsupc++/libsupc++.la
+ ;;
esac
Index: libjava/exception.cc
===================================================================
--- libjava/exception.cc (revision 126800)
+++ libjava/exception.cc (working copy)
@@ -58,8 +58,23 @@
_Unwind_Exception unwindHeader;
};
+#ifdef __ARM_EABI_UNWINDER__
// This is the exception class we report -- "GNUCJAVA".
+
const _Unwind_Exception_Class __gcj_exception_class
+ = {'G', 'N', 'U', 'C', 'J', 'A', 'V', 'A'};
+
+static inline java_exception_header *
+get_exception_header_from_ue (_Unwind_Exception *exc)
+{
+ return reinterpret_cast<java_exception_header *>(exc + 1) - 1;
+}
+
+extern "C" void __cxa_begin_cleanup (_Unwind_Exception*);
+
+#else // !__ARM_EABI_UNWINDER__
+// This is the exception class we report -- "GNUCJAVA".
+const _Unwind_Exception_Class __gcj_exception_class
= ((((((((_Unwind_Exception_Class) 'G'
<< 8 | (_Unwind_Exception_Class) 'N')
<< 8 | (_Unwind_Exception_Class) 'U')
@@ -75,6 +90,7 @@
{
return reinterpret_cast<java_exception_header *>(exc + 1) - 1;
}
+#endif // !__ARM_EABI_UNWINDER__
/* Perform a throw, Java style. Throw will unwind through this call,
so there better not be any handlers or exception thrown here. */
@@ -89,7 +105,8 @@
value = new java::lang::NullPointerException ();
xh->value = value;
- xh->unwindHeader.exception_class = __gcj_exception_class;
+ memcpy (&xh->unwindHeader.exception_class, &__gcj_exception_class,
+ sizeof xh->unwindHeader.exception_class);
xh->unwindHeader.exception_cleanup = NULL;
/* We're happy with setjmp/longjmp exceptions or region-based
@@ -159,7 +176,22 @@
return p;
}
+#ifdef __ARM_EABI_UNWINDER__
+
static void **
+get_ttype_entry(_Unwind_Context *, lsda_header_info* info, _uleb128_t i)
+{
+ _Unwind_Ptr ptr;
+
+ ptr = (_Unwind_Ptr) (info->TType - (i * 4));
+ ptr = _Unwind_decode_target2(ptr);
+
+ return reinterpret_cast<void **>(ptr);
+}
+
+#else
+
+static void **
get_ttype_entry (_Unwind_Context *context, lsda_header_info *info, long i)
{
_Unwind_Ptr ptr;
@@ -170,6 +202,7 @@
return reinterpret_cast<void **>(ptr);
}
+#endif
// Using a different personality function name causes link failures
// when trying to mix code using different exception handling models.
@@ -180,12 +213,28 @@
#define PERSONALITY_FUNCTION __gcj_personality_v0
#endif
+#define CONTINUE_UNWINDING \
+ do \
+ { \
+ if (__gnu_unwind_frame(ue_header, context) != _URC_OK) \
+ return _URC_FAILURE; \
+ return _URC_CONTINUE_UNWIND; \
+ } \
+ while (0)
+
+#ifdef __ARM_EABI_UNWINDER__
extern "C" _Unwind_Reason_Code
+PERSONALITY_FUNCTION (_Unwind_State state,
+ struct _Unwind_Exception* ue_header,
+ struct _Unwind_Context* context)
+#else
+extern "C" _Unwind_Reason_Code
PERSONALITY_FUNCTION (int version,
_Unwind_Action actions,
_Unwind_Exception_Class exception_class,
struct _Unwind_Exception *ue_header,
struct _Unwind_Context *context)
+#endif
{
java_exception_header *xh = get_exception_header_from_ue (ue_header);
@@ -197,16 +246,56 @@
int handler_switch_value;
bool saw_cleanup;
bool saw_handler;
+ bool foreign_exception;
int ip_before_insn = 0;
+#ifdef __ARM_EABI_UNWINDER__
+ _Unwind_Action actions;
+ switch (state & _US_ACTION_MASK)
+ {
+ case _US_VIRTUAL_UNWIND_FRAME:
+ actions = _UA_SEARCH_PHASE;
+ break;
+
+ case _US_UNWIND_FRAME_STARTING:
+ actions = _UA_CLEANUP_PHASE;
+ if (!(state & _US_FORCE_UNWIND)
+ && ue_header->barrier_cache.sp == _Unwind_GetGR(context, 13))
+ actions |= _UA_HANDLER_FRAME;
+ break;
+
+ case _US_UNWIND_FRAME_RESUME:
+ CONTINUE_UNWINDING;
+ break;
+
+ default:
+ std::abort();
+ }
+ actions |= state & _US_FORCE_UNWIND;
+
+ // We don't know which runtime we're working with, so can't check this.
+ // However the ABI routines hide this from us, and we don't actually need
+ // to know.
+ foreign_exception = false;
+
+ // The dwarf unwinder assumes the context structure holds things like the
+ // function and LSDA pointers. The ARM implementation caches these in
+ // the exception header (UCB). To avoid rewriting everything we make the
+ // virtual IP register point at the UCB.
+ ip = (_Unwind_Ptr) ue_header;
+ _Unwind_SetGR(context, 12, ip);
+
+#else
// Interface version check.
if (version != 1)
return _URC_FATAL_PHASE1_ERROR;
+ foreign_exception = exception_class != __gcj_exception_class)
+#endif
// Shortcut for phase 2 found handler for domestic exception.
if (actions == (_UA_CLEANUP_PHASE | _UA_HANDLER_FRAME)
- && exception_class == __gcj_exception_class)
+ && !foreign_exception)
{
handler_switch_value = xh->handlerSwitchValue;
landing_pad = xh->landingPad;
@@ -227,17 +316,17 @@
// If no LSDA, then there are no handlers or cleanups.
if (! language_specific_data)
- return _URC_CONTINUE_UNWIND;
+ CONTINUE_UNWINDING;
// Parse the LSDA header.
p = parse_lsda_header (context, language_specific_data, &info);
#ifdef HAVE_GETIPINFO
ip = _Unwind_GetIPInfo (context, &ip_before_insn);
- if (! ip_before_insn)
- --ip;
#else
ip = _Unwind_GetIP (context) - 1;
#endif
+ if (! ip_before_insn)
+ --ip;
landing_pad = 0;
action_record = 0;
handler_switch_value = 0;
@@ -296,7 +385,7 @@
// If ip is not present in the table, C++ would call terminate.
// ??? It is perhaps better to tweek the LSDA so that no-action
// is mapped to no-entry for Java.
- return _URC_CONTINUE_UNWIND;
+ CONTINUE_UNWINDING;
found_something:
saw_cleanup = false;
@@ -334,7 +423,7 @@
// During forced unwinding, we only run cleanups. With a
// foreign exception class, we have no class info to match.
else if ((actions & _UA_FORCE_UNWIND)
- || exception_class != __gcj_exception_class)
+ || foreign_exception)
;
else if (ar_filter > 0)
@@ -374,15 +463,15 @@
}
if (! saw_handler && ! saw_cleanup)
- return _URC_CONTINUE_UNWIND;
+ CONTINUE_UNWINDING;
if (actions & _UA_SEARCH_PHASE)
{
if (! saw_handler)
- return _URC_CONTINUE_UNWIND;
+ CONTINUE_UNWINDING;
// For domestic exceptions, we cache data from phase 1 for phase 2.
- if (exception_class == __gcj_exception_class)
+ if (! foreign_exception)
{
xh->handlerSwitchValue = handler_switch_value;
xh->landingPad = landing_pad;
@@ -396,5 +485,9 @@
_Unwind_SetGR (context, __builtin_eh_return_data_regno (1),
handler_switch_value);
_Unwind_SetIP (context, landing_pad);
+#ifdef __ARM_EABI_UNWINDER__
+ if (saw_cleanup)
+ __cxa_begin_cleanup(ue_header);
+#endif
return _URC_INSTALL_CONTEXT;
}
Index: libjava/gnu/classpath/natVMStackWalker.cc
===================================================================
--- libjava/gnu/classpath/natVMStackWalker.cc (revision 126800)
+++ libjava/gnu/classpath/natVMStackWalker.cc (working copy)
@@ -19,6 +19,7 @@
#include <java/lang/ClassLoader.h>
#include <java/lang/Class.h>
+#ifndef __ARM_EABI_UNWINDER__
// Return the class of the method that contains PC.
// This is a macro not a function, since defining it as one would
// introduce an extra frame on the stack. */
@@ -44,6 +45,9 @@
\
klass; \
})
+#else
+#define GET_CALLING_CLASS(PC) NULL
+#endif
JArray<jclass> *
gnu::classpath::VMStackWalker::getClassContext(void)
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Enable gcj on ARM EABI
2007-07-27 15:56 Enable gcj on ARM EABI Andrew Haley
@ 2007-09-04 18:06 ` Andrew Haley
2007-09-04 20:22 ` Paolo Bonzini
0 siblings, 1 reply; 3+ messages in thread
From: Andrew Haley @ 2007-09-04 18:06 UTC (permalink / raw)
To: gcc-patches, java-patches
Andrew Haley writes:
> Add soft-float support for ARM libffi.
>
> Add EABI exception handling.
>
> Stub backtraces -- just for the time being.
>
> Andrew.
>
>
> 2007-07-27 Andrew Haley <aph@redhat.com>
>
> * configure.ac (noconfigdirs): Remove target-libffi and
> target-libjava.
>
I posted this a month ago. It's a toplevel patch that enables libjava
for ARM EABI.
As libjava on EABI passes all tests, I guess it's OK.
Andrew.
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: Enable gcj on ARM EABI
2007-09-04 18:06 ` Andrew Haley
@ 2007-09-04 20:22 ` Paolo Bonzini
0 siblings, 0 replies; 3+ messages in thread
From: Paolo Bonzini @ 2007-09-04 20:22 UTC (permalink / raw)
To: Andrew Haley; +Cc: gcc-patches, java-patches
> > 2007-07-27 Andrew Haley <aph@redhat.com>
> >
> > * configure.ac (noconfigdirs): Remove target-libffi and
> > target-libjava.
> >
>
> I posted this a month ago. It's a toplevel patch that enables libjava
> for ARM EABI.
>
> As libjava on EABI passes all tests, I guess it's OK.
Of course, I must have missed it. I left for holiday on the 28th indeed.
Paolo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2007-09-04 20:22 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-07-27 15:56 Enable gcj on ARM EABI Andrew Haley
2007-09-04 18:06 ` Andrew Haley
2007-09-04 20:22 ` Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).