+ // Search the call-site table for the action associated with this IP.
+ while (p < info.action_table)
+ {
+ _Unwind_Ptr cs_start, cs_len, cs_lp;
+ _Unwind_Word cs_action;
+
+ // Note that all call-site encodings are "absolute" displacements.
+ p = read_encoded_value (0, info.call_site_encoding, p, &cs_start);
+ p = read_encoded_value (0, info.call_site_encoding, p, &cs_len);
+ p = read_encoded_value (0, info.call_site_encoding, p, &cs_lp);
+ p = read_uleb128 (p, &cs_action);
+
+ // The table is sorted, so if we've passed the ip, stop.
+ if (ip < info.Start + cs_start)
+ p = info.action_table;
+ else if (ip < info.Start + cs_start + cs_len)
+ {
+ if (cs_lp)
+ landing_pad = info.LPStart + cs_lp;
+ if (cs_action)
+ action_record = info.action_table + cs_action - 1;
+ goto found_something;
+ }
+ }
+#endif // SJLJ_EXCEPTIONS
+
+ // 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;
+
+ found_something:
+ saw_cleanup = false;
+ saw_handler = false;
+
+ if (landing_pad == 0)
+ {
+ // If ip is present, and has a null landing pad, there are
+ // no cleanups or handlers to be run.
+ }
+ else if (action_record == 0)
+ {
+ // If ip is present, has a non-null landing pad, and a null
+ // action table offset, then there are only cleanups present.
+ // Cleanups use a zero switch value, as set above.
+ saw_cleanup = true;
+ }
+ else
+ {
+ // Otherwise we have a catch handler.
+ _Unwind_Sword ar_filter, ar_disp;
+
+ while (1)
+ {
+ p = action_record;
+ p = read_sleb128 (p, &ar_filter);
+ read_sleb128 (p, &ar_disp);
+
+ if (ar_filter == 0)
+ {
+ // Zero filter values are cleanups.
+ saw_cleanup = true;
+ }
+
+ // 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)
+ ;
+
+ else if (ar_filter > 0)
+ {
+ // Positive filter values are handlers.
+
+ jclass catch_type = get_ttype_entry (context, &info, ar_filter);
+
+ // The catch_type is either a (java::lang::Class*) or
+ // is one more than a (Utf8Const*).
+ if ((size_t)catch_type & 1)
+ catch_type = _Jv_FindClass ((Utf8Const*)catch_type - 1, NULL);
+
+ if (_Jv_IsInstanceOf (xh->value, catch_type))
+ {
+ handler_switch_value = ar_filter;
+ saw_handler = true;
+ break;
+ }
+ }
+ else
+ {
+ // Negative filter values are exception specifications,
+ // which Java does not use.
+ // ??? Perhaps better to make them an index into a table
+ // of null-terminated strings instead of playing games
+ // with Utf8Const+1 as above.
+ abort ();
+ }
+
+ if (ar_disp == 0)
+ break;
+ action_record = p + ar_disp;
+ }
+ }
+
+ if (! saw_handler && ! saw_cleanup)
+ return _URC_CONTINUE_UNWIND;
+
+ if (actions & _UA_SEARCH_PHASE)
+ {
+ if (! saw_handler)
+ return _URC_CONTINUE_UNWIND;
+
+ // For domestic exceptions, we cache data from phase 1 for phase 2.
+ if (exception_class == __gcj_exception_class)
+ {
+ xh->handlerSwitchValue = handler_switch_value;
+ xh->landingPad = landing_pad;
+ }
+ return _URC_HANDLER_FOUND;
+ }
+
+ install_context:
+ _Unwind_SetGR (context, __builtin_eh_return_data_regno (0),
+ (_Unwind_Ptr) &xh->unwindHeader);
+ _Unwind_SetGR (context, __builtin_eh_return_data_regno (1),
+ handler_switch_value);
+ _Unwind_SetIP (context, landing_pad);
+ return _URC_INSTALL_CONTEXT;