src/share/vm/gc_implementation/g1/g1ConcurrentMarkObjArrayProcessor.cpp

Sat, 07 Nov 2020 10:30:02 +0800

author
aoqi
date
Sat, 07 Nov 2020 10:30:02 +0800
changeset 10026
8c95980d0b66
parent 9982
72053ed6f8d4
permissions
-rw-r--r--

Added tag mips-jdk8u275-b01 for changeset d3b4d62f391f

tschatzl@9982 1 /*
tschatzl@9982 2 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved.
tschatzl@9982 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
tschatzl@9982 4 *
tschatzl@9982 5 * This code is free software; you can redistribute it and/or modify it
tschatzl@9982 6 * under the terms of the GNU General Public License version 2 only, as
tschatzl@9982 7 * published by the Free Software Foundation.
tschatzl@9982 8 *
tschatzl@9982 9 * This code is distributed in the hope that it will be useful, but WITHOUT
tschatzl@9982 10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
tschatzl@9982 11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
tschatzl@9982 12 * version 2 for more details (a copy is included in the LICENSE file that
tschatzl@9982 13 * accompanied this code).
tschatzl@9982 14 *
tschatzl@9982 15 * You should have received a copy of the GNU General Public License version
tschatzl@9982 16 * 2 along with this work; if not, write to the Free Software Foundation,
tschatzl@9982 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
tschatzl@9982 18 *
tschatzl@9982 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
tschatzl@9982 20 * or visit www.oracle.com if you need additional information or have any
tschatzl@9982 21 * questions.
tschatzl@9982 22 *
tschatzl@9982 23 */
tschatzl@9982 24
tschatzl@9982 25 #include "precompiled.hpp"
tschatzl@9982 26 #include "gc_implementation/g1/concurrentMark.inline.hpp"
tschatzl@9982 27 #include "gc_implementation/g1/g1ConcurrentMarkObjArrayProcessor.inline.hpp"
tschatzl@9982 28
tschatzl@9982 29 oop G1CMObjArrayProcessor::encode_array_slice(HeapWord* addr) {
tschatzl@9982 30 return oop((void*)((uintptr_t)addr | ArraySliceBit));
tschatzl@9982 31 }
tschatzl@9982 32
tschatzl@9982 33 HeapWord* G1CMObjArrayProcessor::decode_array_slice(oop value) {
tschatzl@9982 34 assert(is_array_slice(value), err_msg("Given value " PTR_FORMAT " is not an array slice", p2i(value)));
tschatzl@9982 35 return (HeapWord*)((uintptr_t)(void*)value & ~ArraySliceBit);
tschatzl@9982 36 }
tschatzl@9982 37
tschatzl@9982 38 void G1CMObjArrayProcessor::push_array_slice(HeapWord* what) {
tschatzl@9982 39 oop obj = encode_array_slice(what);
tschatzl@9982 40 _task->push(obj);
tschatzl@9982 41 }
tschatzl@9982 42
tschatzl@9982 43 size_t G1CMObjArrayProcessor::process_array_slice(objArrayOop obj, HeapWord* start_from, size_t remaining) {
tschatzl@9982 44 size_t words_to_scan = MIN2(remaining, ObjArrayMarkingStride);
tschatzl@9982 45
tschatzl@9982 46 if (remaining > ObjArrayMarkingStride) {
tschatzl@9982 47 push_array_slice(start_from + ObjArrayMarkingStride);
tschatzl@9982 48 }
tschatzl@9982 49
tschatzl@9982 50 // Then process current area.
tschatzl@9982 51 MemRegion mr(start_from, words_to_scan);
tschatzl@9982 52 return _task->scan_objArray(obj, mr);
tschatzl@9982 53 }
tschatzl@9982 54
tschatzl@9982 55 size_t G1CMObjArrayProcessor::process_obj(oop obj) {
tschatzl@9982 56 assert(should_be_sliced(obj), err_msg("Must be an array object %d and large " SIZE_FORMAT, obj->is_objArray(), (size_t)obj->size()));
tschatzl@9982 57
tschatzl@9982 58 return process_array_slice(objArrayOop(obj), (HeapWord*)obj, (size_t)objArrayOop(obj)->size());
tschatzl@9982 59 }
tschatzl@9982 60
tschatzl@9982 61 size_t G1CMObjArrayProcessor::process_slice(oop obj) {
tschatzl@9982 62 HeapWord* const decoded_address = decode_array_slice(obj);
tschatzl@9982 63
tschatzl@9982 64 // Find the start address of the objArrayOop.
tschatzl@9982 65 // Shortcut the BOT access if the given address is from a humongous object. The BOT
tschatzl@9982 66 // slide is fast enough for "smaller" objects in non-humongous regions, but is slower
tschatzl@9982 67 // than directly using heap region table.
tschatzl@9982 68 G1CollectedHeap* g1h = G1CollectedHeap::heap();
tschatzl@9982 69 HeapRegion* r = g1h->heap_region_containing(decoded_address);
tschatzl@9982 70
tschatzl@9982 71 HeapWord* const start_address = r->isHumongous() ?
tschatzl@9982 72 r->humongous_start_region()->bottom() :
tschatzl@9982 73 g1h->block_start(decoded_address);
tschatzl@9982 74
tschatzl@9982 75 assert(oop(start_address)->is_objArray(), err_msg("Address " PTR_FORMAT " does not refer to an object array ", p2i(start_address)));
tschatzl@9982 76 assert(start_address < decoded_address,
tschatzl@9982 77 err_msg("Object start address " PTR_FORMAT " must be smaller than decoded address " PTR_FORMAT,
tschatzl@9982 78 p2i(start_address),
tschatzl@9982 79 p2i(decoded_address)));
tschatzl@9982 80
tschatzl@9982 81 objArrayOop objArray = objArrayOop(start_address);
tschatzl@9982 82
tschatzl@9982 83 size_t already_scanned = decoded_address - start_address;
tschatzl@9982 84 size_t remaining = objArray->size() - already_scanned;
tschatzl@9982 85
tschatzl@9982 86 return process_array_slice(objArray, decoded_address, remaining);
tschatzl@9982 87 }

mercurial