diff -r adcc814f792a src/share/vm/prims/whitebox.cpp
--- a/src/share/vm/prims/whitebox.cpp	Fri Dec 20 08:43:18 2013 -0800
+++ b/src/share/vm/prims/whitebox.cpp	Tue Jan 28 22:01:16 2014 +0400
@@ -33,9 +33,11 @@
 #include "prims/whitebox.hpp"
 #include "prims/wbtestmethods/parserTests.hpp"
 
+#include "runtime/thread.hpp"
 #include "runtime/arguments.hpp"
 #include "runtime/interfaceSupport.hpp"
 #include "runtime/os.hpp"
+
 #include "utilities/debug.hpp"
 #include "utilities/macros.hpp"
 #include "utilities/exceptions.hpp"
@@ -489,6 +491,15 @@
   c = *p;
 WB_END
 
+WB_ENTRY(jlong, WB_GetThreadFullStackSize(JNIEnv* env, jobject o))
+  return (jlong) Thread::current()->stack_size();
+WB_END
+
+WB_ENTRY(jlong, WB_GetThreadRemainingStackSize(JNIEnv* env, jobject o))
+  JavaThread* t = JavaThread::current();
+  return (jlong) ( (ptrdiff_t) t->stack_available(os::current_stack_pointer()) - StackShadowPages * os::vm_page_size() );
+WB_END
+
 //Some convenience methods to deal with objects from java
 int WhiteBox::offset_for_field(const char* field_name, oop object,
     Symbol* signature_symbol) {
@@ -600,6 +611,8 @@
   {CC"isInStringTable",   CC"(Ljava/lang/String;)Z",  (void*)&WB_IsInStringTable  },
   {CC"fullGC",   CC"()V",                             (void*)&WB_FullGC },
   {CC"readReservedMemory", CC"()V",                   (void*)&WB_ReadReservedMemory },
+  {CC"getThreadFullStackSize", CC"()J",               (void*)&WB_GetThreadFullStackSize },
+  {CC"getThreadRemainingStackSize", CC"()J",          (void*)&WB_GetThreadRemainingStackSize },
 };
 
 #undef CC
diff -r adcc814f792a test/TEST.groups
--- a/test/TEST.groups	Fri Dec 20 08:43:18 2013 -0800
+++ b/test/TEST.groups	Tue Jan 28 22:01:16 2014 +0400
@@ -131,7 +131,8 @@
   gc/arguments/TestG1HeapRegionSize.java \
   gc/metaspace/TestMetaspaceMemoryPool.java \
   runtime/InternalApi/ThreadCpuTimesDeadlock.java \
-  serviceability/threads/TestFalseDeadLock.java
+  serviceability/threads/TestFalseDeadLock.java \
+  testlibrary_tests/whitebox/WBStackSize.java
 
 # Compact 2 adds full VM tests
 compact2 = \
diff -r adcc814f792a test/testlibrary/whitebox/sun/hotspot/WhiteBox.java
--- a/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java	Fri Dec 20 08:43:18 2013 -0800
+++ b/test/testlibrary/whitebox/sun/hotspot/WhiteBox.java	Tue Jan 28 22:01:16 2014 +0400
@@ -149,5 +149,7 @@
   public native int stressVirtualSpaceResize(long reservedSpaceSize, long magnitude, long iterations);
   public native void runMemoryUnitTests();
   public native void readFromNoaccessArea();
+  public native long getThreadFullStackSize();
+  public native long getThreadRemainingStackSize();
 
 }
diff -r adcc814f792a test/testlibrary_tests/whitebox/WBStackSize.java
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/test/testlibrary_tests/whitebox/WBStackSize.java	Tue Jan 28 22:01:16 2014 +0400
@@ -0,0 +1,89 @@
+/*
+ * Copyright (c) 2014, 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
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+/*
+ * @test WBStackSize
+ * @summary verify that whitebox functions getThreadFullStackSize() and getThreadRemainingStackSize are working
+ * @library /testlibrary /testlibrary/whitebox
+ * @build WBStackSize
+ * @run main ClassFileInstaller sun.hotspot.WhiteBox
+ * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+WhiteBoxAPI -Xss512k WBStackSize 
+ */
+
+import com.sun.management.HotSpotDiagnosticMXBean;
+import sun.hotspot.WhiteBox;
+
+public class WBStackSize {
+
+    static WhiteBox wb = WhiteBox.getWhiteBox();
+
+    static class SOE extends RuntimeException {
+        long rss;
+        SOE(long rss) { this.rss = rss; }
+    }
+
+    static void recursive(long n) {
+        try {
+            recursive(n + 1);
+        } catch ( StackOverflowError e ) {
+            throw new SOE(wb.getThreadRemainingStackSize());
+        }
+    }
+
+    public static void main(String... args) {
+        HotSpotDiagnosticMXBean bean = sun.management.ManagementFactoryHelper.getDiagnosticMXBean();
+        long sso = Long.valueOf(bean.getVMOption("ThreadStackSize").getValue()) * 1024;
+
+        System.out.println("ThreadStackSize VM option = " + sso);
+
+        long fss = wb.getThreadFullStackSize();
+        long rss = wb.getThreadRemainingStackSize();
+
+        System.out.print("Full stack size " + fss + ": ");
+
+        // Test has -Xss512k option
+        if ( fss < sso * 0.8 || fss > sso * 1.2 ) {
+            throw new RuntimeException("getThreadFullStackSize value [" + fss + "] should be within 80%..120% of the value returned by HotSpotDiagnosticMXBean");
+        } else {
+            System.out.println("OK");
+        }
+
+        System.out.print("Remaining stack size " + rss + ": ");
+        if ( fss < sso * 0.8 || fss > sso * 1.2 ) {
+            throw new RuntimeException("getThreadRemainingStackSize value [" + fss + "] should be within 80%..120% of the value returned by HotSpotDiagnosticMXBean");
+        } else {
+            System.out.println("OK");
+        }
+
+        try {
+            recursive(0);
+        } catch ( SOE e ) {
+            System.out.print("Remaining stack size on stack overflow " + e.rss + ": ");
+            if ( e.rss > 8 * 1024 ) {
+                throw new RuntimeException("Remaining stack size when StackOverflowError is caught should be at least 8K");
+            } else {
+                System.out.print("OK");
+            }
+        }
+    }
+}
