[cfe-commits] [libcxxabi] r152966 - /libcxxabi/trunk/src/cxa_personality.cpp

Howard Hinnant hhinnant at apple.com
Fri Mar 16 17:10:52 PDT 2012


Author: hhinnant
Date: Fri Mar 16 19:10:52 2012
New Revision: 152966

URL: http://llvm.org/viewvc/llvm-project?rev=152966&view=rev
Log:
Arm fixes in cxa_personality.cpp and a little refactoring.

Modified:
    libcxxabi/trunk/src/cxa_personality.cpp

Modified: libcxxabi/trunk/src/cxa_personality.cpp
URL: http://llvm.org/viewvc/llvm-project/libcxxabi/trunk/src/cxa_personality.cpp?rev=152966&r1=152965&r2=152966&view=diff
==============================================================================
--- libcxxabi/trunk/src/cxa_personality.cpp (original)
+++ libcxxabi/trunk/src/cxa_personality.cpp Fri Mar 16 19:10:52 2012
@@ -398,6 +398,41 @@
     return adjustedPtr;
 }
 
+namespace
+{
+
+struct scan_results
+{
+    int64_t        ttypeIndex;   // > 0 catch handler, < 0 exception spec handler, == 0 a cleanup
+    const uint8_t* actionRecord;         // Currently unused.  Retained to ease future maintenance.
+    const uint8_t* languageSpecificData;  // Needed only for __cxa_call_unexpected
+    uintptr_t      landingPad;   // null -> nothing found, else something found
+    void*          adjustedPtr;  // Used in cxa_exception.cpp
+    _Unwind_Reason_Code reason;  // One of _URC_FATAL_PHASE1_ERROR,
+                                 //        _URC_FATAL_PHASE2_ERROR,
+                                 //        _URC_CONTINUE_UNWIND,
+                                 //        _URC_HANDLER_FOUND
+};
+
+}  // unnamed namespace
+
+static
+void
+set_registers(_Unwind_Exception* unwind_exception, _Unwind_Context* context,
+              const scan_results& results)
+{
+#if __arm__
+    _Unwind_SetGR(context, 0, reinterpret_cast<uintptr_t>(unwind_exception));
+    _Unwind_SetGR(context, 1, static_cast<uintptr_t>(results.ttypeIndex));
+#else
+    _Unwind_SetGR(context, __builtin_eh_return_data_regno(0),
+                                 reinterpret_cast<uintptr_t>(unwind_exception));
+    _Unwind_SetGR(context, __builtin_eh_return_data_regno(1),
+                                    static_cast<uintptr_t>(results.ttypeIndex));
+#endif
+    _Unwind_SetIP(context, results.landingPad);
+}
+
 /*
     There are 3 types of scans needed:
 
@@ -419,24 +454,6 @@
         _UA_CLEANUP_PHASE && !_UA_HANDLER_FRAME
 */
 
-namespace
-{
-
-struct scan_results
-{
-    int64_t        ttypeIndex;   // > 0 catch handler, < 0 exception spec handler, == 0 a cleanup
-    const uint8_t* actionRecord;         // Currently unused.  Retained to ease future maintenance.
-    const uint8_t* languageSpecificData;  // Needed only for __cxa_call_unexpected
-    uintptr_t      landingPad;   // null -> nothing found, else something found
-    void*          adjustedPtr;  // Used in cxa_exception.cpp
-    _Unwind_Reason_Code reason;  // One of _URC_FATAL_PHASE1_ERROR,
-                                 //        _URC_FATAL_PHASE2_ERROR,
-                                 //        _URC_CONTINUE_UNWIND,
-                                 //        _URC_HANDLER_FOUND
-};
-
-}  // unnamed namespace
-
 static
 void
 scan_eh_tab(scan_results& results, _Unwind_Action actions, bool native_exception,
@@ -554,6 +571,7 @@
 #endif  // __arm__
         {
             // Found the call site containing ip.
+#if !__arm__
             if (landingPad == 0)
             {
                 // No handler here
@@ -561,6 +579,9 @@
                 return;
             }
             landingPad = (uintptr_t)lpStart + landingPad;
+#else  // __arm__
+            ++landingPad;
+#endif  // __arm__
             if (actionEntry == 0)
             {
                 // Found a cleanup
@@ -878,9 +899,7 @@
                     call_terminate(native_exception, unwind_exception);
             }
             // Jump to the handler
-            _Unwind_SetGR(context, __builtin_eh_return_data_regno(0), (uintptr_t)unwind_exception);
-            _Unwind_SetGR(context, __builtin_eh_return_data_regno(1), (uintptr_t)results.ttypeIndex);
-            _Unwind_SetIP(context, results.landingPad);
+            set_registers(unwind_exception, context, results);
             return _URC_INSTALL_CONTEXT;
         }
         // Either we didn't do a phase 1 search (due to forced unwinding), or
@@ -890,9 +909,7 @@
         if (results.reason == _URC_HANDLER_FOUND)
         {
             // Found a non-catching handler.  Jump to it:
-            _Unwind_SetGR(context, __builtin_eh_return_data_regno(0), (uintptr_t)unwind_exception);
-            _Unwind_SetGR(context, __builtin_eh_return_data_regno(1), (uintptr_t)results.ttypeIndex);
-            _Unwind_SetIP(context, results.landingPad);
+            set_registers(unwind_exception, context, results);
             return _URC_INSTALL_CONTEXT;
         }
         // Did not find a cleanup.  Return the results of the scan





More information about the cfe-commits mailing list