Path: blob/master/src/hotspot/share/gc/g1/g1CardTable.cpp
40961 views
/*1* Copyright (c) 2001, 2018, 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 "gc/g1/g1CardTable.hpp"26#include "gc/g1/g1CollectedHeap.inline.hpp"27#include "gc/shared/memset_with_concurrent_readers.hpp"28#include "logging/log.hpp"2930void G1CardTable::g1_mark_as_young(const MemRegion& mr) {31CardValue *const first = byte_for(mr.start());32CardValue *const last = byte_after(mr.last());3334memset_with_concurrent_readers(first, g1_young_gen, last - first);35}3637#ifndef PRODUCT38void G1CardTable::verify_g1_young_region(MemRegion mr) {39verify_region(mr, g1_young_gen, true);40}41#endif4243void G1CardTableChangedListener::on_commit(uint start_idx, size_t num_regions, bool zero_filled) {44// Default value for a clean card on the card table is -1. So we cannot take advantage of the zero_filled parameter.45MemRegion mr(G1CollectedHeap::heap()->bottom_addr_for_region(start_idx), num_regions * HeapRegion::GrainWords);46_card_table->clear(mr);47}4849void G1CardTable::initialize(G1RegionToSpaceMapper* mapper) {50mapper->set_mapping_changed_listener(&_listener);5152_byte_map_size = mapper->reserved().byte_size();5354_guard_index = cards_required(_whole_heap.word_size()) - 1;55_last_valid_index = _guard_index - 1;5657HeapWord* low_bound = _whole_heap.start();58HeapWord* high_bound = _whole_heap.end();5960_cur_covered_regions = 1;61_covered[0] = _whole_heap;6263_byte_map = (CardValue*) mapper->reserved().start();64_byte_map_base = _byte_map - (uintptr_t(low_bound) >> card_shift);65assert(byte_for(low_bound) == &_byte_map[0], "Checking start of map");66assert(byte_for(high_bound-1) <= &_byte_map[_last_valid_index], "Checking end of map");6768log_trace(gc, barrier)("G1CardTable::G1CardTable: ");69log_trace(gc, barrier)(" &_byte_map[0]: " INTPTR_FORMAT " &_byte_map[_last_valid_index]: " INTPTR_FORMAT,70p2i(&_byte_map[0]), p2i(&_byte_map[_last_valid_index]));71log_trace(gc, barrier)(" _byte_map_base: " INTPTR_FORMAT, p2i(_byte_map_base));72}7374bool G1CardTable::is_in_young(oop obj) const {75volatile CardValue* p = byte_for(obj);76return *p == G1CardTable::g1_young_card_val();77}787980