15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/classLoader.hpp"
27 #include "classfile/javaClasses.hpp"
28 #include "gc/shared/allocTracer.hpp"
29 #include "gc/shared/gcId.hpp"
30 #include "gc/shared/gcLocker.hpp"
31 #include "gc/shared/gcVMOperations.hpp"
32 #include "gc/shared/genCollectedHeap.hpp"
33 #include "interpreter/oopMapCache.hpp"
34 #include "logging/log.hpp"
35 #include "memory/oopFactory.hpp"
36 #include "memory/universe.hpp"
37 #include "runtime/handles.inline.hpp"
38 #include "runtime/init.hpp"
39 #include "utilities/dtrace.hpp"
40 #include "utilities/macros.hpp"
41 #include "utilities/preserveException.hpp"
42 #if INCLUDE_G1GC
43 #include "gc/g1/g1CollectedHeap.inline.hpp"
44 #include "gc/g1/g1Policy.hpp"
45 #endif // INCLUDE_G1GC
46
47 VM_GC_Operation::~VM_GC_Operation() {
48 CollectedHeap* ch = Universe::heap();
49 ch->soft_ref_policy()->set_all_soft_refs_clear(false);
50 }
51
52 // The same dtrace probe can't be inserted in two different files, so we
53 // have to call it here, so it's only in one file. Can't create new probes
54 // for the other file anymore. The dtrace probes have to remain stable.
163 GenCollectedHeap* gch = GenCollectedHeap::heap();
164 GCCauseSetter gccs(gch, _gc_cause);
165 _result = gch->satisfy_failed_allocation(_word_size, _tlab);
166 assert(gch->is_in_reserved_or_null(_result), "result not in heap");
167
168 if (_result == NULL && GCLocker::is_active_and_needs_gc()) {
169 set_gc_locked();
170 }
171 }
172
173 void VM_GenCollectFull::doit() {
174 SvcGCMarker sgcm(SvcGCMarker::FULL);
175
176 GenCollectedHeap* gch = GenCollectedHeap::heap();
177 GCCauseSetter gccs(gch, _gc_cause);
178 gch->do_full_collection(gch->must_clear_all_soft_refs(), _max_generation);
179 }
180
181 VM_CollectForMetadataAllocation::VM_CollectForMetadataAllocation(ClassLoaderData* loader_data,
182 size_t size,
183 Metaspace::MetadataType mdtype,
184 uint gc_count_before,
185 uint full_gc_count_before,
186 GCCause::Cause gc_cause)
187 : VM_GC_Operation(gc_count_before, gc_cause, full_gc_count_before, true),
188 _result(NULL), _size(size), _mdtype(mdtype), _loader_data(loader_data) {
189 assert(_size != 0, "An allocation should always be requested with this operation.");
190 AllocTracer::send_allocation_requiring_gc_event(_size * HeapWordSize, GCId::peek());
191 }
192
193 // Returns true iff concurrent GCs unloads metadata.
194 bool VM_CollectForMetadataAllocation::initiate_concurrent_GC() {
195 #if INCLUDE_CMSGC
196 if (UseConcMarkSweepGC && CMSClassUnloadingEnabled) {
197 MetaspaceGC::set_should_concurrent_collect(true);
198 return true;
199 }
200 #endif
201
202 #if INCLUDE_G1GC
203 if (UseG1GC && ClassUnloadingWithConcurrentMark) {
|
15 * You should have received a copy of the GNU General Public License version
16 * 2 along with this work; if not, write to the Free Software Foundation,
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
18 *
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
20 * or visit www.oracle.com if you need additional information or have any
21 * questions.
22 *
23 */
24
25 #include "precompiled.hpp"
26 #include "classfile/classLoader.hpp"
27 #include "classfile/javaClasses.hpp"
28 #include "gc/shared/allocTracer.hpp"
29 #include "gc/shared/gcId.hpp"
30 #include "gc/shared/gcLocker.hpp"
31 #include "gc/shared/gcVMOperations.hpp"
32 #include "gc/shared/genCollectedHeap.hpp"
33 #include "interpreter/oopMapCache.hpp"
34 #include "logging/log.hpp"
35 #include "memory/metaspace/classLoaderMetaspace.hpp"
36 #include "memory/metaspace/metaspaceEnums.hpp"
37 #include "memory/oopFactory.hpp"
38 #include "memory/universe.hpp"
39 #include "runtime/handles.inline.hpp"
40 #include "runtime/init.hpp"
41 #include "utilities/dtrace.hpp"
42 #include "utilities/macros.hpp"
43 #include "utilities/preserveException.hpp"
44 #if INCLUDE_G1GC
45 #include "gc/g1/g1CollectedHeap.inline.hpp"
46 #include "gc/g1/g1Policy.hpp"
47 #endif // INCLUDE_G1GC
48
49 VM_GC_Operation::~VM_GC_Operation() {
50 CollectedHeap* ch = Universe::heap();
51 ch->soft_ref_policy()->set_all_soft_refs_clear(false);
52 }
53
54 // The same dtrace probe can't be inserted in two different files, so we
55 // have to call it here, so it's only in one file. Can't create new probes
56 // for the other file anymore. The dtrace probes have to remain stable.
165 GenCollectedHeap* gch = GenCollectedHeap::heap();
166 GCCauseSetter gccs(gch, _gc_cause);
167 _result = gch->satisfy_failed_allocation(_word_size, _tlab);
168 assert(gch->is_in_reserved_or_null(_result), "result not in heap");
169
170 if (_result == NULL && GCLocker::is_active_and_needs_gc()) {
171 set_gc_locked();
172 }
173 }
174
175 void VM_GenCollectFull::doit() {
176 SvcGCMarker sgcm(SvcGCMarker::FULL);
177
178 GenCollectedHeap* gch = GenCollectedHeap::heap();
179 GCCauseSetter gccs(gch, _gc_cause);
180 gch->do_full_collection(gch->must_clear_all_soft_refs(), _max_generation);
181 }
182
183 VM_CollectForMetadataAllocation::VM_CollectForMetadataAllocation(ClassLoaderData* loader_data,
184 size_t size,
185 metaspace::MetadataType mdtype,
186 uint gc_count_before,
187 uint full_gc_count_before,
188 GCCause::Cause gc_cause)
189 : VM_GC_Operation(gc_count_before, gc_cause, full_gc_count_before, true),
190 _result(NULL), _size(size), _mdtype(mdtype), _loader_data(loader_data) {
191 assert(_size != 0, "An allocation should always be requested with this operation.");
192 AllocTracer::send_allocation_requiring_gc_event(_size * HeapWordSize, GCId::peek());
193 }
194
195 // Returns true iff concurrent GCs unloads metadata.
196 bool VM_CollectForMetadataAllocation::initiate_concurrent_GC() {
197 #if INCLUDE_CMSGC
198 if (UseConcMarkSweepGC && CMSClassUnloadingEnabled) {
199 MetaspaceGC::set_should_concurrent_collect(true);
200 return true;
201 }
202 #endif
203
204 #if INCLUDE_G1GC
205 if (UseG1GC && ClassUnloadingWithConcurrentMark) {
|