changeset 2232:881a0e4117fa

Rearrange
author Gary Benson <gbenson@redhat.com>
date Wed, 23 Feb 2011 12:47:59 +0000
parents 49d8bea3c3c8
children ee660518caf7
files src/cpu/zero/vm/cppInterpreter_zero.cpp src/cpu/zero/vm/cppInterpreter_zero.hpp
diffstat 2 files changed, 111 insertions(+), 99 deletions(-) [+]
line wrap: on
line diff
--- a/src/cpu/zero/vm/cppInterpreter_zero.cpp	Thu Feb 17 10:08:24 2011 +0000
+++ b/src/cpu/zero/vm/cppInterpreter_zero.cpp	Wed Feb 23 12:47:59 2011 +0000
@@ -610,6 +610,7 @@
   return 0;
 }
 
+// XXX put in bytecodeInterpreter_zero.hpp
 #define VMSLOTS_SLOT(offset)    ((intptr_t*)&vmslots[(offset)])
 #define VMSLOTS_OBJECT(offset)  ((oop)vmslots[(offset)])
 
@@ -650,112 +651,119 @@
   }
 
   // invokeExact
-  while (true) {
-    MethodHandleEntry *mhentry = java_dyn_MethodHandle::vmentry(method_handle);
-    MethodHandles::EntryKind entry_kind =
-      (MethodHandles::EntryKind) (((intptr_t) mhentry) & 0xffffffff);
+  process_method_handle(method_handle, THREAD);
+
+  // No deoptimized frames on the stack
+  return 0;
+}
+
+void CppInterpreter::process_method_handle(oop method_handle, TRAPS) {
+  JavaThread *thread = (JavaThread *) THREAD;
+  ZeroStack *stack = thread->zero_stack();
+  intptr_t *vmslots = stack->sp();
+
+  bool direct_to_method = false;
+
+  MethodHandleEntry *entry = java_dyn_MethodHandle::vmentry(method_handle);
+  MethodHandles::EntryKind entry_kind =
+    (MethodHandles::EntryKind) (((intptr_t) entry) & 0xffffffff);
+
+  switch (entry_kind) {
+  case MethodHandles::_invokestatic_mh:
+    direct_to_method = true;
+    break;
+
+  case MethodHandles::_invokespecial_mh:
+    {
+      oop receiver =
+        VMSLOTS_OBJECT(java_dyn_MethodHandle::vmslots(method_handle) - 1);
+      if (receiver == NULL) {
+        // XXX throw exception
+        Unimplemented();
+      }
+    }
+    direct_to_method = true;
+    break;
 
-    switch (entry_kind) {
-    case MethodHandles::_invokespecial_mh:
-      {
-        oop receiver =
-          VMSLOTS_OBJECT(java_dyn_MethodHandle::vmslots(method_handle) - 1);
-        if (receiver == NULL) {
+  case MethodHandles::_bound_ref_direct_mh:
+  case MethodHandles::_bound_int_direct_mh:
+  case MethodHandles::_bound_long_direct_mh:
+    direct_to_method = true;
+    // fall through
+  case MethodHandles::_bound_ref_mh:
+  case MethodHandles::_bound_int_mh:
+  case MethodHandles::_bound_long_mh:
+    {
+      BasicType arg_type  = T_ILLEGAL;
+      int       arg_mask  = MethodHandles::_INSERT_NO_MASK;
+      int       arg_slots = -1;
+      MethodHandles::get_ek_bound_mh_info(
+        entry_kind, arg_type, arg_mask, arg_slots);
+      
+      // Allocate the space
+      stack->overflow_check(arg_slots, THREAD);
+      if (HAS_PENDING_EXCEPTION)
+        break;
+      stack->alloc(arg_slots * wordSize);
+      vmslots = stack->sp();
+
+      // Shuffle everything up
+      int arg_slot = sun_dyn_BoundMethodHandle::vmargslot(method_handle);
+      for (int i = 0; i < arg_slot; i++)
+        SET_VMSLOTS_SLOT(VMSLOTS_SLOT(i + 1), i);
+
+      // Store bound argument into new stack slot
+      oop arg = sun_dyn_BoundMethodHandle::argument(method_handle);
+      if (arg_type == T_OBJECT) {
+        assert(arg_slots == 1, "should be");
+        SET_VMSLOTS_OBJECT(arg, arg_slot);
+      }
+      else {
+        Unimplemented();
+      }
+    }
+    break;
+
+  case MethodHandles::_adapter_retype_only:
+    break;
+
+  case MethodHandles::_adapter_retype_raw:
+    // XXX Unimplemented();
+    break;
+    
+  case MethodHandles::_adapter_check_cast:
+    {
+      int arg_slot = sun_dyn_AdapterMethodHandle::vmargslot(method_handle);
+      oop arg = VMSLOTS_OBJECT(arg_slot);
+      if (arg != NULL) {
+        klassOop objKlassOop = arg->klass();
+        klassOop klassOf = java_lang_Class::as_klassOop(
+          sun_dyn_AdapterMethodHandle::argument(method_handle));
+          
+        if (objKlassOop != klassOf &&
+            !objKlassOop->klass_part()->is_subtype_of(klassOf)) {
+          // XXX copy from bytecode interpreter
           Unimplemented();
         }
       }
-      // fall through
-    case MethodHandles::_invokestatic_mh:
-      {
-        method = (methodOop) java_dyn_MethodHandle::vmtarget(method_handle);
-        address entry_point = method->from_interpreted_entry();
-        Interpreter::invoke_method(method, entry_point, THREAD);
-        // NB all oops trashed!
-      }
-      return 0; // No deoptimized frames on the stack
-
-    //case MethodHandles::_bound_ref_mh:
-    //case MethodHandles::_bound_int_mh:
-    //case MethodHandles::_bound_long_mh:
-    case MethodHandles::_bound_ref_direct_mh:
-    //case MethodHandles::_bound_int_direct_mh:
-    //case MethodHandles::_bound_long_direct_mh:
-      {
-        bool direct_to_method =
-          (entry_kind >= MethodHandles::_bound_ref_direct_mh);
-        BasicType arg_type  = T_ILLEGAL;
-        int       arg_mask  = MethodHandles::_INSERT_NO_MASK;
-        int       arg_slots = -1;
-        MethodHandles::get_ek_bound_mh_info(
-          entry_kind, arg_type, arg_mask, arg_slots);
-
-        // Allocate the space
-        stack->overflow_check(arg_slots, THREAD);
-        if (HAS_PENDING_EXCEPTION)
-          break;
-        stack->alloc(arg_slots * wordSize);
-        vmslots = stack->sp();
-
-        // Shuffle everything up
-        int arg_slot = sun_dyn_BoundMethodHandle::vmargslot(method_handle);
-        for (int i = 0; i < arg_slot; i++)
-          SET_VMSLOTS_SLOT(VMSLOTS_SLOT(i + 1), i);
+    }
+    break;
 
-        // Store bound argument into new stack slot
-        oop arg = sun_dyn_BoundMethodHandle::argument(method_handle);
-        if (arg_type == T_OBJECT) {
-          assert(arg_slots == 1, "should be");
-          SET_VMSLOTS_OBJECT(arg, arg_slot);
-        }
-        else {
-          Unimplemented();
-        }
-        
-        // Continue
-        if (direct_to_method) {
-          method = (methodOop) java_dyn_MethodHandle::vmtarget(method_handle);
-          address entry_point = method->from_interpreted_entry();
-          Interpreter::invoke_method(method, entry_point, THREAD);
-          // NB all oops trashed!
-          return 0; // No deoptimized frames on the stack
-        }
-        else {
-          method_handle = java_dyn_MethodHandle::vmtarget(method_handle);
-        }
-      }
-      break;
-
-    case MethodHandles::_adapter_retype_only:
-    case MethodHandles::_adapter_retype_raw:
-      method_handle = java_dyn_MethodHandle::vmtarget(method_handle);
-      break;
-    
-    case MethodHandles::_adapter_check_cast:
-      {
-        int arg_slot = sun_dyn_AdapterMethodHandle::vmargslot(method_handle);
-        oop arg = VMSLOTS_OBJECT(arg_slot);
-        if (arg != NULL) {
-          klassOop objKlassOop = arg->klass();
-          klassOop klassOf = java_lang_Class::as_klassOop(
-            sun_dyn_AdapterMethodHandle::argument(method_handle));
-          
-          if (objKlassOop != klassOf &&
-              !objKlassOop->klass_part()->is_subtype_of(klassOf)) {
-            // XXX copy from bytecode interpreter
-            Unimplemented();
-          }
-        }
-      }
-      method_handle = java_dyn_MethodHandle::vmtarget(method_handle);
-      break;
-
-    default:
-      tty->print_cr("unhandled entry_kind %d", entry_kind); // XXX
-      ShouldNotReachHere();
-    }
+  default:
+    tty->print_cr("unhandled entry_kind %d", entry_kind); // XXX
+    ShouldNotReachHere();
   }
 
-  ShouldNotReachHere();  
+  oop vmtarget = java_dyn_MethodHandle::vmtarget(method_handle);
+  if (direct_to_method) {
+    methodOop method = (methodOop) vmtarget;
+    address entry_point = method->from_interpreted_entry();
+    Interpreter::invoke_method(method, entry_point, THREAD);
+  }
+  else {
+    process_method_handle(vmtarget, THREAD);
+  }
+  // NB all oops now trashed
 }
 
 InterpreterFrame *InterpreterFrame::build(const methodOop method, TRAPS) {
--- a/src/cpu/zero/vm/cppInterpreter_zero.hpp	Thu Feb 17 10:08:24 2011 +0000
+++ b/src/cpu/zero/vm/cppInterpreter_zero.hpp	Wed Feb 23 12:47:59 2011 +0000
@@ -43,6 +43,10 @@
   static void main_loop(int recurse, TRAPS);
 
  private:
+  // Main part of method_handle_entry
+  static void process_method_handle(oop method_handle, TRAPS);
+
+ private:
   // Fast result type determination
   static BasicType result_type_of(methodOop method);