< prev index next >

src/hotspot/os/windows/os_perf_windows.cpp

Print this page

 127 static void pdh_cleanup(HQUERY* const query, HCOUNTER* const counter) {
 128   if (counter != NULL && *counter != NULL) {
 129     PdhDll::PdhRemoveCounter(*counter);
 130     *counter = NULL;
 131   }
 132   if (query != NULL && *query != NULL) {
 133     PdhDll::PdhCloseQuery(*query);
 134     *query = NULL;
 135   }
 136 }
 137 
 138 static CounterQueryP create_counter_query() {
 139   CounterQueryP const query = NEW_C_HEAP_OBJ(CounterQueryS, mtInternal);
 140   memset(query, 0, sizeof(CounterQueryS));
 141   return query;
 142 }
 143 
 144 static void destroy_counter_query(CounterQueryP query) {
 145   assert(query != NULL, "invariant");
 146   pdh_cleanup(&query->query.query, &query->counter);
 147   FREE_C_HEAP_ARRAY(CounterQueryS, query);
 148 }
 149 
 150 static MultiCounterQueryP create_multi_counter_query() {
 151   MultiCounterQueryP const query = NEW_C_HEAP_OBJ(MultiCounterQueryS, mtInternal);
 152   memset(query, 0, sizeof(MultiCounterQueryS));
 153   return query;
 154 }
 155 
 156 static void destroy_counter_query(MultiCounterQueryP counter_query) {
 157   if (counter_query != NULL) {
 158     for (int i = 0; i < counter_query->noOfCounters; ++i) {
 159       pdh_cleanup(NULL, &counter_query->counters[i]);
 160     }
 161     FREE_C_HEAP_ARRAY(char, counter_query->counters);
 162     pdh_cleanup(&counter_query->query.query, NULL);
 163     FREE_C_HEAP_ARRAY(MultiCounterQueryS, counter_query);
 164   }
 165 }
 166 
 167 static void destroy_multi_counter_query(MultiCounterQuerySetP counter_query_set) {
 168   for (int i = 0; i < counter_query_set->size; i++) {
 169     for (int j = 0; j < counter_query_set->queries[i].noOfCounters; ++j) {
 170       pdh_cleanup(NULL, &counter_query_set->queries[i].counters[j]);
 171     }

 165 }
 166 
 167 static void destroy_multi_counter_query(MultiCounterQuerySetP counter_query_set) {
 168   for (int i = 0; i < counter_query_set->size; i++) {
 169     for (int j = 0; j < counter_query_set->queries[i].noOfCounters; ++j) {
 170       pdh_cleanup(NULL, &counter_query_set->queries[i].counters[j]);
 171     }
 172     FREE_C_HEAP_ARRAY(char, counter_query_set->queries[i].counters);
 173     pdh_cleanup(&counter_query_set->queries[i].query.query, NULL);
 174   }
 175   FREE_C_HEAP_ARRAY(MultiCounterQueryS, counter_query_set->queries);
 176 }
 177 
 178 static void destroy_counter_query(MultiCounterQuerySetP counter_query_set) {
 179   destroy_multi_counter_query(counter_query_set);
 180   FREE_C_HEAP_ARRAY(MultiCounterQuerySetS, counter_query_set);
 181 }
 182 
 183 static void destroy_counter_query(ProcessQueryP process_query) {
 184   destroy_multi_counter_query(&process_query->set);
 185   FREE_C_HEAP_ARRAY(ProcessQueryS, process_query);
 186 }
 187 
 188 static int open_query(HQUERY* query) {
 189   return PdhDll::PdhOpenQuery(NULL, 0, query);
 190 }
 191 
 192 template <typename QueryP>
 193 static int open_query(QueryP query) {
 194   return open_query(&query->query);
 195 }
 196 
 197 static int allocate_counters(MultiCounterQueryP query, size_t nofCounters) {
 198   assert(query != NULL, "invariant");
 199   assert(!query->initialized, "invariant");
 200   assert(0 == query->noOfCounters, "invariant");
 201   assert(query->counters == NULL, "invariant");
 202   query->counters = NEW_C_HEAP_ARRAY(HCOUNTER, nofCounters, mtInternal);
 203   if (query->counters == NULL) {
 204     return OS_ERR;
 205   }

 127 static void pdh_cleanup(HQUERY* const query, HCOUNTER* const counter) {
 128   if (counter != NULL && *counter != NULL) {
 129     PdhDll::PdhRemoveCounter(*counter);
 130     *counter = NULL;
 131   }
 132   if (query != NULL && *query != NULL) {
 133     PdhDll::PdhCloseQuery(*query);
 134     *query = NULL;
 135   }
 136 }
 137 
 138 static CounterQueryP create_counter_query() {
 139   CounterQueryP const query = NEW_C_HEAP_OBJ(CounterQueryS, mtInternal);
 140   memset(query, 0, sizeof(CounterQueryS));
 141   return query;
 142 }
 143 
 144 static void destroy_counter_query(CounterQueryP query) {
 145   assert(query != NULL, "invariant");
 146   pdh_cleanup(&query->query.query, &query->counter);
 147   FREE_C_HEAP_OBJ(query);
 148 }
 149 
 150 static MultiCounterQueryP create_multi_counter_query() {
 151   MultiCounterQueryP const query = NEW_C_HEAP_ARRAY(MultiCounterQueryS, 1, mtInternal);
 152   memset(query, 0, sizeof(MultiCounterQueryS));
 153   return query;
 154 }
 155 
 156 static void destroy_counter_query(MultiCounterQueryP counter_query) {
 157   if (counter_query != NULL) {
 158     for (int i = 0; i < counter_query->noOfCounters; ++i) {
 159       pdh_cleanup(NULL, &counter_query->counters[i]);
 160     }
 161     FREE_C_HEAP_ARRAY(char, counter_query->counters);
 162     pdh_cleanup(&counter_query->query.query, NULL);
 163     FREE_C_HEAP_ARRAY(MultiCounterQueryS, counter_query);
 164   }
 165 }
 166 
 167 static void destroy_multi_counter_query(MultiCounterQuerySetP counter_query_set) {
 168   for (int i = 0; i < counter_query_set->size; i++) {
 169     for (int j = 0; j < counter_query_set->queries[i].noOfCounters; ++j) {
 170       pdh_cleanup(NULL, &counter_query_set->queries[i].counters[j]);
 171     }

 165 }
 166 
 167 static void destroy_multi_counter_query(MultiCounterQuerySetP counter_query_set) {
 168   for (int i = 0; i < counter_query_set->size; i++) {
 169     for (int j = 0; j < counter_query_set->queries[i].noOfCounters; ++j) {
 170       pdh_cleanup(NULL, &counter_query_set->queries[i].counters[j]);
 171     }
 172     FREE_C_HEAP_ARRAY(char, counter_query_set->queries[i].counters);
 173     pdh_cleanup(&counter_query_set->queries[i].query.query, NULL);
 174   }
 175   FREE_C_HEAP_ARRAY(MultiCounterQueryS, counter_query_set->queries);
 176 }
 177 
 178 static void destroy_counter_query(MultiCounterQuerySetP counter_query_set) {
 179   destroy_multi_counter_query(counter_query_set);
 180   FREE_C_HEAP_ARRAY(MultiCounterQuerySetS, counter_query_set);
 181 }
 182 
 183 static void destroy_counter_query(ProcessQueryP process_query) {
 184   destroy_multi_counter_query(&process_query->set);
 185   FREE_C_HEAP_OBJ(process_query);
 186 }
 187 
 188 static int open_query(HQUERY* query) {
 189   return PdhDll::PdhOpenQuery(NULL, 0, query);
 190 }
 191 
 192 template <typename QueryP>
 193 static int open_query(QueryP query) {
 194   return open_query(&query->query);
 195 }
 196 
 197 static int allocate_counters(MultiCounterQueryP query, size_t nofCounters) {
 198   assert(query != NULL, "invariant");
 199   assert(!query->initialized, "invariant");
 200   assert(0 == query->noOfCounters, "invariant");
 201   assert(query->counters == NULL, "invariant");
 202   query->counters = NEW_C_HEAP_ARRAY(HCOUNTER, nofCounters, mtInternal);
 203   if (query->counters == NULL) {
 204     return OS_ERR;
 205   }
< prev index next >