hotspot/src/share/vm/runtime/safepoint.hpp
changeset 11631 33813f69207b
parent 7397 5b173b4ca846
child 11637 030466036615
equal deleted inserted replaced
11573:e1deb7ec91fa 11631:33813f69207b
     1 /*
     1 /*
     2  * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 1997, 2012, 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.
    27 
    27 
    28 #include "asm/assembler.hpp"
    28 #include "asm/assembler.hpp"
    29 #include "code/nmethod.hpp"
    29 #include "code/nmethod.hpp"
    30 #include "memory/allocation.hpp"
    30 #include "memory/allocation.hpp"
    31 #include "runtime/extendedPC.hpp"
    31 #include "runtime/extendedPC.hpp"
       
    32 #include "runtime/mutexLocker.hpp"
    32 #include "runtime/os.hpp"
    33 #include "runtime/os.hpp"
    33 #include "utilities/ostream.hpp"
    34 #include "utilities/ostream.hpp"
    34 
    35 
    35 //
    36 //
    36 // Safepoint synchronization
    37 // Safepoint synchronization
    90   } SafepointStats;
    91   } SafepointStats;
    91 
    92 
    92  private:
    93  private:
    93   static volatile SynchronizeState _state;     // Threads might read this flag directly, without acquireing the Threads_lock
    94   static volatile SynchronizeState _state;     // Threads might read this flag directly, without acquireing the Threads_lock
    94   static volatile int _waiting_to_block;       // number of threads we are waiting for to block
    95   static volatile int _waiting_to_block;       // number of threads we are waiting for to block
       
    96   static int _current_jni_active_count;        // Counts the number of active critical natives during the safepoint
    95 
    97 
    96   // This counter is used for fast versions of jni_Get<Primitive>Field.
    98   // This counter is used for fast versions of jni_Get<Primitive>Field.
    97   // An even value means there is no ongoing safepoint operations.
    99   // An even value means there is no ongoing safepoint operations.
    98   // The counter is incremented ONLY at the beginning and end of each
   100   // The counter is incremented ONLY at the beginning and end of each
    99   // safepoint. The fact that Threads_lock is held throughout each pair of
   101   // safepoint. The fact that Threads_lock is held throughout each pair of
   144 
   146 
   145   inline static bool do_call_back() {
   147   inline static bool do_call_back() {
   146     return (_state != _not_synchronized);
   148     return (_state != _not_synchronized);
   147   }
   149   }
   148 
   150 
       
   151   inline static void increment_jni_active_count() {
       
   152     assert_locked_or_safepoint(Safepoint_lock);
       
   153     _current_jni_active_count++;
       
   154   }
       
   155 
   149   // Called when a thread volantary blocks
   156   // Called when a thread volantary blocks
   150   static void   block(JavaThread *thread);
   157   static void   block(JavaThread *thread);
   151   static void   signal_thread_at_safepoint()              { _waiting_to_block--; }
   158   static void   signal_thread_at_safepoint()              { _waiting_to_block--; }
   152 
   159 
   153   // Exception handling for page polling
   160   // Exception handling for page polling