/* * Copyright (c) 2012, 2016, 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. * */ #include "precompiled.hpp" #include "memory/metaspace/constants.hpp" #include "memory/metaspace/commitMask.hpp" #include "memory/metaspace/metaspaceCommon.hpp" #include "runtime/stubRoutines.hpp" #include "utilities/align.hpp" #include "utilities/debug.hpp" namespace metaspace { #ifdef ASSERT volatile u1 x; void CommitMask::verify(bool slow) const { // Walk the whole commit mask. // For each 1 bit, check if the associated granule is accessible. // For each 0 bit, check if the associated granule is not accessible. Slow mode only. assert_is_aligned(_base, constants::commit_granule_bytes); assert_is_aligned(_word_size, constants::commit_granule_words); if (slow) { assert(CanUseSafeFetch32, "We need SafeFetch for this test."); } for (idx_t i = 0; i < size(); i ++) { const MetaWord* const p = _base + (i * constants::commit_granule_words); if (at(i)) { // Should be accessible. Just touch it. x ^= *(u1*)p; } else { // Should not be accessible. if (slow) { // Note: results may differ between platforms. On Linux, this should be true since // we uncommit memory by setting protection to PROT_NONE. We may have to look if // this works as expected on other platforms. assert(os::is_readable_pointer(p) == false, "Should not be accessible."); } } } } #endif // ASSERT } // namespace metaspace