os_linux_aarch64.cpp revision 9685:15ce8135ef98
1/* 2 * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. 3 * Copyright (c) 2014, Red Hat Inc. 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 * 24 */ 25 26// no precompiled headers 27#include "asm/macroAssembler.hpp" 28#include "classfile/classLoader.hpp" 29#include "classfile/systemDictionary.hpp" 30#include "classfile/vmSymbols.hpp" 31#include "code/codeCache.hpp" 32#include "code/icBuffer.hpp" 33#include "code/vtableStubs.hpp" 34#include "code/nativeInst.hpp" 35#include "interpreter/interpreter.hpp" 36#include "jvm_linux.h" 37#include "memory/allocation.inline.hpp" 38#include "mutex_linux.inline.hpp" 39#include "os_share_linux.hpp" 40#include "prims/jniFastGetField.hpp" 41#include "prims/jvm.h" 42#include "prims/jvm_misc.hpp" 43#include "runtime/arguments.hpp" 44#include "runtime/extendedPC.hpp" 45#include "runtime/frame.inline.hpp" 46#include "runtime/interfaceSupport.hpp" 47#include "runtime/java.hpp" 48#include "runtime/javaCalls.hpp" 49#include "runtime/mutexLocker.hpp" 50#include "runtime/osThread.hpp" 51#include "runtime/sharedRuntime.hpp" 52#include "runtime/stubRoutines.hpp" 53#include "runtime/thread.inline.hpp" 54#include "runtime/timer.hpp" 55#include "utilities/events.hpp" 56#include "utilities/vmError.hpp" 57#ifdef BUILTIN_SIM 58#include "../../../../../../simulator/simulator.hpp" 59#endif 60 61// put OS-includes here 62# include <sys/types.h> 63# include <sys/mman.h> 64# include <pthread.h> 65# include <signal.h> 66# include <errno.h> 67# include <dlfcn.h> 68# include <stdlib.h> 69# include <stdio.h> 70# include <unistd.h> 71# include <sys/resource.h> 72# include <pthread.h> 73# include <sys/stat.h> 74# include <sys/time.h> 75# include <sys/utsname.h> 76# include <sys/socket.h> 77# include <sys/wait.h> 78# include <pwd.h> 79# include <poll.h> 80# include <ucontext.h> 81# include <fpu_control.h> 82 83#ifdef BUILTIN_SIM 84#define REG_SP REG_RSP 85#define REG_PC REG_RIP 86#define REG_FP REG_RBP 87#define SPELL_REG_SP "rsp" 88#define SPELL_REG_FP "rbp" 89#else 90#define REG_FP 29 91 92#define SPELL_REG_SP "sp" 93#define SPELL_REG_FP "x29" 94#endif 95 96address os::current_stack_pointer() { 97 register void *esp __asm__ (SPELL_REG_SP); 98 return (address) esp; 99} 100 101char* os::non_memory_address_word() { 102 // Must never look like an address returned by reserve_memory, 103 // even in its subfields (as defined by the CPU immediate fields, 104 // if the CPU splits constants across multiple instructions). 105 106 return (char*) 0xffffffffffff; 107} 108 109void os::initialize_thread(Thread *thr) { 110} 111 112address os::Linux::ucontext_get_pc(ucontext_t * uc) { 113#ifdef BUILTIN_SIM 114 return (address)uc->uc_mcontext.gregs[REG_PC]; 115#else 116 return (address)uc->uc_mcontext.pc; 117#endif 118} 119 120void os::Linux::ucontext_set_pc(ucontext_t * uc, address pc) { 121#ifdef BUILTIN_SIM 122 uc->uc_mcontext.gregs[REG_PC] = (intptr_t)pc; 123#else 124 uc->uc_mcontext.pc = (intptr_t)pc; 125#endif 126} 127 128intptr_t* os::Linux::ucontext_get_sp(ucontext_t * uc) { 129#ifdef BUILTIN_SIM 130 return (intptr_t*)uc->uc_mcontext.gregs[REG_SP]; 131#else 132 return (intptr_t*)uc->uc_mcontext.sp; 133#endif 134} 135 136intptr_t* os::Linux::ucontext_get_fp(ucontext_t * uc) { 137#ifdef BUILTIN_SIM 138 return (intptr_t*)uc->uc_mcontext.gregs[REG_FP]; 139#else 140 return (intptr_t*)uc->uc_mcontext.regs[REG_FP]; 141#endif 142} 143 144// For Forte Analyzer AsyncGetCallTrace profiling support - thread 145// is currently interrupted by SIGPROF. 146// os::Solaris::fetch_frame_from_ucontext() tries to skip nested signal 147// frames. Currently we don't do that on Linux, so it's the same as 148// os::fetch_frame_from_context(). 149ExtendedPC os::Linux::fetch_frame_from_ucontext(Thread* thread, 150 ucontext_t* uc, intptr_t** ret_sp, intptr_t** ret_fp) { 151 152 assert(thread != NULL, "just checking"); 153 assert(ret_sp != NULL, "just checking"); 154 assert(ret_fp != NULL, "just checking"); 155 156 return os::fetch_frame_from_context(uc, ret_sp, ret_fp); 157} 158 159ExtendedPC os::fetch_frame_from_context(void* ucVoid, 160 intptr_t** ret_sp, intptr_t** ret_fp) { 161 162 ExtendedPC epc; 163 ucontext_t* uc = (ucontext_t*)ucVoid; 164 165 if (uc != NULL) { 166 epc = ExtendedPC(os::Linux::ucontext_get_pc(uc)); 167 if (ret_sp) *ret_sp = os::Linux::ucontext_get_sp(uc); 168 if (ret_fp) *ret_fp = os::Linux::ucontext_get_fp(uc); 169 } else { 170 // construct empty ExtendedPC for return value checking 171 epc = ExtendedPC(NULL); 172 if (ret_sp) *ret_sp = (intptr_t *)NULL; 173 if (ret_fp) *ret_fp = (intptr_t *)NULL; 174 } 175 176 return epc; 177} 178 179frame os::fetch_frame_from_context(void* ucVoid) { 180 intptr_t* sp; 181 intptr_t* fp; 182 ExtendedPC epc = fetch_frame_from_context(ucVoid, &sp, &fp); 183 return frame(sp, fp, epc.pc()); 184} 185 186// By default, gcc always saves frame pointer rfp on this stack. This 187// may get turned off by -fomit-frame-pointer. 188frame os::get_sender_for_C_frame(frame* fr) { 189#ifdef BUILTIN_SIM 190 return frame(fr->sender_sp(), fr->link(), fr->sender_pc()); 191#else 192 return frame(fr->link(), fr->link(), fr->sender_pc()); 193#endif 194} 195 196intptr_t* _get_previous_fp() { 197 register intptr_t **ebp __asm__ (SPELL_REG_FP); 198 return (intptr_t*) *ebp; // we want what it points to. 199} 200 201 202frame os::current_frame() { 203 intptr_t* fp = _get_previous_fp(); 204 frame myframe((intptr_t*)os::current_stack_pointer(), 205 (intptr_t*)fp, 206 CAST_FROM_FN_PTR(address, os::current_frame)); 207 if (os::is_first_C_frame(&myframe)) { 208 // stack is not walkable 209 return frame(); 210 } else { 211 return os::get_sender_for_C_frame(&myframe); 212 } 213} 214 215// Utility functions 216 217// From IA32 System Programming Guide 218enum { 219 trap_page_fault = 0xE 220}; 221 222#ifdef BUILTIN_SIM 223extern "C" void Fetch32PFI () ; 224extern "C" void Fetch32Resume () ; 225extern "C" void FetchNPFI () ; 226extern "C" void FetchNResume () ; 227#endif 228 229// An operation in Unsafe has faulted. We're going to return to the 230// instruction after the faulting load or store. We also set 231// pending_unsafe_access_error so that at some point in the future our 232// user will get a helpful message. 233static address handle_unsafe_access(JavaThread* thread, address pc) { 234 // pc is the instruction which we must emulate 235 // doing a no-op is fine: return garbage from the load 236 // therefore, compute npc 237 address npc = pc + NativeCall::instruction_size; 238 239 // request an async exception 240 thread->set_pending_unsafe_access_error(); 241 242 // return address of next instruction to execute 243 return npc; 244} 245 246extern "C" JNIEXPORT int 247JVM_handle_linux_signal(int sig, 248 siginfo_t* info, 249 void* ucVoid, 250 int abort_if_unrecognized) { 251 ucontext_t* uc = (ucontext_t*) ucVoid; 252 253 Thread* t = Thread::current_or_null_safe(); 254 255 // Must do this before SignalHandlerMark, if crash protection installed we will longjmp away 256 // (no destructors can be run) 257 os::WatcherThreadCrashProtection::check_crash_protection(sig, t); 258 259 SignalHandlerMark shm(t); 260 261 // Note: it's not uncommon that JNI code uses signal/sigset to install 262 // then restore certain signal handler (e.g. to temporarily block SIGPIPE, 263 // or have a SIGILL handler when detecting CPU type). When that happens, 264 // JVM_handle_linux_signal() might be invoked with junk info/ucVoid. To 265 // avoid unnecessary crash when libjsig is not preloaded, try handle signals 266 // that do not require siginfo/ucontext first. 267 268 if (sig == SIGPIPE || sig == SIGXFSZ) { 269 // allow chained handler to go first 270 if (os::Linux::chained_handler(sig, info, ucVoid)) { 271 return true; 272 } else { 273 if (PrintMiscellaneous && (WizardMode || Verbose)) { 274 char buf[64]; 275 warning("Ignoring %s - see bugs 4229104 or 646499219", 276 os::exception_name(sig, buf, sizeof(buf))); 277 } 278 return true; 279 } 280 } 281 282 JavaThread* thread = NULL; 283 VMThread* vmthread = NULL; 284 if (os::Linux::signal_handlers_are_installed) { 285 if (t != NULL ){ 286 if(t->is_Java_thread()) { 287 thread = (JavaThread*)t; 288 } 289 else if(t->is_VM_thread()){ 290 vmthread = (VMThread *)t; 291 } 292 } 293 } 294/* 295 NOTE: does not seem to work on linux. 296 if (info == NULL || info->si_code <= 0 || info->si_code == SI_NOINFO) { 297 // can't decode this kind of signal 298 info = NULL; 299 } else { 300 assert(sig == info->si_signo, "bad siginfo"); 301 } 302*/ 303 // decide if this trap can be handled by a stub 304 address stub = NULL; 305 306 address pc = NULL; 307 308 //%note os_trap_1 309 if (info != NULL && uc != NULL && thread != NULL) { 310 pc = (address) os::Linux::ucontext_get_pc(uc); 311 312#ifdef BUILTIN_SIM 313 if (pc == (address) Fetch32PFI) { 314 uc->uc_mcontext.gregs[REG_PC] = intptr_t(Fetch32Resume) ; 315 return 1 ; 316 } 317 if (pc == (address) FetchNPFI) { 318 uc->uc_mcontext.gregs[REG_PC] = intptr_t (FetchNResume) ; 319 return 1 ; 320 } 321#else 322 if (StubRoutines::is_safefetch_fault(pc)) { 323 os::Linux::ucontext_set_pc(uc, StubRoutines::continuation_for_safefetch_fault(pc)); 324 return 1; 325 } 326#endif 327 328 // Handle ALL stack overflow variations here 329 if (sig == SIGSEGV) { 330 address addr = (address) info->si_addr; 331 332 // check if fault address is within thread stack 333 if (addr < thread->stack_base() && 334 addr >= thread->stack_base() - thread->stack_size()) { 335 // stack overflow 336 if (thread->in_stack_yellow_zone(addr)) { 337 thread->disable_stack_yellow_zone(); 338 if (thread->thread_state() == _thread_in_Java) { 339 // Throw a stack overflow exception. Guard pages will be reenabled 340 // while unwinding the stack. 341 stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::STACK_OVERFLOW); 342 } else { 343 // Thread was in the vm or native code. Return and try to finish. 344 return 1; 345 } 346 } else if (thread->in_stack_red_zone(addr)) { 347 // Fatal red zone violation. Disable the guard pages and fall through 348 // to handle_unexpected_exception way down below. 349 thread->disable_stack_red_zone(); 350 tty->print_raw_cr("An irrecoverable stack overflow has occurred."); 351 352 // This is a likely cause, but hard to verify. Let's just print 353 // it as a hint. 354 tty->print_raw_cr("Please check if any of your loaded .so files has " 355 "enabled executable stack (see man page execstack(8))"); 356 } else { 357 // Accessing stack address below sp may cause SEGV if current 358 // thread has MAP_GROWSDOWN stack. This should only happen when 359 // current thread was created by user code with MAP_GROWSDOWN flag 360 // and then attached to VM. See notes in os_linux.cpp. 361 if (thread->osthread()->expanding_stack() == 0) { 362 thread->osthread()->set_expanding_stack(); 363 if (os::Linux::manually_expand_stack(thread, addr)) { 364 thread->osthread()->clear_expanding_stack(); 365 return 1; 366 } 367 thread->osthread()->clear_expanding_stack(); 368 } else { 369 fatal("recursive segv. expanding stack."); 370 } 371 } 372 } 373 } 374 375 if (thread->thread_state() == _thread_in_Java) { 376 // Java thread running in Java code => find exception handler if any 377 // a fault inside compiled code, the interpreter, or a stub 378 379 // Handle signal from NativeJump::patch_verified_entry(). 380 if ((sig == SIGILL || sig == SIGTRAP) 381 && nativeInstruction_at(pc)->is_sigill_zombie_not_entrant()) { 382 if (TraceTraps) { 383 tty->print_cr("trap: zombie_not_entrant (%s)", (sig == SIGTRAP) ? "SIGTRAP" : "SIGILL"); 384 } 385 stub = SharedRuntime::get_handle_wrong_method_stub(); 386 } else if (sig == SIGSEGV && os::is_poll_address((address)info->si_addr)) { 387 stub = SharedRuntime::get_poll_stub(pc); 388 } else if (sig == SIGBUS /* && info->si_code == BUS_OBJERR */) { 389 // BugId 4454115: A read from a MappedByteBuffer can fault 390 // here if the underlying file has been truncated. 391 // Do not crash the VM in such a case. 392 CodeBlob* cb = CodeCache::find_blob_unsafe(pc); 393 nmethod* nm = (cb != NULL && cb->is_nmethod()) ? (nmethod*)cb : NULL; 394 if (nm != NULL && nm->has_unsafe_access()) { 395 stub = handle_unsafe_access(thread, pc); 396 } 397 } 398 else 399 400 if (sig == SIGFPE && 401 (info->si_code == FPE_INTDIV || info->si_code == FPE_FLTDIV)) { 402 stub = 403 SharedRuntime:: 404 continuation_for_implicit_exception(thread, 405 pc, 406 SharedRuntime:: 407 IMPLICIT_DIVIDE_BY_ZERO); 408 } else if (sig == SIGSEGV && 409 !MacroAssembler::needs_explicit_null_check((intptr_t)info->si_addr)) { 410 // Determination of interpreter/vtable stub/compiled code null exception 411 stub = SharedRuntime::continuation_for_implicit_exception(thread, pc, SharedRuntime::IMPLICIT_NULL); 412 } 413 } else if (thread->thread_state() == _thread_in_vm && 414 sig == SIGBUS && /* info->si_code == BUS_OBJERR && */ 415 thread->doing_unsafe_access()) { 416 stub = handle_unsafe_access(thread, pc); 417 } 418 419 // jni_fast_Get<Primitive>Field can trap at certain pc's if a GC kicks in 420 // and the heap gets shrunk before the field access. 421 if ((sig == SIGSEGV) || (sig == SIGBUS)) { 422 address addr = JNI_FastGetField::find_slowcase_pc(pc); 423 if (addr != (address)-1) { 424 stub = addr; 425 } 426 } 427 428 // Check to see if we caught the safepoint code in the 429 // process of write protecting the memory serialization page. 430 // It write enables the page immediately after protecting it 431 // so we can just return to retry the write. 432 if ((sig == SIGSEGV) && 433 os::is_memory_serialize_page(thread, (address) info->si_addr)) { 434 // Block current thread until the memory serialize page permission restored. 435 os::block_on_serialize_page_trap(); 436 return true; 437 } 438 } 439 440 if (stub != NULL) { 441 // save all thread context in case we need to restore it 442 if (thread != NULL) thread->set_saved_exception_pc(pc); 443 444 os::Linux::ucontext_set_pc(uc, stub); 445 return true; 446 } 447 448 // signal-chaining 449 if (os::Linux::chained_handler(sig, info, ucVoid)) { 450 return true; 451 } 452 453 if (!abort_if_unrecognized) { 454 // caller wants another chance, so give it to him 455 return false; 456 } 457 458 if (pc == NULL && uc != NULL) { 459 pc = os::Linux::ucontext_get_pc(uc); 460 } 461 462 // unmask current signal 463 sigset_t newset; 464 sigemptyset(&newset); 465 sigaddset(&newset, sig); 466 sigprocmask(SIG_UNBLOCK, &newset, NULL); 467 468 VMError::report_and_die(t, sig, pc, info, ucVoid); 469 470 ShouldNotReachHere(); 471 return true; // Mute compiler 472} 473 474void os::Linux::init_thread_fpu_state(void) { 475} 476 477int os::Linux::get_fpu_control_word(void) { 478 return 0; 479} 480 481void os::Linux::set_fpu_control_word(int fpu_control) { 482} 483 484// Check that the linux kernel version is 2.4 or higher since earlier 485// versions do not support SSE without patches. 486bool os::supports_sse() { 487 return true; 488} 489 490bool os::is_allocatable(size_t bytes) { 491 return true; 492} 493 494//////////////////////////////////////////////////////////////////////////////// 495// thread stack 496 497size_t os::Linux::min_stack_allowed = 64 * K; 498 499// return default stack size for thr_type 500size_t os::Linux::default_stack_size(os::ThreadType thr_type) { 501 // default stack size (compiler thread needs larger stack) 502 size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M); 503 return s; 504} 505 506size_t os::Linux::default_guard_size(os::ThreadType thr_type) { 507 // Creating guard page is very expensive. Java thread has HotSpot 508 // guard page, only enable glibc guard page for non-Java threads. 509 return (thr_type == java_thread ? 0 : page_size()); 510} 511 512// Java thread: 513// 514// Low memory addresses 515// +------------------------+ 516// | |\ JavaThread created by VM does not have glibc 517// | glibc guard page | - guard, attached Java thread usually has 518// | |/ 1 page glibc guard. 519// P1 +------------------------+ Thread::stack_base() - Thread::stack_size() 520// | |\ 521// | HotSpot Guard Pages | - red and yellow pages 522// | |/ 523// +------------------------+ JavaThread::stack_yellow_zone_base() 524// | |\ 525// | Normal Stack | - 526// | |/ 527// P2 +------------------------+ Thread::stack_base() 528// 529// Non-Java thread: 530// 531// Low memory addresses 532// +------------------------+ 533// | |\ 534// | glibc guard page | - usually 1 page 535// | |/ 536// P1 +------------------------+ Thread::stack_base() - Thread::stack_size() 537// | |\ 538// | Normal Stack | - 539// | |/ 540// P2 +------------------------+ Thread::stack_base() 541// 542// ** P1 (aka bottom) and size ( P2 = P1 - size) are the address and stack size returned from 543// pthread_attr_getstack() 544 545static void current_stack_region(address * bottom, size_t * size) { 546 if (os::Linux::is_initial_thread()) { 547 // initial thread needs special handling because pthread_getattr_np() 548 // may return bogus value. 549 *bottom = os::Linux::initial_thread_stack_bottom(); 550 *size = os::Linux::initial_thread_stack_size(); 551 } else { 552 pthread_attr_t attr; 553 554 int rslt = pthread_getattr_np(pthread_self(), &attr); 555 556 // JVM needs to know exact stack location, abort if it fails 557 if (rslt != 0) { 558 if (rslt == ENOMEM) { 559 vm_exit_out_of_memory(0, OOM_MMAP_ERROR, "pthread_getattr_np"); 560 } else { 561 fatal("pthread_getattr_np failed with errno = %d", rslt); 562 } 563 } 564 565 if (pthread_attr_getstack(&attr, (void **)bottom, size) != 0) { 566 fatal("Can not locate current stack attributes!"); 567 } 568 569 pthread_attr_destroy(&attr); 570 571 } 572 assert(os::current_stack_pointer() >= *bottom && 573 os::current_stack_pointer() < *bottom + *size, "just checking"); 574} 575 576address os::current_stack_base() { 577 address bottom; 578 size_t size; 579 current_stack_region(&bottom, &size); 580 return (bottom + size); 581} 582 583size_t os::current_stack_size() { 584 // stack size includes normal stack and HotSpot guard pages 585 address bottom; 586 size_t size; 587 current_stack_region(&bottom, &size); 588 return size; 589} 590 591///////////////////////////////////////////////////////////////////////////// 592// helper functions for fatal error handler 593 594void os::print_context(outputStream *st, void *context) { 595 if (context == NULL) return; 596 597 ucontext_t *uc = (ucontext_t*)context; 598 st->print_cr("Registers:"); 599#ifdef BUILTIN_SIM 600 st->print( "RAX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RAX]); 601 st->print(", RBX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RBX]); 602 st->print(", RCX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RCX]); 603 st->print(", RDX=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RDX]); 604 st->cr(); 605 st->print( "RSP=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RSP]); 606 st->print(", RBP=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RBP]); 607 st->print(", RSI=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RSI]); 608 st->print(", RDI=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RDI]); 609 st->cr(); 610 st->print( "R8 =" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R8]); 611 st->print(", R9 =" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R9]); 612 st->print(", R10=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R10]); 613 st->print(", R11=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R11]); 614 st->cr(); 615 st->print( "R12=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R12]); 616 st->print(", R13=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R13]); 617 st->print(", R14=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R14]); 618 st->print(", R15=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_R15]); 619 st->cr(); 620 st->print( "RIP=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_RIP]); 621 st->print(", EFLAGS=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_EFL]); 622 st->print(", CSGSFS=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_CSGSFS]); 623 st->print(", ERR=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_ERR]); 624 st->cr(); 625 st->print(" TRAPNO=" INTPTR_FORMAT, uc->uc_mcontext.gregs[REG_TRAPNO]); 626 st->cr(); 627#else 628 for (int r = 0; r < 31; r++) 629 st->print_cr( "R%d=" INTPTR_FORMAT, r, (size_t)uc->uc_mcontext.regs[r]); 630#endif 631 st->cr(); 632 633 intptr_t *sp = (intptr_t *)os::Linux::ucontext_get_sp(uc); 634 st->print_cr("Top of Stack: (sp=" PTR_FORMAT ")", p2i(sp)); 635 print_hex_dump(st, (address)sp, (address)(sp + 8*sizeof(intptr_t)), sizeof(intptr_t)); 636 st->cr(); 637 638 // Note: it may be unsafe to inspect memory near pc. For example, pc may 639 // point to garbage if entry point in an nmethod is corrupted. Leave 640 // this at the end, and hope for the best. 641 address pc = os::Linux::ucontext_get_pc(uc); 642 st->print_cr("Instructions: (pc=" PTR_FORMAT ")", p2i(pc)); 643 print_hex_dump(st, pc - 32, pc + 32, sizeof(char)); 644} 645 646void os::print_register_info(outputStream *st, void *context) { 647 if (context == NULL) return; 648 649 ucontext_t *uc = (ucontext_t*)context; 650 651 st->print_cr("Register to memory mapping:"); 652 st->cr(); 653 654 // this is horrendously verbose but the layout of the registers in the 655 // context does not match how we defined our abstract Register set, so 656 // we can't just iterate through the gregs area 657 658 // this is only for the "general purpose" registers 659 660#ifdef BUILTIN_SIM 661 st->print("RAX="); print_location(st, uc->uc_mcontext.gregs[REG_RAX]); 662 st->print("RBX="); print_location(st, uc->uc_mcontext.gregs[REG_RBX]); 663 st->print("RCX="); print_location(st, uc->uc_mcontext.gregs[REG_RCX]); 664 st->print("RDX="); print_location(st, uc->uc_mcontext.gregs[REG_RDX]); 665 st->print("RSP="); print_location(st, uc->uc_mcontext.gregs[REG_RSP]); 666 st->print("RBP="); print_location(st, uc->uc_mcontext.gregs[REG_RBP]); 667 st->print("RSI="); print_location(st, uc->uc_mcontext.gregs[REG_RSI]); 668 st->print("RDI="); print_location(st, uc->uc_mcontext.gregs[REG_RDI]); 669 st->print("R8 ="); print_location(st, uc->uc_mcontext.gregs[REG_R8]); 670 st->print("R9 ="); print_location(st, uc->uc_mcontext.gregs[REG_R9]); 671 st->print("R10="); print_location(st, uc->uc_mcontext.gregs[REG_R10]); 672 st->print("R11="); print_location(st, uc->uc_mcontext.gregs[REG_R11]); 673 st->print("R12="); print_location(st, uc->uc_mcontext.gregs[REG_R12]); 674 st->print("R13="); print_location(st, uc->uc_mcontext.gregs[REG_R13]); 675 st->print("R14="); print_location(st, uc->uc_mcontext.gregs[REG_R14]); 676 st->print("R15="); print_location(st, uc->uc_mcontext.gregs[REG_R15]); 677#else 678 for (int r = 0; r < 31; r++) 679 st->print_cr( "R%d=" INTPTR_FORMAT, r, (uintptr_t)uc->uc_mcontext.regs[r]); 680#endif 681 st->cr(); 682} 683 684void os::setup_fpu() { 685} 686 687#ifndef PRODUCT 688void os::verify_stack_alignment() { 689 assert(((intptr_t)os::current_stack_pointer() & (StackAlignmentInBytes-1)) == 0, "incorrect stack alignment"); 690} 691#endif 692 693int os::extra_bang_size_in_bytes() { 694 // AArch64 does not require the additional stack bang. 695 return 0; 696} 697 698extern "C" { 699 int SpinPause() { 700 return 0; 701 } 702 703 void _Copy_conjoint_jshorts_atomic(jshort* from, jshort* to, size_t count) { 704 if (from > to) { 705 jshort *end = from + count; 706 while (from < end) 707 *(to++) = *(from++); 708 } 709 else if (from < to) { 710 jshort *end = from; 711 from += count - 1; 712 to += count - 1; 713 while (from >= end) 714 *(to--) = *(from--); 715 } 716 } 717 void _Copy_conjoint_jints_atomic(jint* from, jint* to, size_t count) { 718 if (from > to) { 719 jint *end = from + count; 720 while (from < end) 721 *(to++) = *(from++); 722 } 723 else if (from < to) { 724 jint *end = from; 725 from += count - 1; 726 to += count - 1; 727 while (from >= end) 728 *(to--) = *(from--); 729 } 730 } 731 void _Copy_conjoint_jlongs_atomic(jlong* from, jlong* to, size_t count) { 732 if (from > to) { 733 jlong *end = from + count; 734 while (from < end) 735 os::atomic_copy64(from++, to++); 736 } 737 else if (from < to) { 738 jlong *end = from; 739 from += count - 1; 740 to += count - 1; 741 while (from >= end) 742 os::atomic_copy64(from--, to--); 743 } 744 } 745 746 void _Copy_arrayof_conjoint_bytes(HeapWord* from, 747 HeapWord* to, 748 size_t count) { 749 memmove(to, from, count); 750 } 751 void _Copy_arrayof_conjoint_jshorts(HeapWord* from, 752 HeapWord* to, 753 size_t count) { 754 memmove(to, from, count * 2); 755 } 756 void _Copy_arrayof_conjoint_jints(HeapWord* from, 757 HeapWord* to, 758 size_t count) { 759 memmove(to, from, count * 4); 760 } 761 void _Copy_arrayof_conjoint_jlongs(HeapWord* from, 762 HeapWord* to, 763 size_t count) { 764 memmove(to, from, count * 8); 765 } 766}; 767