aoqi@0: /* aoqi@0: * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. aoqi@0: * Copyright 2012, 2014 SAP AG. All rights reserved. aoqi@0: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. aoqi@0: * aoqi@0: * This code is free software; you can redistribute it and/or modify it aoqi@0: * under the terms of the GNU General Public License version 2 only, as aoqi@0: * published by the Free Software Foundation. aoqi@0: * aoqi@0: * This code is distributed in the hope that it will be useful, but WITHOUT aoqi@0: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or aoqi@0: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License aoqi@0: * version 2 for more details (a copy is included in the LICENSE file that aoqi@0: * accompanied this code). aoqi@0: * aoqi@0: * You should have received a copy of the GNU General Public License version aoqi@0: * 2 along with this work; if not, write to the Free Software Foundation, aoqi@0: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. aoqi@0: * aoqi@0: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA aoqi@0: * or visit www.oracle.com if you need additional information or have any aoqi@0: * questions. aoqi@0: * aoqi@0: */ aoqi@0: aoqi@0: // no precompiled headers aoqi@0: #include "assembler_ppc.inline.hpp" aoqi@0: #include "classfile/classLoader.hpp" aoqi@0: #include "classfile/systemDictionary.hpp" aoqi@0: #include "classfile/vmSymbols.hpp" aoqi@0: #include "code/icBuffer.hpp" aoqi@0: #include "code/vtableStubs.hpp" aoqi@0: #include "interpreter/interpreter.hpp" aoqi@0: #include "jvm_aix.h" aoqi@0: #include "memory/allocation.inline.hpp" aoqi@0: #include "mutex_aix.inline.hpp" aoqi@0: #include "nativeInst_ppc.hpp" aoqi@0: #include "os_share_aix.hpp" aoqi@0: #include "prims/jniFastGetField.hpp" aoqi@0: #include "prims/jvm.h" aoqi@0: #include "prims/jvm_misc.hpp" aoqi@0: #include "runtime/arguments.hpp" aoqi@0: #include "runtime/extendedPC.hpp" aoqi@0: #include "runtime/frame.inline.hpp" aoqi@0: #include "runtime/interfaceSupport.hpp" aoqi@0: #include "runtime/java.hpp" aoqi@0: #include "runtime/javaCalls.hpp" aoqi@0: #include "runtime/mutexLocker.hpp" aoqi@0: #include "runtime/osThread.hpp" aoqi@0: #include "runtime/sharedRuntime.hpp" aoqi@0: #include "runtime/stubRoutines.hpp" aoqi@0: #include "runtime/thread.inline.hpp" aoqi@0: #include "runtime/timer.hpp" aoqi@0: #include "utilities/events.hpp" aoqi@0: #include "utilities/vmError.hpp" aoqi@0: #ifdef COMPILER1 aoqi@0: #include "c1/c1_Runtime1.hpp" aoqi@0: #endif aoqi@0: #ifdef COMPILER2 aoqi@0: #include "opto/runtime.hpp" aoqi@0: #endif aoqi@0: aoqi@0: // put OS-includes here aoqi@0: # include aoqi@0: aoqi@0: address os::current_stack_pointer() { aoqi@0: address csp; aoqi@0: aoqi@0: #if !defined(USE_XLC_BUILTINS) aoqi@0: // inline assembly for `mr regno(csp), R1_SP': aoqi@0: __asm__ __volatile__ ("mr %0, 1":"=r"(csp):); aoqi@0: #else aoqi@0: csp = (address) __builtin_frame_address(0); aoqi@0: #endif aoqi@0: aoqi@0: return csp; aoqi@0: } aoqi@0: aoqi@0: char* os::non_memory_address_word() { aoqi@0: // Must never look like an address returned by reserve_memory, aoqi@0: // even in its subfields (as defined by the CPU immediate fields, aoqi@0: // if the CPU splits constants across multiple instructions). aoqi@0: aoqi@0: return (char*) -1; aoqi@0: } aoqi@0: aoqi@0: // OS specific thread initialization aoqi@0: // aoqi@0: // Calculate and store the limits of the memory stack. aoqi@0: void os::initialize_thread(Thread *thread) { } aoqi@0: aoqi@0: // Frame information (pc, sp, fp) retrieved via ucontext aoqi@0: // always looks like a C-frame according to the frame aoqi@0: // conventions in frame_ppc64.hpp. aoqi@0: address os::Aix::ucontext_get_pc(ucontext_t * uc) { aoqi@0: return (address)uc->uc_mcontext.jmp_context.iar; aoqi@0: } aoqi@0: aoqi@0: intptr_t* os::Aix::ucontext_get_sp(ucontext_t * uc) { aoqi@0: // gpr1 holds the stack pointer on aix aoqi@0: return (intptr_t*)uc->uc_mcontext.jmp_context.gpr[1/*REG_SP*/]; aoqi@0: } aoqi@0: aoqi@0: intptr_t* os::Aix::ucontext_get_fp(ucontext_t * uc) { aoqi@0: return NULL; aoqi@0: } aoqi@0: aoqi@0: void os::Aix::ucontext_set_pc(ucontext_t* uc, address new_pc) { aoqi@0: uc->uc_mcontext.jmp_context.iar = (uint64_t) new_pc; aoqi@0: } aoqi@0: aoqi@0: ExtendedPC os::fetch_frame_from_context(void* ucVoid, aoqi@0: intptr_t** ret_sp, intptr_t** ret_fp) { aoqi@0: aoqi@0: ExtendedPC epc; aoqi@0: ucontext_t* uc = (ucontext_t*)ucVoid; aoqi@0: aoqi@0: if (uc != NULL) { aoqi@0: epc = ExtendedPC(os::Aix::ucontext_get_pc(uc)); aoqi@0: if (ret_sp) *ret_sp = os::Aix::ucontext_get_sp(uc); aoqi@0: if (ret_fp) *ret_fp = os::Aix::ucontext_get_fp(uc); aoqi@0: } else { aoqi@0: // construct empty ExtendedPC for return value checking aoqi@0: epc = ExtendedPC(NULL); aoqi@0: if (ret_sp) *ret_sp = (intptr_t *)NULL; aoqi@0: if (ret_fp) *ret_fp = (intptr_t *)NULL; aoqi@0: } aoqi@0: aoqi@0: return epc; aoqi@0: } aoqi@0: aoqi@0: frame os::fetch_frame_from_context(void* ucVoid) { aoqi@0: intptr_t* sp; aoqi@0: intptr_t* fp; aoqi@0: ExtendedPC epc = fetch_frame_from_context(ucVoid, &sp, &fp); aoqi@0: // Avoid crash during crash if pc broken. aoqi@0: if (epc.pc()) { aoqi@0: frame fr(sp, epc.pc()); aoqi@0: return fr; aoqi@0: } aoqi@0: frame fr(sp); aoqi@0: return fr; aoqi@0: } aoqi@0: aoqi@0: frame os::get_sender_for_C_frame(frame* fr) { aoqi@0: if (*fr->sp() == NULL) { aoqi@0: // fr is the last C frame aoqi@0: return frame(NULL, NULL); aoqi@0: } aoqi@0: return frame(fr->sender_sp(), fr->sender_pc()); aoqi@0: } aoqi@0: aoqi@0: aoqi@0: frame os::current_frame() { aoqi@0: intptr_t* csp = (intptr_t*) *((intptr_t*) os::current_stack_pointer()); aoqi@0: // hack. aoqi@0: frame topframe(csp, (address)0x8); aoqi@0: // return sender of current topframe which hopefully has pc != NULL. aoqi@0: return os::get_sender_for_C_frame(&topframe); aoqi@0: } aoqi@0: aoqi@0: // Utility functions aoqi@0: aoqi@0: extern "C" JNIEXPORT int aoqi@0: JVM_handle_aix_signal(int sig, siginfo_t* info, void* ucVoid, int abort_if_unrecognized) { aoqi@0: aoqi@0: ucontext_t* uc = (ucontext_t*) ucVoid; aoqi@0: aoqi@0: Thread* t = ThreadLocalStorage::get_thread_slow(); // slow & steady aoqi@0: aoqi@0: SignalHandlerMark shm(t); aoqi@0: aoqi@0: // Note: it's not uncommon that JNI code uses signal/sigset to install aoqi@0: // then restore certain signal handler (e.g. to temporarily block SIGPIPE, aoqi@0: // or have a SIGILL handler when detecting CPU type). When that happens, aoqi@0: // JVM_handle_aix_signal() might be invoked with junk info/ucVoid. To aoqi@0: // avoid unnecessary crash when libjsig is not preloaded, try handle signals aoqi@0: // that do not require siginfo/ucontext first. aoqi@0: aoqi@0: if (sig == SIGPIPE) { aoqi@0: if (os::Aix::chained_handler(sig, info, ucVoid)) { aoqi@0: return 1; aoqi@0: } else { aoqi@0: if (PrintMiscellaneous && (WizardMode || Verbose)) { aoqi@0: warning("Ignoring SIGPIPE - see bug 4229104"); aoqi@0: } aoqi@0: return 1; aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: JavaThread* thread = NULL; aoqi@0: VMThread* vmthread = NULL; aoqi@0: if (os::Aix::signal_handlers_are_installed) { aoqi@0: if (t != NULL) { aoqi@0: if(t->is_Java_thread()) { aoqi@0: thread = (JavaThread*)t; aoqi@0: } aoqi@0: else if(t->is_VM_thread()) { aoqi@0: vmthread = (VMThread *)t; aoqi@0: } aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: // Decide if this trap can be handled by a stub. aoqi@0: address stub = NULL; aoqi@0: aoqi@0: // retrieve program counter aoqi@0: address const pc = uc ? os::Aix::ucontext_get_pc(uc) : NULL; aoqi@0: aoqi@0: // retrieve crash address aoqi@0: address const addr = info ? (const address) info->si_addr : NULL; aoqi@0: aoqi@0: // SafeFetch 32 handling: aoqi@0: // - make it work if _thread is null aoqi@0: // - make it use the standard os::...::ucontext_get/set_pc APIs aoqi@0: if (uc) { aoqi@0: address const pc = os::Aix::ucontext_get_pc(uc); aoqi@0: if (pc && StubRoutines::is_safefetch_fault(pc)) { aoqi@0: os::Aix::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc)); aoqi@0: return true; aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: // Handle SIGDANGER right away. AIX would raise SIGDANGER whenever available swap aoqi@0: // space falls below 30%. This is only a chance for the process to gracefully abort. aoqi@0: // We can't hope to proceed after SIGDANGER since SIGKILL tailgates. aoqi@0: if (sig == SIGDANGER) { aoqi@0: goto report_and_die; aoqi@0: } aoqi@0: aoqi@0: if (info == NULL || uc == NULL || thread == NULL && vmthread == NULL) { aoqi@0: goto run_chained_handler; aoqi@0: } aoqi@0: aoqi@0: // If we are a java thread... aoqi@0: if (thread != NULL) { aoqi@0: aoqi@0: // Handle ALL stack overflow variations here aoqi@0: if (sig == SIGSEGV && (addr < thread->stack_base() && aoqi@0: addr >= thread->stack_base() - thread->stack_size())) { aoqi@0: // stack overflow aoqi@0: // aoqi@0: // If we are in a yellow zone and we are inside java, we disable the yellow zone and aoqi@0: // throw a stack overflow exception. aoqi@0: // If we are in native code or VM C code, we report-and-die. The original coding tried aoqi@0: // to continue with yellow zone disabled, but that doesn't buy us much and prevents aoqi@0: // hs_err_pid files. aoqi@0: if (thread->in_stack_yellow_zone(addr)) { aoqi@0: thread->disable_stack_yellow_zone(); aoqi@0: if (thread->thread_state() == _thread_in_Java) { aoqi@0: // Throw a stack overflow exception. aoqi@0: // Guard pages will be reenabled while unwinding the stack. aoqi@0: stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::STACK_OVERFLOW); aoqi@0: goto run_stub; aoqi@0: } else { aoqi@0: // Thread was in the vm or native code. Return and try to finish. aoqi@0: return 1; aoqi@0: } aoqi@0: } else if (thread->in_stack_red_zone(addr)) { aoqi@0: // Fatal red zone violation. Disable the guard pages and fall through aoqi@0: // to handle_unexpected_exception way down below. aoqi@0: thread->disable_stack_red_zone(); aoqi@0: tty->print_raw_cr("An irrecoverable stack overflow has occurred."); aoqi@0: goto report_and_die; aoqi@0: } else { aoqi@0: // This means a segv happened inside our stack, but not in aoqi@0: // the guarded zone. I'd like to know when this happens, aoqi@0: tty->print_raw_cr("SIGSEGV happened inside stack but outside yellow and red zone."); aoqi@0: goto report_and_die; aoqi@0: } aoqi@0: aoqi@0: } // end handle SIGSEGV inside stack boundaries aoqi@0: aoqi@0: if (thread->thread_state() == _thread_in_Java) { aoqi@0: // Java thread running in Java code aoqi@0: aoqi@0: // The following signals are used for communicating VM events: aoqi@0: // aoqi@0: // SIGILL: the compiler generates illegal opcodes aoqi@0: // at places where it wishes to interrupt the VM: aoqi@0: // Safepoints, Unreachable Code, Entry points of Zombie methods, aoqi@0: // This results in a SIGILL with (*pc) == inserted illegal instruction. aoqi@0: // aoqi@0: // (so, SIGILLs with a pc inside the zero page are real errors) aoqi@0: // aoqi@0: // SIGTRAP: aoqi@0: // The ppc trap instruction raises a SIGTRAP and is very efficient if it aoqi@0: // does not trap. It is used for conditional branches that are expected aoqi@0: // to be never taken. These are: aoqi@0: // - zombie methods aoqi@0: // - IC (inline cache) misses. aoqi@0: // - null checks leading to UncommonTraps. aoqi@0: // - range checks leading to Uncommon Traps. aoqi@0: // On Aix, these are especially null checks, as the ImplicitNullCheck aoqi@0: // optimization works only in rare cases, as the page at address 0 is only aoqi@0: // write protected. // aoqi@0: // Note: !UseSIGTRAP is used to prevent SIGTRAPS altogether, to facilitate debugging. aoqi@0: // aoqi@0: // SIGSEGV: aoqi@0: // used for safe point polling: aoqi@0: // To notify all threads that they have to reach a safe point, safe point polling is used: aoqi@0: // All threads poll a certain mapped memory page. Normally, this page has read access. aoqi@0: // If the VM wants to inform the threads about impending safe points, it puts this aoqi@0: // page to read only ("poisens" the page), and the threads then reach a safe point. aoqi@0: // used for null checks: aoqi@0: // If the compiler finds a store it uses it for a null check. Unfortunately this aoqi@0: // happens rarely. In heap based and disjoint base compressd oop modes also loads aoqi@0: // are used for null checks. aoqi@0: aoqi@0: // A VM-related SIGILL may only occur if we are not in the zero page. aoqi@0: // On AIX, we get a SIGILL if we jump to 0x0 or to somewhere else aoqi@0: // in the zero page, because it is filled with 0x0. We ignore aoqi@0: // explicit SIGILLs in the zero page. aoqi@0: if (sig == SIGILL && (pc < (address) 0x200)) { aoqi@0: if (TraceTraps) { aoqi@0: tty->print_raw_cr("SIGILL happened inside zero page."); aoqi@0: } aoqi@0: goto report_and_die; aoqi@0: } aoqi@0: aoqi@0: // Handle signal from NativeJump::patch_verified_entry(). aoqi@0: if (( TrapBasedNotEntrantChecks && sig == SIGTRAP && nativeInstruction_at(pc)->is_sigtrap_zombie_not_entrant()) || aoqi@0: (!TrapBasedNotEntrantChecks && sig == SIGILL && nativeInstruction_at(pc)->is_sigill_zombie_not_entrant())) { aoqi@0: if (TraceTraps) { aoqi@0: tty->print_cr("trap: zombie_not_entrant (%s)", (sig == SIGTRAP) ? "SIGTRAP" : "SIGILL"); aoqi@0: } aoqi@0: stub = SharedRuntime::get_handle_wrong_method_stub(); aoqi@0: goto run_stub; aoqi@0: } aoqi@0: aoqi@0: else if (sig == SIGSEGV && os::is_poll_address(addr)) { aoqi@0: if (TraceTraps) { aoqi@0: tty->print_cr("trap: safepoint_poll at " INTPTR_FORMAT " (SIGSEGV)", pc); aoqi@0: } aoqi@0: stub = SharedRuntime::get_poll_stub(pc); aoqi@0: goto run_stub; aoqi@0: } aoqi@0: aoqi@0: // SIGTRAP-based ic miss check in compiled code. aoqi@0: else if (sig == SIGTRAP && TrapBasedICMissChecks && aoqi@0: nativeInstruction_at(pc)->is_sigtrap_ic_miss_check()) { aoqi@0: if (TraceTraps) { aoqi@0: tty->print_cr("trap: ic_miss_check at " INTPTR_FORMAT " (SIGTRAP)", pc); aoqi@0: } aoqi@0: stub = SharedRuntime::get_ic_miss_stub(); aoqi@0: goto run_stub; aoqi@0: } aoqi@0: aoqi@0: // SIGTRAP-based implicit null check in compiled code. aoqi@0: else if (sig == SIGTRAP && TrapBasedNullChecks && aoqi@0: nativeInstruction_at(pc)->is_sigtrap_null_check()) { aoqi@0: if (TraceTraps) { aoqi@0: tty->print_cr("trap: null_check at " INTPTR_FORMAT " (SIGTRAP)", pc); aoqi@0: } aoqi@0: stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL); aoqi@0: goto run_stub; aoqi@0: } aoqi@0: aoqi@0: // SIGSEGV-based implicit null check in compiled code. aoqi@0: else if (sig == SIGSEGV && ImplicitNullChecks && aoqi@0: CodeCache::contains((void*) pc) && aoqi@0: !MacroAssembler::needs_explicit_null_check((intptr_t) info->si_addr)) { aoqi@0: if (TraceTraps) { aoqi@0: tty->print_cr("trap: null_check at " INTPTR_FORMAT " (SIGSEGV)", pc); aoqi@0: } aoqi@0: stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL); aoqi@0: } aoqi@0: aoqi@0: #ifdef COMPILER2 aoqi@0: // SIGTRAP-based implicit range check in compiled code. aoqi@0: else if (sig == SIGTRAP && TrapBasedRangeChecks && aoqi@0: nativeInstruction_at(pc)->is_sigtrap_range_check()) { aoqi@0: if (TraceTraps) { aoqi@0: tty->print_cr("trap: range_check at " INTPTR_FORMAT " (SIGTRAP)", pc); aoqi@0: } aoqi@0: stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL); aoqi@0: goto run_stub; aoqi@0: } aoqi@0: #endif aoqi@0: aoqi@0: else if (sig == SIGFPE /* && info->si_code == FPE_INTDIV */) { aoqi@0: if (TraceTraps) { aoqi@0: tty->print_raw_cr("Fix SIGFPE handler, trying divide by zero handler."); aoqi@0: } aoqi@0: stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_DIVIDE_BY_ZERO); aoqi@0: goto run_stub; aoqi@0: } aoqi@0: aoqi@0: else if (sig == SIGBUS) { aoqi@0: // BugId 4454115: A read from a MappedByteBuffer can fault here if the aoqi@0: // underlying file has been truncated. Do not crash the VM in such a case. aoqi@0: CodeBlob* cb = CodeCache::find_blob_unsafe(pc); aoqi@0: nmethod* nm = cb->is_nmethod() ? (nmethod*)cb : NULL; aoqi@0: if (nm != NULL && nm->has_unsafe_access()) { aoqi@0: // We don't really need a stub here! Just set the pending exeption and aoqi@0: // continue at the next instruction after the faulting read. Returning aoqi@0: // garbage from this read is ok. aoqi@0: thread->set_pending_unsafe_access_error(); aoqi@0: uc->uc_mcontext.jmp_context.iar = ((unsigned long)pc) + 4; aoqi@0: return 1; aoqi@0: } aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: else { // thread->thread_state() != _thread_in_Java aoqi@0: // Detect CPU features. This is only done at the very start of the VM. Later, the aoqi@0: // VM_Version::is_determine_features_test_running() flag should be false. aoqi@0: aoqi@0: if (sig == SIGILL && VM_Version::is_determine_features_test_running()) { aoqi@0: // SIGILL must be caused by VM_Version::determine_features(). aoqi@0: *(int *)pc = 0; // patch instruction to 0 to indicate that it causes a SIGILL, aoqi@0: // flushing of icache is not necessary. aoqi@0: stub = pc + 4; // continue with next instruction. aoqi@0: goto run_stub; aoqi@0: } aoqi@0: else if (thread->thread_state() == _thread_in_vm && aoqi@0: sig == SIGBUS && thread->doing_unsafe_access()) { aoqi@0: // We don't really need a stub here! Just set the pending exeption and aoqi@0: // continue at the next instruction after the faulting read. Returning aoqi@0: // garbage from this read is ok. aoqi@0: thread->set_pending_unsafe_access_error(); aoqi@0: uc->uc_mcontext.jmp_context.iar = ((unsigned long)pc) + 4; aoqi@0: return 1; aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: // Check to see if we caught the safepoint code in the aoqi@0: // process of write protecting the memory serialization page. aoqi@0: // It write enables the page immediately after protecting it aoqi@0: // so we can just return to retry the write. aoqi@0: if ((sig == SIGSEGV) && aoqi@0: os::is_memory_serialize_page(thread, addr)) { aoqi@0: // Synchronization problem in the pseudo memory barrier code (bug id 6546278) aoqi@0: // Block current thread until the memory serialize page permission restored. aoqi@0: os::block_on_serialize_page_trap(); aoqi@0: return true; aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: run_stub: aoqi@0: aoqi@0: // One of the above code blocks ininitalized the stub, so we want to aoqi@0: // delegate control to that stub. aoqi@0: if (stub != NULL) { aoqi@0: // Save all thread context in case we need to restore it. aoqi@0: if (thread != NULL) thread->set_saved_exception_pc(pc); aoqi@0: uc->uc_mcontext.jmp_context.iar = (unsigned long)stub; aoqi@0: return 1; aoqi@0: } aoqi@0: aoqi@0: run_chained_handler: aoqi@0: aoqi@0: // signal-chaining aoqi@0: if (os::Aix::chained_handler(sig, info, ucVoid)) { aoqi@0: return 1; aoqi@0: } aoqi@0: if (!abort_if_unrecognized) { aoqi@0: // caller wants another chance, so give it to him aoqi@0: return 0; aoqi@0: } aoqi@0: aoqi@0: report_and_die: aoqi@0: aoqi@0: // Use sigthreadmask instead of sigprocmask on AIX and unmask current signal. aoqi@0: sigset_t newset; aoqi@0: sigemptyset(&newset); aoqi@0: sigaddset(&newset, sig); aoqi@0: sigthreadmask(SIG_UNBLOCK, &newset, NULL); aoqi@0: aoqi@0: VMError err(t, sig, pc, info, ucVoid); aoqi@0: err.report_and_die(); aoqi@0: aoqi@0: ShouldNotReachHere(); aoqi@0: return 0; aoqi@0: } aoqi@0: aoqi@0: void os::Aix::init_thread_fpu_state(void) { aoqi@0: #if !defined(USE_XLC_BUILTINS) aoqi@0: // Disable FP exceptions. aoqi@0: __asm__ __volatile__ ("mtfsfi 6,0"); aoqi@0: #else aoqi@0: __mtfsfi(6, 0); aoqi@0: #endif aoqi@0: } aoqi@0: aoqi@0: //////////////////////////////////////////////////////////////////////////////// aoqi@0: // thread stack aoqi@0: aoqi@0: size_t os::Aix::min_stack_allowed = 768*K; aoqi@0: aoqi@0: // Aix is always in floating stack mode. The stack size for a new aoqi@0: // thread can be set via pthread_attr_setstacksize(). aoqi@0: bool os::Aix::supports_variable_stack_size() { return true; } aoqi@0: aoqi@0: // return default stack size for thr_type aoqi@0: size_t os::Aix::default_stack_size(os::ThreadType thr_type) { aoqi@0: // default stack size (compiler thread needs larger stack) aoqi@0: // Notice that the setting for compiler threads here have no impact aoqi@0: // because of the strange 'fallback logic' in os::create_thread(). aoqi@0: // Better set CompilerThreadStackSize in globals_.hpp if you want to aoqi@0: // specify a different stack size for compiler threads! aoqi@0: size_t s = (thr_type == os::compiler_thread ? 4 * M : 1024 * K); aoqi@0: return s; aoqi@0: } aoqi@0: aoqi@0: size_t os::Aix::default_guard_size(os::ThreadType thr_type) { aoqi@0: return 2 * page_size(); aoqi@0: } aoqi@0: aoqi@0: ///////////////////////////////////////////////////////////////////////////// aoqi@0: // helper functions for fatal error handler aoqi@0: aoqi@0: void os::print_context(outputStream *st, void *context) { aoqi@0: if (context == NULL) return; aoqi@0: aoqi@0: ucontext_t* uc = (ucontext_t*)context; aoqi@0: aoqi@0: st->print_cr("Registers:"); aoqi@0: st->print("pc =" INTPTR_FORMAT " ", uc->uc_mcontext.jmp_context.iar); aoqi@0: st->print("lr =" INTPTR_FORMAT " ", uc->uc_mcontext.jmp_context.lr); aoqi@0: st->print("ctr=" INTPTR_FORMAT " ", uc->uc_mcontext.jmp_context.ctr); aoqi@0: st->cr(); aoqi@0: for (int i = 0; i < 32; i++) { aoqi@0: st->print("r%-2d=" INTPTR_FORMAT " ", i, uc->uc_mcontext.jmp_context.gpr[i]); aoqi@0: if (i % 3 == 2) st->cr(); aoqi@0: } aoqi@0: st->cr(); aoqi@0: st->cr(); aoqi@0: aoqi@0: intptr_t *sp = (intptr_t *)os::Aix::ucontext_get_sp(uc); aoqi@0: st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", sp); aoqi@0: print_hex_dump(st, (address)sp, (address)(sp + 128), sizeof(intptr_t)); aoqi@0: st->cr(); aoqi@0: aoqi@0: // Note: it may be unsafe to inspect memory near pc. For example, pc may aoqi@0: // point to garbage if entry point in an nmethod is corrupted. Leave aoqi@0: // this at the end, and hope for the best. aoqi@0: address pc = os::Aix::ucontext_get_pc(uc); aoqi@0: st->print_cr("Instructions: (pc=" PTR_FORMAT ")", pc); aoqi@0: print_hex_dump(st, pc - 64, pc + 64, /*instrsize=*/4); aoqi@0: st->cr(); aoqi@0: aoqi@0: // Try to decode the instructions. aoqi@0: st->print_cr("Decoded instructions: (pc=" PTR_FORMAT ")", pc); aoqi@0: st->print(""); aoqi@0: // TODO: PPC port Disassembler::decode(pc, 16, 16, st); aoqi@0: st->cr(); aoqi@0: } aoqi@0: aoqi@0: void os::print_register_info(outputStream *st, void *context) { aoqi@0: if (context == NULL) return; aoqi@0: st->print("Not ported - print_register_info\n"); aoqi@0: } aoqi@0: aoqi@0: extern "C" { aoqi@0: int SpinPause() { aoqi@0: return 0; aoqi@0: } aoqi@0: } aoqi@0: aoqi@0: #ifndef PRODUCT aoqi@0: void os::verify_stack_alignment() { aoqi@0: assert(((intptr_t)os::current_stack_pointer() & (StackAlignmentInBytes-1)) == 0, "incorrect stack alignment"); aoqi@0: } aoqi@0: #endif