sim: make Python Root object a singleton
Review Request #26 - Created June 27, 2010 and submitted
Information | |
---|---|
Steve Reinhardt | |
gem5 | |
Reviewers | |
Default | |
sim: make Python Root object a singleton Enforce that the Python Root SimObject is instantiated only once. The C++ Root object already panics if more than one is created. This change avoids the need to track what the root object is, since it's available from Root.getInstance() (if it exists). It's now redundant to have the user pass the root object to functions like instantiate(), checkpoint(), and restoreCheckpoint(), so that arg is gone. Users who use configs/common/Simulate.py should not notice.
Posted (June 27, 2010, 3:02 p.m.)
-
src/python/m5/simulate.py (Diff revision 1) -
OK, I got ahead of myself... this doesn't compile. I may redo this whole optional argument scheme using *posargs after all.
Posted (June 28, 2010, 10:32 a.m.)
-
src/python/m5/simulate.py (Diff revision 3) -
You say *posargs in this code, whereas we use *args everywhere else in the python code. (Python itself uses *args, so I'd suggest a change for consistency). I assume that the *args is for backward compat where people say instantiate(root). If so, perhaps you should document this. Actually, is it really even worth doing all of this? It's pretty trivial to update a script to support this and if people are updating to the latest M5, it's not a huge change to ask of them. We don't typically dirty the code with backward compat stuff.
-
src/sim/Root.py (Diff revision 3) -
I don't understand why you overload both __new__ and __init__. Seems like everything should go in __new__. (i.e. why not just fatal() in __new__?) I think you might also need to pass **kwargs to SimObject.__new__. All this said, I'm not sure how __new__ interacts with a metaclass, so I could be wrong.
Review request changed
Updated (July 29, 2010, 2:32 p.m.)
Description: |
|
---|