src/hotspot/share/runtime/safepointVerifiers.hpp
author dholmes
Sat, 23 Jun 2018 01:32:41 -0400
changeset 50735 2f2af62dfac7
parent 49594 898ef81cbc0e
child 53244 9807daeb47c4
permissions -rw-r--r--
8010319: Implementation of JEP 181: Nest-Based Access Control Reviewed-by: alanb, psandoz, mchung, coleenp, acorn, mcimadamore, forax, jlahoda, sspitsyn, abuckley Contributed-by: alex.buckley@oracle.com, maurizio.mimadamore@oracle.com, mandy.chung@oracle.com, tobias.hartmann@oracle.com, david.holmes@oracle.com, vladimir.x.ivanov@oracle.com, karen.kinnear@oracle.com, vladimir.kozlov@oracle.com, john.r.rose@oracle.com, daniel.smith@oracle.com, serguei.spitsyn@oracle.com, kumardotsrinivasan@gmail.com, boris.ulasevich@bell-sw.com
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
49594
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
     1
/*
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
     2
 * Copyright (c) 1997, 2018, Oracle and/or its affiliates. All rights reserved.
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
     4
 *
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
     7
 * published by the Free Software Foundation.
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
     8
 *
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    13
 * accompanied this code).
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    14
 *
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    18
 *
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    21
 * questions.
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    22
 *
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    23
 */
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    24
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    25
#ifndef SHARE_VM_RUNTIME_SAFEPOINTVERIFIERS_HPP
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    26
#define SHARE_VM_RUNTIME_SAFEPOINTVERIFIERS_HPP
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    27
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    28
#include "memory/allocation.hpp"
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    29
#include "runtime/thread.hpp"
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    30
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    31
// A NoGCVerifier object can be placed in methods where one assumes that
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    32
// no garbage collection will occur. The destructor will verify this property
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    33
// unless the constructor is called with argument false (not verifygc).
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    34
//
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    35
// The check will only be done in debug mode and if verifygc true.
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    36
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    37
class NoGCVerifier: public StackObj {
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    38
 friend class PauseNoGCVerifier;
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    39
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    40
 protected:
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    41
  bool _verifygc;
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    42
  unsigned int _old_invocations;
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    43
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    44
 public:
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    45
#ifdef ASSERT
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    46
  NoGCVerifier(bool verifygc = true);
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    47
  ~NoGCVerifier();
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    48
#else
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    49
  NoGCVerifier(bool verifygc = true) {}
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    50
  ~NoGCVerifier() {}
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    51
#endif
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    52
};
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    53
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    54
// A PauseNoGCVerifier is used to temporarily pause the behavior
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    55
// of a NoGCVerifier object. If we are not in debug mode or if the
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    56
// NoGCVerifier object has a _verifygc value of false, then there
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    57
// is nothing to do.
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    58
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    59
class PauseNoGCVerifier: public StackObj {
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    60
 private:
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    61
  NoGCVerifier * _ngcv;
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    62
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    63
 public:
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    64
#ifdef ASSERT
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    65
  PauseNoGCVerifier(NoGCVerifier * ngcv);
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    66
  ~PauseNoGCVerifier();
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    67
#else
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    68
  PauseNoGCVerifier(NoGCVerifier * ngcv) {}
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    69
  ~PauseNoGCVerifier() {}
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    70
#endif
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    71
};
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    72
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    73
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    74
// A NoSafepointVerifier object will throw an assertion failure if
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    75
// the current thread passes a possible safepoint while this object is
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    76
// instantiated. A safepoint, will either be: an oop allocation, blocking
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    77
// on a Mutex or JavaLock, or executing a VM operation.
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    78
//
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    79
// If StrictSafepointChecks is turned off, it degrades into a NoGCVerifier
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    80
//
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    81
class NoSafepointVerifier : public NoGCVerifier {
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    82
 friend class PauseNoSafepointVerifier;
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    83
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    84
 private:
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    85
  bool _activated;
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    86
  Thread *_thread;
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    87
 public:
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    88
#ifdef ASSERT
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    89
  NoSafepointVerifier(bool activated = true, bool verifygc = true ) :
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    90
    NoGCVerifier(verifygc),
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    91
    _activated(activated) {
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    92
    _thread = Thread::current();
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    93
    if (_activated) {
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    94
      _thread->_allow_allocation_count++;
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    95
      _thread->_allow_safepoint_count++;
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    96
    }
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    97
  }
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    98
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
    99
  ~NoSafepointVerifier() {
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   100
    if (_activated) {
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   101
      _thread->_allow_allocation_count--;
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   102
      _thread->_allow_safepoint_count--;
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   103
    }
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   104
  }
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   105
#else
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   106
  NoSafepointVerifier(bool activated = true, bool verifygc = true) : NoGCVerifier(verifygc){}
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   107
  ~NoSafepointVerifier() {}
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   108
#endif
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   109
};
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   110
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   111
// A PauseNoSafepointVerifier is used to temporarily pause the
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   112
// behavior of a NoSafepointVerifier object. If we are not in debug
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   113
// mode then there is nothing to do. If the NoSafepointVerifier
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   114
// object has an _activated value of false, then there is nothing to
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   115
// do for safepoint and allocation checking, but there may still be
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   116
// something to do for the underlying NoGCVerifier object.
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   117
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   118
class PauseNoSafepointVerifier : public PauseNoGCVerifier {
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   119
 private:
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   120
  NoSafepointVerifier * _nsv;
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   121
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   122
 public:
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   123
#ifdef ASSERT
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   124
  PauseNoSafepointVerifier(NoSafepointVerifier * nsv)
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   125
    : PauseNoGCVerifier(nsv) {
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   126
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   127
    _nsv = nsv;
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   128
    if (_nsv->_activated) {
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   129
      _nsv->_thread->_allow_allocation_count--;
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   130
      _nsv->_thread->_allow_safepoint_count--;
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   131
    }
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   132
  }
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   133
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   134
  ~PauseNoSafepointVerifier() {
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   135
    if (_nsv->_activated) {
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   136
      _nsv->_thread->_allow_allocation_count++;
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   137
      _nsv->_thread->_allow_safepoint_count++;
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   138
    }
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   139
  }
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   140
#else
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   141
  PauseNoSafepointVerifier(NoSafepointVerifier * nsv)
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   142
    : PauseNoGCVerifier(nsv) {}
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   143
  ~PauseNoSafepointVerifier() {}
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   144
#endif
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   145
};
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   146
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   147
// A NoAllocVerifier object can be placed in methods where one assumes that
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   148
// no allocation will occur. The destructor will verify this property
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   149
// unless the constructor is called with argument false (not activated).
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   150
//
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   151
// The check will only be done in debug mode and if activated.
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   152
// Note: this only makes sense at safepoints (otherwise, other threads may
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   153
// allocate concurrently.)
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   154
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   155
class NoAllocVerifier : public StackObj {
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   156
 private:
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   157
  bool  _activated;
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   158
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   159
 public:
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   160
#ifdef ASSERT
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   161
  NoAllocVerifier(bool activated = true) {
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   162
    _activated = activated;
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   163
    if (_activated) Thread::current()->_allow_allocation_count++;
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   164
  }
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   165
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   166
  ~NoAllocVerifier() {
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   167
    if (_activated) Thread::current()->_allow_allocation_count--;
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   168
  }
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   169
#else
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   170
  NoAllocVerifier(bool activated = true) {}
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   171
  ~NoAllocVerifier() {}
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   172
#endif
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   173
};
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   174
898ef81cbc0e 8200106: Move NoSafepointVerifier out from gcLocker.hpp
stefank
parents:
diff changeset
   175
#endif // SHARE_VM_RUNTIME_SAFEPOINTVERIFIERS_HPP