Fri, 07 Nov 2008 09:29:38 -0800
6462850: generate biased locking code in C2 ideal graph
Summary: Inline biased locking code in C2 ideal graph during macro nodes expansion
Reviewed-by: never
duke@435 | 1 | /* |
duke@435 | 2 | * Copyright 1998-2000 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 | // This class provides a framework for collecting various statistics. |
duke@435 | 26 | // The current implementation is oriented towards counting invocations |
duke@435 | 27 | // of various types, but that can be easily changed. |
duke@435 | 28 | // |
duke@435 | 29 | // To use it, you need to declare a Histogram*, and a subtype of |
duke@435 | 30 | // HistogramElement: |
duke@435 | 31 | // |
duke@435 | 32 | // HistogramElement* MyHistogram; |
duke@435 | 33 | // |
duke@435 | 34 | // class MyHistogramElement : public HistogramElement { |
duke@435 | 35 | // public: |
duke@435 | 36 | // MyHistogramElement(char* name); |
duke@435 | 37 | // }; |
duke@435 | 38 | // |
duke@435 | 39 | // MyHistogramElement::MyHistogramElement(char* elementName) { |
duke@435 | 40 | // _name = elementName; |
duke@435 | 41 | // |
duke@435 | 42 | // if(MyHistogram == NULL) |
duke@435 | 43 | // MyHistogram = new Histogram("My Call Counts",100); |
duke@435 | 44 | // |
duke@435 | 45 | // MyHistogram->add_element(this); |
duke@435 | 46 | // } |
duke@435 | 47 | // |
duke@435 | 48 | // #define MyCountWrapper(arg) static MyHistogramElement* e = new MyHistogramElement(arg); e->increment_count() |
duke@435 | 49 | // |
duke@435 | 50 | // This gives you a simple way to count invocations of specfic functions: |
duke@435 | 51 | // |
duke@435 | 52 | // void a_function_that_is_being_counted() { |
duke@435 | 53 | // MyCountWrapper("FunctionName"); |
duke@435 | 54 | // ... |
duke@435 | 55 | // } |
duke@435 | 56 | // |
duke@435 | 57 | // To print the results, invoke print() on your Histogram*. |
duke@435 | 58 | |
duke@435 | 59 | #ifdef ASSERT |
duke@435 | 60 | |
duke@435 | 61 | class HistogramElement : public CHeapObj { |
duke@435 | 62 | protected: |
duke@435 | 63 | jint _count; |
duke@435 | 64 | const char* _name; |
duke@435 | 65 | |
duke@435 | 66 | public: |
duke@435 | 67 | HistogramElement(); |
duke@435 | 68 | virtual int count(); |
duke@435 | 69 | virtual const char* name(); |
duke@435 | 70 | virtual void increment_count(); |
duke@435 | 71 | void print_on(outputStream* st) const; |
duke@435 | 72 | virtual int compare(HistogramElement* e1,HistogramElement* e2); |
duke@435 | 73 | }; |
duke@435 | 74 | |
duke@435 | 75 | class Histogram : public CHeapObj { |
duke@435 | 76 | protected: |
duke@435 | 77 | GrowableArray<HistogramElement*>* _elements; |
duke@435 | 78 | GrowableArray<HistogramElement*>* elements() { return _elements; } |
duke@435 | 79 | const char* _title; |
duke@435 | 80 | const char* title() { return _title; } |
duke@435 | 81 | static int sort_helper(HistogramElement** e1,HistogramElement** e2); |
duke@435 | 82 | virtual void print_header(outputStream* st); |
duke@435 | 83 | virtual void print_elements(outputStream* st); |
duke@435 | 84 | |
duke@435 | 85 | public: |
duke@435 | 86 | Histogram(const char* title,int estimatedSize); |
duke@435 | 87 | virtual void add_element(HistogramElement* element); |
duke@435 | 88 | void print_on(outputStream* st) const; |
duke@435 | 89 | }; |
duke@435 | 90 | |
duke@435 | 91 | #endif |