/* * Copyright (c) 2015, 2022, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it * under the terms of the GNU General Public License version 2 only, as * published by the Free Software Foundation. * * This code is distributed in the hope that it will be useful, but WITHOUT * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License * version 2 for more details (a copy is included in the LICENSE file that * accompanied this code). * * You should have received a copy of the GNU General Public License version * 2 along with this work; if not, write to the Free Software Foundation, * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. * * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions.
*/
template <bool finalizable> bool ZBarrier::should_mark_through(uintptr_t addr) { // Finalizable marked oops can still exists on the heap after marking // has completed, in which case we just want to convert this into a // good oop and not push it on the mark stack. if (!during_mark()) {
assert(ZAddress::is_marked(addr), "Should be marked");
assert(ZAddress::is_finalizable(addr), "Should be finalizable"); returnfalse;
}
// During marking, we mark through already marked oops to avoid having // some large part of the object graph hidden behind a pushed, but not // yet flushed, entry on a mutator mark stack. Always marking through // allows the GC workers to proceed through the object graph even if a // mutator touched an oop first, which in turn will reduce the risk of // having to flush mark stacks multiple times to terminate marking. // // However, when doing finalizable marking we don't always want to mark // through. First, marking through an already strongly marked oop would // be wasteful, since we will then proceed to do finalizable marking on // an object which is, or will be, marked strongly. Second, marking // through an already finalizable marked oop would also be wasteful, // since such oops can never end up on a mutator mark stack and can // therefore not hide some part of the object graph from GC workers. if (finalizable) { return !ZAddress::is_marked(addr);
}
if (ZAddress::is_marked(addr)) { // Already marked, but try to mark though anyway
good_addr = ZAddress::good(addr);
} elseif (ZAddress::is_remapped(addr)) { // Already remapped, but also needs to be marked
good_addr = ZAddress::good(addr);
} else { // Needs to be both remapped and marked
good_addr = remap(addr);
}
// Mark if (should_mark_through<finalizable>(addr)) {
ZHeap::heap()->mark_object<gc_thread, follow, finalizable, publish>(good_addr);
}
if (finalizable) { // Make the oop finalizable marked/good, instead of normal marked/good. // This is needed because an object might first becomes finalizable // marked by the GC, and then loaded by a mutator thread. In this case, // the mutator thread must be able to tell that the object needs to be // strongly marked. The finalizable bit in the oop exists to make sure // that a load of a finalizable marked oop will fall into the barrier // slow path so that we can mark the object as strongly reachable. return ZAddress::finalizable_good(good_addr);
}
return good_addr;
}
uintptr_t ZBarrier::remap(uintptr_t addr) {
assert(!ZAddress::is_good(addr), "Should not be good");
assert(!ZAddress::is_weak_good(addr), "Should not be weak good"); return ZHeap::heap()->remap_object(addr);
}
uintptr_t ZBarrier::relocate(uintptr_t addr) {
assert(!ZAddress::is_good(addr), "Should not be good");
assert(!ZAddress::is_weak_good(addr), "Should not be weak good"); return ZHeap::heap()->relocate_object(addr);
}
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.