Path: blob/master/src/hotspot/share/gc/g1/g1CodeBlobClosure.cpp
40957 views
/*1* Copyright (c) 2015, 2017, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "code/nmethod.hpp"26#include "gc/g1/g1CodeBlobClosure.hpp"27#include "gc/g1/g1CollectedHeap.inline.hpp"28#include "gc/g1/g1ConcurrentMark.inline.hpp"29#include "gc/g1/heapRegion.hpp"30#include "gc/g1/heapRegionRemSet.hpp"31#include "oops/access.inline.hpp"32#include "oops/compressedOops.inline.hpp"33#include "oops/oop.inline.hpp"3435template <typename T>36void G1CodeBlobClosure::HeapRegionGatheringOopClosure::do_oop_work(T* p) {37_work->do_oop(p);38T oop_or_narrowoop = RawAccess<>::oop_load(p);39if (!CompressedOops::is_null(oop_or_narrowoop)) {40oop o = CompressedOops::decode_not_null(oop_or_narrowoop);41HeapRegion* hr = _g1h->heap_region_containing(o);42assert(!_g1h->is_in_cset(o) || hr->rem_set()->strong_code_roots_list_contains(_nm), "if o still in collection set then evacuation failed and nm must already be in the remset");43hr->add_strong_code_root(_nm);44}45}4647void G1CodeBlobClosure::HeapRegionGatheringOopClosure::do_oop(oop* o) {48do_oop_work(o);49}5051void G1CodeBlobClosure::HeapRegionGatheringOopClosure::do_oop(narrowOop* o) {52do_oop_work(o);53}5455template<typename T>56void G1CodeBlobClosure::MarkingOopClosure::do_oop_work(T* p) {57T oop_or_narrowoop = RawAccess<>::oop_load(p);58if (!CompressedOops::is_null(oop_or_narrowoop)) {59oop o = CompressedOops::decode_not_null(oop_or_narrowoop);60_cm->mark_in_next_bitmap(_worker_id, o);61}62}6364G1CodeBlobClosure::MarkingOopClosure::MarkingOopClosure(uint worker_id) :65_cm(G1CollectedHeap::heap()->concurrent_mark()), _worker_id(worker_id) { }6667void G1CodeBlobClosure::MarkingOopClosure::do_oop(oop* o) {68do_oop_work(o);69}7071void G1CodeBlobClosure::MarkingOopClosure::do_oop(narrowOop* o) {72do_oop_work(o);73}7475void G1CodeBlobClosure::do_evacuation_and_fixup(nmethod* nm) {76_oc.set_nm(nm);77nm->oops_do(&_oc);78nm->fix_oop_relocations();79}8081void G1CodeBlobClosure::do_marking(nmethod* nm) {82nm->oops_do(&_marking_oc);83}8485class G1NmethodProcessor : public nmethod::OopsDoProcessor {86G1CodeBlobClosure* _cl;8788public:89G1NmethodProcessor(G1CodeBlobClosure* cl) : _cl(cl) { }9091void do_regular_processing(nmethod* nm) {92_cl->do_evacuation_and_fixup(nm);93}9495void do_remaining_strong_processing(nmethod* nm) {96_cl->do_marking(nm);97}98};99100void G1CodeBlobClosure::do_code_blob(CodeBlob* cb) {101nmethod* nm = cb->as_nmethod_or_null();102if (nm == NULL) {103return;104}105106G1NmethodProcessor cl(this);107108if (_strong) {109nm->oops_do_process_strong(&cl);110} else {111nm->oops_do_process_weak(&cl);112}113}114115116