8151342: Add module name/version to class histogram output
Add additional column to histogram containing module@version Reviewed-by: sundar, gtriantafill
This commit is contained in:
parent
7d20b786fd
commit
d30adc68f2
@ -24,6 +24,7 @@
|
|||||||
|
|
||||||
#include "precompiled.hpp"
|
#include "precompiled.hpp"
|
||||||
#include "classfile/classLoaderData.hpp"
|
#include "classfile/classLoaderData.hpp"
|
||||||
|
#include "classfile/moduleEntry.hpp"
|
||||||
#include "classfile/systemDictionary.hpp"
|
#include "classfile/systemDictionary.hpp"
|
||||||
#include "gc/shared/collectedHeap.hpp"
|
#include "gc/shared/collectedHeap.hpp"
|
||||||
#include "gc/shared/genCollectedHeap.hpp"
|
#include "gc/shared/genCollectedHeap.hpp"
|
||||||
@ -105,10 +106,20 @@ void KlassInfoEntry::print_on(outputStream* st) const {
|
|||||||
ResourceMark rm;
|
ResourceMark rm;
|
||||||
|
|
||||||
// simplify the formatting (ILP32 vs LP64) - always cast the numbers to 64-bit
|
// simplify the formatting (ILP32 vs LP64) - always cast the numbers to 64-bit
|
||||||
st->print_cr(INT64_FORMAT_W(13) " " UINT64_FORMAT_W(13) " %s",
|
ModuleEntry* module = _klass->module();
|
||||||
(int64_t)_instance_count,
|
if (module->is_named()) {
|
||||||
(uint64_t)_instance_words * HeapWordSize,
|
st->print_cr(INT64_FORMAT_W(13) " " UINT64_FORMAT_W(13) " %s (%s@%s)",
|
||||||
name());
|
(int64_t)_instance_count,
|
||||||
|
(uint64_t)_instance_words * HeapWordSize,
|
||||||
|
name(),
|
||||||
|
module->name()->as_C_string(),
|
||||||
|
module->version() != NULL ? module->version()->as_C_string() : "");
|
||||||
|
} else {
|
||||||
|
st->print_cr(INT64_FORMAT_W(13) " " UINT64_FORMAT_W(13) " %s",
|
||||||
|
(int64_t)_instance_count,
|
||||||
|
(uint64_t)_instance_words * HeapWordSize,
|
||||||
|
name());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
KlassInfoEntry* KlassInfoBucket::lookup(Klass* const k) {
|
KlassInfoEntry* KlassInfoBucket::lookup(Klass* const k) {
|
||||||
@ -647,8 +658,8 @@ void KlassInfoHisto::print_histo_on(outputStream* st, bool print_stats,
|
|||||||
if (print_stats) {
|
if (print_stats) {
|
||||||
print_class_stats(st, csv_format, columns);
|
print_class_stats(st, csv_format, columns);
|
||||||
} else {
|
} else {
|
||||||
st->print_cr(" num #instances #bytes class name");
|
st->print_cr(" num #instances #bytes class name (module)");
|
||||||
st->print_cr("----------------------------------------------");
|
st->print_cr("-------------------------------------------------------");
|
||||||
print_elements(st);
|
print_elements(st);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -57,33 +57,34 @@ public class ClassHistogramTest {
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* example output:
|
* example output:
|
||||||
* num #instances #bytes class name
|
* num #instances #bytes class name (module)
|
||||||
* ----------------------------------------------
|
* -------------------------------------------------------
|
||||||
* 1: 1647 1133752 [B
|
* 1: 7991 757792 [B (java.base@9-internal)
|
||||||
* 2: 6198 383168 [C
|
* 2: 1811 217872 java.lang.Class (java.base@9-internal)
|
||||||
* 3: 1464 165744 java.lang.Class
|
* 3: 6724 215168 java.util.HashMap$Node (java.base@9-internal)
|
||||||
* 4: 6151 147624 java.lang.String
|
* 4: 7852 188448 java.lang.String (java.base@9-internal)
|
||||||
* 5: 2304 73728 java.util.concurrent.ConcurrentHashMap$Node
|
* 5: 1378 105040 [Ljava.util.HashMap$Node; (java.base@9-internal)
|
||||||
* 6: 1199 64280 [Ljava.lang.Object;
|
* 6: 1863 95096 [Ljava.lang.Object; (java.base@9-internal)
|
||||||
|
|
||||||
* ...
|
* ...
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/* Require at least one java.lang.Class */
|
/* Require at least one java.lang.Class */
|
||||||
output.shouldMatch("^\\s+\\d+:\\s+\\d+\\s+\\d+\\s+java.lang.Class\\s*$");
|
output.shouldMatch("^\\s+\\d+:\\s+\\d+\\s+\\d+\\s+java.lang.Class \\(java.base@\\S*\\)\\s*$");
|
||||||
|
|
||||||
/* Require at least one java.lang.String */
|
/* Require at least one java.lang.String */
|
||||||
output.shouldMatch("^\\s+\\d+:\\s+\\d+\\s+\\d+\\s+java.lang.String\\s*$");
|
output.shouldMatch("^\\s+\\d+:\\s+\\d+\\s+\\d+\\s+java.lang.String \\(java.base@\\S*\\)\\s*$");
|
||||||
|
|
||||||
/* Require at least one java.lang.Object */
|
/* Require at least one java.lang.Object */
|
||||||
output.shouldMatch("^\\s+\\d+:\\s+\\d+\\s+\\d+\\s+java.lang.Object\\s*$");
|
output.shouldMatch("^\\s+\\d+:\\s+\\d+\\s+\\d+\\s+java.lang.Object \\(java.base@\\S*\\)\\s*$");
|
||||||
|
|
||||||
/* Require at exactly one TestClass[] */
|
/* Require at exactly one TestClass[] */
|
||||||
output.shouldMatch("^\\s+\\d+:\\s+1\\s+\\d+\\s+" +
|
output.shouldMatch("^\\s+\\d+:\\s+1\\s+\\d+\\s+" +
|
||||||
Pattern.quote(TestClass[].class.getName()) + "\\s*$");
|
Pattern.quote(TestClass[].class.getName()) + "\\s*$");
|
||||||
|
|
||||||
/* Require at exactly 1024 TestClass */
|
/* Require at exactly 1024 TestClass */
|
||||||
output.shouldMatch("^\\s+\\d+:\\s+1024\\s+\\d+\\s+" +
|
output.shouldMatch("^\\s+\\d+:\\s+1024\\s+\\d+\\s+" +
|
||||||
Pattern.quote(TestClass.class.getName()) + "\\s*$");
|
Pattern.quote(TestClass.class.getName()) + "\\s*$");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
|
Loading…
x
Reference in New Issue
Block a user