changeset 51683:604f34b6c6cf cont

monitors detection
author rbackman
date Wed, 15 Aug 2018 08:56:44 +0200
parents 56b9d21a4543
children 89d1272f666a 259c05b297e4
files src/hotspot/share/c1/c1_Compilation.cpp src/hotspot/share/c1/c1_Compilation.hpp src/hotspot/share/c1/c1_GraphBuilder.cpp src/hotspot/share/ci/ciEnv.cpp src/hotspot/share/ci/ciEnv.hpp src/hotspot/share/code/compiledMethod.cpp src/hotspot/share/code/compiledMethod.hpp src/hotspot/share/opto/compile.cpp src/hotspot/share/opto/compile.hpp src/hotspot/share/opto/locknode.cpp src/hotspot/share/opto/parse1.cpp
diffstat 11 files changed, 25 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/src/hotspot/share/c1/c1_Compilation.cpp	Thu Sep 13 09:24:02 2018 +0200
+++ b/src/hotspot/share/c1/c1_Compilation.cpp	Wed Aug 15 08:56:44 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	Thu Sep 13 09:24:02 2018 +0200
+++ b/src/hotspot/share/c1/c1_Compilation.hpp	Wed Aug 15 08:56:44 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	Thu Sep 13 09:24:02 2018 +0200
+++ b/src/hotspot/share/c1/c1_GraphBuilder.cpp	Wed Aug 15 08:56:44 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	Thu Sep 13 09:24:02 2018 +0200
+++ b/src/hotspot/share/ci/ciEnv.cpp	Wed Aug 15 08:56:44 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	Thu Sep 13 09:24:02 2018 +0200
+++ b/src/hotspot/share/ci/ciEnv.hpp	Wed Aug 15 08:56:44 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/code/compiledMethod.cpp	Thu Sep 13 09:24:02 2018 +0200
+++ b/src/hotspot/share/code/compiledMethod.cpp	Wed Aug 15 08:56:44 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	Thu Sep 13 09:24:02 2018 +0200
+++ b/src/hotspot/share/code/compiledMethod.hpp	Wed Aug 15 08:56:44 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	Thu Sep 13 09:24:02 2018 +0200
+++ b/src/hotspot/share/opto/compile.cpp	Wed Aug 15 08:56:44 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	Thu Sep 13 09:24:02 2018 +0200
+++ b/src/hotspot/share/opto/compile.hpp	Wed Aug 15 08:56:44 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	Thu Sep 13 09:24:02 2018 +0200
+++ b/src/hotspot/share/opto/locknode.cpp	Wed Aug 15 08:56:44 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	Thu Sep 13 09:24:02 2018 +0200
+++ b/src/hotspot/share/opto/parse1.cpp	Wed Aug 15 08:56:44 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();