89 NoSafepointVerifier(bool activated = true, bool verifygc = true ) : |
89 NoSafepointVerifier(bool activated = true, bool verifygc = true ) : |
90 NoGCVerifier(verifygc), |
90 NoGCVerifier(verifygc), |
91 _activated(activated) { |
91 _activated(activated) { |
92 _thread = Thread::current(); |
92 _thread = Thread::current(); |
93 if (_activated) { |
93 if (_activated) { |
94 _thread->_allow_allocation_count++; |
|
95 _thread->_allow_safepoint_count++; |
94 _thread->_allow_safepoint_count++; |
96 } |
95 } |
97 } |
96 } |
98 |
97 |
99 ~NoSafepointVerifier() { |
98 ~NoSafepointVerifier() { |
100 if (_activated) { |
99 if (_activated) { |
101 _thread->_allow_allocation_count--; |
|
102 _thread->_allow_safepoint_count--; |
100 _thread->_allow_safepoint_count--; |
103 } |
101 } |
104 } |
102 } |
105 #else |
103 #else |
106 NoSafepointVerifier(bool activated = true, bool verifygc = true) : NoGCVerifier(verifygc){} |
104 NoSafepointVerifier(bool activated = true, bool verifygc = true) : NoGCVerifier(verifygc){} |
124 PauseNoSafepointVerifier(NoSafepointVerifier * nsv) |
122 PauseNoSafepointVerifier(NoSafepointVerifier * nsv) |
125 : PauseNoGCVerifier(nsv) { |
123 : PauseNoGCVerifier(nsv) { |
126 |
124 |
127 _nsv = nsv; |
125 _nsv = nsv; |
128 if (_nsv->_activated) { |
126 if (_nsv->_activated) { |
129 _nsv->_thread->_allow_allocation_count--; |
|
130 _nsv->_thread->_allow_safepoint_count--; |
127 _nsv->_thread->_allow_safepoint_count--; |
131 } |
128 } |
132 } |
129 } |
133 |
130 |
134 ~PauseNoSafepointVerifier() { |
131 ~PauseNoSafepointVerifier() { |
135 if (_nsv->_activated) { |
132 if (_nsv->_activated) { |
136 _nsv->_thread->_allow_allocation_count++; |
|
137 _nsv->_thread->_allow_safepoint_count++; |
133 _nsv->_thread->_allow_safepoint_count++; |
138 } |
134 } |
139 } |
135 } |
140 #else |
136 #else |
141 PauseNoSafepointVerifier(NoSafepointVerifier * nsv) |
137 PauseNoSafepointVerifier(NoSafepointVerifier * nsv) |
142 : PauseNoGCVerifier(nsv) {} |
138 : PauseNoGCVerifier(nsv) {} |
143 ~PauseNoSafepointVerifier() {} |
139 ~PauseNoSafepointVerifier() {} |
144 #endif |
140 #endif |
145 }; |
141 }; |
146 |
142 |
147 // A NoAllocVerifier object can be placed in methods where one assumes that |
|
148 // no allocation will occur. The destructor will verify this property |
|
149 // unless the constructor is called with argument false (not activated). |
|
150 // |
|
151 // The check will only be done in debug mode and if activated. |
|
152 // Note: this only makes sense at safepoints (otherwise, other threads may |
|
153 // allocate concurrently.) |
|
154 |
|
155 class NoAllocVerifier : public StackObj { |
|
156 private: |
|
157 bool _activated; |
|
158 |
|
159 public: |
|
160 #ifdef ASSERT |
|
161 NoAllocVerifier(bool activated = true) { |
|
162 _activated = activated; |
|
163 if (_activated) Thread::current()->_allow_allocation_count++; |
|
164 } |
|
165 |
|
166 ~NoAllocVerifier() { |
|
167 if (_activated) Thread::current()->_allow_allocation_count--; |
|
168 } |
|
169 #else |
|
170 NoAllocVerifier(bool activated = true) {} |
|
171 ~NoAllocVerifier() {} |
|
172 #endif |
|
173 }; |
|
174 |
|
175 #endif // SHARE_RUNTIME_SAFEPOINTVERIFIERS_HPP |
143 #endif // SHARE_RUNTIME_SAFEPOINTVERIFIERS_HPP |