changeset in /hg/icedtea6: 2008-11-06 Gary Benson <gbenson at red...

Gary Benson gbenson at redhat.com
Thu Nov 6 03:22:59 PST 2008


changeset bbb37067ce04 in /hg/icedtea6
details: http://icedtea.classpath.org/hg/icedtea6?cmd=changeset;node=bbb37067ce04
description:
	2008-11-06  Gary Benson  <gbenson at redhat.com>

		* ports/hotspot/src/cpu/zero/vm/cppInterpreter_zero.hpp
		(CppInterpreter::stack_overflow_imminent): New method.

		* ports/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp
		(CppInterpreter::stack_overflow_imminent): New method.
		(CppInterpreter::normal_entry): Add stack overflow check.

diffstat:

3 files changed, 48 insertions(+), 1 deletion(-)
ChangeLog                                             |   12 +++++-
ports/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp |   33 +++++++++++++++++
ports/hotspot/src/cpu/zero/vm/cppInterpreter_zero.hpp |    4 ++

diffs (94 lines):

diff -r 6c81f8c8aab3 -r bbb37067ce04 ChangeLog
--- a/ChangeLog	Wed Nov 05 22:51:47 2008 -0500
+++ b/ChangeLog	Thu Nov 06 06:22:51 2008 -0500
@@ -1,3 +1,12 @@ 2008-11-05  Deepak Bhole  <dbhole at redhat
+2008-11-06  Gary Benson  <gbenson at redhat.com>
+
+	* ports/hotspot/src/cpu/zero/vm/cppInterpreter_zero.hpp
+	(CppInterpreter::stack_overflow_imminent): New method.
+
+	* ports/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp
+	(CppInterpreter::stack_overflow_imminent): New method.
+	(CppInterpreter::normal_entry): Add stack overflow check.
+
 2008-11-05  Deepak Bhole  <dbhole at redhat.com>
 
 	* patches/icedtea-copy-plugs.patch: Add netscape.* classes to rt.jar when
@@ -8,7 +17,8 @@ 2008-11-05  Deepak Bhole  <dbhole at redhat
 	* rt/net/sourceforge/jnlp/runtime/JNLPClassLoader.java: Correct
 	indentation from last commit, remove debug output.
 
-2008-11-05  Gary Benson  <gbenson at redhat.com>
+2008-11-05  Andrew Haley  <aph at redhat.com>
+	    Gary Benson  <gbenson at redhat.com>
 
 	* contrib/mixtec-hacks.patch: new file.
 
diff -r 6c81f8c8aab3 -r bbb37067ce04 ports/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp
--- a/ports/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp	Wed Nov 05 22:51:47 2008 -0500
+++ b/ports/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp	Thu Nov 06 06:22:51 2008 -0500
@@ -77,6 +77,13 @@ void CppInterpreter::main_loop(int recur
 
   intptr_t *result = NULL;
   int result_slots = 0;
+
+  // Check we're not about to run out of stack
+  if (stack_overflow_imminent(thread)) {
+    CALL_VM_NOCHECK(InterpreterRuntime::throw_StackOverflowError(thread));
+    goto unwind_and_return;
+  }
+
   while (true) {
     // We can set up the frame anchor with everything we want at
     // this point as we are thread_in_Java and no safepoints can
@@ -150,6 +157,8 @@ void CppInterpreter::main_loop(int recur
       break;
     }
   }
+
+ unwind_and_return:
 
   // Unwind the current frame
   thread->pop_zero_frame();
@@ -534,6 +543,30 @@ void CppInterpreter::empty_entry(methodO
 
   // Pop our parameters
   stack->set_sp(stack->sp() + method->size_of_parameters());
+}
+
+bool CppInterpreter::stack_overflow_imminent(JavaThread *thread)
+{
+  // How is the ABI stack?
+  address stack_top = thread->stack_base() - thread->stack_size();
+  int free_stack = os::current_stack_pointer() - stack_top;
+  if (free_stack < StackShadowPages * os::vm_page_size()) {
+    return true;
+  }
+
+  // How is the Zero stack?
+  // Throwing a StackOverflowError involves a VM call, which means
+  // we need a frame on the stack.  We should be checking here to
+  // ensure that methods we call have enough room to install the
+  // largest possible frame, but that's more than twice the size
+  // of the entire Zero stack we get by default, so we just check
+  // we have *some* space instead...
+  free_stack = thread->zero_stack()->available_words() * wordSize;
+  if (free_stack < StackShadowPages * os::vm_page_size()) {
+    return true;
+  }
+  
+  return false;
 }
 
 InterpreterFrame *InterpreterFrame::build(ZeroStack*       stack,
diff -r 6c81f8c8aab3 -r bbb37067ce04 ports/hotspot/src/cpu/zero/vm/cppInterpreter_zero.hpp
--- a/ports/hotspot/src/cpu/zero/vm/cppInterpreter_zero.hpp	Wed Nov 05 22:51:47 2008 -0500
+++ b/ports/hotspot/src/cpu/zero/vm/cppInterpreter_zero.hpp	Thu Nov 06 06:22:51 2008 -0500
@@ -38,3 +38,7 @@
  public:
   // Main loop of normal_entry
   static void main_loop(int recurse, TRAPS);
+
+ private:
+  // Stack overflow checks
+  static bool stack_overflow_imminent(JavaThread *thread);



More information about the distro-pkg-dev mailing list