duke@435: /* drchase@6680: * Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved. duke@435: * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. duke@435: * duke@435: * This code is free software; you can redistribute it and/or modify it duke@435: * under the terms of the GNU General Public License version 2 only, as duke@435: * published by the Free Software Foundation. duke@435: * duke@435: * This code is distributed in the hope that it will be useful, but WITHOUT duke@435: * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or duke@435: * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License duke@435: * version 2 for more details (a copy is included in the LICENSE file that duke@435: * accompanied this code). duke@435: * duke@435: * You should have received a copy of the GNU General Public License version duke@435: * 2 along with this work; if not, write to the Free Software Foundation, duke@435: * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. duke@435: * trims@1907: * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA trims@1907: * or visit www.oracle.com if you need additional information or have any trims@1907: * questions. duke@435: * duke@435: */ duke@435: stefank@2314: #include "precompiled.hpp" jprovino@4542: #include "utilities/macros.hpp" jprovino@4542: #if INCLUDE_ALL_GCS stefank@2314: #include "gc_implementation/shared/immutableSpace.hpp" stefank@2314: #include "memory/universe.hpp" stefank@2314: #include "oops/oop.inline.hpp" jprovino@4542: #endif // INCLUDE_ALL_GCS duke@435: duke@435: void ImmutableSpace::initialize(MemRegion mr) { duke@435: HeapWord* bottom = mr.start(); duke@435: HeapWord* end = mr.end(); duke@435: duke@435: assert(Universe::on_page_boundary(bottom) && Universe::on_page_boundary(end), duke@435: "invalid space boundaries"); duke@435: duke@435: _bottom = bottom; duke@435: _end = end; duke@435: } duke@435: coleenp@4037: void ImmutableSpace::oop_iterate(ExtendedOopClosure* cl) { duke@435: HeapWord* obj_addr = bottom(); duke@435: HeapWord* t = end(); duke@435: // Could call objects iterate, but this is easier. duke@435: while (obj_addr < t) { duke@435: obj_addr += oop(obj_addr)->oop_iterate(cl); duke@435: } duke@435: } duke@435: duke@435: void ImmutableSpace::object_iterate(ObjectClosure* cl) { duke@435: HeapWord* p = bottom(); duke@435: while (p < end()) { duke@435: cl->do_object(oop(p)); duke@435: p += oop(p)->size(); duke@435: } duke@435: } duke@435: duke@435: #ifndef PRODUCT duke@435: duke@435: void ImmutableSpace::print_short() const { duke@435: tty->print(" space " SIZE_FORMAT "K, 100%% used", capacity_in_bytes() / K); duke@435: } duke@435: duke@435: void ImmutableSpace::print() const { duke@435: print_short(); drchase@6680: tty->print_cr(" [" INTPTR_FORMAT_W(#-6) "," INTPTR_FORMAT_W(#-6) ")", p2i(bottom()), p2i(end())); duke@435: } duke@435: duke@435: #endif duke@435: brutisso@3711: void ImmutableSpace::verify() { duke@435: HeapWord* p = bottom(); duke@435: HeapWord* t = end(); duke@435: HeapWord* prev_p = NULL; duke@435: while (p < t) { duke@435: oop(p)->verify(); duke@435: prev_p = p; duke@435: p += oop(p)->size(); duke@435: } duke@435: guarantee(p == end(), "end of last object must match end of space"); duke@435: }