src/os/linux/vm/os_linux.cpp

changeset 7994
04ff2f6cd0eb
parent 7824
bbceafdc7a5f
parent 7535
7ae4e26cb1e0
child 8021
7745bb9444be
     1.1 --- a/src/os/linux/vm/os_linux.cpp	Thu Aug 06 00:08:57 2015 -0700
     1.2 +++ b/src/os/linux/vm/os_linux.cpp	Tue Oct 17 12:58:25 2017 +0800
     1.3 @@ -971,6 +971,14 @@
     1.4    Monitor* sync_with_child = osthread->startThread_lock();
     1.5    MutexLockerEx ml(sync_with_child, Mutex::_no_safepoint_check_flag);
     1.6    sync_with_child->notify();
     1.7 +
     1.8 +#ifdef MIPS64
     1.9 +  /* 2013/11/5 Jin: To be accessed in NativeGeneralJump::patch_verified_entry() */
    1.10 +  if (thread->is_Java_thread())
    1.11 +  {
    1.12 +    ((JavaThread*)thread)->set_handle_wrong_method_stub(SharedRuntime::get_handle_wrong_method_stub());
    1.13 +  }
    1.14 +#endif
    1.15  }
    1.16  
    1.17  // Free Linux resources related to the OSThread
    1.18 @@ -1896,6 +1904,7 @@
    1.19      {EM_ALPHA,       EM_ALPHA,   ELFCLASS64, ELFDATA2LSB, (char*)"Alpha"},
    1.20      {EM_MIPS_RS3_LE, EM_MIPS_RS3_LE, ELFCLASS32, ELFDATA2LSB, (char*)"MIPSel"},
    1.21      {EM_MIPS,        EM_MIPS,    ELFCLASS32, ELFDATA2MSB, (char*)"MIPS"},
    1.22 +    {EM_MIPS,        EM_MIPS,    ELFCLASS64, ELFDATA2LSB, (char*)"MIPS64 LE"},
    1.23      {EM_PARISC,      EM_PARISC,  ELFCLASS32, ELFDATA2MSB, (char*)"PARISC"},
    1.24      {EM_68K,         EM_68K,     ELFCLASS32, ELFDATA2MSB, (char*)"M68k"}
    1.25    };
    1.26 @@ -1910,6 +1919,8 @@
    1.27      static  Elf32_Half running_arch_code=EM_SPARCV9;
    1.28    #elif  (defined __sparc) && (!defined _LP64)
    1.29      static  Elf32_Half running_arch_code=EM_SPARC;
    1.30 +  #elif  (defined MIPS64)
    1.31 +    static  Elf32_Half running_arch_code=EM_MIPS;
    1.32    #elif  (defined __powerpc64__)
    1.33      static  Elf32_Half running_arch_code=EM_PPC64;
    1.34    #elif  (defined __powerpc__)
    1.35 @@ -1930,7 +1941,7 @@
    1.36      static  Elf32_Half running_arch_code=EM_68K;
    1.37    #else
    1.38      #error Method os::dll_load requires that one of following is defined:\
    1.39 -         IA32, AMD64, IA64, __sparc, __powerpc__, ARM, S390, ALPHA, MIPS, MIPSEL, PARISC, M68K
    1.40 +         IA32, AMD64, IA64, __sparc, __powerpc__, ARM, S390, ALPHA, MIPS, MIPSEL, __mips64, PARISC, M68K
    1.41    #endif
    1.42  
    1.43    // Identify compatability class for VM's architecture and library's architecture
    1.44 @@ -3221,7 +3232,7 @@
    1.45  
    1.46  #ifndef ZERO
    1.47    large_page_size = IA32_ONLY(4 * M) AMD64_ONLY(2 * M) IA64_ONLY(256 * M) SPARC_ONLY(4 * M)
    1.48 -                     ARM_ONLY(2 * M) PPC_ONLY(4 * M);
    1.49 +                     ARM_ONLY(2 * M) PPC_ONLY(4 * M) MIPS64_ONLY(4 * M); //In MIPS _large_page_size is seted 4*M.
    1.50  #endif // ZERO
    1.51  
    1.52    FILE *fp = fopen("/proc/meminfo", "r");
    1.53 @@ -4750,7 +4761,12 @@
    1.54    Linux::fast_thread_clock_init();
    1.55  
    1.56    // Allocate a single page and mark it as readable for safepoint polling
    1.57 +#ifdef OPT_SAFEPOINT
    1.58 +  void * p = (void *)(0x10000);
    1.59 +  address polling_page = (address) ::mmap(p, Linux::page_size(), PROT_READ, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
    1.60 +#else
    1.61    address polling_page = (address) ::mmap(NULL, Linux::page_size(), PROT_READ, MAP_PRIVATE|MAP_ANONYMOUS, -1, 0);
    1.62 +#endif
    1.63    guarantee( polling_page != MAP_FAILED, "os::init_2: failed to allocate polling page" );
    1.64  
    1.65    os::set_polling_page( polling_page );
    1.66 @@ -4785,13 +4801,18 @@
    1.67    // size.  Add a page for compiler2 recursion in main thread.
    1.68    // Add in 2*BytesPerWord times page size to account for VM stack during
    1.69    // class initialization depending on 32 or 64 bit VM.
    1.70 +
    1.71 +  /* 2014/1/2 Liao: JDK8 requires larger -Xss option.
    1.72 +   *   TongWeb cannot run with -Xss192K.
    1.73 +   *   We are not sure whether this causes errors, so simply print a warning. */
    1.74 +  size_t min_stack_allowed_jdk6 = os::Linux::min_stack_allowed;
    1.75    os::Linux::min_stack_allowed = MAX2(os::Linux::min_stack_allowed,
    1.76              (size_t)(StackYellowPages+StackRedPages+StackShadowPages) * Linux::page_size() +
    1.77                      (2*BytesPerWord COMPILER2_PRESENT(+1)) * Linux::vm_default_page_size());
    1.78  
    1.79    size_t threadStackSizeInBytes = ThreadStackSize * K;
    1.80    if (threadStackSizeInBytes != 0 &&
    1.81 -      threadStackSizeInBytes < os::Linux::min_stack_allowed) {
    1.82 +      threadStackSizeInBytes < min_stack_allowed_jdk6) {
    1.83          tty->print_cr("\nThe stack size specified is too small, "
    1.84                        "Specify at least %dk",
    1.85                        os::Linux::min_stack_allowed/ K);
    1.86 @@ -4908,10 +4929,39 @@
    1.87    }
    1.88  };
    1.89  
    1.90 +#ifdef MIPS64
    1.91 +/* 2016/9/18 Jin 
    1.92 + * Refer to:  libnuma_init() */
    1.93 +int get_available_cpus() {
    1.94 +  typedef int (*numa_num_task_cpus_t)(void);
    1.95 +  static numa_num_task_cpus_t _numa_num_task_cpus;
    1.96 +
    1.97 +  void *handle = dlopen("libnuma.so.1", RTLD_LAZY);
    1.98 +
    1.99 +  if (handle == NULL)
   1.100 +    return sysconf(_SC_NPROCESSORS_ONLN);
   1.101 +
   1.102 +  _numa_num_task_cpus = CAST_FROM_FN_PTR(numa_num_task_cpus_t, dlsym(handle, "numa_num_task_cpus"));
   1.103 +
   1.104 +  if (_numa_num_task_cpus == NULL) {
   1.105 +    dlclose(handle);
   1.106 +    return sysconf(_SC_NPROCESSORS_ONLN);
   1.107 +  }
   1.108 +
   1.109 +  int ret = _numa_num_task_cpus();
   1.110 +  dlclose(handle);
   1.111 +  return ret;
   1.112 +}
   1.113 +#endif
   1.114 +
   1.115  int os::active_processor_count() {
   1.116    // Linux doesn't yet have a (official) notion of processor sets,
   1.117    // so just return the number of online processors.
   1.118 +#ifdef MIPS64
   1.119 +  int online_cpus = get_available_cpus();
   1.120 +#else
   1.121    int online_cpus = ::sysconf(_SC_NPROCESSORS_ONLN);
   1.122 +#endif
   1.123    assert(online_cpus > 0 && online_cpus <= processor_count(), "sanity check");
   1.124    return online_cpus;
   1.125  }

mercurial