8080298: Clean up os::...::supports_variable_stack_size()
authordholmes
Mon, 03 Aug 2015 16:54:08 -0400
changeset 32080 9d2ace436482
parent 32079 654a242d6dc8
child 32081 43cb85a46633
8080298: Clean up os::...::supports_variable_stack_size() Reviewed-by: kbarrett, simonis, stuefe, coleenp
hotspot/src/os/aix/vm/os_aix.cpp
hotspot/src/os/aix/vm/os_aix.hpp
hotspot/src/os/bsd/vm/os_bsd.cpp
hotspot/src/os/bsd/vm/os_bsd.hpp
hotspot/src/os/linux/vm/os_linux.cpp
hotspot/src/os/linux/vm/os_linux.hpp
hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp
hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp
hotspot/src/os_cpu/bsd_zero/vm/os_bsd_zero.cpp
hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp
hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp
hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp
hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp
hotspot/src/os_cpu/linux_zero/vm/os_linux_zero.cpp
--- a/hotspot/src/os/aix/vm/os_aix.cpp	Mon Aug 03 11:12:57 2015 +0200
+++ b/hotspot/src/os/aix/vm/os_aix.cpp	Mon Aug 03 16:54:08 2015 -0400
@@ -971,34 +971,32 @@
   guarantee(pthread_attr_setsuspendstate_np(&attr, PTHREAD_CREATE_SUSPENDED_NP) == 0, "???");
 
   // calculate stack size if it's not specified by caller
-  if (os::Aix::supports_variable_stack_size()) {
-    if (stack_size == 0) {
-      stack_size = os::Aix::default_stack_size(thr_type);
-
-      switch (thr_type) {
-      case os::java_thread:
-        // Java threads use ThreadStackSize whose default value can be changed with the flag -Xss.
-        assert(JavaThread::stack_size_at_create() > 0, "this should be set");
-        stack_size = JavaThread::stack_size_at_create();
+  if (stack_size == 0) {
+    stack_size = os::Aix::default_stack_size(thr_type);
+
+    switch (thr_type) {
+    case os::java_thread:
+      // Java threads use ThreadStackSize whose default value can be changed with the flag -Xss.
+      assert(JavaThread::stack_size_at_create() > 0, "this should be set");
+      stack_size = JavaThread::stack_size_at_create();
+      break;
+    case os::compiler_thread:
+      if (CompilerThreadStackSize > 0) {
+        stack_size = (size_t)(CompilerThreadStackSize * K);
         break;
-      case os::compiler_thread:
-        if (CompilerThreadStackSize > 0) {
-          stack_size = (size_t)(CompilerThreadStackSize * K);
-          break;
-        } // else fall through:
-          // use VMThreadStackSize if CompilerThreadStackSize is not defined
-      case os::vm_thread:
-      case os::pgc_thread:
-      case os::cgc_thread:
-      case os::watcher_thread:
-        if (VMThreadStackSize > 0) stack_size = (size_t)(VMThreadStackSize * K);
-        break;
-      }
+      } // else fall through:
+        // use VMThreadStackSize if CompilerThreadStackSize is not defined
+    case os::vm_thread:
+    case os::pgc_thread:
+    case os::cgc_thread:
+    case os::watcher_thread:
+      if (VMThreadStackSize > 0) stack_size = (size_t)(VMThreadStackSize * K);
+      break;
     }
-
-    stack_size = MAX2(stack_size, os::Aix::min_stack_allowed);
-    pthread_attr_setstacksize(&attr, stack_size);
-  } //else let thread_create() pick the default value (96 K on AIX)
+  }
+
+  stack_size = MAX2(stack_size, os::Aix::min_stack_allowed);
+  pthread_attr_setstacksize(&attr, stack_size);
 
   pthread_t tid;
   int ret = pthread_create(&tid, &attr, (void* (*)(void*)) java_start, thread);
--- a/hotspot/src/os/aix/vm/os_aix.hpp	Mon Aug 03 11:12:57 2015 +0200
+++ b/hotspot/src/os/aix/vm/os_aix.hpp	Mon Aug 03 16:54:08 2015 -0400
@@ -131,8 +131,6 @@
   static void initialize_libo4();
   static void initialize_libperfstat();
 
-  static bool supports_variable_stack_size();
-
  public:
   static void init_thread_fpu_state();
   static pthread_t main_thread(void)                                { return _main_thread; }
--- a/hotspot/src/os/bsd/vm/os_bsd.cpp	Mon Aug 03 11:12:57 2015 +0200
+++ b/hotspot/src/os/bsd/vm/os_bsd.cpp	Mon Aug 03 16:54:08 2015 -0400
@@ -739,40 +739,35 @@
   pthread_attr_init(&attr);
   pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
 
-  // stack size
-  if (os::Bsd::supports_variable_stack_size()) {
-    // calculate stack size if it's not specified by caller
-    if (stack_size == 0) {
-      stack_size = os::Bsd::default_stack_size(thr_type);
-
-      switch (thr_type) {
-      case os::java_thread:
-        // Java threads use ThreadStackSize which default value can be
-        // changed with the flag -Xss
-        assert(JavaThread::stack_size_at_create() > 0, "this should be set");
-        stack_size = JavaThread::stack_size_at_create();
+  // calculate stack size if it's not specified by caller
+  if (stack_size == 0) {
+    stack_size = os::Bsd::default_stack_size(thr_type);
+
+    switch (thr_type) {
+    case os::java_thread:
+      // Java threads use ThreadStackSize which default value can be
+      // changed with the flag -Xss
+      assert(JavaThread::stack_size_at_create() > 0, "this should be set");
+      stack_size = JavaThread::stack_size_at_create();
+      break;
+    case os::compiler_thread:
+      if (CompilerThreadStackSize > 0) {
+        stack_size = (size_t)(CompilerThreadStackSize * K);
         break;
-      case os::compiler_thread:
-        if (CompilerThreadStackSize > 0) {
-          stack_size = (size_t)(CompilerThreadStackSize * K);
-          break;
-        } // else fall through:
-          // use VMThreadStackSize if CompilerThreadStackSize is not defined
-      case os::vm_thread:
-      case os::pgc_thread:
-      case os::cgc_thread:
-      case os::watcher_thread:
-        if (VMThreadStackSize > 0) stack_size = (size_t)(VMThreadStackSize * K);
-        break;
-      }
+      } // else fall through:
+        // use VMThreadStackSize if CompilerThreadStackSize is not defined
+    case os::vm_thread:
+    case os::pgc_thread:
+    case os::cgc_thread:
+    case os::watcher_thread:
+      if (VMThreadStackSize > 0) stack_size = (size_t)(VMThreadStackSize * K);
+      break;
     }
-
-    stack_size = MAX2(stack_size, os::Bsd::min_stack_allowed);
-    pthread_attr_setstacksize(&attr, stack_size);
-  } else {
-    // let pthread_create() pick the default value.
   }
 
+  stack_size = MAX2(stack_size, os::Bsd::min_stack_allowed);
+  pthread_attr_setstacksize(&attr, stack_size);
+
   ThreadState state;
 
   {
--- a/hotspot/src/os/bsd/vm/os_bsd.hpp	Mon Aug 03 11:12:57 2015 +0200
+++ b/hotspot/src/os/bsd/vm/os_bsd.hpp	Mon Aug 03 16:54:08 2015 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -75,8 +75,6 @@
   static julong physical_memory() { return _physical_memory; }
   static void initialize_system_info();
 
-  static bool supports_variable_stack_size();
-
   static void rebuild_cpu_to_node_map();
   static GrowableArray<int>* cpu_to_node()    { return _cpu_to_node; }
 
--- a/hotspot/src/os/linux/vm/os_linux.cpp	Mon Aug 03 11:12:57 2015 +0200
+++ b/hotspot/src/os/linux/vm/os_linux.cpp	Mon Aug 03 16:54:08 2015 -0400
@@ -711,38 +711,34 @@
   pthread_attr_setdetachstate(&attr, PTHREAD_CREATE_DETACHED);
 
   // stack size
-  if (os::Linux::supports_variable_stack_size()) {
-    // calculate stack size if it's not specified by caller
-    if (stack_size == 0) {
-      stack_size = os::Linux::default_stack_size(thr_type);
-
-      switch (thr_type) {
-      case os::java_thread:
-        // Java threads use ThreadStackSize which default value can be
-        // changed with the flag -Xss
-        assert(JavaThread::stack_size_at_create() > 0, "this should be set");
-        stack_size = JavaThread::stack_size_at_create();
+  // calculate stack size if it's not specified by caller
+  if (stack_size == 0) {
+    stack_size = os::Linux::default_stack_size(thr_type);
+
+    switch (thr_type) {
+    case os::java_thread:
+      // Java threads use ThreadStackSize which default value can be
+      // changed with the flag -Xss
+      assert(JavaThread::stack_size_at_create() > 0, "this should be set");
+      stack_size = JavaThread::stack_size_at_create();
+      break;
+    case os::compiler_thread:
+      if (CompilerThreadStackSize > 0) {
+        stack_size = (size_t)(CompilerThreadStackSize * K);
         break;
-      case os::compiler_thread:
-        if (CompilerThreadStackSize > 0) {
-          stack_size = (size_t)(CompilerThreadStackSize * K);
-          break;
-        } // else fall through:
-          // use VMThreadStackSize if CompilerThreadStackSize is not defined
-      case os::vm_thread:
-      case os::pgc_thread:
-      case os::cgc_thread:
-      case os::watcher_thread:
-        if (VMThreadStackSize > 0) stack_size = (size_t)(VMThreadStackSize * K);
-        break;
-      }
+      } // else fall through:
+        // use VMThreadStackSize if CompilerThreadStackSize is not defined
+    case os::vm_thread:
+    case os::pgc_thread:
+    case os::cgc_thread:
+    case os::watcher_thread:
+      if (VMThreadStackSize > 0) stack_size = (size_t)(VMThreadStackSize * K);
+      break;
     }
-
-    stack_size = MAX2(stack_size, os::Linux::min_stack_allowed);
-    pthread_attr_setstacksize(&attr, stack_size);
-  } else {
-    // let pthread_create() pick the default value.
-  }
+  }
+
+  stack_size = MAX2(stack_size, os::Linux::min_stack_allowed);
+  pthread_attr_setstacksize(&attr, stack_size);
 
   // glibc guard page
   pthread_attr_setguardsize(&attr, os::Linux::default_guard_size(thr_type));
--- a/hotspot/src/os/linux/vm/os_linux.hpp	Mon Aug 03 11:12:57 2015 +0200
+++ b/hotspot/src/os/linux/vm/os_linux.hpp	Mon Aug 03 16:54:08 2015 -0400
@@ -83,8 +83,6 @@
   static void set_glibc_version(const char *s)      { _glibc_version = s; }
   static void set_libpthread_version(const char *s) { _libpthread_version = s; }
 
-  static bool supports_variable_stack_size();
-
   static void rebuild_cpu_to_node_map();
   static GrowableArray<int>* cpu_to_node()    { return _cpu_to_node; }
 
--- a/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp	Mon Aug 03 11:12:57 2015 +0200
+++ b/hotspot/src/os_cpu/aix_ppc/vm/os_aix_ppc.cpp	Mon Aug 03 16:54:08 2015 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2012, 2014 SAP AG. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -489,10 +489,6 @@
 
 size_t os::Aix::min_stack_allowed = 128*K;
 
-// Aix is always in floating stack mode. The stack size for a new
-// thread can be set via pthread_attr_setstacksize().
-bool os::Aix::supports_variable_stack_size() { return true; }
-
 // return default stack size for thr_type
 size_t os::Aix::default_stack_size(os::ThreadType thr_type) {
   // default stack size (compiler thread needs larger stack)
--- a/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp	Mon Aug 03 11:12:57 2015 +0200
+++ b/hotspot/src/os_cpu/bsd_x86/vm/os_bsd_x86.cpp	Mon Aug 03 16:54:08 2015 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -780,9 +780,6 @@
 
 #ifdef AMD64
 size_t os::Bsd::min_stack_allowed  = 64 * K;
-
-// amd64: pthread on amd64 is always in floating stack mode
-bool os::Bsd::supports_variable_stack_size() {  return true; }
 #else
 size_t os::Bsd::min_stack_allowed  =  (48 DEBUG_ONLY(+4))*K;
 
@@ -790,7 +787,6 @@
 #define GET_GS() ({int gs; __asm__ volatile("movw %%gs, %w0":"=q"(gs)); gs&0xffff;})
 #endif
 
-bool os::Bsd::supports_variable_stack_size() { return true; }
 #endif // AMD64
 
 // return default stack size for thr_type
--- a/hotspot/src/os_cpu/bsd_zero/vm/os_bsd_zero.cpp	Mon Aug 03 11:12:57 2015 +0200
+++ b/hotspot/src/os_cpu/bsd_zero/vm/os_bsd_zero.cpp	Mon Aug 03 16:54:08 2015 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2007, 2008, 2009, 2010 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -290,10 +290,6 @@
 
 size_t os::Bsd::min_stack_allowed = 64 * K;
 
-bool os::Bsd::supports_variable_stack_size() {
-  return true;
-}
-
 size_t os::Bsd::default_stack_size(os::ThreadType thr_type) {
 #ifdef _LP64
   size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M);
--- a/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp	Mon Aug 03 11:12:57 2015 +0200
+++ b/hotspot/src/os_cpu/linux_aarch64/vm/os_linux_aarch64.cpp	Mon Aug 03 16:54:08 2015 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
  * Copyright (c) 2014, Red Hat Inc. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -496,9 +496,6 @@
 
 size_t os::Linux::min_stack_allowed  = 64 * K;
 
-// aarch64: pthread on aarch64 is always in floating stack mode
-bool os::Linux::supports_variable_stack_size() {  return true; }
-
 // return default stack size for thr_type
 size_t os::Linux::default_stack_size(os::ThreadType thr_type) {
   // default stack size (compiler thread needs larger stack)
--- a/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp	Mon Aug 03 11:12:57 2015 +0200
+++ b/hotspot/src/os_cpu/linux_ppc/vm/os_linux_ppc.cpp	Mon Aug 03 16:54:08 2015 -0400
@@ -467,8 +467,6 @@
 
 size_t os::Linux::min_stack_allowed = 128*K;
 
-bool os::Linux::supports_variable_stack_size() { return true; }
-
 // return default stack size for thr_type
 size_t os::Linux::default_stack_size(os::ThreadType thr_type) {
   // default stack size (compiler thread needs larger stack)
--- a/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp	Mon Aug 03 11:12:57 2015 +0200
+++ b/hotspot/src/os_cpu/linux_sparc/vm/os_linux_sparc.cpp	Mon Aug 03 16:54:08 2015 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -733,9 +733,6 @@
 
 size_t os::Linux::min_stack_allowed  = 128 * K;
 
-// pthread on Ubuntu is always in floating stack mode
-bool os::Linux::supports_variable_stack_size() {  return true; }
-
 // return default stack size for thr_type
 size_t os::Linux::default_stack_size(os::ThreadType thr_type) {
   // default stack size (compiler thread needs larger stack)
--- a/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp	Mon Aug 03 11:12:57 2015 +0200
+++ b/hotspot/src/os_cpu/linux_x86/vm/os_linux_x86.cpp	Mon Aug 03 16:54:08 2015 -0400
@@ -623,11 +623,6 @@
 size_t os::Linux::min_stack_allowed  =  (48 DEBUG_ONLY(+4))*K;
 #endif // AMD64
 
-// Test if pthread library can support variable thread stack size.
-bool os::Linux::supports_variable_stack_size() {
-  return true;
-}
-
 // return default stack size for thr_type
 size_t os::Linux::default_stack_size(os::ThreadType thr_type) {
   // default stack size (compiler thread needs larger stack)
--- a/hotspot/src/os_cpu/linux_zero/vm/os_linux_zero.cpp	Mon Aug 03 11:12:57 2015 +0200
+++ b/hotspot/src/os_cpu/linux_zero/vm/os_linux_zero.cpp	Mon Aug 03 16:54:08 2015 -0400
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved.
  * Copyright 2007, 2008, 2009, 2010 Red Hat, Inc.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
@@ -305,10 +305,6 @@
 
 size_t os::Linux::min_stack_allowed = 64 * K;
 
-bool os::Linux::supports_variable_stack_size() {
-  return true;
-}
-
 size_t os::Linux::default_stack_size(os::ThreadType thr_type) {
 #ifdef _LP64
   size_t s = (thr_type == os::compiler_thread ? 4 * M : 1 * M);