--- /dev/null 2020-01-14 10:13:11.907818291 +0100 +++ new/src/hotspot/share/gc/shenandoah/shenandoahObjectMarker.cpp 2020-02-21 11:14:41.032210252 +0100 @@ -0,0 +1,60 @@ +/* + * Copyright (c) 2020, Red Hat, Inc. 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. + * + */ + + +#include "precompiled.hpp" + +#include "gc/shared/markBitMap.inline.hpp" +#include "gc/shenandoah/shenandoahHeap.hpp" +#include "gc/shenandoah/shenandoahObjectMarker.hpp" + +bool ShenandoahObjectMarker::init() { + assert(SafepointSynchronize::is_at_safepoint(), "safe iteration is only available during safepoints"); + // Bailout if failed to commit aux bitmap + if (!_heap->commit_aux_bitmap()) { + _bit_map = NULL; + return false; + } + _bit_map->clear(); + return true; +} + +void ShenandoahObjectMarker::done() { + if (_bit_map != NULL) { + _heap->uncommit_aux_bit_map(); + } + delete this; +} + +bool ShenandoahObjectMarker::mark(oop o) { + assert(_bit_map != NULL, "Should have been bailed out"); + if (_bit_map->is_marked(o)) return false; + _bit_map->mark(o); + return true; +} + +bool ShenandoahObjectMarker::marked(oop o) { + assert(_bit_map != NULL, "Should have been bailed out"); + return _bit_map->is_marked(o); +}