changeset 56527:375659635d8c cont

imported patch fixes
author rpressler
date Wed, 21 Aug 2019 15:29:21 +0100
parents 0d56a52a5be8
children 9df945d6114b ac0156a4d2f4
files src/hotspot/cpu/x86/abstractInterpreter_x86.cpp src/hotspot/cpu/x86/continuation_x86.inline.hpp src/hotspot/cpu/x86/frame_x86.cpp src/hotspot/cpu/x86/frame_x86.inline.hpp src/hotspot/share/runtime/continuation.cpp src/hotspot/share/runtime/continuation.hpp
diffstat 6 files changed, 50 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/cpu/x86/abstractInterpreter_x86.cpp	Mon Aug 19 16:03:56 2019 +0100
+++ b/src/hotspot/cpu/x86/abstractInterpreter_x86.cpp	Wed Aug 21 15:29:21 2019 +0100
@@ -74,9 +74,7 @@
   int extra_locals = (method->max_locals() - method->size_of_parameters()) *
     Interpreter::stackElementWords;
 
-#ifdef ASSERT
   assert(caller->sp() == interpreter_frame->sender_sp(), "Frame not properly walkable");
-#endif
 
   interpreter_frame->interpreter_frame_set_method(method);
   // NOTE the difference in using sender_sp and
--- a/src/hotspot/cpu/x86/continuation_x86.inline.hpp	Mon Aug 19 16:03:56 2019 +0100
+++ b/src/hotspot/cpu/x86/continuation_x86.inline.hpp	Wed Aug 21 15:29:21 2019 +0100
@@ -633,8 +633,8 @@
   frame::update_map_with_saved_link(map, fp);
 }
 
-inline frame ContinuationHelper::frame_with(frame& f, intptr_t* sp, address pc) {
-  return frame(sp, f.unextended_sp(), f.fp(), pc, CodeCache::find_blob(pc));
+inline frame ContinuationHelper::frame_with(frame& f, intptr_t* sp, address pc, intptr_t* fp) {
+  return frame(sp, f.unextended_sp(), fp, pc, CodeCache::find_blob(pc));
 }
 
 inline void ContinuationHelper::set_last_vstack_frame(RegisterMap* map, const frame& hf) {
@@ -1106,6 +1106,7 @@
     st->print("\t'real' return_pc: "); os::print_location(st, *(intptr_t*)(f.real_fp() - 1));
     // st->print("\treturn_pc: "); os::print_location(st, *(intptr_t*)(fp + frame::return_addr_offset));
   }
+  st->print_cr("-------");
 }
 
 #endif // CPU_X86_CONTINUATION_X86_INLINE_HPP
--- a/src/hotspot/cpu/x86/frame_x86.cpp	Mon Aug 19 16:03:56 2019 +0100
+++ b/src/hotspot/cpu/x86/frame_x86.cpp	Wed Aug 21 15:29:21 2019 +0100
@@ -155,7 +155,7 @@
     }
 
     if (Continuation::is_return_barrier_entry(sender_pc)) {	
-      Continuation::fix_continuation_bottom_sender(thread, *this, &sender_pc, &sender_sp);	
+      Continuation::fix_continuation_bottom_sender(thread, *this, &sender_pc, &sender_sp, &saved_fp);	
     }
 
     // If the potential sender is the interpreter then we can do some more checking
@@ -434,6 +434,7 @@
 
   // This is the sp before any possible extension (adapter/locals).
   intptr_t* unextended_sp = interpreter_frame_sender_sp();
+  intptr_t* sender_fp = link();
 
 #if COMPILER2_OR_JVMCI
   if (map->update_map()) {
@@ -447,10 +448,10 @@
     if (map->walk_cont()) { // about to walk into an h-stack	
       return Continuation::top_frame(*this, map);	
     } else {
-      Continuation::fix_continuation_bottom_sender(map, *this, &sender_pc, NULL);
+      Continuation::fix_continuation_bottom_sender(map, *this, &sender_pc, &unextended_sp, &sender_fp);
     }
   }
-  return frame(sender_sp, unextended_sp, link(), sender_pc); // Continuation::fix_continuation_bottom_sender(*this, map, frame(sender_sp, unextended_sp, link(), sender_pc));
+  return frame(sender_sp, unextended_sp, sender_fp, sender_pc);
 }
 
 
--- a/src/hotspot/cpu/x86/frame_x86.inline.hpp	Mon Aug 19 16:03:56 2019 +0100
+++ b/src/hotspot/cpu/x86/frame_x86.inline.hpp	Wed Aug 21 15:29:21 2019 +0100
@@ -410,7 +410,7 @@
   // This is the saved value of EBP which may or may not really be an FP.
   // It is only an FP if the sender is an interpreter frame (or C1?).
   intptr_t** saved_fp_addr = (intptr_t**) (sender_sp - frame::sender_sp_offset);
-
+  intptr_t* sender_fp = *saved_fp_addr;
   if (map->update_map()) {
     // Tell GC to use argument oopmaps for some runtime stubs that need it.
     // For C1, the runtime stub might not have oop maps, so set this flag
@@ -438,17 +438,17 @@
     if (map->walk_cont()) { // about to walk into an h-stack 	
       return Continuation::top_frame(*this, map);	
     } else {
-      Continuation::fix_continuation_bottom_sender(map, *this, &sender_pc, &sender_sp);	
+      Continuation::fix_continuation_bottom_sender(map, *this, &sender_pc, &sender_sp, &sender_fp);	
     }
   }
 
   intptr_t* unextended_sp = sender_sp;
   CodeBlob* sender_cb = LOOKUP::find_blob(sender_pc);
   if (sender_cb != NULL) {
-    return frame(sender_sp, unextended_sp, *saved_fp_addr, sender_pc, sender_cb); // Continuation::fix_continuation_bottom_sender(*this, map, frame(sender_sp, unextended_sp, *saved_fp_addr, sender_pc, sender_cb));
+    return frame(sender_sp, unextended_sp, sender_fp, sender_pc, sender_cb);
   }
   // tty->print_cr(">>>> NO CB:"); print_on(tty);
-  return frame(sender_sp, unextended_sp, *saved_fp_addr, sender_pc); // Continuation::fix_continuation_bottom_sender(*this, map, frame(sender_sp, unextended_sp, *saved_fp_addr, sender_pc));
+  return frame(sender_sp, unextended_sp, sender_fp, sender_pc);
 }
 
 inline const ImmutableOopMap* frame::get_oop_map() const {
--- a/src/hotspot/share/runtime/continuation.cpp	Mon Aug 19 16:03:56 2019 +0100
+++ b/src/hotspot/share/runtime/continuation.cpp	Wed Aug 21 15:29:21 2019 +0100
@@ -1070,7 +1070,7 @@
   static void update_register_map(RegisterMap* map, const hframe& sender, const ContMirror& cont);
   static void update_register_map_from_last_vstack_frame(RegisterMap* map);
 
-  static inline frame frame_with(frame& f, intptr_t* sp, address pc);
+  static inline frame frame_with(frame& f, intptr_t* sp, address pc, intptr_t* fp);
   static inline frame last_frame(JavaThread* thread);
   static inline void to_frame_info(const frame& f, const frame& callee, FrameInfo* fi);
   template<typename FKind> static inline void to_frame_info_pd(const frame& f, const frame& callee, FrameInfo* fi);
@@ -2779,9 +2779,9 @@
 
       // This is part of the mechanism to pop stack-passed compiler arguments; see generate_cont_thaw's no_saved_sp label.
       // we use thread->_cont_frame->sp rather than the continuations themselves (which allow nesting) b/c it's faser and simpler.
-      // for that to work, we rely on the fact that parent continuation's have at lesat Continuation.run on the stack, which does not require stack arguments
+      // for that to work, we rely on the fact that parent continuation's have at least Continuation.run on the stack, which does not require stack arguments
       _cont.thread()->cont_frame()->sp = NULL;
-      _cont.set_entryPC(NULL);
+      // _cont.set_entryPC(NULL);
     } else {
       _cont.set_last_frame<mode>(hf); // _last_frame = hf;
       if (!FKind::interpreted && !hf.is_interpreted_frame()) {
@@ -3356,8 +3356,10 @@
 
 static oop get_continuation_for_frame(JavaThread* thread, intptr_t* const sp) {
   oop cont = get_continuation(thread);
-  while (cont != NULL && !is_sp_in_continuation(sp, cont))
+  while (cont != NULL && !is_sp_in_continuation(sp, cont)) {
     cont = java_lang_Continuation::parent(cont);
+  }
+  // tty->print_cr("get_continuation_for_frame cont: %p entrySP: %p", (oopDesc*)cont, cont != NULL ? java_lang_Continuation::entrySP(cont): NULL);
   return cont;
 }
 
@@ -3394,16 +3396,8 @@
   return pc_addr;
 }
 
-static address get_entry_pc_past_barrier(JavaThread* thread, const frame& f) {
-  oop cont = get_continuation_for_frame(thread, f.unextended_sp());
-  assert (cont != NULL, "");
-  address pc = java_lang_Continuation::entryPC(cont);
-  // log_develop_trace(jvmcont)("YEYEYEYEYEYEYEEYEY: " INTPTR_FORMAT, p2i(pc));
-  assert (pc != NULL, "");
-  return pc;
-}
-bool Continuation::fix_continuation_bottom_sender(RegisterMap* map, const frame& callee, address* sender_pc, intptr_t** sender_sp) {
-  bool res = fix_continuation_bottom_sender(map->thread(), callee, sender_pc, sender_sp);
+bool Continuation::fix_continuation_bottom_sender(RegisterMap* map, const frame& callee, address* sender_pc, intptr_t** sender_sp, intptr_t** sender_fp) {
+  bool res = fix_continuation_bottom_sender(map->thread(), callee, sender_pc, sender_sp, sender_fp);
   if (res && !callee.is_interpreted_frame()) {
     ContinuationHelper::set_last_vstack_frame(map, callee);
   } else {
@@ -3412,11 +3406,26 @@
   return res;
 }
 
-bool Continuation::fix_continuation_bottom_sender(JavaThread* thread, const frame& callee, address* sender_pc, intptr_t** sender_sp) {
+bool Continuation::fix_continuation_bottom_sender(JavaThread* thread, const frame& callee, address* sender_pc, intptr_t** sender_sp, intptr_t** sender_fp) {
+  // TODO : this code and its use sites probably need more work
   if (thread != NULL && is_return_barrier_entry(*sender_pc)) {
-    address new_pc = get_entry_pc_past_barrier(thread, callee);
+    log_develop_trace(jvmcont)("fix_continuation_bottom_sender callee:"); if (log_develop_is_enabled(Debug, jvmcont)) callee.print_value_on(tty, thread);
+    log_develop_trace(jvmcont)("fix_continuation_bottom_sender: sender_pc: " INTPTR_FORMAT " sender_sp: " INTPTR_FORMAT " sender_fp: " INTPTR_FORMAT, p2i(*sender_pc), p2i(*sender_sp), p2i(*sender_fp));
+      
+    oop cont = get_continuation_for_frame(thread, callee.is_interpreted_frame() ? callee.interpreter_frame_last_sp() : callee.unextended_sp());
+    assert (cont != NULL, "callee.unextended_sp(): " INTPTR_FORMAT, p2i(callee.unextended_sp()));
+    log_develop_trace(jvmcont)("fix_continuation_bottom_sender: continuation entrySP: " INTPTR_FORMAT " entryPC: " INTPTR_FORMAT " entryFP: " INTPTR_FORMAT, 
+      p2i(java_lang_Continuation::entrySP(cont)), p2i(java_lang_Continuation::entryPC(cont)), p2i(java_lang_Continuation::entryFP(cont)));
+
+    address new_pc = java_lang_Continuation::entryPC(cont);
     log_develop_trace(jvmcont)("fix_continuation_bottom_sender: sender_pc: " INTPTR_FORMAT " -> " INTPTR_FORMAT, p2i(*sender_pc), p2i(new_pc));
-    *sender_pc = new_pc; 
+    assert (new_pc != NULL, "");
+    *sender_pc = new_pc;
+
+    intptr_t* new_fp = java_lang_Continuation::entryFP(cont);
+    log_develop_trace(jvmcont)("fix_continuation_bottom_sender: sender_fp: " INTPTR_FORMAT " -> " INTPTR_FORMAT, p2i(*sender_fp), p2i(new_fp));
+    *sender_fp = new_fp;
+
     if (callee.is_compiled_frame() && !Interpreter::contains(*sender_pc)) {
       // The callee's stack arguments (part of the caller frame) are also thawed to the stack when using lazy-copy
       int argsize = callee.cb()->as_compiled_method()->method()->num_stack_arg_slots() * VMRegImpl::stack_slot_size;
@@ -3428,6 +3437,13 @@
     #endif
       log_develop_trace(jvmcont)("fix_continuation_bottom_sender: sender_sp: " INTPTR_FORMAT " -> " INTPTR_FORMAT, p2i(*sender_sp), p2i(*sender_sp + argsize));
       *sender_sp += argsize;
+    } else {
+      // intptr_t* new_sp = java_lang_Continuation::entrySP(cont);
+      // if (Interpreter::contains(*sender_pc)) {
+      //   new_sp -= 2;
+      // }
+      // log_develop_trace(jvmcont)("fix_continuation_bottom_sender: sender_sp: " INTPTR_FORMAT " -> " INTPTR_FORMAT, p2i(*sender_sp), p2i(new_sp));
+      // *sender_sp = new_sp;
     }
     return true;
   }
@@ -3446,8 +3462,9 @@
   if (map->thread() != NULL) {
     address   sender_pc = f.pc();
     intptr_t* sender_sp = f.sp();
-    fix_continuation_bottom_sender(map, callee, &sender_pc, &sender_sp);
-    return ContinuationHelper::frame_with(f, sender_sp, sender_pc);
+    intptr_t* sender_fp = f.fp();
+    fix_continuation_bottom_sender(map, callee, &sender_pc, &sender_sp, &sender_fp);
+    return ContinuationHelper::frame_with(f, sender_sp, sender_pc, sender_fp);
   }
 
   return f;
@@ -4550,7 +4567,7 @@
   int i = 0;
   for (frame f = thread->last_frame(); !f.is_entry_frame(); f = f.sender(&map)) {
 #ifndef PRODUCT
-    print_vframe(f, &map, st);
+    // print_vframe(f, &map, st);
     f.describe(values, i, &map);
 #else
     print_vframe(f, &map, st);
--- a/src/hotspot/share/runtime/continuation.hpp	Mon Aug 19 16:03:56 2019 +0100
+++ b/src/hotspot/share/runtime/continuation.hpp	Wed Aug 21 15:29:21 2019 +0100
@@ -90,8 +90,8 @@
   static bool is_return_barrier_entry(const address pc);
   static bool is_frame_in_continuation(const frame& f, oop cont);
   static bool is_frame_in_continuation(JavaThread* thread, const frame& f);
-  static bool fix_continuation_bottom_sender(JavaThread* thread, const frame& callee, address* sender_pc, intptr_t** sender_sp);
-  static bool fix_continuation_bottom_sender(RegisterMap* map, const frame& callee, address* sender_pc, intptr_t** sender_sp);
+  static bool fix_continuation_bottom_sender(JavaThread* thread, const frame& callee, address* sender_pc, intptr_t** sender_sp, intptr_t** sender_fp);
+  static bool fix_continuation_bottom_sender(RegisterMap* map, const frame& callee, address* sender_pc, intptr_t** sender_sp, intptr_t** sender_fp);
   static frame fix_continuation_bottom_sender(const frame& callee, RegisterMap* map, frame f);
   static address* get_continuation_entry_pc_for_sender(Thread* thread, const frame& f, address* pc_addr);
   static address get_top_return_pc_post_barrier(JavaThread* thread, address pc);