< prev index next >

src/share/vm/memory/metaspaceTracer.cpp

Print this page
rev 8910 : full patch for jfr
   1 /*
   2  * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


  45                                                           size_t word_size,
  46                                                           MetaspaceObj::Type objtype,
  47                                                           Metaspace::MetadataType mdtype) const {
  48   send_allocation_failure_event<EventMetaspaceAllocationFailure>(cld, word_size, objtype, mdtype);
  49 }
  50 
  51 void MetaspaceTracer::report_metadata_oom(ClassLoaderData *cld,
  52                                          size_t word_size,
  53                                          MetaspaceObj::Type objtype,
  54                                          Metaspace::MetadataType mdtype) const {
  55   send_allocation_failure_event<EventMetaspaceOOM>(cld, word_size, objtype, mdtype);
  56 }
  57 
  58 template <typename E>
  59 void MetaspaceTracer::send_allocation_failure_event(ClassLoaderData *cld,
  60                                                     size_t word_size,
  61                                                     MetaspaceObj::Type objtype,
  62                                                     Metaspace::MetadataType mdtype) const {
  63   E event;
  64   if (event.should_commit()) {

  65     if (cld->is_anonymous()) {
  66       event.set_classLoader(NULL);
  67       event.set_anonymousClassLoader(true);
  68     } else {
  69       if (cld->is_the_null_class_loader_data()) {
  70         event.set_classLoader((Klass*) NULL);
  71       } else {
  72         event.set_classLoader(cld->class_loader()->klass());
  73       }
  74       event.set_anonymousClassLoader(false);
  75     }
  76 
  77     event.set_size(word_size * BytesPerWord);
  78     event.set_metadataType((u1) mdtype);
  79     event.set_metaspaceObjectType((u1) objtype);
  80     event.commit();
  81   }
  82 }
   1 /*
   2  * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  *


  45                                                           size_t word_size,
  46                                                           MetaspaceObj::Type objtype,
  47                                                           Metaspace::MetadataType mdtype) const {
  48   send_allocation_failure_event<EventMetaspaceAllocationFailure>(cld, word_size, objtype, mdtype);
  49 }
  50 
  51 void MetaspaceTracer::report_metadata_oom(ClassLoaderData *cld,
  52                                          size_t word_size,
  53                                          MetaspaceObj::Type objtype,
  54                                          Metaspace::MetadataType mdtype) const {
  55   send_allocation_failure_event<EventMetaspaceOOM>(cld, word_size, objtype, mdtype);
  56 }
  57 
  58 template <typename E>
  59 void MetaspaceTracer::send_allocation_failure_event(ClassLoaderData *cld,
  60                                                     size_t word_size,
  61                                                     MetaspaceObj::Type objtype,
  62                                                     Metaspace::MetadataType mdtype) const {
  63   E event;
  64   if (event.should_commit()) {
  65     event.set_classLoader(cld);
  66     if (cld->is_anonymous()) {

  67       event.set_anonymousClassLoader(true);
  68     } else {





  69       event.set_anonymousClassLoader(false);
  70     }
  71 
  72     event.set_size(word_size * BytesPerWord);
  73     event.set_metadataType((u1) mdtype);
  74     event.set_metaspaceObjectType((u1) objtype);
  75     event.commit();
  76   }
  77 }
< prev index next >