Tue, 12 Feb 2013 12:19:28 -0500
8007950: Undo hs_file permission change
Summary: Reverse hs_err file permission back to 0666, as early push was premature
Reviewed-by: dsamersoff, dcubed, acorn
duke@435 | 1 | /* |
mikael@4153 | 2 | * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. |
duke@435 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
duke@435 | 4 | * |
duke@435 | 5 | * This code is free software; you can redistribute it and/or modify it |
duke@435 | 6 | * under the terms of the GNU General Public License version 2 only, as |
duke@435 | 7 | * published by the Free Software Foundation. |
duke@435 | 8 | * |
duke@435 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
duke@435 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
duke@435 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
duke@435 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
duke@435 | 13 | * accompanied this code). |
duke@435 | 14 | * |
duke@435 | 15 | * You should have received a copy of the GNU General Public License version |
duke@435 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
duke@435 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
duke@435 | 18 | * |
trims@1907 | 19 | * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
trims@1907 | 20 | * or visit www.oracle.com if you need additional information or have any |
trims@1907 | 21 | * questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
stefank@2314 | 25 | #include "precompiled.hpp" |
stefank@2314 | 26 | #include "oops/oop.inline.hpp" |
stefank@2314 | 27 | #include "utilities/histogram.hpp" |
duke@435 | 28 | |
duke@435 | 29 | #ifdef ASSERT |
duke@435 | 30 | |
duke@435 | 31 | ////////////////// HistogramElement //////////////////////// |
duke@435 | 32 | |
duke@435 | 33 | HistogramElement::HistogramElement() { |
duke@435 | 34 | _count = 0; |
duke@435 | 35 | } |
duke@435 | 36 | |
duke@435 | 37 | int HistogramElement::count() { |
duke@435 | 38 | return _count; |
duke@435 | 39 | } |
duke@435 | 40 | |
duke@435 | 41 | const char* HistogramElement::name() { |
duke@435 | 42 | return _name; |
duke@435 | 43 | } |
duke@435 | 44 | |
duke@435 | 45 | void HistogramElement::increment_count() { |
duke@435 | 46 | // We can't use the accessor :-(. |
duke@435 | 47 | Atomic::inc(&_count); |
duke@435 | 48 | } |
duke@435 | 49 | |
duke@435 | 50 | int HistogramElement::compare(HistogramElement* e1,HistogramElement* e2) { |
duke@435 | 51 | if(e1->count() > e2->count()) { |
duke@435 | 52 | return -1; |
duke@435 | 53 | } else if(e1->count() < e2->count()) { |
duke@435 | 54 | return 1; |
duke@435 | 55 | } |
duke@435 | 56 | return 0; |
duke@435 | 57 | } |
duke@435 | 58 | |
duke@435 | 59 | void HistogramElement::print_on(outputStream* st) const { |
duke@435 | 60 | st->print("%10d ",((HistogramElement*)this)->count()); |
duke@435 | 61 | st->print_cr("%s",((HistogramElement*)this)->name()); |
duke@435 | 62 | } |
duke@435 | 63 | |
duke@435 | 64 | ////////////////// Histogram //////////////////////// |
duke@435 | 65 | |
duke@435 | 66 | int Histogram::sort_helper(HistogramElement** e1, HistogramElement** e2) { |
duke@435 | 67 | return (*e1)->compare(*e1,*e2); |
duke@435 | 68 | } |
duke@435 | 69 | |
duke@435 | 70 | Histogram::Histogram(const char* title,int estimatedCount) { |
duke@435 | 71 | _title = title; |
zgu@3900 | 72 | _elements = new (ResourceObj::C_HEAP, mtInternal) GrowableArray<HistogramElement*>(estimatedCount,true); |
duke@435 | 73 | } |
duke@435 | 74 | |
duke@435 | 75 | void Histogram::add_element(HistogramElement* element) { |
duke@435 | 76 | // Note, we need to add locking ! |
duke@435 | 77 | elements()->append(element); |
duke@435 | 78 | } |
duke@435 | 79 | |
duke@435 | 80 | void Histogram::print_header(outputStream* st) { |
duke@435 | 81 | st->print_cr("%s",title()); |
duke@435 | 82 | st->print_cr("--------------------------------------------------"); |
duke@435 | 83 | } |
duke@435 | 84 | |
duke@435 | 85 | void Histogram::print_elements(outputStream* st) { |
duke@435 | 86 | elements()->sort(Histogram::sort_helper); |
duke@435 | 87 | jint total = 0; |
duke@435 | 88 | for(int i=0; i < elements()->length(); i++) { |
duke@435 | 89 | elements()->at(i)->print(); |
duke@435 | 90 | total += elements()->at(i)->count(); |
duke@435 | 91 | } |
duke@435 | 92 | st->print("%10d ", total); |
duke@435 | 93 | st->print_cr("Total"); |
duke@435 | 94 | } |
duke@435 | 95 | |
duke@435 | 96 | void Histogram::print_on(outputStream* st) const { |
duke@435 | 97 | ((Histogram*)this)->print_header(st); |
duke@435 | 98 | ((Histogram*)this)->print_elements(st); |
duke@435 | 99 | } |
duke@435 | 100 | |
duke@435 | 101 | #endif |