This is the mail archive of the libstdc++@gcc.gnu.org mailing list for the libstdc++ project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

[v3] libsupc++ vs. -fno-exceptions


Fixed thusly. Base line exception handling overhead, based on a stripped
version of F11 x86_64's libstdc++.so.6.0.14 as compiled by trunk:

-Os -fno-exceptions 	815K   +6.8%
-Os -fexceptions 	871K
-O2 -fno-exceptions 	941K
-O2 -fexceptions 	1009K  +7.2%

Let's call it 7%.

tested x86_64/linux.

-benjamin
2009-09-28  Benjamin Kosnik  <bkoz@redhat.com>

	*  libsupc++/eh_terminate.cc: Fixes for -fno-exceptions.
	*  libsupc++/vec.cc: Same.
	*  libsupc++/vterminate.cc: Same.
	*  libsupc++/new_opnt.cc: Same.

Index: libsupc++/eh_terminate.cc
===================================================================
--- libsupc++/eh_terminate.cc	(revision 152257)
+++ libsupc++/eh_terminate.cc	(working copy)
@@ -34,12 +34,13 @@
 void
 __cxxabiv1::__terminate (std::terminate_handler handler) throw ()
 {
-  try {
-    handler ();
-    std::abort ();
-  } catch (...) {
-    std::abort ();
-  }
+  __try 
+    {
+      handler ();
+      std::abort ();
+    } 
+  __catch(...) 
+    { std::abort (); }
 }
 
 void
Index: libsupc++/vec.cc
===================================================================
--- libsupc++/vec.cc	(revision 152257)
+++ libsupc++/vec.cc	(working copy)
@@ -95,12 +95,12 @@
 	reinterpret_cast <std::size_t *> (base)[-2] = element_size;
 #endif
       }
-    try
+    __try
       {
 	__cxa_vec_ctor(base, element_count, element_size,
 		       constructor, destructor);
       }
-    catch (...)
+    __catch(...)
       {
 	{
 	  uncatch_exception ue;
@@ -136,12 +136,12 @@
 	reinterpret_cast <std::size_t *> (base)[-2] = element_size;
 #endif
       }
-    try
+    __try
       {
 	__cxa_vec_ctor(base, element_count, element_size,
 		       constructor, destructor);
       }
-    catch (...)
+    __catch(...)
       {
 	{
 	  uncatch_exception ue;
@@ -164,13 +164,13 @@
     std::size_t ix = 0;
     char *ptr = static_cast<char *>(array_address);
     
-    try
+    __try
       {
 	if (constructor)
 	  for (; ix != element_count; ix++, ptr += element_size)
 	    constructor(ptr);
       }
-    catch (...)
+    __catch(...)
       {
 	{
 	  uncatch_exception ue;
@@ -194,14 +194,14 @@
     char *dest_ptr = static_cast<char *>(dest_array);
     char *src_ptr = static_cast<char *>(src_array);
     
-    try
+    __try
       {
 	if (constructor)
 	  for (; ix != element_count; 
 	       ix++, src_ptr += element_size, dest_ptr += element_size)
 	    constructor(dest_ptr, src_ptr);
       }
-    catch (...)
+    __catch(...)
       {
 	{
 	  uncatch_exception ue;
@@ -226,7 +226,7 @@
 
 	ptr += element_count * element_size;
 
-	try
+	__try
 	  {
 	    while (ix--)
 	      {
@@ -234,7 +234,7 @@
 		destructor(ptr);
 	      }
 	  }
-	catch (...)
+	__catch(...)
 	  {
 	    {
 	      uncatch_exception ue;
@@ -261,7 +261,7 @@
 
 	ptr += element_count * element_size;
 
-	try
+	__try
 	  {
 	    while (ix--)
 	      {
@@ -269,7 +269,7 @@
 		destructor(ptr);
 	      }
 	  }
-	catch (...)
+	__catch(...)
 	  {
 	    std::terminate();
 	  }
@@ -304,12 +304,12 @@
       {
 	std::size_t element_count = reinterpret_cast<std::size_t *>(base)[-1];
 	base -= padding_size;
-	try
+	__try
 	  {
 	    __cxa_vec_dtor(array_address, element_count, element_size,
 			   destructor);
 	  }
-	catch (...)
+	__catch(...)
 	  {
 	    {
 	      uncatch_exception ue;
@@ -339,12 +339,12 @@
 	std::size_t element_count = reinterpret_cast<std::size_t *> (base)[-1];
 	base -= padding_size;
 	size = element_count * element_size + padding_size;
-	try
+	__try
 	  {
 	    __cxa_vec_dtor(array_address, element_count, element_size,
 			   destructor);
 	  }
-	catch (...)
+	__catch(...)
 	  {
 	    {
 	      uncatch_exception ue;
Index: libsupc++/vterminate.cc
===================================================================
--- libsupc++/vterminate.cc	(revision 152257)
+++ libsupc++/vterminate.cc	(working copy)
@@ -75,9 +75,9 @@
 
 	// If the exception is derived from std::exception, we can
 	// give more information.
-	try { __throw_exception_again; }
+	__try { __throw_exception_again; }
 #ifdef __EXCEPTIONS
-	catch (exception &exc)
+	__catch(const exception& exc)
 	  {
 	    char const *w = exc.what();
 	    fputs("  what():  ", stderr);
@@ -85,7 +85,7 @@
 	    fputs("\n", stderr);
           }
 #endif
-	catch (...) { }
+	__catch(...) { }
       }
     else
       fputs("terminate called without an active exception\n", stderr);
Index: libsupc++/new_opnt.cc
===================================================================
--- libsupc++/new_opnt.cc	(revision 152257)
+++ libsupc++/new_opnt.cc	(working copy)
@@ -47,11 +47,11 @@
       new_handler handler = __new_handler;
       if (! handler)
 	return 0;
-      try
+      __try
 	{
 	  handler ();
 	}
-      catch (bad_alloc &)
+      __catch(const bad_alloc&)
 	{
 	  return 0;
 	}

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]