--- old/src/hotspot/share/c1/c1_Compilation.cpp 2017-10-02 11:11:42.623792151 +0200 +++ new/src/hotspot/share/c1/c1_Compilation.cpp 2017-10-02 11:11:41.655792933 +0200 @@ -500,11 +500,13 @@ scope_depths->trunc_to(0); pcos->trunc_to(0); + DEBUG_ONLY(int prev_scope = 0); for (int i = 0; i < handlers->length(); i++) { XHandler* handler = handlers->handler_at(i); assert(handler->entry_pco() != -1, "must have been generated"); + assert(handler->scope_count() >= prev_scope, "handlers should be sorted by scope"); - int e = bcis->find(handler->handler_bci()); + int e = bcis->find_from_end(handler->handler_bci()); if (e >= 0 && scope_depths->at(e) == handler->scope_count()) { // two different handlers are declared to dispatch to the same // catch bci. During parsing we created edges for each @@ -521,13 +523,14 @@ scope_depths->append(0); } else { scope_depths->append(handler->scope_count()); - } + } pcos->append(handler->entry_pco()); // stop processing once we hit a catch any if (handler->is_catch_all()) { assert(i == handlers->length() - 1, "catch all must be last handler"); - } + } + DEBUG_ONLY(prev_scope = handler->scope_count()); } exception_handler_table()->add_subtable(info->pco(), bcis, scope_depths, pcos); }