340 //%note os_trap_1
341 if (info != NULL && uc != NULL && thread != NULL) {
342 pc = (address) os::Linux::ucontext_get_pc(uc);
343
344 #ifdef BUILTIN_SIM
345 if (pc == (address) Fetch32PFI) {
346 uc->uc_mcontext.gregs[REG_PC] = intptr_t(Fetch32Resume) ;
347 return 1 ;
348 }
349 if (pc == (address) FetchNPFI) {
350 uc->uc_mcontext.gregs[REG_PC] = intptr_t (FetchNResume) ;
351 return 1 ;
352 }
353 #else
354 if (StubRoutines::is_safefetch_fault(pc)) {
355 os::Linux::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
356 return 1;
357 }
358 #endif
359
360 // Handle ALL stack overflow variations here
361 if (sig == SIGSEGV) {
362 address addr = (address) info->si_addr;
363
364 // check if fault address is within thread stack
365 if (thread->on_local_stack(addr)) {
366 // stack overflow
367 if (thread->in_stack_yellow_reserved_zone(addr)) {
368 thread->disable_stack_yellow_reserved_zone();
369 if (thread->thread_state() == _thread_in_Java) {
370 if (thread->in_stack_reserved_zone(addr)) {
371 frame fr;
372 if (os::Linux::get_frame_at_stack_banging_point(thread, uc, &fr)) {
373 assert(fr.is_java_frame(), "Must be a Java frame");
374 frame activation =
375 SharedRuntime::look_for_reserved_stack_annotated_method(thread, fr);
376 if (activation.sp() != NULL) {
377 thread->disable_stack_reserved_zone();
378 if (activation.is_interpreted_frame()) {
379 thread->set_reserved_stack_activation((address)(
380 activation.fp() + frame::interpreter_frame_initial_sp_offset));
381 } else {
382 thread->set_reserved_stack_activation((address)activation.unextended_sp());
383 }
439 // here if the underlying file has been truncated.
440 // Do not crash the VM in such a case.
441 CodeBlob* cb = CodeCache::find_blob_unsafe(pc);
442 CompiledMethod* nm = (cb != NULL) ? cb->as_compiled_method_or_null() : NULL;
443 if (nm != NULL && nm->has_unsafe_access()) {
444 address next_pc = pc + NativeCall::instruction_size;
445 stub = SharedRuntime::handle_unsafe_access(thread, next_pc);
446 }
447 }
448 else
449
450 if (sig == SIGFPE &&
451 (info->si_code == FPE_INTDIV || info->si_code == FPE_FLTDIV)) {
452 stub =
453 SharedRuntime::
454 continuation_for_implicit_exception(thread,
455 pc,
456 SharedRuntime::
457 IMPLICIT_DIVIDE_BY_ZERO);
458 } else if (sig == SIGSEGV &&
459 !MacroAssembler::needs_explicit_null_check((intptr_t)info->si_addr)) {
460 // Determination of interpreter/vtable stub/compiled code null exception
461 stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL);
462 }
463 } else if (thread->thread_state() == _thread_in_vm &&
464 sig == SIGBUS && /* info->si_code == BUS_OBJERR && */
465 thread->doing_unsafe_access()) {
466 address next_pc = pc + NativeCall::instruction_size;
467 stub = SharedRuntime::handle_unsafe_access(thread, next_pc);
468 }
469
470 // jni_fast_Get<Primitive>Field can trap at certain pc's if a GC kicks in
471 // and the heap gets shrunk before the field access.
472 if ((sig == SIGSEGV) || (sig == SIGBUS)) {
473 address addr = JNI_FastGetField::find_slowcase_pc(pc);
474 if (addr != (address)-1) {
475 stub = addr;
476 }
477 }
478
479 // Check to see if we caught the safepoint code in the
|
340 //%note os_trap_1
341 if (info != NULL && uc != NULL && thread != NULL) {
342 pc = (address) os::Linux::ucontext_get_pc(uc);
343
344 #ifdef BUILTIN_SIM
345 if (pc == (address) Fetch32PFI) {
346 uc->uc_mcontext.gregs[REG_PC] = intptr_t(Fetch32Resume) ;
347 return 1 ;
348 }
349 if (pc == (address) FetchNPFI) {
350 uc->uc_mcontext.gregs[REG_PC] = intptr_t (FetchNResume) ;
351 return 1 ;
352 }
353 #else
354 if (StubRoutines::is_safefetch_fault(pc)) {
355 os::Linux::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc));
356 return 1;
357 }
358 #endif
359
360 address addr = (address) info->si_addr;
361
362 // Make sure the high order byte is sign extended, as it may be masked away by the hardware.
363 if ((uintptr_t(addr) & (uintptr_t(1) << 55)) != 0) {
364 addr = address(uintptr_t(addr) | (uintptr_t(0xFF) << 56));
365 }
366
367 // Handle ALL stack overflow variations here
368 if (sig == SIGSEGV) {
369 // check if fault address is within thread stack
370 if (thread->on_local_stack(addr)) {
371 // stack overflow
372 if (thread->in_stack_yellow_reserved_zone(addr)) {
373 thread->disable_stack_yellow_reserved_zone();
374 if (thread->thread_state() == _thread_in_Java) {
375 if (thread->in_stack_reserved_zone(addr)) {
376 frame fr;
377 if (os::Linux::get_frame_at_stack_banging_point(thread, uc, &fr)) {
378 assert(fr.is_java_frame(), "Must be a Java frame");
379 frame activation =
380 SharedRuntime::look_for_reserved_stack_annotated_method(thread, fr);
381 if (activation.sp() != NULL) {
382 thread->disable_stack_reserved_zone();
383 if (activation.is_interpreted_frame()) {
384 thread->set_reserved_stack_activation((address)(
385 activation.fp() + frame::interpreter_frame_initial_sp_offset));
386 } else {
387 thread->set_reserved_stack_activation((address)activation.unextended_sp());
388 }
444 // here if the underlying file has been truncated.
445 // 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 address next_pc = pc + NativeCall::instruction_size;
450 stub = SharedRuntime::handle_unsafe_access(thread, next_pc);
451 }
452 }
453 else
454
455 if (sig == SIGFPE &&
456 (info->si_code == FPE_INTDIV || info->si_code == FPE_FLTDIV)) {
457 stub =
458 SharedRuntime::
459 continuation_for_implicit_exception(thread,
460 pc,
461 SharedRuntime::
462 IMPLICIT_DIVIDE_BY_ZERO);
463 } else if (sig == SIGSEGV &&
464 MacroAssembler::uses_implicit_null_check((void*)addr)) {
465 // Determination of interpreter/vtable stub/compiled code null exception
466 stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL);
467 }
468 } else if (thread->thread_state() == _thread_in_vm &&
469 sig == SIGBUS && /* info->si_code == BUS_OBJERR && */
470 thread->doing_unsafe_access()) {
471 address next_pc = pc + NativeCall::instruction_size;
472 stub = SharedRuntime::handle_unsafe_access(thread, next_pc);
473 }
474
475 // jni_fast_Get<Primitive>Field can trap at certain pc's if a GC kicks in
476 // and the heap gets shrunk before the field access.
477 if ((sig == SIGSEGV) || (sig == SIGBUS)) {
478 address addr = JNI_FastGetField::find_slowcase_pc(pc);
479 if (addr != (address)-1) {
480 stub = addr;
481 }
482 }
483
484 // Check to see if we caught the safepoint code in the
|