< prev index next >

src/hotspot/os_cpu/linux_aarch64/os_linux_aarch64.cpp

Print this page




  66 # include <dlfcn.h>
  67 # include <stdlib.h>
  68 # include <stdio.h>
  69 # include <unistd.h>
  70 # include <sys/resource.h>
  71 # include <pthread.h>
  72 # include <sys/stat.h>
  73 # include <sys/time.h>
  74 # include <sys/utsname.h>
  75 # include <sys/socket.h>
  76 # include <sys/wait.h>
  77 # include <pwd.h>
  78 # include <poll.h>
  79 # include <ucontext.h>
  80 # include <fpu_control.h>
  81 
  82 #ifdef BUILTIN_SIM
  83 #define REG_SP REG_RSP
  84 #define REG_PC REG_RIP
  85 #define REG_FP REG_RBP


  86 #else
  87 #define REG_FP 29
  88 #define REG_LR 30



  89 #endif
  90 
  91 NOINLINE address os::current_stack_pointer() {
  92   return (address)__builtin_frame_address(0);

  93 }
  94 
  95 char* os::non_memory_address_word() {
  96   // Must never look like an address returned by reserve_memory,
  97   // even in its subfields (as defined by the CPU immediate fields,
  98   // if the CPU splits constants across multiple instructions).
  99 
 100   return (char*) 0xffffffffffff;
 101 }
 102 
 103 address os::Linux::ucontext_get_pc(const ucontext_t * uc) {
 104 #ifdef BUILTIN_SIM
 105   return (address)uc->uc_mcontext.gregs[REG_PC];
 106 #else
 107   return (address)uc->uc_mcontext.pc;
 108 #endif
 109 }
 110 
 111 void os::Linux::ucontext_set_pc(ucontext_t * uc, address pc) {
 112 #ifdef BUILTIN_SIM


 207         assert(fr->safe_for_sender(thread), "Safety check");
 208         assert(!fr->is_first_frame(), "Safety check");
 209         *fr = fr->java_sender();
 210       }
 211     }
 212   }
 213   assert(fr->is_java_frame(), "Safety check");
 214   return true;
 215 }
 216 
 217 // By default, gcc always saves frame pointer rfp on this stack. This
 218 // may get turned off by -fomit-frame-pointer.
 219 frame os::get_sender_for_C_frame(frame* fr) {
 220 #ifdef BUILTIN_SIM
 221   return frame(fr->sender_sp(), fr->link(), fr->sender_pc());
 222 #else
 223   return frame(fr->link(), fr->link(), fr->sender_pc());
 224 #endif
 225 }
 226 
 227 NOINLINE frame os::current_frame() {
 228   intptr_t *fp = *(intptr_t **)__builtin_frame_address(0);















 229   frame myframe((intptr_t*)os::current_stack_pointer(),
 230                 (intptr_t*)fp,
 231                 CAST_FROM_FN_PTR(address, os::current_frame));
 232   if (os::is_first_C_frame(&myframe)) {
 233     // stack is not walkable
 234     return frame();
 235   } else {
 236     return os::get_sender_for_C_frame(&myframe);
 237   }
 238 }
 239 
 240 // Utility functions






 241 #ifdef BUILTIN_SIM
 242 extern "C" void Fetch32PFI () ;
 243 extern "C" void Fetch32Resume () ;
 244 extern "C" void FetchNPFI () ;
 245 extern "C" void FetchNResume () ;
 246 #endif
 247 
 248 extern "C" JNIEXPORT int
 249 JVM_handle_linux_signal(int sig,
 250                         siginfo_t* info,
 251                         void* ucVoid,
 252                         int abort_if_unrecognized) {
 253   ucontext_t* uc = (ucontext_t*) ucVoid;
 254 
 255   Thread* t = Thread::current_or_null_safe();
 256 
 257   // Must do this before SignalHandlerMark, if crash protection installed we will longjmp away
 258   // (no destructors can be run)
 259   os::ThreadCrashProtection::check_crash_protection(sig, t);
 260 


 623 
 624 void os::setup_fpu() {
 625 }
 626 
 627 #ifndef PRODUCT
 628 void os::verify_stack_alignment() {
 629   assert(((intptr_t)os::current_stack_pointer() & (StackAlignmentInBytes-1)) == 0, "incorrect stack alignment");
 630 }
 631 #endif
 632 
 633 int os::extra_bang_size_in_bytes() {
 634   // AArch64 does not require the additional stack bang.
 635   return 0;
 636 }
 637 
 638 extern "C" {
 639   int SpinPause() {
 640     return 0;
 641   }
 642 
 643   void _Copy_conjoint_jshorts_atomic(const jshort* from, jshort* to, size_t count) {
 644     if (from > to) {
 645       const jshort *end = from + count;
 646       while (from < end)
 647         *(to++) = *(from++);
 648     }
 649     else if (from < to) {
 650       const jshort *end = from;
 651       from += count - 1;
 652       to   += count - 1;
 653       while (from >= end)
 654         *(to--) = *(from--);
 655     }
 656   }
 657   void _Copy_conjoint_jints_atomic(const jint* from, jint* to, size_t count) {
 658     if (from > to) {
 659       const jint *end = from + count;
 660       while (from < end)
 661         *(to++) = *(from++);
 662     }
 663     else if (from < to) {
 664       const jint *end = from;
 665       from += count - 1;
 666       to   += count - 1;
 667       while (from >= end)
 668         *(to--) = *(from--);
 669     }
 670   }
 671   void _Copy_conjoint_jlongs_atomic(const jlong* from, jlong* to, size_t count) {
 672     if (from > to) {
 673       const jlong *end = from + count;
 674       while (from < end)
 675         os::atomic_copy64(from++, to++);
 676     }
 677     else if (from < to) {
 678       const jlong *end = from;
 679       from += count - 1;
 680       to   += count - 1;
 681       while (from >= end)
 682         os::atomic_copy64(from--, to--);
 683     }
 684   }
 685 
 686   void _Copy_arrayof_conjoint_bytes(const HeapWord* from,
 687                                     HeapWord* to,
 688                                     size_t    count) {
 689     memmove(to, from, count);
 690   }
 691   void _Copy_arrayof_conjoint_jshorts(const HeapWord* from,
 692                                       HeapWord* to,
 693                                       size_t    count) {
 694     memmove(to, from, count * 2);
 695   }
 696   void _Copy_arrayof_conjoint_jints(const HeapWord* from,
 697                                     HeapWord* to,
 698                                     size_t    count) {
 699     memmove(to, from, count * 4);
 700   }
 701   void _Copy_arrayof_conjoint_jlongs(const HeapWord* from,
 702                                      HeapWord* to,
 703                                      size_t    count) {
 704     memmove(to, from, count * 8);
 705   }
 706 };


  66 # include <dlfcn.h>
  67 # include <stdlib.h>
  68 # include <stdio.h>
  69 # include <unistd.h>
  70 # include <sys/resource.h>
  71 # include <pthread.h>
  72 # include <sys/stat.h>
  73 # include <sys/time.h>
  74 # include <sys/utsname.h>
  75 # include <sys/socket.h>
  76 # include <sys/wait.h>
  77 # include <pwd.h>
  78 # include <poll.h>
  79 # include <ucontext.h>
  80 # include <fpu_control.h>
  81 
  82 #ifdef BUILTIN_SIM
  83 #define REG_SP REG_RSP
  84 #define REG_PC REG_RIP
  85 #define REG_FP REG_RBP
  86 #define SPELL_REG_SP "rsp"
  87 #define SPELL_REG_FP "rbp"
  88 #else
  89 #define REG_FP 29
  90 #define REG_LR 30
  91 
  92 #define SPELL_REG_SP "sp"
  93 #define SPELL_REG_FP "x29"
  94 #endif
  95 
  96 address os::current_stack_pointer() {
  97   register void *esp __asm__ (SPELL_REG_SP);
  98   return (address) esp;
  99 }
 100 
 101 char* 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 
 109 address os::Linux::ucontext_get_pc(const ucontext_t * uc) {
 110 #ifdef BUILTIN_SIM
 111   return (address)uc->uc_mcontext.gregs[REG_PC];
 112 #else
 113   return (address)uc->uc_mcontext.pc;
 114 #endif
 115 }
 116 
 117 void os::Linux::ucontext_set_pc(ucontext_t * uc, address pc) {
 118 #ifdef BUILTIN_SIM


 213         assert(fr->safe_for_sender(thread), "Safety check");
 214         assert(!fr->is_first_frame(), "Safety check");
 215         *fr = fr->java_sender();
 216       }
 217     }
 218   }
 219   assert(fr->is_java_frame(), "Safety check");
 220   return true;
 221 }
 222 
 223 // By default, gcc always saves frame pointer rfp on this stack. This
 224 // may get turned off by -fomit-frame-pointer.
 225 frame os::get_sender_for_C_frame(frame* fr) {
 226 #ifdef BUILTIN_SIM
 227   return frame(fr->sender_sp(), fr->link(), fr->sender_pc());
 228 #else
 229   return frame(fr->link(), fr->link(), fr->sender_pc());
 230 #endif
 231 }
 232 
 233 intptr_t* _get_previous_fp() {
 234   register intptr_t **fp __asm__ (SPELL_REG_FP);
 235 
 236   // fp is for this frame (_get_previous_fp). We want the fp for the
 237   // caller of os::current_frame*(), so go up two frames. However, for
 238   // optimized builds, _get_previous_fp() will be inlined, so only go
 239   // up 1 frame in that case.
 240   #ifdef _NMT_NOINLINE_
 241     return **(intptr_t***)fp;
 242   #else
 243     return *fp;
 244   #endif
 245 }
 246 
 247 
 248 frame os::current_frame() {
 249   intptr_t* fp = _get_previous_fp();
 250   frame myframe((intptr_t*)os::current_stack_pointer(),
 251                 (intptr_t*)fp,
 252                 CAST_FROM_FN_PTR(address, os::current_frame));
 253   if (os::is_first_C_frame(&myframe)) {
 254     // stack is not walkable
 255     return frame();
 256   } else {
 257     return os::get_sender_for_C_frame(&myframe);
 258   }
 259 }
 260 
 261 // Utility functions
 262 
 263 // From IA32 System Programming Guide
 264 enum {
 265   trap_page_fault = 0xE
 266 };
 267 
 268 #ifdef BUILTIN_SIM
 269 extern "C" void Fetch32PFI () ;
 270 extern "C" void Fetch32Resume () ;
 271 extern "C" void FetchNPFI () ;
 272 extern "C" void FetchNResume () ;
 273 #endif
 274 
 275 extern "C" JNIEXPORT int
 276 JVM_handle_linux_signal(int sig,
 277                         siginfo_t* info,
 278                         void* ucVoid,
 279                         int abort_if_unrecognized) {
 280   ucontext_t* uc = (ucontext_t*) ucVoid;
 281 
 282   Thread* t = Thread::current_or_null_safe();
 283 
 284   // Must do this before SignalHandlerMark, if crash protection installed we will longjmp away
 285   // (no destructors can be run)
 286   os::ThreadCrashProtection::check_crash_protection(sig, t);
 287 


 650 
 651 void os::setup_fpu() {
 652 }
 653 
 654 #ifndef PRODUCT
 655 void os::verify_stack_alignment() {
 656   assert(((intptr_t)os::current_stack_pointer() & (StackAlignmentInBytes-1)) == 0, "incorrect stack alignment");
 657 }
 658 #endif
 659 
 660 int os::extra_bang_size_in_bytes() {
 661   // AArch64 does not require the additional stack bang.
 662   return 0;
 663 }
 664 
 665 extern "C" {
 666   int SpinPause() {
 667     return 0;
 668   }
 669 
 670   void _Copy_conjoint_jshorts_atomic(jshort* from, jshort* to, size_t count) {
 671     if (from > to) {
 672       jshort *end = from + count;
 673       while (from < end)
 674         *(to++) = *(from++);
 675     }
 676     else if (from < to) {
 677       jshort *end = from;
 678       from += count - 1;
 679       to   += count - 1;
 680       while (from >= end)
 681         *(to--) = *(from--);
 682     }
 683   }
 684   void _Copy_conjoint_jints_atomic(jint* from, jint* to, size_t count) {
 685     if (from > to) {
 686       jint *end = from + count;
 687       while (from < end)
 688         *(to++) = *(from++);
 689     }
 690     else if (from < to) {
 691       jint *end = from;
 692       from += count - 1;
 693       to   += count - 1;
 694       while (from >= end)
 695         *(to--) = *(from--);
 696     }
 697   }
 698   void _Copy_conjoint_jlongs_atomic(jlong* from, jlong* to, size_t count) {
 699     if (from > to) {
 700       jlong *end = from + count;
 701       while (from < end)
 702         os::atomic_copy64(from++, to++);
 703     }
 704     else if (from < to) {
 705       jlong *end = from;
 706       from += count - 1;
 707       to   += count - 1;
 708       while (from >= end)
 709         os::atomic_copy64(from--, to--);
 710     }
 711   }
 712 
 713   void _Copy_arrayof_conjoint_bytes(HeapWord* from,
 714                                     HeapWord* to,
 715                                     size_t    count) {
 716     memmove(to, from, count);
 717   }
 718   void _Copy_arrayof_conjoint_jshorts(HeapWord* from,
 719                                       HeapWord* to,
 720                                       size_t    count) {
 721     memmove(to, from, count * 2);
 722   }
 723   void _Copy_arrayof_conjoint_jints(HeapWord* from,
 724                                     HeapWord* to,
 725                                     size_t    count) {
 726     memmove(to, from, count * 4);
 727   }
 728   void _Copy_arrayof_conjoint_jlongs(HeapWord* from,
 729                                      HeapWord* to,
 730                                      size_t    count) {
 731     memmove(to, from, count * 8);
 732   }
 733 };
< prev index next >