+ MonoMethodHeader *header = cfg->header;
+ MonoExceptionClause *clause, *clause2;
+ int i, j;
+ gboolean *outer_try;
+
+ /*
+ * Determine which clauses are outer try clauses, i.e. they are not contained in any
+ * other non-try clause.
+ */
+ outer_try = mono_mempool_alloc0 (cfg->mempool, sizeof (gboolean) * header->num_clauses);
+ for (i = 0; i < header->num_clauses; ++i)
+ outer_try [i] = TRUE;
+ /* Iterate over the clauses backward, so outer clauses come first */
+ /* This avoids doing an O(2) search, since we can determine when inner clauses end */
+ for (i = header->num_clauses - 1; i >= 0; --i) {
+ clause = &header->clauses [i];
+
+ if (clause->flags != 0) {
+ outer_try [i] = TRUE;
+ /* Iterate over inner clauses */
+ for (j = i - 1; j >= 0; --j) {
+ clause2 = &header->clauses [j];
+
+ if (clause2->flags == 0 && MONO_OFFSET_IN_HANDLER (clause, clause2->try_offset)) {
+ outer_try [j] = FALSE;
+ break;
+ }
+ if (clause2->try_offset < clause->try_offset)
+ /* End of inner clauses */
+ break;
+ }
+ }
+ }