summaryrefslogtreecommitdiffstats
path: root/libstdc++-v3/libsupc++
diff options
context:
space:
mode:
authoraldyh <aldyh@138bc75d-0d04-0410-961f-82ee72b054a4>2011-11-08 11:13:41 +0000
committeraldyh <aldyh@138bc75d-0d04-0410-961f-82ee72b054a4>2011-11-08 11:13:41 +0000
commit4c0315d05fa0f707875686abc4f91f7a979a7c7b (patch)
treee07de8d0b6265f8d72388d335bd471022e753d57 /libstdc++-v3/libsupc++
parentbf09288ee7b5f264f28081a84fde4c6aa1ac5c82 (diff)
downloadppe42-gcc-4c0315d05fa0f707875686abc4f91f7a979a7c7b.tar.gz
ppe42-gcc-4c0315d05fa0f707875686abc4f91f7a979a7c7b.zip
Merge from transactional-memory branch.
git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@181154 138bc75d-0d04-0410-961f-82ee72b054a4
Diffstat (limited to 'libstdc++-v3/libsupc++')
-rw-r--r--libstdc++-v3/libsupc++/Makefile.am1
-rw-r--r--libstdc++-v3/libsupc++/Makefile.in16
-rw-r--r--libstdc++-v3/libsupc++/eh_tm.cc124
-rw-r--r--libstdc++-v3/libsupc++/unwind-cxx.h3
4 files changed, 137 insertions, 7 deletions
diff --git a/libstdc++-v3/libsupc++/Makefile.am b/libstdc++-v3/libsupc++/Makefile.am
index 701c2d9a76a..c8e661d5788 100644
--- a/libstdc++-v3/libsupc++/Makefile.am
+++ b/libstdc++-v3/libsupc++/Makefile.am
@@ -68,6 +68,7 @@ sources = \
eh_ptr.cc \
eh_term_handler.cc \
eh_terminate.cc \
+ eh_tm.cc \
eh_throw.cc \
eh_type.cc \
eh_unex_handler.cc \
diff --git a/libstdc++-v3/libsupc++/Makefile.in b/libstdc++-v3/libsupc++/Makefile.in
index 9ef5e683af8..191bd281e3d 100644
--- a/libstdc++-v3/libsupc++/Makefile.in
+++ b/libstdc++-v3/libsupc++/Makefile.in
@@ -95,13 +95,14 @@ am__objects_1 = array_type_info.lo atexit_arm.lo bad_alloc.lo \
del_opnt.lo del_opv.lo del_opvnt.lo dyncast.lo eh_alloc.lo \
eh_arm.lo eh_aux_runtime.lo eh_call.lo eh_catch.lo \
eh_exception.lo eh_globals.lo eh_personality.lo eh_ptr.lo \
- eh_term_handler.lo eh_terminate.lo eh_throw.lo eh_type.lo \
- eh_unex_handler.lo enum_type_info.lo function_type_info.lo \
- fundamental_type_info.lo guard.lo guard_error.lo hash_bytes.lo \
- nested_exception.lo new_handler.lo new_op.lo new_opnt.lo \
- new_opv.lo new_opvnt.lo pbase_type_info.lo pmem_type_info.lo \
- pointer_type_info.lo pure.lo si_class_type_info.lo tinfo.lo \
- tinfo2.lo vec.lo vmi_class_type_info.lo vterminate.lo
+ eh_term_handler.lo eh_terminate.lo eh_tm.lo eh_throw.lo \
+ eh_type.lo eh_unex_handler.lo enum_type_info.lo \
+ function_type_info.lo fundamental_type_info.lo guard.lo \
+ guard_error.lo hash_bytes.lo nested_exception.lo \
+ new_handler.lo new_op.lo new_opnt.lo new_opv.lo new_opvnt.lo \
+ pbase_type_info.lo pmem_type_info.lo pointer_type_info.lo \
+ pure.lo si_class_type_info.lo tinfo.lo tinfo2.lo vec.lo \
+ vmi_class_type_info.lo vterminate.lo
@GLIBCXX_HOSTED_TRUE@am__objects_2 = cp-demangle.lo
am_libsupc___la_OBJECTS = $(am__objects_1) $(am__objects_2)
libsupc___la_OBJECTS = $(am_libsupc___la_OBJECTS)
@@ -375,6 +376,7 @@ sources = \
eh_ptr.cc \
eh_term_handler.cc \
eh_terminate.cc \
+ eh_tm.cc \
eh_throw.cc \
eh_type.cc \
eh_unex_handler.cc \
diff --git a/libstdc++-v3/libsupc++/eh_tm.cc b/libstdc++-v3/libsupc++/eh_tm.cc
new file mode 100644
index 00000000000..f5815a180df
--- /dev/null
+++ b/libstdc++-v3/libsupc++/eh_tm.cc
@@ -0,0 +1,124 @@
+// -*- C++ -*- Exception handling routines for Transactional Memory.
+// Copyright (C) 2009 Free Software Foundation, Inc.
+//
+// This file is part of GCC.
+//
+// GCC is free software; you can redistribute it and/or modify
+// it under the terms of the GNU General Public License as published by
+// the Free Software Foundation; either version 3, or (at your option)
+// any later version.
+//
+// GCC 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 General Public License for more details.
+//
+// Under Section 7 of GPL version 3, you are granted additional
+// permissions described in the GCC Runtime Library Exception, version
+// 3.1, as published by the Free Software Foundation.
+
+// You should have received a copy of the GNU General Public License and
+// a copy of the GCC Runtime Library Exception along with this program;
+// see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
+// <http://www.gnu.org/licenses/>.
+
+#include <cstdlib>
+#include "unwind-cxx.h"
+
+using namespace __cxxabiv1;
+
+// Free one C++ exception.
+
+static void
+free_any_cxa_exception (_Unwind_Exception *eo)
+{
+ __cxa_refcounted_exception *h
+ = __get_refcounted_exception_header_from_ue (eo);
+
+ if (__is_dependent_exception (eo->exception_class))
+ {
+ __cxa_dependent_exception *dep
+ = __get_dependent_exception_from_ue (eo);
+
+ h = __get_refcounted_exception_header_from_obj (dep->primaryException);
+
+ __cxa_free_dependent_exception (dep);
+ }
+
+ if (__sync_sub_and_fetch (&h->referenceCount, 1) == 0)
+ __cxa_free_exception (h + 1);
+}
+
+// Cleanup exception handling state while rolling back state for
+// a software transactional memory transaction.
+//
+// UNTHROWN_OBJ is non-null if we've called __cxa_allocate_exception
+// but not yet called __cxa_throw for it.
+//
+// CLEANUP_EXC is non-null if we're currently processing a cleanup
+// along an exception path, but we've not caught the exception yet.
+//
+// CAUGHT_COUNT is the nesting depth of __cxa_begin_catch within
+// the transaction; undo as if calling __cxa_end_catch that many times.
+
+extern "C" void
+__cxxabiv1::__cxa_tm_cleanup (void *unthrown_obj,
+ void *cleanup_exc,
+ unsigned int caught_count) throw()
+{
+ __cxa_eh_globals *globals = __cxa_get_globals_fast ();
+
+ // Handle a C++ exception not yet thrown.
+ if (unthrown_obj)
+ {
+ globals->uncaughtExceptions -= 1;
+ __cxa_free_exception (unthrown_obj);
+ }
+
+ // Handle an exception not yet caught ie. processing a cleanup
+ // in between the throw and the catch.
+ if (cleanup_exc)
+ {
+ _Unwind_Exception *eo
+ = reinterpret_cast <_Unwind_Exception *>(cleanup_exc);
+ if (__is_gxx_exception_class (eo->exception_class))
+ free_any_cxa_exception (eo);
+ else
+ _Unwind_DeleteException (eo);
+ }
+
+ // Do __cxa_end_catch caught_count times, but don't bother running
+ // the destructors for the objects involved. All of that is being
+ // undone by the transaction restart.
+ if (caught_count > 0)
+ {
+ __cxa_exception *h = globals->caughtExceptions;
+
+ // Rethrown foreign exceptions are removed from the stack immediately.
+ // We would have freed this exception via THIS_EXC above.
+ if (h == NULL)
+ return;
+
+ do
+ {
+ __cxa_exception *next;
+ _Unwind_Exception *eo = &h->unwindHeader;
+
+ if (__is_gxx_exception_class (eo->exception_class))
+ {
+ next = h->nextException;
+ free_any_cxa_exception (eo);
+ }
+ else
+ {
+ _Unwind_DeleteException (eo);
+ next = 0;
+ }
+
+ h = next;
+ }
+ while (--caught_count);
+
+ globals->caughtExceptions = h;
+ }
+}
diff --git a/libstdc++-v3/libsupc++/unwind-cxx.h b/libstdc++-v3/libsupc++/unwind-cxx.h
index 84dd36781df..e538bdedf05 100644
--- a/libstdc++-v3/libsupc++/unwind-cxx.h
+++ b/libstdc++-v3/libsupc++/unwind-cxx.h
@@ -167,6 +167,9 @@ extern "C" bool __cxa_begin_cleanup (_Unwind_Exception*);
extern "C" void __cxa_end_cleanup (void);
#endif
+// Handles cleanup from transactional memory restart.
+extern "C" void __cxa_tm_cleanup (void *, void *, unsigned int) throw();
+
// Invokes given handler, dying appropriately if the user handler was
// so inconsiderate as to return.
extern void __terminate(std::terminate_handler) throw ()
OpenPOWER on IntegriCloud