Gabe Black has submitted this change and it was merged. ( https://gem5-review.googlesource.com/c/public/gem5/+/12077 )

Change subject: systemc: Use an std::list to track all modules.
......................................................................

systemc: Use an std::list to track all modules.

This is less efficient when modules are destroyed since the list isn't
sorted, and each module needs to find its own entry to remove. The
benefit is that entries added to the end of the list while the list is
being iterated over will still be included, and that the order the
modules are added will be preserved so that it matches what the order
in the regression tests.

Change-Id: I5af5d15f316fa58561e8fd9ca77f667ddc8b2c5e
Reviewed-on: https://gem5-review.googlesource.com/12077
Reviewed-by: Gabe Black <[email protected]>
Maintainer: Gabe Black <[email protected]>
---
M src/systemc/core/module.cc
M src/systemc/core/module.hh
2 files changed, 5 insertions(+), 6 deletions(-)

Approvals:
  Gabe Black: Looks good to me, approved; Looks good to me, approved



diff --git a/src/systemc/core/module.cc b/src/systemc/core/module.cc
index 986ad25..b13b50d 100644
--- a/src/systemc/core/module.cc
+++ b/src/systemc/core/module.cc
@@ -30,7 +30,6 @@
 #include "systemc/core/module.hh"

 #include <cassert>
-#include <list>

 #include "base/logging.hh"

@@ -53,7 +52,7 @@
     _new_module = this;
 }

-Module::~Module() { allModules.erase(this); }
+Module::~Module() { allModules.remove(this); }

 void
 Module::finish(Object *this_obj)
@@ -65,7 +64,7 @@
     // This is called from the constructor of this_obj, so it can't use
     // dynamic cast.
     sc_mod(static_cast<::sc_core::sc_module *>(this_obj->sc_obj()));
-    allModules.insert(this);
+    allModules.emplace_back(this);
 }

 void
@@ -95,6 +94,6 @@
 void callbackModule(Module *m) { _callbackModule = m; }
 Module *callbackModule() { return _callbackModule; }

-std::set<Module *> allModules;
+std::list<Module *> allModules;

 } // namespace sc_gem5
diff --git a/src/systemc/core/module.hh b/src/systemc/core/module.hh
index 7e54e29..a5bf929 100644
--- a/src/systemc/core/module.hh
+++ b/src/systemc/core/module.hh
@@ -31,8 +31,8 @@
 #define __SYSTEMC_CORE_MODULE_HH__

 #include <cassert>
+#include <list>
 #include <map>
-#include <set>
 #include <sstream>
 #include <string>

@@ -109,7 +109,7 @@
 void callbackModule(Module *m);
 Module *callbackModule();

-extern std::set<Module *> allModules;
+extern std::list<Module *> allModules;

 } // namespace sc_gem5


--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/12077
To unsubscribe, or for help writing mail filters, visit https://gem5-review.googlesource.com/settings

Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-Change-Id: I5af5d15f316fa58561e8fd9ca77f667ddc8b2c5e
Gerrit-Change-Number: 12077
Gerrit-PatchSet: 10
Gerrit-Owner: Gabe Black <[email protected]>
Gerrit-Reviewer: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Gabe Black <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: Matthias Jung <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to