Sat, 07 Nov 2020 10:30:02 +0800
Added tag mips-jdk8u275-b01 for changeset d3b4d62f391f
aoqi@0 | 1 | /* |
aoqi@0 | 2 | * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. |
aoqi@0 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
aoqi@0 | 4 | * |
aoqi@0 | 5 | * This code is free software; you can redistribute it and/or modify it |
aoqi@0 | 6 | * under the terms of the GNU General Public License version 2 only, as |
aoqi@0 | 7 | * published by the Free Software Foundation. |
aoqi@0 | 8 | * |
aoqi@0 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
aoqi@0 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
aoqi@0 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
aoqi@0 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
aoqi@0 | 13 | * accompanied this code). |
aoqi@0 | 14 | * |
aoqi@0 | 15 | * You should have received a copy of the GNU General Public License version |
aoqi@0 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
aoqi@0 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
aoqi@0 | 18 | * |
aoqi@0 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
aoqi@0 | 20 | * or visit www.oracle.com if you need additional information or have any |
aoqi@0 | 21 | * questions. |
aoqi@0 | 22 | * |
aoqi@0 | 23 | */ |
aoqi@0 | 24 | |
aoqi@0 | 25 | #include "precompiled.hpp" |
aoqi@0 | 26 | #include "classfile/symbolTable.hpp" |
aoqi@0 | 27 | #include "classfile/systemDictionary.hpp" |
aoqi@0 | 28 | #include "code/codeCache.hpp" |
aoqi@0 | 29 | #include "gc_interface/collectedHeap.inline.hpp" |
aoqi@0 | 30 | #include "memory/sharedHeap.hpp" |
aoqi@0 | 31 | #include "oops/oop.inline.hpp" |
stefank@6992 | 32 | #include "runtime/atomic.inline.hpp" |
aoqi@0 | 33 | #include "runtime/fprofiler.hpp" |
aoqi@0 | 34 | #include "runtime/java.hpp" |
aoqi@0 | 35 | #include "utilities/copy.hpp" |
aoqi@0 | 36 | #include "utilities/workgroup.hpp" |
aoqi@0 | 37 | |
aoqi@0 | 38 | PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC |
aoqi@0 | 39 | |
aoqi@0 | 40 | SharedHeap* SharedHeap::_sh; |
aoqi@0 | 41 | |
aoqi@0 | 42 | SharedHeap::SharedHeap(CollectorPolicy* policy_) : |
aoqi@0 | 43 | CollectedHeap(), |
aoqi@0 | 44 | _collector_policy(policy_), |
aoqi@0 | 45 | _rem_set(NULL), |
aoqi@0 | 46 | _strong_roots_parity(0), |
aoqi@0 | 47 | _workers(NULL) |
aoqi@0 | 48 | { |
aoqi@0 | 49 | _sh = this; // ch is static, should be set only once. |
aoqi@0 | 50 | if ((UseParNewGC || |
aoqi@0 | 51 | (UseConcMarkSweepGC && (CMSParallelInitialMarkEnabled || |
aoqi@0 | 52 | CMSParallelRemarkEnabled)) || |
aoqi@0 | 53 | UseG1GC) && |
aoqi@0 | 54 | ParallelGCThreads > 0) { |
aoqi@0 | 55 | _workers = new FlexibleWorkGang("Parallel GC Threads", ParallelGCThreads, |
aoqi@0 | 56 | /* are_GC_task_threads */true, |
aoqi@0 | 57 | /* are_ConcurrentGC_threads */false); |
aoqi@0 | 58 | if (_workers == NULL) { |
aoqi@0 | 59 | vm_exit_during_initialization("Failed necessary allocation."); |
aoqi@0 | 60 | } else { |
aoqi@0 | 61 | _workers->initialize_workers(); |
aoqi@0 | 62 | } |
aoqi@0 | 63 | } |
aoqi@0 | 64 | } |
aoqi@0 | 65 | |
aoqi@0 | 66 | bool SharedHeap::heap_lock_held_for_gc() { |
aoqi@0 | 67 | Thread* t = Thread::current(); |
aoqi@0 | 68 | return Heap_lock->owned_by_self() |
aoqi@0 | 69 | || ( (t->is_GC_task_thread() || t->is_VM_thread()) |
aoqi@0 | 70 | && _thread_holds_heap_lock_for_gc); |
aoqi@0 | 71 | } |
aoqi@0 | 72 | |
aoqi@0 | 73 | void SharedHeap::set_par_threads(uint t) { |
aoqi@0 | 74 | assert(t == 0 || !UseSerialGC, "Cannot have parallel threads"); |
aoqi@0 | 75 | _n_par_threads = t; |
stefank@6992 | 76 | } |
stefank@6992 | 77 | |
aoqi@0 | 78 | void SharedHeap::change_strong_roots_parity() { |
aoqi@0 | 79 | // Also set the new collection parity. |
aoqi@0 | 80 | assert(_strong_roots_parity >= 0 && _strong_roots_parity <= 2, |
aoqi@0 | 81 | "Not in range."); |
aoqi@0 | 82 | _strong_roots_parity++; |
aoqi@0 | 83 | if (_strong_roots_parity == 3) _strong_roots_parity = 1; |
aoqi@0 | 84 | assert(_strong_roots_parity >= 1 && _strong_roots_parity <= 2, |
aoqi@0 | 85 | "Not in range."); |
aoqi@0 | 86 | } |
aoqi@0 | 87 | |
stefank@6992 | 88 | SharedHeap::StrongRootsScope::StrongRootsScope(SharedHeap* heap, bool activate) |
mgerdin@7659 | 89 | : MarkScope(activate), _sh(heap) |
aoqi@0 | 90 | { |
aoqi@0 | 91 | if (_active) { |
stefank@6992 | 92 | _sh->change_strong_roots_parity(); |
aoqi@0 | 93 | // Zero the claimed high water mark in the StringTable |
aoqi@0 | 94 | StringTable::clear_parallel_claimed_index(); |
aoqi@0 | 95 | } |
aoqi@0 | 96 | } |
aoqi@0 | 97 | |
aoqi@0 | 98 | void SharedHeap::set_barrier_set(BarrierSet* bs) { |
aoqi@0 | 99 | _barrier_set = bs; |
aoqi@0 | 100 | // Cached barrier set for fast access in oops |
aoqi@0 | 101 | oopDesc::set_bs(bs); |
aoqi@0 | 102 | } |
aoqi@0 | 103 | |
aoqi@0 | 104 | void SharedHeap::post_initialize() { |
aoqi@0 | 105 | CollectedHeap::post_initialize(); |
aoqi@0 | 106 | ref_processing_init(); |
aoqi@0 | 107 | } |
aoqi@0 | 108 | |
aoqi@0 | 109 | void SharedHeap::ref_processing_init() {} |
aoqi@0 | 110 | |
aoqi@0 | 111 | // Some utilities. |
aoqi@0 | 112 | void SharedHeap::print_size_transition(outputStream* out, |
aoqi@0 | 113 | size_t bytes_before, |
aoqi@0 | 114 | size_t bytes_after, |
aoqi@0 | 115 | size_t capacity) { |
aoqi@0 | 116 | out->print(" %d%s->%d%s(%d%s)", |
aoqi@0 | 117 | byte_size_in_proper_unit(bytes_before), |
aoqi@0 | 118 | proper_unit_for_byte_size(bytes_before), |
aoqi@0 | 119 | byte_size_in_proper_unit(bytes_after), |
aoqi@0 | 120 | proper_unit_for_byte_size(bytes_after), |
aoqi@0 | 121 | byte_size_in_proper_unit(capacity), |
aoqi@0 | 122 | proper_unit_for_byte_size(capacity)); |
aoqi@0 | 123 | } |