zgu@3900: /* zgu@3900: * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. zgu@3900: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. zgu@3900: * zgu@3900: * This code is free software; you can redistribute it and/or modify it zgu@3900: * under the terms of the GNU General Public License version 2 only, as zgu@3900: * published by the Free Software Foundation. zgu@3900: * zgu@3900: * This code is distributed in the hope that it will be useful, but WITHOUT zgu@3900: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or zgu@3900: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License zgu@3900: * version 2 for more details (a copy is included in the LICENSE file that zgu@3900: * accompanied this code). zgu@3900: * zgu@3900: * You should have received a copy of the GNU General Public License version zgu@3900: * 2 along with this work; if not, write to the Free Software Foundation, zgu@3900: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. zgu@3900: * zgu@3900: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA zgu@3900: * or visit www.oracle.com if you need additional information or have any zgu@3900: * questions. zgu@3900: * zgu@3900: */ zgu@3900: zgu@3900: #include "precompiled.hpp" zgu@3900: #include "services/memPtr.hpp" zgu@3900: #include "services/memTracker.hpp" zgu@3900: zgu@3900: volatile jint SequenceGenerator::_seq_number = 1; zgu@3900: DEBUG_ONLY(jint SequenceGenerator::_max_seq_number = 1;) zgu@3900: DEBUG_ONLY(volatile unsigned long SequenceGenerator::_generation = 0;) zgu@3900: zgu@3900: jint SequenceGenerator::next() { zgu@3900: jint seq = Atomic::add(1, &_seq_number); zgu@3900: if (seq < 0) { zgu@3900: MemTracker::shutdown(MemTracker::NMT_sequence_overflow); zgu@3900: } zgu@3900: assert(seq > 0, "counter overflow"); zgu@3900: DEBUG_ONLY(_max_seq_number = (seq > _max_seq_number) ? seq : _max_seq_number;) zgu@3900: return seq; zgu@3900: } zgu@3900: zgu@3900: zgu@3900: zgu@3900: bool VMMemRegion::contains(const VMMemRegion* mr) const { zgu@3900: assert(base() != 0, "no base address"); zgu@3900: assert(size() != 0 || committed_size() != 0, zgu@3900: "no range"); zgu@3900: address base_addr = base(); zgu@3900: address end_addr = base_addr + zgu@3900: (is_reserve_record()? reserved_size(): committed_size()); zgu@3900: if (mr->is_reserve_record()) { zgu@3900: if (mr->base() == base_addr && mr->size() == size()) { zgu@3900: // the same range zgu@3900: return true; zgu@3900: } zgu@3900: return false; zgu@3900: } else if (mr->is_commit_record() || mr->is_uncommit_record()) { zgu@3900: assert(mr->base() != 0 && mr->committed_size() > 0, zgu@3900: "bad record"); zgu@3900: return (mr->base() >= base_addr && zgu@3900: (mr->base() + mr->committed_size()) <= end_addr); zgu@3900: } else if (mr->is_type_tagging_record()) { zgu@3900: assert(mr->base() != 0, "no base"); zgu@3900: return mr->base() == base_addr; zgu@3900: } else if (mr->is_release_record()) { zgu@3900: assert(mr->base() != 0 && mr->size() > 0, zgu@3900: "bad record"); zgu@3900: return (mr->base() == base_addr && mr->size() == size()); zgu@3900: } else { zgu@3900: assert(false, "what happened?"); zgu@3900: return false; zgu@3900: } zgu@3900: }