Fri, 05 Oct 2012 18:57:10 -0700
7177003: C1: LogCompilation support
Summary: add LogCompilation support in C1 - both client and tiered mode.
Reviewed-by: twisti, kvn
ysr@777 | 1 | /* |
brutisso@3641 | 2 | * Copyright (c) 2001, 2012, Oracle and/or its affiliates. All rights reserved. |
ysr@777 | 3 | * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
ysr@777 | 4 | * |
ysr@777 | 5 | * This code is free software; you can redistribute it and/or modify it |
ysr@777 | 6 | * under the terms of the GNU General Public License version 2 only, as |
ysr@777 | 7 | * published by the Free Software Foundation. |
ysr@777 | 8 | * |
ysr@777 | 9 | * This code is distributed in the hope that it will be useful, but WITHOUT |
ysr@777 | 10 | * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
ysr@777 | 11 | * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
ysr@777 | 12 | * version 2 for more details (a copy is included in the LICENSE file that |
ysr@777 | 13 | * accompanied this code). |
ysr@777 | 14 | * |
ysr@777 | 15 | * You should have received a copy of the GNU General Public License version |
ysr@777 | 16 | * 2 along with this work; if not, write to the Free Software Foundation, |
ysr@777 | 17 | * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
ysr@777 | 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. |
ysr@777 | 22 | * |
ysr@777 | 23 | */ |
ysr@777 | 24 | |
stefank@2314 | 25 | #ifndef SHARE_VM_UTILITIES_NUMBERSEQ_HPP |
stefank@2314 | 26 | #define SHARE_VM_UTILITIES_NUMBERSEQ_HPP |
stefank@2314 | 27 | |
zgu@3900 | 28 | #include "memory/allocation.hpp" |
zgu@3900 | 29 | |
ysr@777 | 30 | /** |
ysr@777 | 31 | ** This file contains a few classes that represent number sequence, |
ysr@777 | 32 | ** x1, x2, x3, ..., xN, and can calculate their avg, max, and sd. |
ysr@777 | 33 | ** |
ysr@777 | 34 | ** Here's a quick description of the classes: |
ysr@777 | 35 | ** |
ysr@777 | 36 | ** AbsSeq: abstract superclass |
ysr@777 | 37 | ** NumberSeq: the sequence is assumed to be very long and the |
ysr@777 | 38 | ** maximum, avg, sd, davg, and dsd are calculated over all its elements |
ysr@777 | 39 | ** TruncatedSeq: this class keeps track of the last L elements |
ysr@777 | 40 | ** of the sequence and calculates avg, max, and sd only over them |
ysr@777 | 41 | **/ |
ysr@777 | 42 | |
ysr@777 | 43 | #define DEFAULT_ALPHA_VALUE 0.7 |
ysr@777 | 44 | |
zgu@3900 | 45 | class AbsSeq: public CHeapObj<mtInternal> { |
ysr@777 | 46 | private: |
ysr@777 | 47 | void init(double alpha); |
ysr@777 | 48 | |
ysr@777 | 49 | protected: |
ysr@777 | 50 | int _num; // the number of elements in the sequence |
ysr@777 | 51 | double _sum; // the sum of the elements in the sequence |
ysr@777 | 52 | double _sum_of_squares; // the sum of squares of the elements in the sequence |
ysr@777 | 53 | |
ysr@777 | 54 | double _davg; // decaying average |
ysr@777 | 55 | double _dvariance; // decaying variance |
ysr@777 | 56 | double _alpha; // factor for the decaying average / variance |
ysr@777 | 57 | |
ysr@777 | 58 | // This is what we divide with to get the average. In a standard |
ysr@777 | 59 | // number sequence, this should just be the number of elements in it. |
ysr@777 | 60 | virtual double total() const { return (double) _num; }; |
ysr@777 | 61 | |
ysr@777 | 62 | public: |
ysr@777 | 63 | AbsSeq(double alpha = DEFAULT_ALPHA_VALUE); |
ysr@777 | 64 | |
ysr@777 | 65 | virtual void add(double val); // adds a new element to the sequence |
ysr@777 | 66 | void add(unsigned val) { add((double) val); } |
ysr@777 | 67 | virtual double maximum() const = 0; // maximum element in the sequence |
ysr@777 | 68 | virtual double last() const = 0; // last element added in the sequence |
ysr@777 | 69 | |
ysr@777 | 70 | // the number of elements in the sequence |
ysr@777 | 71 | int num() const { return _num; } |
ysr@777 | 72 | // the sum of the elements in the sequence |
ysr@777 | 73 | double sum() const { return _sum; } |
ysr@777 | 74 | |
ysr@777 | 75 | double avg() const; // the average of the sequence |
ysr@777 | 76 | double variance() const; // the variance of the sequence |
ysr@777 | 77 | double sd() const; // the standard deviation of the sequence |
ysr@777 | 78 | |
ysr@777 | 79 | double davg() const; // decaying average |
ysr@777 | 80 | double dvariance() const; // decaying variance |
ysr@777 | 81 | double dsd() const; // decaying "standard deviation" |
ysr@1521 | 82 | |
ysr@1521 | 83 | // Debugging/Printing |
ysr@1521 | 84 | virtual void dump(); |
ysr@1521 | 85 | virtual void dump_on(outputStream* s); |
ysr@777 | 86 | }; |
ysr@777 | 87 | |
ysr@777 | 88 | class NumberSeq: public AbsSeq { |
ysr@777 | 89 | private: |
ysr@777 | 90 | bool check_nums(NumberSeq* total, int n, NumberSeq** parts); |
ysr@777 | 91 | |
ysr@777 | 92 | protected: |
ysr@777 | 93 | double _last; |
ysr@777 | 94 | double _maximum; // keep track of maximum value |
ysr@777 | 95 | |
ysr@777 | 96 | public: |
ysr@777 | 97 | NumberSeq(double alpha = DEFAULT_ALPHA_VALUE); |
ysr@777 | 98 | |
ysr@777 | 99 | virtual void add(double val); |
ysr@777 | 100 | virtual double maximum() const { return _maximum; } |
ysr@777 | 101 | virtual double last() const { return _last; } |
ysr@1521 | 102 | |
ysr@1521 | 103 | // Debugging/Printing |
ysr@1521 | 104 | virtual void dump_on(outputStream* s); |
ysr@777 | 105 | }; |
ysr@777 | 106 | |
ysr@777 | 107 | class TruncatedSeq: public AbsSeq { |
ysr@777 | 108 | private: |
ysr@777 | 109 | enum PrivateConstants { |
ysr@777 | 110 | DefaultSeqLength = 10 |
ysr@777 | 111 | }; |
ysr@777 | 112 | void init(); |
ysr@777 | 113 | protected: |
ysr@777 | 114 | double *_sequence; // buffers the last L elements in the sequence |
ysr@777 | 115 | int _length; // this is L |
ysr@777 | 116 | int _next; // oldest slot in the array, i.e. next to be overwritten |
ysr@777 | 117 | |
ysr@777 | 118 | public: |
ysr@777 | 119 | // accepts a value for L |
ysr@777 | 120 | TruncatedSeq(int length = DefaultSeqLength, |
ysr@777 | 121 | double alpha = DEFAULT_ALPHA_VALUE); |
brutisso@3641 | 122 | ~TruncatedSeq(); |
ysr@777 | 123 | virtual void add(double val); |
ysr@777 | 124 | virtual double maximum() const; |
ysr@777 | 125 | virtual double last() const; // the last value added to the sequence |
ysr@777 | 126 | |
ysr@777 | 127 | double oldest() const; // the oldest valid value in the sequence |
ysr@777 | 128 | double predict_next() const; // prediction based on linear regression |
ysr@1521 | 129 | |
ysr@1521 | 130 | // Debugging/Printing |
ysr@1521 | 131 | virtual void dump_on(outputStream* s); |
ysr@777 | 132 | }; |
stefank@2314 | 133 | |
stefank@2314 | 134 | #endif // SHARE_VM_UTILITIES_NUMBERSEQ_HPP |