hotspot/src/share/vm/runtime/thread.hpp
changeset 46643 cb5f289ba033
parent 46625 edefffab74e2
child 46644 a5813fb66270
equal deleted inserted replaced
46641:f64dc604ef8d 46643:cb5f289ba033
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2016, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2017, Oracle and/or its affiliates. All rights reserved.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
     4  *
     4  *
     5  * This code is free software; you can redistribute it and/or modify it
     5  * This code is free software; you can redistribute it and/or modify it
     6  * under the terms of the GNU General Public License version 2 only, as
     6  * under the terms of the GNU General Public License version 2 only, as
     7  * published by the Free Software Foundation.
     7  * published by the Free Software Foundation.
   200     _external_suspend       = 0x20000000U, // thread is asked to self suspend
   200     _external_suspend       = 0x20000000U, // thread is asked to self suspend
   201     _ext_suspended          = 0x40000000U, // thread has self-suspended
   201     _ext_suspended          = 0x40000000U, // thread has self-suspended
   202     _deopt_suspend          = 0x10000000U, // thread needs to self suspend for deopt
   202     _deopt_suspend          = 0x10000000U, // thread needs to self suspend for deopt
   203 
   203 
   204     _has_async_exception    = 0x00000001U, // there is a pending async exception
   204     _has_async_exception    = 0x00000001U, // there is a pending async exception
   205     _critical_native_unlock = 0x00000002U  // Must call back to unlock JNI critical lock
   205     _critical_native_unlock = 0x00000002U, // Must call back to unlock JNI critical lock
       
   206 
       
   207     _trace_flag             = 0x00000004U  // call tracing backend
   206   };
   208   };
   207 
   209 
   208   // various suspension related flags - atomically updated
   210   // various suspension related flags - atomically updated
   209   // overloaded for async exception checking in check_special_condition_for_native_trans.
   211   // overloaded for async exception checking in check_special_condition_for_native_trans.
   210   volatile uint32_t _suspend_flags;
   212   volatile uint32_t _suspend_flags;
   380   bool do_critical_native_unlock() const { return (_suspend_flags & _critical_native_unlock) != 0; }
   382   bool do_critical_native_unlock() const { return (_suspend_flags & _critical_native_unlock) != 0; }
   381 
   383 
   382   inline void set_critical_native_unlock();
   384   inline void set_critical_native_unlock();
   383   inline void clear_critical_native_unlock();
   385   inline void clear_critical_native_unlock();
   384 
   386 
       
   387   inline void set_trace_flag();
       
   388   inline void clear_trace_flag();
       
   389 
   385   // Support for Unhandled Oop detection
   390   // Support for Unhandled Oop detection
   386   // Add the field for both, fastdebug and debug, builds to keep
   391   // Add the field for both, fastdebug and debug, builds to keep
   387   // Thread's fields layout the same.
   392   // Thread's fields layout the same.
   388   // Note: CHECK_UNHANDLED_OOPS is defined only for fastdebug build.
   393   // Note: CHECK_UNHANDLED_OOPS is defined only for fastdebug build.
   389 #ifdef CHECK_UNHANDLED_OOPS
   394 #ifdef CHECK_UNHANDLED_OOPS
   448   void incr_allocated_bytes(jlong size) { _allocated_bytes += size; }
   453   void incr_allocated_bytes(jlong size) { _allocated_bytes += size; }
   449   inline jlong cooked_allocated_bytes();
   454   inline jlong cooked_allocated_bytes();
   450 
   455 
   451   TRACE_DEFINE_THREAD_TRACE_DATA_OFFSET;
   456   TRACE_DEFINE_THREAD_TRACE_DATA_OFFSET;
   452   TRACE_DATA* trace_data() const        { return &_trace_data; }
   457   TRACE_DATA* trace_data() const        { return &_trace_data; }
       
   458   bool is_trace_suspend()               { return (_suspend_flags & _trace_flag) != 0; }
   453 
   459 
   454   const ThreadExt& ext() const          { return _ext; }
   460   const ThreadExt& ext() const          { return _ext; }
   455   ThreadExt& ext()                      { return _ext; }
   461   ThreadExt& ext()                      { return _ext; }
   456 
   462 
   457   // VM operation support
   463   // VM operation support
  1259   void handle_special_runtime_exit_condition(bool check_asyncs = true);
  1265   void handle_special_runtime_exit_condition(bool check_asyncs = true);
  1260 
  1266 
  1261   // Return true if JavaThread has an asynchronous condition or
  1267   // Return true if JavaThread has an asynchronous condition or
  1262   // if external suspension is requested.
  1268   // if external suspension is requested.
  1263   bool has_special_runtime_exit_condition() {
  1269   bool has_special_runtime_exit_condition() {
  1264     // We call is_external_suspend() last since external suspend should
  1270     // Because we don't use is_external_suspend_with_lock
  1265     // be less common. Because we don't use is_external_suspend_with_lock
       
  1266     // it is possible that we won't see an asynchronous external suspend
  1271     // it is possible that we won't see an asynchronous external suspend
  1267     // request that has just gotten started, i.e., SR_lock grabbed but
  1272     // request that has just gotten started, i.e., SR_lock grabbed but
  1268     // _external_suspend field change either not made yet or not visible
  1273     // _external_suspend field change either not made yet or not visible
  1269     // yet. However, this is okay because the request is asynchronous and
  1274     // yet. However, this is okay because the request is asynchronous and
  1270     // we will see the new flag value the next time through. It's also
  1275     // we will see the new flag value the next time through. It's also
  1271     // possible that the external suspend request is dropped after
  1276     // possible that the external suspend request is dropped after
  1272     // we have checked is_external_suspend(), we will recheck its value
  1277     // we have checked is_external_suspend(), we will recheck its value
  1273     // under SR_lock in java_suspend_self().
  1278     // under SR_lock in java_suspend_self().
  1274     return (_special_runtime_exit_condition != _no_async_condition) ||
  1279     return (_special_runtime_exit_condition != _no_async_condition) ||
  1275             is_external_suspend() || is_deopt_suspend();
  1280             is_external_suspend() || is_deopt_suspend() || is_trace_suspend();
  1276   }
  1281   }
  1277 
  1282 
  1278   void set_pending_unsafe_access_error()          { _special_runtime_exit_condition = _async_unsafe_access_error; }
  1283   void set_pending_unsafe_access_error()          { _special_runtime_exit_condition = _async_unsafe_access_error; }
  1279 
  1284 
  1280   inline void set_pending_async_exception(oop e);
  1285   inline void set_pending_async_exception(oop e);