mirror of
https://github.com/dart-lang/sdk
synced 2024-09-15 23:19:47 +00:00
[VM] Refactors metrics variables to avoid multiple instances per compiled unit.
This moves the definition of the global static VM metric variables out of the header to avoid defining them multiple times. This could cause multiple instances which defeats the whole purpose. Bug: None Change-Id: Idb8b2da1c2b4591c4824e2bb4b1474437231b3c6 Reviewed-on: https://dart-review.googlesource.com/c/sdk/+/98324 Commit-Queue: Clement Skau <cskau@google.com> Reviewed-by: Vyacheslav Egorov <vegorov@google.com>
This commit is contained in:
parent
3a93cf9464
commit
405bd06725
|
@ -1045,7 +1045,7 @@ DART_EXPORT bool Dart_IsVMFlagSet(const char* flag_name) {
|
|||
#if !defined(PRODUCT)
|
||||
#define VM_METRIC_API(type, variable, name, unit) \
|
||||
DART_EXPORT int64_t Dart_VM##variable##Metric() { \
|
||||
return vm_metric_##variable##_.value(); \
|
||||
return vm_metric_##variable.value(); \
|
||||
}
|
||||
VM_METRIC_LIST(VM_METRIC_API);
|
||||
#undef VM_METRIC_API
|
||||
|
|
|
@ -303,9 +303,14 @@ int64_t MetricPeakRSS::Value() const {
|
|||
return Service::MaxRSS();
|
||||
}
|
||||
|
||||
#define VM_METRIC_VARIABLE(type, variable, name, unit) \
|
||||
type vm_metric_##variable;
|
||||
VM_METRIC_LIST(VM_METRIC_VARIABLE);
|
||||
#undef VM_METRIC_VARIABLE
|
||||
|
||||
void Metric::Init() {
|
||||
#define VM_METRIC_INIT(type, variable, name, unit) \
|
||||
vm_metric_##variable##_.InitInstance(name, NULL, Metric::unit);
|
||||
vm_metric_##variable.InitInstance(name, NULL, Metric::unit);
|
||||
VM_METRIC_LIST(VM_METRIC_INIT);
|
||||
#undef VM_METRIC_INIT
|
||||
}
|
||||
|
@ -323,7 +328,7 @@ void Metric::Cleanup() {
|
|||
OS::PrintErr("\n");
|
||||
}
|
||||
#define VM_METRIC_CLEANUP(type, variable, name, unit) \
|
||||
vm_metric_##variable##_.CleanupInstance();
|
||||
vm_metric_##variable.CleanupInstance();
|
||||
VM_METRIC_LIST(VM_METRIC_CLEANUP);
|
||||
#undef VM_METRIC_CLEANUP
|
||||
}
|
||||
|
|
|
@ -182,7 +182,7 @@ class MetricHeapUsed : public Metric {
|
|||
|
||||
#if !defined(PRODUCT)
|
||||
#define VM_METRIC_VARIABLE(type, variable, name, unit) \
|
||||
static type vm_metric_##variable##_;
|
||||
extern type vm_metric_##variable;
|
||||
VM_METRIC_LIST(VM_METRIC_VARIABLE);
|
||||
#undef VM_METRIC_VARIABLE
|
||||
#endif // !defined(PRODUCT)
|
||||
|
|
Loading…
Reference in a new issue