Path: blob/aarch64-shenandoah-jdk8u272-b10/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/freeChunk.cpp
38921 views
/*1* Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.2* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.3*4* This code is free software; you can redistribute it and/or modify it5* under the terms of the GNU General Public License version 2 only, as6* published by the Free Software Foundation.7*8* This code is distributed in the hope that it will be useful, but WITHOUT9* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or10* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License11* version 2 for more details (a copy is included in the LICENSE file that12* accompanied this code).13*14* You should have received a copy of the GNU General Public License version15* 2 along with this work; if not, write to the Free Software Foundation,16* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.17*18* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA19* or visit www.oracle.com if you need additional information or have any20* questions.21*22*/2324#include "precompiled.hpp"25#include "gc_implementation/concurrentMarkSweep/freeChunk.hpp"26#include "memory/freeBlockDictionary.hpp"27#include "utilities/copy.hpp"2829PRAGMA_FORMAT_MUTE_WARNINGS_FOR_GCC3031#ifndef PRODUCT3233#define baadbabeHeapWord badHeapWordVal34#define deadbeefHeapWord 0xdeadbeef3536size_t const FreeChunk::header_size() {37return sizeof(FreeChunk)/HeapWordSize;38}3940void FreeChunk::mangleAllocated(size_t size) {41// mangle all but the header of a just-allocated block42// of storage43assert(size >= MinChunkSize, "smallest size of object");44// we can't assert that _size == size because this may be an45// allocation out of a linear allocation block46assert(sizeof(FreeChunk) % HeapWordSize == 0,47"shouldn't write beyond chunk");48HeapWord* addr = (HeapWord*)this;49size_t hdr = header_size();50Copy::fill_to_words(addr + hdr, size - hdr, baadbabeHeapWord);51}5253void FreeChunk::mangleFreed(size_t sz) {54assert(baadbabeHeapWord != deadbeefHeapWord, "Need distinct patterns");55// mangle all but the header of a just-freed block of storage56// just prior to passing it to the storage dictionary57assert(sz >= MinChunkSize, "smallest size of object");58assert(sz == size(), "just checking");59HeapWord* addr = (HeapWord*)this;60size_t hdr = header_size();61Copy::fill_to_words(addr + hdr, sz - hdr, deadbeefHeapWord);62}6364void FreeChunk::verifyList() const {65FreeChunk* nextFC = next();66if (nextFC != NULL) {67assert(this == nextFC->prev(), "broken chain");68assert(size() == nextFC->size(), "wrong size");69nextFC->verifyList();70}71}72#endif7374void FreeChunk::print_on(outputStream* st) {75st->print_cr("Next: " PTR_FORMAT " Prev: " PTR_FORMAT " %s",76next(), prev(), cantCoalesce() ? "[can't coalesce]" : "");77}787980