1 /*
2 * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
530 // New exception handling mechanism can support inlined methods
531 // with exception handlers since the mappings are from PC to PC
532
533 // debugging support
534 // tracing
535 if (TraceExceptions) {
536 ttyLocker ttyl;
537 ResourceMark rm;
538 tty->print_cr("Exception <%s> (" INTPTR_FORMAT ") thrown in compiled method <%s> at PC " INTPTR_FORMAT " for thread " INTPTR_FORMAT "",
539 exception->print_value_string(), p2i((address)exception()), nm->method()->print_value_string(), p2i(pc), p2i(thread));
540 }
541 // for AbortVMOnException flag
542 NOT_PRODUCT(Exceptions::debug_check_abort(exception));
543
544 // Clear out the exception oop and pc since looking up an
545 // exception handler can cause class loading, which might throw an
546 // exception and those fields are expected to be clear during
547 // normal bytecode execution.
548 thread->clear_exception_oop_and_pc();
549
550 Handle original_exception(thread, exception());
551
552 continuation = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, false, false);
553 // If an exception was thrown during exception dispatch, the exception oop may have changed
554 thread->set_exception_oop(exception());
555 thread->set_exception_pc(pc);
556
557 // the exception cache is used only by non-implicit exceptions
558 // Update the exception cache only when there didn't happen
559 // another exception during the computation of the compiled
560 // exception handler.
561 if (continuation != NULL && original_exception() == exception()) {
562 nm->add_handler_for_exception_and_pc(exception, pc, continuation);
563 }
564 }
565
566 thread->set_vm_result(exception());
567 // Set flag if return address is a method handle call site.
568 thread->set_is_method_handle_return(nm->is_method_handle_return(pc));
569
570 if (TraceExceptions) {
571 ttyLocker ttyl;
572 ResourceMark rm;
573 tty->print_cr("Thread " PTR_FORMAT " continuing at PC " PTR_FORMAT " for exception thrown at PC " PTR_FORMAT,
574 p2i(thread), p2i(continuation), p2i(pc));
575 }
576
577 return continuation;
578 JRT_END
579
580 // Enter this method from compiled code only if there is a Java exception handler
581 // in the method handling the exception.
|
1 /*
2 * Copyright (c) 1999, 2018, Oracle and/or its affiliates. All rights reserved.
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4 *
5 * This code is free software; you can redistribute it and/or modify it
6 * under the terms of the GNU General Public License version 2 only, as
7 * published by the Free Software Foundation.
8 *
9 * This code is distributed in the hope that it will be useful, but WITHOUT
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
12 * version 2 for more details (a copy is included in the LICENSE file that
13 * accompanied this code).
14 *
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
530 // New exception handling mechanism can support inlined methods
531 // with exception handlers since the mappings are from PC to PC
532
533 // debugging support
534 // tracing
535 if (TraceExceptions) {
536 ttyLocker ttyl;
537 ResourceMark rm;
538 tty->print_cr("Exception <%s> (" INTPTR_FORMAT ") thrown in compiled method <%s> at PC " INTPTR_FORMAT " for thread " INTPTR_FORMAT "",
539 exception->print_value_string(), p2i((address)exception()), nm->method()->print_value_string(), p2i(pc), p2i(thread));
540 }
541 // for AbortVMOnException flag
542 NOT_PRODUCT(Exceptions::debug_check_abort(exception));
543
544 // Clear out the exception oop and pc since looking up an
545 // exception handler can cause class loading, which might throw an
546 // exception and those fields are expected to be clear during
547 // normal bytecode execution.
548 thread->clear_exception_oop_and_pc();
549
550 bool recursive_exception = false;
551 continuation = SharedRuntime::compute_compiled_exc_handler(nm, pc, exception, false, false, recursive_exception);
552 // If an exception was thrown during exception dispatch, the exception oop may have changed
553 thread->set_exception_oop(exception());
554 thread->set_exception_pc(pc);
555
556 // the exception cache is used only by non-implicit exceptions
557 // Update the exception cache only when there didn't happen
558 // another exception during the computation of the compiled
559 // exception handler. Checking for exception oop equality is not
560 // sufficient because some exceptions are pre-allocated and reused.
561 if (continuation != NULL && !recursive_exception) {
562 nm->add_handler_for_exception_and_pc(exception, pc, continuation);
563 }
564 }
565
566 thread->set_vm_result(exception());
567 // Set flag if return address is a method handle call site.
568 thread->set_is_method_handle_return(nm->is_method_handle_return(pc));
569
570 if (TraceExceptions) {
571 ttyLocker ttyl;
572 ResourceMark rm;
573 tty->print_cr("Thread " PTR_FORMAT " continuing at PC " PTR_FORMAT " for exception thrown at PC " PTR_FORMAT,
574 p2i(thread), p2i(continuation), p2i(pc));
575 }
576
577 return continuation;
578 JRT_END
579
580 // Enter this method from compiled code only if there is a Java exception handler
581 // in the method handling the exception.
|