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 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/stringTable.hpp"
27 #include "classfile/systemDictionary.hpp"
28 #include "classfile/vmSymbols.hpp"
29 #include "code/codeCache.hpp"
30 #include "code/compiledIC.hpp"
31 #include "code/codeCacheExtensions.hpp"
32 #include "code/scopeDesc.hpp"
33 #include "code/vtableStubs.hpp"
34 #include "compiler/abstractCompiler.hpp"
35 #include "compiler/compileBroker.hpp"
36 #include "compiler/disassembler.hpp"
37 #include "gc/shared/gcLocker.inline.hpp"
38 #include "interpreter/interpreter.hpp"
39 #include "interpreter/interpreterRuntime.hpp"
40 #include "logging/log.hpp"
41 #include "memory/metaspaceShared.hpp"
42 #include "memory/resourceArea.hpp"
43 #include "memory/universe.inline.hpp"
44 #include "oops/klass.hpp"
45 #include "oops/objArrayKlass.hpp"
46 #include "oops/oop.inline.hpp"
47 #include "aot/aotLoader.hpp"
48 #include "prims/forte.hpp"
49 #include "prims/jvmtiExport.hpp"
50 #include "prims/methodHandles.hpp"
51 #include "prims/nativeLookup.hpp"
52 #include "runtime/arguments.hpp"
53 #include "runtime/atomic.hpp"
54 #include "runtime/biasedLocking.hpp"
55 #include "runtime/compilationPolicy.hpp"
56 #include "runtime/handles.inline.hpp"
57 #include "runtime/init.hpp"
58 #include "runtime/interfaceSupport.hpp"
59 #include "runtime/javaCalls.hpp"
60 #include "runtime/sharedRuntime.hpp"
61 #include "runtime/stubRoutines.hpp"
62 #include "runtime/vframe.hpp"
63 #include "runtime/vframeArray.hpp"
64 #include "trace/tracing.hpp"
65 #include "utilities/copy.hpp"
66 #include "utilities/dtrace.hpp"
67 #include "utilities/events.hpp"
489 // native nmethods don't have exception handlers
490 assert(!nm->is_native_method(), "no exception handler");
491 assert(nm->header_begin() != nm->exception_begin(), "no exception handler");
492 if (nm->is_deopt_pc(return_address)) {
493 // If we come here because of a stack overflow, the stack may be
494 // unguarded. Reguard the stack otherwise if we return to the
495 // deopt blob and the stack bang causes a stack overflow we
496 // crash.
497 bool guard_pages_enabled = thread->stack_guards_enabled();
498 if (!guard_pages_enabled) guard_pages_enabled = thread->reguard_stack();
499 if (thread->reserved_stack_activation() != thread->stack_base()) {
500 thread->set_reserved_stack_activation(thread->stack_base());
501 }
502 assert(guard_pages_enabled, "stack banging in deopt blob may cause crash");
503 return SharedRuntime::deopt_blob()->unpack_with_exception();
504 } else {
505 return nm->exception_begin();
506 }
507 }
508
509 // Entry code
510 if (StubRoutines::returns_to_call_stub(return_address)) {
511 return StubRoutines::catch_exception_entry();
512 }
513 // Interpreted code
514 if (Interpreter::contains(return_address)) {
515 return Interpreter::rethrow_exception_entry();
516 }
517
518 #if INCLUDE_AOT
519 // AOT Compiled code
520 if (UseAOT && AOTLoader::contains(return_address)) {
521 AOTCompiledMethod* aotm = AOTLoader::find_aot((address) return_address);
522 // Set flag if return address is a method handle call site.
523 thread->set_is_method_handle_return(aotm->is_method_handle_return(return_address));
524 return aotm->exception_begin();
525 }
526 #endif
527
528 guarantee(blob == NULL || !blob->is_runtime_stub(), "caller should have skipped stub");
529 guarantee(!VtableStubs::contains(return_address), "NULL exceptions in vtables should have been handled already!");
530
531 #ifndef PRODUCT
532 { ResourceMark rm;
533 tty->print_cr("No exception handler found for exception at " INTPTR_FORMAT " - potential problems:", p2i(return_address));
534 tty->print_cr("a) exception happened in (new?) code stubs/buffers that is not handled here");
535 tty->print_cr("b) other problem");
536 }
537 #endif // PRODUCT
538
539 ShouldNotReachHere();
540 return NULL;
541 }
542
543
544 JRT_LEAF(address, SharedRuntime::exception_handler_for_return_address(JavaThread* thread, address return_address))
545 return raw_exception_handler_for_return_address(thread, return_address);
546 JRT_END
|
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 *
23 */
24
25 #include "precompiled.hpp"
26 #include "aot/aotLoader.hpp"
27 #include "classfile/stringTable.hpp"
28 #include "classfile/systemDictionary.hpp"
29 #include "classfile/vmSymbols.hpp"
30 #include "code/codeCache.hpp"
31 #include "code/compiledIC.hpp"
32 #include "code/codeCacheExtensions.hpp"
33 #include "code/scopeDesc.hpp"
34 #include "code/vtableStubs.hpp"
35 #include "compiler/abstractCompiler.hpp"
36 #include "compiler/compileBroker.hpp"
37 #include "compiler/disassembler.hpp"
38 #include "gc/shared/gcLocker.inline.hpp"
39 #include "interpreter/interpreter.hpp"
40 #include "interpreter/interpreterRuntime.hpp"
41 #include "logging/log.hpp"
42 #include "memory/metaspaceShared.hpp"
43 #include "memory/resourceArea.hpp"
44 #include "memory/universe.inline.hpp"
45 #include "oops/klass.hpp"
46 #include "oops/objArrayKlass.hpp"
47 #include "oops/oop.inline.hpp"
48 #include "prims/forte.hpp"
49 #include "prims/jvmtiExport.hpp"
50 #include "prims/methodHandles.hpp"
51 #include "prims/nativeLookup.hpp"
52 #include "runtime/arguments.hpp"
53 #include "runtime/atomic.hpp"
54 #include "runtime/biasedLocking.hpp"
55 #include "runtime/compilationPolicy.hpp"
56 #include "runtime/handles.inline.hpp"
57 #include "runtime/init.hpp"
58 #include "runtime/interfaceSupport.hpp"
59 #include "runtime/javaCalls.hpp"
60 #include "runtime/sharedRuntime.hpp"
61 #include "runtime/stubRoutines.hpp"
62 #include "runtime/vframe.hpp"
63 #include "runtime/vframeArray.hpp"
64 #include "trace/tracing.hpp"
65 #include "utilities/copy.hpp"
66 #include "utilities/dtrace.hpp"
67 #include "utilities/events.hpp"
489 // native nmethods don't have exception handlers
490 assert(!nm->is_native_method(), "no exception handler");
491 assert(nm->header_begin() != nm->exception_begin(), "no exception handler");
492 if (nm->is_deopt_pc(return_address)) {
493 // If we come here because of a stack overflow, the stack may be
494 // unguarded. Reguard the stack otherwise if we return to the
495 // deopt blob and the stack bang causes a stack overflow we
496 // crash.
497 bool guard_pages_enabled = thread->stack_guards_enabled();
498 if (!guard_pages_enabled) guard_pages_enabled = thread->reguard_stack();
499 if (thread->reserved_stack_activation() != thread->stack_base()) {
500 thread->set_reserved_stack_activation(thread->stack_base());
501 }
502 assert(guard_pages_enabled, "stack banging in deopt blob may cause crash");
503 return SharedRuntime::deopt_blob()->unpack_with_exception();
504 } else {
505 return nm->exception_begin();
506 }
507 }
508
509 #if INCLUDE_AOT
510 if (UseAOT && blob->is_aot()) {
511 // AOT Compiled code
512 return AOTLoader::exception_begin(thread, blob, return_address);
513 }
514 #endif
515
516 // Entry code
517 if (StubRoutines::returns_to_call_stub(return_address)) {
518 return StubRoutines::catch_exception_entry();
519 }
520 // Interpreted code
521 if (Interpreter::contains(return_address)) {
522 return Interpreter::rethrow_exception_entry();
523 }
524
525 guarantee(blob == NULL || !blob->is_runtime_stub(), "caller should have skipped stub");
526 guarantee(!VtableStubs::contains(return_address), "NULL exceptions in vtables should have been handled already!");
527
528 #ifndef PRODUCT
529 { ResourceMark rm;
530 tty->print_cr("No exception handler found for exception at " INTPTR_FORMAT " - potential problems:", p2i(return_address));
531 tty->print_cr("a) exception happened in (new?) code stubs/buffers that is not handled here");
532 tty->print_cr("b) other problem");
533 }
534 #endif // PRODUCT
535
536 ShouldNotReachHere();
537 return NULL;
538 }
539
540
541 JRT_LEAF(address, SharedRuntime::exception_handler_for_return_address(JavaThread* thread, address return_address))
542 return raw_exception_handler_for_return_address(thread, return_address);
543 JRT_END
|