changeset 2273:887b37920ad5

Unwind the stack more forcibly
author Gary Benson <gbenson@redhat.com>
date Mon, 14 Mar 2011 10:37:07 +0000
parents 4a1bc9de9c19
children 40186460e5b8
files src/cpu/zero/vm/cppInterpreter_zero.cpp
diffstat 1 files changed, 17 insertions(+), 19 deletions(-) [+]
line wrap: on
line diff
--- a/src/cpu/zero/vm/cppInterpreter_zero.cpp	Fri Mar 11 11:04:08 2011 +0000
+++ b/src/cpu/zero/vm/cppInterpreter_zero.cpp	Mon Mar 14 10:37:07 2011 +0000
@@ -614,16 +614,14 @@
                                         intptr_t UNUSED, TRAPS) {
   JavaThread *thread = (JavaThread *) THREAD;
   ZeroStack *stack = thread->zero_stack();
+  intptr_t *entry_sp = stack->sp();
 #ifdef ASSERT
-  /* XXX {
-    ResourceMark rm;
-    tty->print_cr(">>> %s", method->name_and_sig_as_C_string());
-  } XXX */
   int initial_frame_size = top_frame_size_words(thread);
+#endif // ASSERT
   int argument_slots = method->size_of_parameters();
-#endif // ASSERT
+  intptr_t *unwind_sp = entry_sp + argument_slots;
   int result_slots = type2size[result_type_of(method)];
-  intptr_t *vmslots = stack->sp();
+  intptr_t *vmslots = entry_sp;
   
   // Find the MethodType
   address p = (address) method;
@@ -637,7 +635,7 @@
   int num_vmslots = java_dyn_MethodTypeForm::vmslots(methodtype_form);
   oop method_handle = VMSLOTS_OBJECT(num_vmslots);
 
-  // Compare the method type against that of the receiver
+  // InvokeGeneric requires some extra shuffling
   oop mhtype = java_dyn_MethodHandle::type(method_handle);
   bool is_exact = mhtype == method_type;
   if (!is_exact) {
@@ -647,7 +645,7 @@
           thread, method_type, mhtype));
       // NB all oops trashed!
       assert(HAS_PENDING_EXCEPTION, "should do");
-      stack->set_sp(stack->sp() + num_vmslots + 1);
+      stack->set_sp(unwind_sp);
       return 0; // No deoptimized frames on the stack
     }
     assert(method->intrinsic_id() == vmIntrinsics::_invokeGeneric, "should be");
@@ -673,21 +671,21 @@
     SET_VMSLOTS_OBJECT(method_handle, num_vmslots - 1);
   }
 
-  // invokeExact
+  // Start processing
   process_method_handle(method_handle, THREAD);
+
+  // Remove any extra stuff from the stack
   if (HAS_PENDING_EXCEPTION)
     result_slots = 0;
+  unwind_sp -= result_slots;
 
-  // Pop the method handle arguments, which inconveniently will
-  // be underneath the result being returned if one is present
-  intptr_t result[2];
-  for (int i = 0; i < result_slots; i++)
-    result[i] = stack->pop();
-  if (!is_exact)
-    stack->pop();
-  stack->pop(); 
-  for (int i = result_slots - 1; i >= 0; i--)
-    stack->push(result[i]);
+  intptr_t *result = stack->sp();
+  assert(result <= unwind_sp, "something popped too much!");
+  if (result != unwind_sp) {
+    for (int i = result_slots - 1; i >= 0; i--)
+      unwind_sp[i] = result[i];
+    stack->set_sp(unwind_sp);
+  }
 
 #ifdef ASSERT
   // XXXtty->print_cr("<<<");