--- old/src/cpu/x86/vm/templateInterpreter_x86_64.cpp	2008-11-08 23:39:35.000000000 -0800
+++ new/src/cpu/x86/vm/templateInterpreter_x86_64.cpp	2008-11-08 23:39:35.000000000 -0800
@@ -176,7 +176,17 @@
 
 
 address TemplateInterpreterGenerator::generate_return_entry_for(TosState state,
-                                                                int step) {
+                                                                int step,
+                                                                bool unbox) {
+  TosState incoming_state = state;
+  if (InvokeDynamic) {
+    if (unbox) {
+      incoming_state = atos;
+    }
+    Unimplemented();
+  } else {
+    assert(!unbox, "old behavior");
+  }
 
   // amd64 doesn't need to do anything special about compiled returns
   // to the interpreter so the code that exists on x86 to place a sentinel
@@ -191,7 +201,14 @@
 
   __ restore_bcp();
   __ restore_locals();
-  __ get_cache_and_index_at_bcp(rbx, rcx, 1);
+
+  Label L_got_cache, L_giant_index;
+  if (InvokeDynamic) {
+    __ cmpb(Address(r13, 0), Bytecodes::_invokedynamic);
+    __ jcc(Assembler::equal, L_giant_index);
+  }
+  __ get_cache_and_index_at_bcp(rbx, rcx, 1, false);
+  __ bind(L_got_cache);
   __ movl(rbx, Address(rbx, rcx,
                        Address::times_8,
                        in_bytes(constantPoolCacheOopDesc::base_offset()) +
@@ -200,6 +217,12 @@
   if (TaggedStackInterpreter) __ shll(rbx, 1); // 2 slots per parameter.
   __ lea(rsp, Address(rsp, rbx, Address::times_8));
   __ dispatch_next(state, step);
+
+  if (InvokeDynamic) {
+    __ get_cache_and_index_at_bcp(rbx, rcx, 1, true);
+    __ jmp(L_got_cache);
+  }
+
   return entry;
 }
 
