changeset 53276:cf30790dc86d fibers

merge
author rpressler
date Mon, 07 Jan 2019 14:26:41 +0000
parents 125b9fdaf353 44dbe0605a43
children a5f73fb9f0c9
files src/hotspot/share/classfile/javaClasses.cpp src/hotspot/share/classfile/javaClasses.hpp src/hotspot/share/runtime/continuation.hpp
diffstat 8 files changed, 57 insertions(+), 30 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/classfile/javaClasses.cpp	Fri Jan 04 23:02:26 2019 +0000
+++ b/src/hotspot/share/classfile/javaClasses.cpp	Mon Jan 07 14:26:41 2019 +0000
@@ -2448,12 +2448,19 @@
       bci = stream.read_bci();
     } else {
       if (fr.is_first_frame()) break;
-      if (Continuation::is_scope_bottom(contScope(), fr, &map)) 
-        is_last = true;
-
+
+      assert (contScope.is_null() || cont != NULL, "must be");
       if (cont != NULL && Continuation::is_continuation_entry_frame(fr, &map)) {
+        oop scope = java_lang_Continuation::scope(cont);
+        if (contScope.not_null() && oopDesc::equals(scope, contScope())) {
+          assert (Continuation::is_frame_in_continuation(fr, cont), "must be"); // assert (Continuation::is_scope_bottom(contScope(), fr, &map), "must be");
+          is_last = true;
+        }
         cont = java_lang_Continuation::parent(cont);
+      } else {
+        assert (!Continuation::is_scope_bottom(contScope(), fr, &map), "");
       }
+
       address pc = fr.pc();
       if (fr.is_interpreted_frame()) {
         address bcp;
@@ -2734,8 +2741,8 @@
   assert((jushort)version == version, "version should be short");
   java_lang_StackFrameInfo::set_version(stackFrame(), (short)version);
 
-  oop contScopeName = (cont != NULL) ? java_lang_ContinuationScope::name(java_lang_Continuation::scope(cont)) : (oop)NULL;
-  java_lang_StackFrameInfo::set_contScopeName(stackFrame(), contScopeName);
+  oop contScope = cont != NULL ? java_lang_Continuation::scope(cont) : (oop)NULL;
+  java_lang_StackFrameInfo::set_contScope(stackFrame(), contScope);
 }
 
 void java_lang_StackFrameInfo::to_stack_trace_element(Handle stackFrame, Handle stack_trace_element, TRAPS) {
@@ -2744,7 +2751,8 @@
   Klass* clazz = java_lang_Class::as_Klass(java_lang_invoke_MemberName::clazz(mname()));
   InstanceKlass* holder = InstanceKlass::cast(clazz);
   Method* method = java_lang_StackFrameInfo::get_method(stackFrame, holder, CHECK);
-  Handle contScopeName(THREAD, stackFrame->obj_field(java_lang_StackFrameInfo::_contScopeName_offset));
+  oop contScope = stackFrame->obj_field(java_lang_StackFrameInfo::_contScope_offset);
+  Handle contScopeName(THREAD, contScope != (oop)NULL ? java_lang_ContinuationScope::name(contScope) : NULL);
 
   short version = stackFrame->short_field(_version_offset);
   short bci = stackFrame->short_field(_bci_offset);
@@ -2753,9 +2761,9 @@
 }
 
 #define STACKFRAMEINFO_FIELDS_DO(macro) \
-  macro(_memberName_offset,     k, "memberName",    object_signature, false); \
-  macro(_bci_offset,            k, "bci",           short_signature,  false); \
-  macro(_contScopeName_offset,  k, "contScopeName", string_signature, false)
+  macro(_memberName_offset,     k, "memberName", object_signature,            false); \
+  macro(_bci_offset,            k, "bci",        short_signature,             false); \
+  macro(_contScope_offset,      k, "contScope",  continuationscope_signature, false)
 
 void java_lang_StackFrameInfo::compute_offsets() {
   InstanceKlass* k = SystemDictionary::StackFrameInfo_klass();
@@ -4164,7 +4172,7 @@
 int java_lang_StackFrameInfo::_memberName_offset;
 int java_lang_StackFrameInfo::_bci_offset;
 int java_lang_StackFrameInfo::_version_offset;
-int java_lang_StackFrameInfo::_contScopeName_offset;
+int java_lang_StackFrameInfo::_contScope_offset;
 int java_lang_LiveStackFrameInfo::_monitors_offset;
 int java_lang_LiveStackFrameInfo::_locals_offset;
 int java_lang_LiveStackFrameInfo::_operands_offset;
@@ -4247,8 +4255,8 @@
   element->int_field_put(_bci_offset, value);
 }
 
-void java_lang_StackFrameInfo::set_contScopeName(oop element, oop value) {
-  element->obj_field_put(_contScopeName_offset, value);
+void java_lang_StackFrameInfo::set_contScope(oop element, oop value) {
+  element->obj_field_put(_contScope_offset, value);
 }
 
 void java_lang_LiveStackFrameInfo::set_monitors(oop element, oop value) {
--- a/src/hotspot/share/classfile/javaClasses.hpp	Fri Jan 04 23:02:26 2019 +0000
+++ b/src/hotspot/share/classfile/javaClasses.hpp	Mon Jan 07 14:26:41 2019 +0000
@@ -1509,7 +1509,7 @@
   static int _memberName_offset;
   static int _bci_offset;
   static int _version_offset;
-  static int _contScopeName_offset;
+  static int _contScope_offset;
 
   static Method* get_method(Handle stackFrame, InstanceKlass* holder, TRAPS);
 
@@ -1519,7 +1519,7 @@
   static void set_bci(oop info, int value);
 
   static void set_version(oop info, short value);
-  static void set_contScopeName(oop info, oop value);
+  static void set_contScope(oop info, oop value);
 
   static void compute_offsets();
   static void serialize_offsets(SerializeClosure* f) NOT_CDS_RETURN;
--- a/src/hotspot/share/prims/stackwalk.cpp	Fri Jan 04 23:02:26 2019 +0000
+++ b/src/hotspot/share/prims/stackwalk.cpp	Mon Jan 07 14:26:41 2019 +0000
@@ -117,16 +117,23 @@
 
 void JavaFrameStream::next() { _vfst.next(); }
 
-void LiveFrameStream::next() { 
+void LiveFrameStream::next() {
+  assert (_cont_scope.is_null() || _cont.not_null(), "must be");
   if (_cont.not_null() && Continuation::is_continuation_entry_frame(_jvf->fr(), _jvf->register_map())) {
-    *(_cont.raw_value()) = java_lang_Continuation::parent(_cont());
+    oop cont = _cont();
+    oop scope = java_lang_Continuation::scope(cont);
+
+    *(_cont.raw_value()) = java_lang_Continuation::parent(cont);
+    
+    if (_cont_scope.not_null() && oopDesc::equals(scope, _cont_scope())) {
+      assert (Continuation::is_frame_in_continuation(_jvf->fr(), cont), "must be"); // assert (Continuation::is_scope_bottom(_cont_scope(), _jvf->fr(), _jvf->register_map()), "must be");
+      _jvf = NULL;
+      return;
+    }
   }
+  assert (!Continuation::is_scope_bottom(_cont_scope(), _jvf->fr(), _jvf->register_map()), "");
   
-  if (Continuation::is_scope_bottom(_cont_scope(), _jvf->fr(), _jvf->register_map())) {
-    _jvf = NULL;
-  } else {
-    _jvf = _jvf->java_sender();
-  }
+  _jvf = _jvf->java_sender();
 }
 
 // Returns the BaseFrameStream for the current stack being traversed.
--- a/src/hotspot/share/runtime/continuation.cpp	Fri Jan 04 23:02:26 2019 +0000
+++ b/src/hotspot/share/runtime/continuation.cpp	Mon Jan 07 14:26:41 2019 +0000
@@ -3043,6 +3043,10 @@
 //   return f;
 // }
 
+bool Continuation::is_frame_in_continuation(const frame& f, oop cont) {
+  return java_lang_Continuation::entrySP(cont) < f.sp();
+}
+
 bool Continuation::is_frame_in_continuation(JavaThread* thread, const frame& f) {
   return find_continuation_for_frame(thread, f.sp()) != NULL;
 }
--- a/src/hotspot/share/runtime/continuation.hpp	Fri Jan 04 23:02:26 2019 +0000
+++ b/src/hotspot/share/runtime/continuation.hpp	Mon Jan 07 14:26:41 2019 +0000
@@ -62,6 +62,7 @@
   static bool is_continuation_entry_frame(const frame& f, const RegisterMap* map);
   static bool is_cont_bottom_frame(const frame& f);
   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 address fix_continuation_bottom_sender(const frame* callee, RegisterMap* map, address pc);
 
--- a/src/hotspot/share/runtime/vframe.inline.hpp	Fri Jan 04 23:02:26 2019 +0000
+++ b/src/hotspot/share/runtime/vframe.inline.hpp	Mon Jan 07 14:26:41 2019 +0000
@@ -51,13 +51,20 @@
 
   // handle general case
   do {
+    assert (_continuation_scope.is_null() || _cont.not_null(), "must be");
     if (_cont.not_null() && Continuation::is_continuation_entry_frame(_frame, &_reg_map)) {
+      oop cont = _cont();
+      oop scope = java_lang_Continuation::scope(cont);
+
       *(_cont.raw_value()) = java_lang_Continuation::parent(_cont());
+
+      if (_continuation_scope.not_null() && oopDesc::equals(scope, _continuation_scope())) {
+        Continuation::is_frame_in_continuation(_frame, cont); // assert (Continuation::is_scope_bottom(_continuation_scope(), _frame, &_reg_map), "must be");
+        _mode = at_end_mode;
+        break;
+      }
     }
-    if (Continuation::is_scope_bottom(_continuation_scope(), _frame, &_reg_map)) {
-      _mode = at_end_mode;
-      break;
-    }
+    assert (!Continuation::is_scope_bottom(_continuation_scope(), _frame, &_reg_map), "");
 
     _prev_frame = _frame;
     _frame = _frame.sender(&_reg_map);
--- a/src/java.base/share/classes/java/lang/StackFrameInfo.java	Fri Jan 04 23:02:26 2019 +0000
+++ b/src/java.base/share/classes/java/lang/StackFrameInfo.java	Mon Jan 07 14:26:41 2019 +0000
@@ -40,7 +40,7 @@
     private final byte flags;
     private Object memberName;
     private short bci;
-    private String contScopeName;
+    private ContinuationScope contScope;
 
     private volatile StackTraceElement ste;
 
@@ -68,8 +68,8 @@
         this.bci = bci;
     }
 
-    void setContinuationScopeName(String contScopeName) {
-        this.contScopeName = contScopeName;
+    void setContinuationScope(ContinuationScope contScope) {
+        this.contScope = contScope;
     }
     
     protected void clear() {
@@ -135,7 +135,7 @@
 
     @Override
     public java.lang.String getContinuationScopeName() {
-        return contScopeName;
+        return contScope.getName();
     }
 
     @Override
--- a/src/java.base/share/classes/java/lang/StackStreamFactory.java	Fri Jan 04 23:02:26 2019 +0000
+++ b/src/java.base/share/classes/java/lang/StackStreamFactory.java	Mon Jan 07 14:26:41 2019 +0000
@@ -566,7 +566,7 @@
             sfi.clear();
             sfi.setMemberName(enter);
             sfi.setBCI((short)-1);
-            sfi.setContinuationScopeName(continuation.getScope().getName());
+            sfi.setContinuationScope(continuation.getScope());
         }
 
         final Function<? super Stream<StackFrame>, ? extends T> function;  // callback