Mercurial > hg > graal-compiler
annotate src/share/vm/utilities/histogram.cpp @ 14562:45812e05cdb3
Move narrow oop handling in reference maps to hotspot specific code.
author | Roland Schatz <roland.schatz@oracle.com> |
---|---|
date | Mon, 17 Mar 2014 12:07:49 +0100 |
parents | b9a9ed0f8eeb |
children |
rev | line source |
---|---|
0 | 1 /* |
6842
b9a9ed0f8eeb
7197424: update copyright year to match last edit in jdk8 hotspot repository
mikael
parents:
6197
diff
changeset
|
2 * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. |
0 | 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 * | |
1552
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
c18cbe5936b8
6941466: Oracle rebranding changes for Hotspot repositories
trims
parents:
0
diff
changeset
|
21 * questions. |
0 | 22 * |
23 */ | |
24 | |
1972 | 25 #include "precompiled.hpp" |
26 #include "oops/oop.inline.hpp" | |
27 #include "utilities/histogram.hpp" | |
0 | 28 |
29 #ifdef ASSERT | |
30 | |
31 ////////////////// HistogramElement //////////////////////// | |
32 | |
33 HistogramElement::HistogramElement() { | |
34 _count = 0; | |
35 } | |
36 | |
37 int HistogramElement::count() { | |
38 return _count; | |
39 } | |
40 | |
41 const char* HistogramElement::name() { | |
42 return _name; | |
43 } | |
44 | |
45 void HistogramElement::increment_count() { | |
46 // We can't use the accessor :-(. | |
47 Atomic::inc(&_count); | |
48 } | |
49 | |
50 int HistogramElement::compare(HistogramElement* e1,HistogramElement* e2) { | |
51 if(e1->count() > e2->count()) { | |
52 return -1; | |
53 } else if(e1->count() < e2->count()) { | |
54 return 1; | |
55 } | |
56 return 0; | |
57 } | |
58 | |
59 void HistogramElement::print_on(outputStream* st) const { | |
60 st->print("%10d ",((HistogramElement*)this)->count()); | |
61 st->print_cr("%s",((HistogramElement*)this)->name()); | |
62 } | |
63 | |
64 ////////////////// Histogram //////////////////////// | |
65 | |
66 int Histogram::sort_helper(HistogramElement** e1, HistogramElement** e2) { | |
67 return (*e1)->compare(*e1,*e2); | |
68 } | |
69 | |
70 Histogram::Histogram(const char* title,int estimatedCount) { | |
71 _title = title; | |
6197 | 72 _elements = new (ResourceObj::C_HEAP, mtInternal) GrowableArray<HistogramElement*>(estimatedCount,true); |
0 | 73 } |
74 | |
75 void Histogram::add_element(HistogramElement* element) { | |
76 // Note, we need to add locking ! | |
77 elements()->append(element); | |
78 } | |
79 | |
80 void Histogram::print_header(outputStream* st) { | |
81 st->print_cr("%s",title()); | |
82 st->print_cr("--------------------------------------------------"); | |
83 } | |
84 | |
85 void Histogram::print_elements(outputStream* st) { | |
86 elements()->sort(Histogram::sort_helper); | |
87 jint total = 0; | |
88 for(int i=0; i < elements()->length(); i++) { | |
89 elements()->at(i)->print(); | |
90 total += elements()->at(i)->count(); | |
91 } | |
92 st->print("%10d ", total); | |
93 st->print_cr("Total"); | |
94 } | |
95 | |
96 void Histogram::print_on(outputStream* st) const { | |
97 ((Histogram*)this)->print_header(st); | |
98 ((Histogram*)this)->print_elements(st); | |
99 } | |
100 | |
101 #endif |