Path: blob/master/src/hotspot/share/memory/metaspaceTracer.cpp
40949 views
/*1* Copyright (c) 2014, 2020, 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 "classfile/classLoaderData.hpp"26#include "jfr/jfrEvents.hpp"27#include "memory/metaspaceTracer.hpp"28#include "oops/oop.inline.hpp"2930void MetaspaceTracer::report_gc_threshold(size_t old_val,31size_t new_val,32MetaspaceGCThresholdUpdater::Type updater) const {33EventMetaspaceGCThreshold event;34if (event.should_commit()) {35event.set_oldValue(old_val);36event.set_newValue(new_val);37event.set_updater((u1)updater);38event.commit();39}40}4142void MetaspaceTracer::report_metaspace_allocation_failure(ClassLoaderData *cld,43size_t word_size,44MetaspaceObj::Type objtype,45Metaspace::MetadataType mdtype) const {46send_allocation_failure_event<EventMetaspaceAllocationFailure>(cld, word_size, objtype, mdtype);47}4849void MetaspaceTracer::report_metadata_oom(ClassLoaderData *cld,50size_t word_size,51MetaspaceObj::Type objtype,52Metaspace::MetadataType mdtype) const {53send_allocation_failure_event<EventMetaspaceOOM>(cld, word_size, objtype, mdtype);54}5556template <typename E>57void MetaspaceTracer::send_allocation_failure_event(ClassLoaderData *cld,58size_t word_size,59MetaspaceObj::Type objtype,60Metaspace::MetadataType mdtype) const {61E event;62if (event.should_commit()) {63event.set_classLoader(cld);64event.set_hiddenClassLoader(cld->has_class_mirror_holder());65event.set_size(word_size * BytesPerWord);66event.set_metadataType((u1) mdtype);67event.set_metaspaceObjectType((u1) objtype);68event.commit();69}70}717273