Tom Rollet has submitted this change. ( https://gem5-review.googlesource.com/c/public/gem5/+/51647 )

Change subject: python: remove SimObject children on NULL assignment
......................................................................

python: remove SimObject children on NULL assignment

Before this commit, on assigning NULL to an 'attr' that is a SimObject,
the corresponding children SimObject was not set to NULL.

This makes some SimObject being initialized in the c++ world
even if they are not needed.

This commit set the children to NULL in that case.

Change-Id: I2030d9d1b80c020fa28e50c0eca4f87b756763d6
Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/51647
Reviewed-by: Andreas Sandberg <andreas.sandb...@arm.com>
Reviewed-by: Jason Lowe-Power <power...@gmail.com>
Maintainer: Jason Lowe-Power <power...@gmail.com>
Tested-by: kokoro <noreply+kok...@google.com>
---
M src/python/m5/SimObject.py
1 file changed, 28 insertions(+), 0 deletions(-)

Approvals:
  Jason Lowe-Power: Looks good to me, approved; Looks good to me, approved
  Andreas Sandberg: Looks good to me, approved
  kokoro: Regressions pass




diff --git a/src/python/m5/SimObject.py b/src/python/m5/SimObject.py
index d18d879..dec630c 100644
--- a/src/python/m5/SimObject.py
+++ b/src/python/m5/SimObject.py
@@ -1443,6 +1443,12 @@
                 e.args = (msg, )
                 raise
             self._values[attr] = value
+
+            # If we assign NULL to an attr that is a SimObject,
+            # remove the corresponding children
+            if attr in self._children and isNullPointer(value):
+                self.clear_child(attr)
+
             # implicitly parent unparented objects assigned as params
             if isSimObjectOrVector(value) and not value.has_parent():
                 self.add_child(attr, value)

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/51647
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: I2030d9d1b80c020fa28e50c0eca4f87b756763d6
Gerrit-Change-Number: 51647
Gerrit-PatchSet: 3
Gerrit-Owner: Tom Rollet <tom.rol...@huawei.com>
Gerrit-Reviewer: Andreas Sandberg <andreas.sandb...@arm.com>
Gerrit-Reviewer: Jason Lowe-Power <ja...@lowepower.com>
Gerrit-Reviewer: Jason Lowe-Power <power...@gmail.com>
Gerrit-Reviewer: Tom Rollet <tom.rol...@huawei.com>
Gerrit-Reviewer: kokoro <noreply+kok...@google.com>
Gerrit-CC: Nathanael Premillieu <nathanael.premill...@huawei.com>
Gerrit-MessageType: merged
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org
%(web_page_url)slistinfo%(cgiext)s/%(_internal_name)s

Reply via email to