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

Gary Benson gbenson at redhat.com
Thu Nov 6 03:53:18 PST 2008


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

		* ports/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp
		(CppInterpreter::native_entry): Add stack overflow check.

diffstat:

2 files changed, 80 insertions(+), 59 deletions(-)
ChangeLog                                             |    5 
ports/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp |  134 +++++++++--------

diffs (189 lines):

diff -r bbb37067ce04 -r a261142d4db9 ChangeLog
--- a/ChangeLog	Thu Nov 06 06:22:51 2008 -0500
+++ b/ChangeLog	Thu Nov 06 06:53:14 2008 -0500
@@ -1,3 +1,8 @@ 2008-11-06  Gary Benson  <gbenson at redhat
+2008-11-06  Gary Benson  <gbenson at redhat.com>
+
+	* ports/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp
+	(CppInterpreter::native_entry): Add stack overflow check.
+
 2008-11-06  Gary Benson  <gbenson at redhat.com>
 
 	* ports/hotspot/src/cpu/zero/vm/cppInterpreter_zero.hpp
diff -r bbb37067ce04 -r a261142d4db9 ports/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp
--- a/ports/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp	Thu Nov 06 06:22:51 2008 -0500
+++ b/ports/hotspot/src/cpu/zero/vm/cppInterpreter_zero.cpp	Thu Nov 06 06:53:14 2008 -0500
@@ -173,6 +173,9 @@ void CppInterpreter::main_loop(int recur
 
 void CppInterpreter::native_entry(methodOop method, intptr_t UNUSED, TRAPS)
 {
+  // Make sure method is native and not abstract
+  assert(method->is_native() && !method->is_abstract(), "should be");
+
   JavaThread *thread = (JavaThread *) THREAD;
   ZeroStack *stack = thread->zero_stack();
 
@@ -182,11 +185,15 @@ void CppInterpreter::native_entry(method
   interpreterState istate = frame->interpreter_state();
   intptr_t *locals = istate->locals();
 
-  // Make sure method is native and not abstract
-  assert(method->is_native() && !method->is_abstract(), "should be");
+  // 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;
+  }
 
   // Lock if necessary
-  BasicObjectLock *monitor = NULL;
+  BasicObjectLock *monitor;
+  monitor = NULL;
   if (method->is_synchronized()) {
     monitor = (BasicObjectLock*) istate->stack_base();
     oop lockee = monitor->obj();
@@ -208,72 +215,79 @@ void CppInterpreter::native_entry(method
   }
 
   // Get the signature handler
-  address handlerAddr = method->signature_handler();
-  if (handlerAddr == NULL) {
-    CALL_VM_NOCHECK(InterpreterRuntime::prepare_native_call(thread, method));
-    if (HAS_PENDING_EXCEPTION) {
-      thread->pop_zero_frame();
-      return;
-    }
-    handlerAddr = method->signature_handler();
-    assert(handlerAddr != NULL, "eh?");
-  }
-  if (handlerAddr == (address) InterpreterRuntime::slow_signature_handler) {
-    CALL_VM_NOCHECK(handlerAddr =
-      InterpreterRuntime::slow_signature_handler(thread, method, NULL, NULL));
-    if (HAS_PENDING_EXCEPTION) {
-      thread->pop_zero_frame();
-      return;
-    }
-  }
-  InterpreterRuntime::SignatureHandler *handler =
-    InterpreterRuntime::SignatureHandler::from_handlerAddr(handlerAddr);
+  InterpreterRuntime::SignatureHandler *handler;
+  {
+    address handlerAddr = method->signature_handler();
+    if (handlerAddr == NULL) {
+      CALL_VM_NOCHECK(InterpreterRuntime::prepare_native_call(thread, method));
+      if (HAS_PENDING_EXCEPTION) {
+        thread->pop_zero_frame();
+        return;
+      }
+      handlerAddr = method->signature_handler();
+      assert(handlerAddr != NULL, "eh?");
+    }
+    if (handlerAddr == (address) InterpreterRuntime::slow_signature_handler) {
+      CALL_VM_NOCHECK(handlerAddr =
+        InterpreterRuntime::slow_signature_handler(thread, method, NULL,NULL));
+      if (HAS_PENDING_EXCEPTION) {
+        thread->pop_zero_frame();
+        return;
+      }
+    }
+    handler = \
+      InterpreterRuntime::SignatureHandler::from_handlerAddr(handlerAddr);
+  }
 
   // Get the native function entry point
-  address function = method->native_function();
+  address function;
+  function = method->native_function();
   assert(function != NULL, "should be set if signature handler is");
 
   // Build the argument list
   if (handler->argument_count() * 2 > stack->available_words()) {
     Unimplemented();
   }
-  void **arguments =
-    (void **) stack->alloc(handler->argument_count() * sizeof(void **));
-  void **dst = arguments;
-
-  void *env = thread->jni_environment();
-  *(dst++) = &env;
-
-  void *mirror = NULL;
-  if (method->is_static()) {
-    istate->set_oop_temp(
-      method->constants()->pool_holder()->klass_part()->java_mirror());
-    mirror = istate->oop_temp_addr();
-    *(dst++) = &mirror;
-  }
-
-  intptr_t *src = locals;
-  for (int i = dst - arguments; i < handler->argument_count(); i++) {
-    ffi_type *type = handler->argument_type(i);
-    if (type == &ffi_type_pointer) {
-      if (*src) {
-        stack->push((intptr_t) src);
-        *(dst++) = stack->sp();
+  void **arguments;
+  {
+    arguments =
+      (void **) stack->alloc(handler->argument_count() * sizeof(void **));
+    void **dst = arguments;
+  
+    void *env = thread->jni_environment();
+    *(dst++) = &env;
+  
+    void *mirror = NULL;
+    if (method->is_static()) {
+      istate->set_oop_temp(
+        method->constants()->pool_holder()->klass_part()->java_mirror());
+      mirror = istate->oop_temp_addr();
+      *(dst++) = &mirror;
+    }
+  
+    intptr_t *src = locals;
+    for (int i = dst - arguments; i < handler->argument_count(); i++) {
+      ffi_type *type = handler->argument_type(i);
+      if (type == &ffi_type_pointer) {
+        if (*src) {
+          stack->push((intptr_t) src);
+          *(dst++) = stack->sp();
+        }
+        else {
+          *(dst++) = src;
+        }
+        src--;
+      }
+      else if (type->size == 4) {
+        *(dst++) = src--;
+      }
+      else if (type->size == 8) {
+        src--;
+        *(dst++) = src--;
       }
       else {
-        *(dst++) = src;
-      }
-      src--;
-    }
-    else if (type->size == 4) {
-      *(dst++) = src--;
-    }
-    else if (type->size == 8) {
-      src--;
-      *(dst++) = src--;
-    }
-    else {
-      ShouldNotReachHere();
+        ShouldNotReachHere();
+      }
     }
   }
 
@@ -326,6 +340,8 @@ void CppInterpreter::native_entry(method
       }
     }
   }
+
+ unwind_and_return:
 
   // Unwind the current activation
   thread->pop_zero_frame();



More information about the distro-pkg-dev mailing list