changeset 51684:89d1272f666a fibers

Merge
author rbackman
date Thu, 13 Sep 2018 09:44:32 +0200
parents 2b98c9e2add6 604f34b6c6cf
children bebc431994c3
files src/hotspot/share/classfile/vmSymbols.hpp src/java.base/share/classes/java/lang/Continuation.java
diffstat 15 files changed, 31 insertions(+), 26 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/c1/c1_Compilation.cpp	Tue Sep 11 19:49:30 2018 +0100
+++ b/src/hotspot/share/c1/c1_Compilation.cpp	Thu Sep 13 09:44:32 2018 +0200
@@ -421,6 +421,7 @@
     implicit_exception_table(),
     compiler(),
     has_unsafe_access(),
+    has_monitors(),
     SharedRuntime::is_wide_vector(max_vector_size())
   );
 }
@@ -558,6 +559,7 @@
 , _would_profile(false)
 , _has_method_handle_invokes(false)
 , _has_reserved_stack_access(method->has_reserved_stack_access())
+, _has_monitors(false)
 , _bailout_msg(NULL)
 , _exception_info_list(NULL)
 , _allocator(NULL)
--- a/src/hotspot/share/c1/c1_Compilation.hpp	Tue Sep 11 19:49:30 2018 +0100
+++ b/src/hotspot/share/c1/c1_Compilation.hpp	Thu Sep 13 09:44:32 2018 +0200
@@ -81,6 +81,7 @@
   bool               _would_profile;
   bool               _has_method_handle_invokes;  // True if this method has MethodHandle invokes.
   bool               _has_reserved_stack_access;
+  bool               _has_monitors; // Fastpath monitors detection for Continuations
   const char*        _bailout_msg;
   ExceptionInfoList* _exception_info_list;
   ExceptionHandlerTable _exception_handler_table;
@@ -136,6 +137,7 @@
   bool has_exception_handlers() const            { return _has_exception_handlers; }
   bool has_fpu_code() const                      { return _has_fpu_code; }
   bool has_unsafe_access() const                 { return _has_unsafe_access; }
+  bool has_monitors() const                      { return _has_monitors; }
   int max_vector_size() const                    { return 0; }
   ciMethod* method() const                       { return _method; }
   int osr_bci() const                            { return _osr_bci; }
@@ -163,6 +165,7 @@
   void set_has_unsafe_access(bool f)             { _has_unsafe_access = f; }
   void set_would_profile(bool f)                 { _would_profile = f; }
   void set_has_access_indexed(bool f)            { _has_access_indexed = f; }
+  void set_has_monitors(bool f)                  { _has_monitors = f; }
   // Add a set of exception handlers covering the given PC offset
   void add_exception_handlers_for_pco(int pco, XHandlers* exception_handlers);
   // Statistics gathering
--- a/src/hotspot/share/c1/c1_GraphBuilder.cpp	Tue Sep 11 19:49:30 2018 +0100
+++ b/src/hotspot/share/c1/c1_GraphBuilder.cpp	Thu Sep 13 09:44:32 2018 +0200
@@ -2227,6 +2227,7 @@
 void GraphBuilder::monitorenter(Value x, int bci) {
   // save state before locking in case of deoptimization after a NullPointerException
   ValueStack* state_before = copy_state_for_exception_with_bci(bci);
+  compilation()->set_has_monitors(true);
   append_with_bci(new MonitorEnter(x, state()->lock(x), state_before), bci);
   kill_all();
 }
--- a/src/hotspot/share/ci/ciEnv.cpp	Tue Sep 11 19:49:30 2018 +0100
+++ b/src/hotspot/share/ci/ciEnv.cpp	Thu Sep 13 09:44:32 2018 +0200
@@ -959,6 +959,7 @@
                             AbstractCompiler* compiler,
                             bool has_unsafe_access,
                             bool has_wide_vectors,
+                            bool has_monitors,
                             RTMState  rtm_state) {
   VM_ENTRY_MARK;
   nmethod* nm = NULL;
@@ -1042,6 +1043,7 @@
     if (nm != NULL) {
       nm->set_has_unsafe_access(has_unsafe_access);
       nm->set_has_wide_vectors(has_wide_vectors);
+      nm->set_has_monitors(has_monitors);
 #if INCLUDE_RTM_OPT
       nm->set_rtm_state(rtm_state);
 #endif
--- a/src/hotspot/share/ci/ciEnv.hpp	Tue Sep 11 19:49:30 2018 +0100
+++ b/src/hotspot/share/ci/ciEnv.hpp	Thu Sep 13 09:44:32 2018 +0200
@@ -370,6 +370,7 @@
                        AbstractCompiler*         compiler,
                        bool                      has_unsafe_access,
                        bool                      has_wide_vectors,
+                       bool                      has_monitors,
                        RTMState                  rtm_state = NoRTM);
 
 
--- a/src/hotspot/share/classfile/vmSymbols.hpp	Tue Sep 11 19:49:30 2018 +0100
+++ b/src/hotspot/share/classfile/vmSymbols.hpp	Thu Sep 13 09:44:32 2018 +0200
@@ -1088,7 +1088,8 @@
                                                                                                                         \
   /* java/lang/Continuation */                                                                                                 \
   do_class(java_lang_Continuation,                      "java/lang/Continuation")                                              \
-  do_alias(continuationEnter_signature,                           void_method_signature)                                       \
+  do_intrinsic(_Continuation_enter,  java_lang_Continuation,       enter_name,    continuationEnter_signature, F_R)            \
+    do_alias(continuationEnter_signature,                           void_method_signature)                                     \
   do_signature(continuationGetStacks_signature,                   "(III)V")                                                    \
   do_alias(continuationOnPinned_signature,                        int_void_signature)                                          \
   do_intrinsic(_Continuation_getSP,  java_lang_Continuation,       getSP_name,    continuationGetSP_signature, F_S)            \
--- a/src/hotspot/share/code/compiledMethod.cpp	Tue Sep 11 19:49:30 2018 +0100
+++ b/src/hotspot/share/code/compiledMethod.cpp	Thu Sep 13 09:44:32 2018 +0200
@@ -54,6 +54,7 @@
   _has_method_handle_invokes  = 0;
   _lazy_critical_native       = 0;
   _has_wide_vectors           = 0;
+  _has_monitors               = 0;
   _unloading_clock            = 0;
   _on_continuation_stack      = 0;
 }
--- a/src/hotspot/share/code/compiledMethod.hpp	Tue Sep 11 19:49:30 2018 +0100
+++ b/src/hotspot/share/code/compiledMethod.hpp	Thu Sep 13 09:44:32 2018 +0200
@@ -162,6 +162,7 @@
   unsigned int _has_method_handle_invokes:1; // Has this method MethodHandle invokes?
   unsigned int _lazy_critical_native:1;      // Lazy JNI critical native
   unsigned int _has_wide_vectors:1;          // Preserve wide vectors at safepoints
+  unsigned int _has_monitors:1;              // Fastpath monitor detection for continuations
 
   ContinuationProfiling _continuationProfiling;
   Method*   _method;
@@ -196,6 +197,9 @@
   bool  has_wide_vectors() const                  { return _has_wide_vectors; }
   void  set_has_wide_vectors(bool z)              { _has_wide_vectors = z; }
 
+  bool  has_monitors() const                      { return _has_monitors; }
+  void  set_has_monitors(bool z)                  { _has_monitors = z; }
+
   enum { not_installed = -1, // in construction, only the owner doing the construction is
                              // allowed to advance state
          in_use        = 0,  // executable nmethod
--- a/src/hotspot/share/opto/compile.cpp	Tue Sep 11 19:49:30 2018 +0100
+++ b/src/hotspot/share/opto/compile.cpp	Thu Sep 13 09:44:32 2018 +0200
@@ -946,6 +946,7 @@
                            compiler,
                            has_unsafe_access(),
                            SharedRuntime::is_wide_vector(max_vector_size()),
+                           has_monitors(),
                            rtm_state()
                            );
 
@@ -1133,6 +1134,7 @@
   set_do_method_data_update(false);
 
   set_do_vector_loop(false);
+  set_has_monitors(false);
 
   if (AllowVectorizeOnDemand) {
     if (has_method() && (_directive->VectorizeOption || _directive->VectorizeDebugOption)) {
--- a/src/hotspot/share/opto/compile.hpp	Tue Sep 11 19:49:30 2018 +0100
+++ b/src/hotspot/share/opto/compile.hpp	Thu Sep 13 09:44:32 2018 +0200
@@ -412,6 +412,7 @@
   bool                  _has_irreducible_loop;  // Found irreducible loops
   // JSR 292
   bool                  _has_method_handle_invokes; // True if this method has MethodHandle invokes.
+  bool                  _has_monitors;          // Metadata transfered to nmethod to enable Continuations lock-detection fastpath
   RTMState              _rtm_state;             // State of Restricted Transactional Memory usage
 
   // Compilation environment.
@@ -711,6 +712,8 @@
   bool          profile_rtm() const              { return _rtm_state == ProfileRTM; }
   uint              max_node_limit() const       { return (uint)_max_node_limit; }
   void          set_max_node_limit(uint n)       { _max_node_limit = n; }
+  bool              has_monitors() const         { return _has_monitors; }
+  void          set_has_monitors(bool v)         { _has_monitors = v; }
 
   // check the CompilerOracle for special behaviours for this compile
   bool          method_has_option(const char * option) {
--- a/src/hotspot/share/opto/locknode.cpp	Tue Sep 11 19:49:30 2018 +0100
+++ b/src/hotspot/share/opto/locknode.cpp	Thu Sep 13 09:44:32 2018 +0200
@@ -182,6 +182,8 @@
 void Parse::do_monitor_enter() {
   kill_dead_locals();
 
+  C->set_has_monitors(true);
+
   // Null check; get casted pointer.
   Node* obj = null_check(peek());
   // Check for locking null object
--- a/src/hotspot/share/opto/parse1.cpp	Tue Sep 11 19:49:30 2018 +0100
+++ b/src/hotspot/share/opto/parse1.cpp	Thu Sep 13 09:44:32 2018 +0200
@@ -422,6 +422,10 @@
     C->set_has_reserved_stack_access(true);
   }
 
+  if (parse_method->is_synchronized()) {
+    C->set_has_monitors(true);
+  }
+
   _tf = TypeFunc::make(method());
   _iter.reset_to_method(method());
   _flow = method()->get_flow_analysis();
--- a/src/hotspot/share/runtime/continuation.cpp	Tue Sep 11 19:49:30 2018 +0100
+++ b/src/hotspot/share/runtime/continuation.cpp	Thu Sep 13 09:44:32 2018 +0200
@@ -1842,9 +1842,6 @@
 
   HandleMark hm(thread);
 
-  // call here, when we know we can handle safepoints, to initialize Continuation::_entry_method
-  // potentially racy, but benign
-  Continuation::entry_method(thread);
   if (thread->has_pending_exception()) {
     fi->fp = NULL; fi->sp = NULL; fi->pc = NULL;
     log_trace(jvmcont)("=== end of freeze (fail 0)");
@@ -2381,28 +2378,13 @@
   thaw1(JavaThread::current(), fi, return_barrier);
 JRT_END
 
-Method* Continuation::_entry_method = NULL;
-
-Method* Continuation::entry_method(Thread* THREAD) {
-  if (_entry_method == NULL) {
-    CallInfo callinfo;
-    Klass* recvrKlass = SystemDictionary::resolve_or_null(vmSymbols::java_lang_Continuation(), THREAD); // SystemDictionary::Continuation_klass();
-    LinkInfo link_info(recvrKlass, vmSymbols::enter_name(), vmSymbols::continuationEnter_signature());
-    LinkResolver::resolve_special_call(callinfo, Handle(), link_info, THREAD);
-    methodHandle method = callinfo.selected_method();
-    assert(method.not_null(), "should have thrown exception");
-    _entry_method = method();
-  }
-  return _entry_method;
-}
-
 bool Continuation::is_continuation_entry_frame(const frame& f) {
   Method* m = frame_method(f);
   if (m == NULL)
     return false;
 
   // we can do this because the entry frame is never inlined
-  return m == _entry_method;
+  return m->intrinsic_id() == vmIntrinsics::_Continuation_enter;
 }
 // When walking the virtual stack, this method returns true
 // iff the frame is a thawed continuation frame whose
@@ -2620,8 +2602,8 @@
 }
 
 void Continuations::print_statistics() {
-  tty->print_cr("Continuations hit/miss %ld / %ld", _exploded_hit, _exploded_miss);
-  tty->print_cr("Continuations nmethod hit/miss %ld / %ld", _nmethod_hit, _nmethod_miss);
+  //tty->print_cr("Continuations hit/miss %ld / %ld", _exploded_hit, _exploded_miss);
+  //tty->print_cr("Continuations nmethod hit/miss %ld / %ld", _nmethod_hit, _nmethod_miss);
 }
 
 JVM_ENTRY(void, CONT_Clean(JNIEnv* env, jobject jcont)) {
--- a/src/hotspot/share/runtime/continuation.hpp	Tue Sep 11 19:49:30 2018 +0100
+++ b/src/hotspot/share/runtime/continuation.hpp	Thu Sep 13 09:44:32 2018 +0200
@@ -52,10 +52,6 @@
 };
 
 class Continuation : AllStatic {
-private:
-  static Method* _entry_method;
-  static Method* entry_method(Thread*);
-
 public:
   static int freeze(JavaThread* thread, FrameInfo* fi);
   static int prepare_thaw(FrameInfo* fi, bool return_barrier);
--- a/src/java.base/share/classes/java/lang/Continuation.java	Tue Sep 11 19:49:30 2018 +0100
+++ b/src/java.base/share/classes/java/lang/Continuation.java	Thu Sep 13 09:44:32 2018 +0200
@@ -197,6 +197,7 @@
     /**
      * TBD
      */
+    @HotSpotIntrinsicCandidate
     @DontInline
     private void enter() {
         // This method runs in the "entry frame".