1 /*
2 * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2016, 2018 SAP SE. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
409 // SIGTRAP-based implicit null check in compiled code.
410 else if ((sig == SIGFPE) &&
411 TrapBasedNullChecks &&
412 (trap_pc != NULL) &&
413 Assembler::is_sigtrap_zero_check(trap_pc)) {
414 if (TraceTraps) {
415 tty->print_cr("trap: NULL_CHECK at " INTPTR_FORMAT " (SIGFPE)", p2i(trap_pc));
416 }
417 stub = SharedRuntime::continuation_for_implicit_exception(thread, trap_pc, SharedRuntime::IMPLICIT_NULL);
418 }
419
420 else if (sig == SIGSEGV && ImplicitNullChecks &&
421 CodeCache::contains((void*) pc) &&
422 MacroAssembler::uses_implicit_null_check(info->si_addr)) {
423 if (TraceTraps) {
424 tty->print_cr("trap: null_check at " INTPTR_FORMAT " (SIGSEGV)", p2i(pc));
425 }
426 stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL);
427 }
428
429 // SIGTRAP-based implicit range check in compiled code.
430 else if (sig == SIGFPE && TrapBasedRangeChecks &&
431 (trap_pc != NULL) &&
432 Assembler::is_sigtrap_range_check(trap_pc)) {
433 if (TraceTraps) {
434 tty->print_cr("trap: RANGE_CHECK at " INTPTR_FORMAT " (SIGFPE)", p2i(trap_pc));
435 }
436 stub = SharedRuntime::continuation_for_implicit_exception(thread, trap_pc, SharedRuntime::IMPLICIT_NULL);
437 }
438
439 else if (sig == SIGFPE && info->si_code == FPE_INTDIV) {
440 stub = SharedRuntime::continuation_for_implicit_exception(thread, trap_pc, SharedRuntime::IMPLICIT_DIVIDE_BY_ZERO);
441 }
442
443 else if (sig == SIGBUS) {
444 // BugId 4454115: A read from a MappedByteBuffer can fault here if the
445 // underlying file has been truncated. Do not crash the VM in such a case.
446 CodeBlob* cb = CodeCache::find_blob_unsafe(pc);
447 CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL;
448 if (nm != NULL && nm->has_unsafe_access()) {
449 // We don't really need a stub here! Just set the pending exeption and
450 // continue at the next instruction after the faulting read. Returning
451 // garbage from this read is ok.
452 thread->set_pending_unsafe_access_error();
453 uc->uc_mcontext.psw.addr = ((unsigned long)pc) + Assembler::instr_len(pc);
454 return true;
455 }
456 }
457 }
|
1 /*
2 * Copyright (c) 2016, 2019, Oracle and/or its affiliates. All rights reserved.
3 * Copyright (c) 2016, 2019 SAP SE. All rights reserved.
4 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
5 *
6 * This code is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License version 2 only, as
8 * published by the Free Software Foundation.
9 *
10 * This code is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
12 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
13 * version 2 for more details (a copy is included in the LICENSE file that
14 * accompanied this code).
15 *
16 * You should have received a copy of the GNU General Public License version
17 * 2 along with this work; if not, write to the Free Software Foundation,
18 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
19 *
20 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
21 * or visit www.oracle.com if you need additional information or have any
22 * questions.
23 *
409 // SIGTRAP-based implicit null check in compiled code.
410 else if ((sig == SIGFPE) &&
411 TrapBasedNullChecks &&
412 (trap_pc != NULL) &&
413 Assembler::is_sigtrap_zero_check(trap_pc)) {
414 if (TraceTraps) {
415 tty->print_cr("trap: NULL_CHECK at " INTPTR_FORMAT " (SIGFPE)", p2i(trap_pc));
416 }
417 stub = SharedRuntime::continuation_for_implicit_exception(thread, trap_pc, SharedRuntime::IMPLICIT_NULL);
418 }
419
420 else if (sig == SIGSEGV && ImplicitNullChecks &&
421 CodeCache::contains((void*) pc) &&
422 MacroAssembler::uses_implicit_null_check(info->si_addr)) {
423 if (TraceTraps) {
424 tty->print_cr("trap: null_check at " INTPTR_FORMAT " (SIGSEGV)", p2i(pc));
425 }
426 stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL);
427 }
428
429 #ifdef COMPILER2
430 // SIGTRAP-based implicit range check in compiled code.
431 else if (sig == SIGFPE && TrapBasedRangeChecks &&
432 (trap_pc != NULL) &&
433 Assembler::is_sigtrap_range_check(trap_pc)) {
434 if (TraceTraps) {
435 tty->print_cr("trap: RANGE_CHECK at " INTPTR_FORMAT " (SIGFPE)", p2i(trap_pc));
436 }
437 stub = SharedRuntime::continuation_for_implicit_exception(thread, trap_pc, SharedRuntime::IMPLICIT_NULL);
438 }
439 #endif
440
441 else if (sig == SIGFPE && info->si_code == FPE_INTDIV) {
442 stub = SharedRuntime::continuation_for_implicit_exception(thread, trap_pc, SharedRuntime::IMPLICIT_DIVIDE_BY_ZERO);
443 }
444
445 else if (sig == SIGBUS) {
446 // BugId 4454115: A read from a MappedByteBuffer can fault here if the
447 // underlying file has been truncated. Do not crash the VM in such a case.
448 CodeBlob* cb = CodeCache::find_blob_unsafe(pc);
449 CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL;
450 if (nm != NULL && nm->has_unsafe_access()) {
451 // We don't really need a stub here! Just set the pending exeption and
452 // continue at the next instruction after the faulting read. Returning
453 // garbage from this read is ok.
454 thread->set_pending_unsafe_access_error();
455 uc->uc_mcontext.psw.addr = ((unsigned long)pc) + Assembler::instr_len(pc);
456 return true;
457 }
458 }
459 }
|