1 // Copyright 2012 the V8 project authors. All rights reserved. 2 // Redistribution and use in source and binary forms, with or without 3 // modification, are permitted provided that the following conditions are 4 // met: 5 // 6 // * Redistributions of source code must retain the above copyright 7 // notice, this list of conditions and the following disclaimer. 8 // * Redistributions in binary form must reproduce the above 9 // copyright notice, this list of conditions and the following 10 // disclaimer in the documentation and/or other materials provided 11 // with the distribution. 12 // * Neither the name of Google Inc. nor the names of its 13 // contributors may be used to endorse or promote products derived 14 // from this software without specific prior written permission. 15 // 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 27 28 #include "v8.h" 29 30 #include "v8-counters.h" 31 32 namespace v8 { 33 namespace internal { 34 35 Counters::Counters(Isolate* isolate) { 36 #define HT(name, caption) \ 37 name##_ = HistogramTimer(#caption, 0, 10000, 50, isolate); 38 HISTOGRAM_TIMER_LIST(HT) 39 #undef HT 40 41 #define HP(name, caption) \ 42 name##_ = Histogram(#caption, 0, 101, 100, isolate); 43 HISTOGRAM_PERCENTAGE_LIST(HP) 44 #undef HP 45 46 #define HM(name, caption) \ 47 name##_ = Histogram(#caption, 1000, 500000, 50, isolate); 48 HISTOGRAM_MEMORY_LIST(HM) 49 #undef HM 50 51 #define SC(name, caption) \ 52 name##_ = StatsCounter(isolate, "c:" #caption); 53 54 STATS_COUNTER_LIST_1(SC) 55 STATS_COUNTER_LIST_2(SC) 56 #undef SC 57 58 #define SC(name) \ 59 count_of_##name##_ = StatsCounter(isolate, "c:" "V8.CountOf_" #name); \ 60 size_of_##name##_ = StatsCounter(isolate, "c:" "V8.SizeOf_" #name); 61 INSTANCE_TYPE_LIST(SC) 62 #undef SC 63 64 #define SC(name) \ 65 count_of_CODE_TYPE_##name##_ = \ 66 StatsCounter(isolate, "c:" "V8.CountOf_CODE_TYPE-" #name); \ 67 size_of_CODE_TYPE_##name##_ = \ 68 StatsCounter(isolate, "c:" "V8.SizeOf_CODE_TYPE-" #name); 69 CODE_KIND_LIST(SC) 70 #undef SC 71 72 #define SC(name) \ 73 count_of_FIXED_ARRAY_##name##_ = \ 74 StatsCounter(isolate, "c:" "V8.CountOf_FIXED_ARRAY-" #name); \ 75 size_of_FIXED_ARRAY_##name##_ = \ 76 StatsCounter(isolate, "c:" "V8.SizeOf_FIXED_ARRAY-" #name); 77 FIXED_ARRAY_SUB_INSTANCE_TYPE_LIST(SC) 78 #undef SC 79 80 #define SC(name) \ 81 count_of_CODE_AGE_##name##_ = \ 82 StatsCounter(isolate, "c:" "V8.CountOf_CODE_AGE-" #name); \ 83 size_of_CODE_AGE_##name##_ = \ 84 StatsCounter(isolate, "c:" "V8.SizeOf_CODE_AGE-" #name); 85 CODE_AGE_LIST_COMPLETE(SC) 86 #undef SC 87 } 88 89 90 void Counters::ResetHistograms() { 91 #define HT(name, caption) name##_.Reset(); 92 HISTOGRAM_TIMER_LIST(HT) 93 #undef HT 94 95 #define HP(name, caption) name##_.Reset(); 96 HISTOGRAM_PERCENTAGE_LIST(HP) 97 #undef HP 98 99 #define HM(name, caption) name##_.Reset(); 100 HISTOGRAM_MEMORY_LIST(HM) 101 #undef HM 102 } 103 104 } } // namespace v8::internal 105