Daniel Carvalho has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/43589 )

Change subject: base-stats: Remove Stats::Group dependency from Stats::Info
......................................................................

base-stats: Remove Stats::Group dependency from Stats::Info

The parent group was not being used. The only thing required
was the information of whether the info concerns a new or an
old-style stats. Removing this dependency simplifies code
and removes a possible cyclic dependency.

Change-Id: I4d734cd83e9c7975a3ef45229edea4eebf1e430e
Signed-off-by: Daniel R. Carvalho <[email protected]>
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/43589
Tested-by: kokoro <[email protected]>
Reviewed-by: Giacomo Travaglini <[email protected]>
Maintainer: Giacomo Travaglini <[email protected]>
---
M src/base/statistics.hh
M src/base/stats/info.cc
M src/base/stats/info.hh
3 files changed, 13 insertions(+), 17 deletions(-)

Approvals:
  Giacomo Travaglini: Looks good to me, approved; Looks good to me, approved
  kokoro: Regressions pass



diff --git a/src/base/statistics.hh b/src/base/statistics.hh
index e0d2680..6a7e23e 100644
--- a/src/base/statistics.hh
+++ b/src/base/statistics.hh
@@ -255,7 +255,7 @@
             parent->addStat(info);

         if (name) {
-            info->setName(parent, name);
+            info->setName(name, parent == nullptr);
             info->flags.set(display);
         }

diff --git a/src/base/stats/info.cc b/src/base/stats/info.cc
index 85bf698..c6024e7 100644
--- a/src/base/stats/info.cc
+++ b/src/base/stats/info.cc
@@ -111,13 +111,7 @@
 }

 void
-Info::setName(const std::string &name)
-{
-    setName(nullptr, name);
-}
-
-void
-Info::setName(const Group *parent, const std::string &name)
+Info::setName(const std::string &name, bool old_style)
 {
     if (!validateStatName(name))
         panic("invalid stat name '%s'", name);
@@ -126,12 +120,10 @@
     // old-style stats without a parent group. New-style stats should
     // be unique since their names should correspond to a member
     // variable.
-    if (!parent) {
+    if (old_style) {
         auto p = nameMap().insert(make_pair(name, this));

-        if (!p.second)
-            panic("same statistic name used twice! name=%s\n",
-                  name);
+ panic_if(!p.second, "same statistic name used twice! name=%s\n", name);
     }

     this->name = name;
diff --git a/src/base/stats/info.hh b/src/base/stats/info.hh
index 6665102..0e7e398 100644
--- a/src/base/stats/info.hh
+++ b/src/base/stats/info.hh
@@ -38,8 +38,6 @@
 namespace statistics
 {

-class Group;
-
 typedef uint16_t FlagsType;
 typedef ::Flags<FlagsType> Flags;

@@ -101,9 +99,15 @@
     Info();
     virtual ~Info();

-    /** Set the name of this statistic */
-    void setName(const std::string &name);
-    void setName(const Group *parent, const std::string &name);
+    /**
+     * Set the name of this statistic. Special handling must be done when
+ * creating an old-style statistic (i.e., stats without a parent group).
+     *
+     * @param name The new name.
+     * @param old_style Whether we are using the old style.
+     */
+    void setName(const std::string &name, bool old_style=true);
+
     void setSeparator(std::string _sep) { separatorString = _sep;}

     /**



7 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted one.
--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/43589
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: develop
Gerrit-Change-Id: I4d734cd83e9c7975a3ef45229edea4eebf1e430e
Gerrit-Change-Number: 43589
Gerrit-PatchSet: 9
Gerrit-Owner: Daniel Carvalho <[email protected]>
Gerrit-Reviewer: Daniel Carvalho <[email protected]>
Gerrit-Reviewer: Giacomo Travaglini <[email protected]>
Gerrit-Reviewer: kokoro <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- [email protected]
To unsubscribe send an email to [email protected]
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to