Tue, 11 May 2010 14:35:43 -0700
6931180: Migration to recent versions of MS Platform SDK
6951582: Build problems on win64
Summary: Changes to enable building JDK7 with Microsoft Visual Studio 2010
Reviewed-by: ohair, art, ccheung, dcubed
duke@435 | 1 | /* |
duke@435 | 2 | * Copyright 1998-2004 Sun Microsystems, Inc. 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 | * |
duke@435 | 19 | * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, |
duke@435 | 20 | * CA 95054 USA or visit www.sun.com if you need additional information or |
duke@435 | 21 | * have any questions. |
duke@435 | 22 | * |
duke@435 | 23 | */ |
duke@435 | 24 | |
duke@435 | 25 | # include "incls/_precompiled.incl" |
duke@435 | 26 | # include "incls/_histogram.cpp.incl" |
duke@435 | 27 | |
duke@435 | 28 | #ifdef ASSERT |
duke@435 | 29 | |
duke@435 | 30 | ////////////////// HistogramElement //////////////////////// |
duke@435 | 31 | |
duke@435 | 32 | HistogramElement::HistogramElement() { |
duke@435 | 33 | _count = 0; |
duke@435 | 34 | } |
duke@435 | 35 | |
duke@435 | 36 | int HistogramElement::count() { |
duke@435 | 37 | return _count; |
duke@435 | 38 | } |
duke@435 | 39 | |
duke@435 | 40 | const char* HistogramElement::name() { |
duke@435 | 41 | return _name; |
duke@435 | 42 | } |
duke@435 | 43 | |
duke@435 | 44 | void HistogramElement::increment_count() { |
duke@435 | 45 | // We can't use the accessor :-(. |
duke@435 | 46 | Atomic::inc(&_count); |
duke@435 | 47 | } |
duke@435 | 48 | |
duke@435 | 49 | int HistogramElement::compare(HistogramElement* e1,HistogramElement* e2) { |
duke@435 | 50 | if(e1->count() > e2->count()) { |
duke@435 | 51 | return -1; |
duke@435 | 52 | } else if(e1->count() < e2->count()) { |
duke@435 | 53 | return 1; |
duke@435 | 54 | } |
duke@435 | 55 | return 0; |
duke@435 | 56 | } |
duke@435 | 57 | |
duke@435 | 58 | void HistogramElement::print_on(outputStream* st) const { |
duke@435 | 59 | st->print("%10d ",((HistogramElement*)this)->count()); |
duke@435 | 60 | st->print_cr("%s",((HistogramElement*)this)->name()); |
duke@435 | 61 | } |
duke@435 | 62 | |
duke@435 | 63 | ////////////////// Histogram //////////////////////// |
duke@435 | 64 | |
duke@435 | 65 | int Histogram::sort_helper(HistogramElement** e1, HistogramElement** e2) { |
duke@435 | 66 | return (*e1)->compare(*e1,*e2); |
duke@435 | 67 | } |
duke@435 | 68 | |
duke@435 | 69 | Histogram::Histogram(const char* title,int estimatedCount) { |
duke@435 | 70 | _title = title; |
duke@435 | 71 | _elements = new (ResourceObj::C_HEAP) GrowableArray<HistogramElement*>(estimatedCount,true); |
duke@435 | 72 | } |
duke@435 | 73 | |
duke@435 | 74 | void Histogram::add_element(HistogramElement* element) { |
duke@435 | 75 | // Note, we need to add locking ! |
duke@435 | 76 | elements()->append(element); |
duke@435 | 77 | } |
duke@435 | 78 | |
duke@435 | 79 | void Histogram::print_header(outputStream* st) { |
duke@435 | 80 | st->print_cr("%s",title()); |
duke@435 | 81 | st->print_cr("--------------------------------------------------"); |
duke@435 | 82 | } |
duke@435 | 83 | |
duke@435 | 84 | void Histogram::print_elements(outputStream* st) { |
duke@435 | 85 | elements()->sort(Histogram::sort_helper); |
duke@435 | 86 | jint total = 0; |
duke@435 | 87 | for(int i=0; i < elements()->length(); i++) { |
duke@435 | 88 | elements()->at(i)->print(); |
duke@435 | 89 | total += elements()->at(i)->count(); |
duke@435 | 90 | } |
duke@435 | 91 | st->print("%10d ", total); |
duke@435 | 92 | st->print_cr("Total"); |
duke@435 | 93 | } |
duke@435 | 94 | |
duke@435 | 95 | void Histogram::print_on(outputStream* st) const { |
duke@435 | 96 | ((Histogram*)this)->print_header(st); |
duke@435 | 97 | ((Histogram*)this)->print_elements(st); |
duke@435 | 98 | } |
duke@435 | 99 | |
duke@435 | 100 | #endif |