Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/gc_implementation/g1/g1ConcurrentMarkObjArrayProcessor.cpp
38920 views
/*1* Copyright (c) 2016, 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_implementation/g1/concurrentMark.inline.hpp"26#include "gc_implementation/g1/g1ConcurrentMarkObjArrayProcessor.inline.hpp"2728oop G1CMObjArrayProcessor::encode_array_slice(HeapWord* addr) {29return oop((void*)((uintptr_t)addr | ArraySliceBit));30}3132HeapWord* G1CMObjArrayProcessor::decode_array_slice(oop value) {33assert(is_array_slice(value), err_msg("Given value " PTR_FORMAT " is not an array slice", p2i(value)));34return (HeapWord*)((uintptr_t)(void*)value & ~ArraySliceBit);35}3637void G1CMObjArrayProcessor::push_array_slice(HeapWord* what) {38oop obj = encode_array_slice(what);39_task->push(obj);40}4142size_t G1CMObjArrayProcessor::process_array_slice(objArrayOop obj, HeapWord* start_from, size_t remaining) {43size_t words_to_scan = MIN2(remaining, ObjArrayMarkingStride);4445if (remaining > ObjArrayMarkingStride) {46push_array_slice(start_from + ObjArrayMarkingStride);47}4849// Then process current area.50MemRegion mr(start_from, words_to_scan);51return _task->scan_objArray(obj, mr);52}5354size_t G1CMObjArrayProcessor::process_obj(oop obj) {55assert(should_be_sliced(obj), err_msg("Must be an array object %d and large " SIZE_FORMAT, obj->is_objArray(), (size_t)obj->size()));5657return process_array_slice(objArrayOop(obj), (HeapWord*)obj, (size_t)objArrayOop(obj)->size());58}5960size_t G1CMObjArrayProcessor::process_slice(oop obj) {61HeapWord* const decoded_address = decode_array_slice(obj);6263// Find the start address of the objArrayOop.64// Shortcut the BOT access if the given address is from a humongous object. The BOT65// slide is fast enough for "smaller" objects in non-humongous regions, but is slower66// than directly using heap region table.67G1CollectedHeap* g1h = G1CollectedHeap::heap();68HeapRegion* r = g1h->heap_region_containing(decoded_address);6970HeapWord* const start_address = r->isHumongous() ?71r->humongous_start_region()->bottom() :72g1h->block_start(decoded_address);7374assert(oop(start_address)->is_objArray(), err_msg("Address " PTR_FORMAT " does not refer to an object array ", p2i(start_address)));75assert(start_address < decoded_address,76err_msg("Object start address " PTR_FORMAT " must be smaller than decoded address " PTR_FORMAT,77p2i(start_address),78p2i(decoded_address)));7980objArrayOop objArray = objArrayOop(start_address);8182size_t already_scanned = decoded_address - start_address;83size_t remaining = objArray->size() - already_scanned;8485return process_array_slice(objArray, decoded_address, remaining);86}878889