OLD | NEW |
1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file | 1 // Copyright (c) 2014, the Dart project authors. Please see the AUTHORS file |
2 // for details. All rights reserved. Use of this source code is governed by a | 2 // for details. All rights reserved. Use of this source code is governed by a |
3 // BSD-style license that can be found in the LICENSE file. | 3 // BSD-style license that can be found in the LICENSE file. |
4 | 4 |
5 #include "vm/metrics.h" | 5 #include "vm/metrics.h" |
6 | 6 |
7 #include "vm/isolate.h" | 7 #include "vm/isolate.h" |
8 #include "vm/json_stream.h" | 8 #include "vm/json_stream.h" |
9 #include "vm/native_entry.h" | 9 #include "vm/native_entry.h" |
10 #include "vm/runtime_entry.h" | 10 #include "vm/runtime_entry.h" |
(...skipping 33 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
44 ASSERT(next_ == NULL); | 44 ASSERT(next_ == NULL); |
45 ASSERT(name != NULL); | 45 ASSERT(name != NULL); |
46 name_ = name; | 46 name_ = name; |
47 description_ = description; | 47 description_ = description; |
48 unit_ = unit; | 48 unit_ = unit; |
49 RegisterWithVM(); | 49 RegisterWithVM(); |
50 } | 50 } |
51 | 51 |
52 | 52 |
53 Metric::~Metric() { | 53 Metric::~Metric() { |
54 if (isolate_ == NULL) { | 54 // Only deregister metrics which had been registered. Metrics without a name |
55 DeregisterWithVM(); | 55 // are from shallow copy isolates. |
56 } else { | 56 if (name_ != NULL) { |
57 DeregisterWithIsolate(); | 57 if (isolate_ == NULL) { |
| 58 DeregisterWithVM(); |
| 59 } else { |
| 60 DeregisterWithIsolate(); |
| 61 } |
58 } | 62 } |
59 } | 63 } |
60 | 64 |
61 | 65 |
62 static const char* UnitString(intptr_t unit) { | 66 static const char* UnitString(intptr_t unit) { |
63 switch (unit) { | 67 switch (unit) { |
64 case Metric::kCounter: return "counter"; | 68 case Metric::kCounter: return "counter"; |
65 case Metric::kByte: return "byte"; | 69 case Metric::kByte: return "byte"; |
66 default: | 70 default: |
67 UNREACHABLE(); | 71 UNREACHABLE(); |
(...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
233 | 237 |
234 | 238 |
235 void Metric::InitOnce() { | 239 void Metric::InitOnce() { |
236 #define VM_METRIC_INIT(type, variable, name, unit) \ | 240 #define VM_METRIC_INIT(type, variable, name, unit) \ |
237 vm_metric_##variable##_.Init(name, NULL, Metric::unit); | 241 vm_metric_##variable##_.Init(name, NULL, Metric::unit); |
238 VM_METRIC_LIST(VM_METRIC_INIT); | 242 VM_METRIC_LIST(VM_METRIC_INIT); |
239 #undef VM_METRIC_INIT | 243 #undef VM_METRIC_INIT |
240 } | 244 } |
241 | 245 |
242 } // namespace dart | 246 } // namespace dart |
OLD | NEW |