systemc: Fix memory leak of sc_event_list
Make SensitivityAnd/OrList class track the sc_event_and/or_list and delete it when the Sensitivity object itself is deleted. Bug: 222177290 Test: Run gem5 unittests, presubmits, and systemc unittests Change-Id: Ib46f8dfb6727f77ad843ba33ce22c7e6d2645ff2 Reviewed-on: https://gem5-review.googlesource.com/c/public/gem5/+/57329 Reviewed-by: Gabe Black <gabe.black@gmail.com> Maintainer: Gabe Black <gabe.black@gmail.com> Tested-by: kokoro <noreply+kokoro@google.com>
This commit is contained in:
@@ -214,9 +214,21 @@ void newDynamicSensitivityEventAndList(
|
||||
|
||||
DynamicSensitivityEventOrList::DynamicSensitivityEventOrList(
|
||||
Process *p, const sc_core::sc_event_or_list *eol) :
|
||||
Sensitivity(p), DynamicSensitivity(p), SensitivityEvents(p, eol->events)
|
||||
Sensitivity(p),
|
||||
DynamicSensitivity(p),
|
||||
SensitivityEvents(p, eol->events),
|
||||
list(eol)
|
||||
{}
|
||||
|
||||
DynamicSensitivityEventOrList::~DynamicSensitivityEventOrList()
|
||||
{
|
||||
if (list->autoDelete) {
|
||||
panic_if(list->busy,
|
||||
"sc_event_or_list can never be busy in gem5 implementation");
|
||||
delete list;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
DynamicSensitivityEventOrList::notifyWork(Event *e)
|
||||
{
|
||||
@@ -233,9 +245,21 @@ DynamicSensitivityEventOrList::notifyWork(Event *e)
|
||||
|
||||
DynamicSensitivityEventAndList::DynamicSensitivityEventAndList(
|
||||
Process *p, const sc_core::sc_event_and_list *eal) :
|
||||
Sensitivity(p), DynamicSensitivity(p), SensitivityEvents(p, eal->events)
|
||||
Sensitivity(p),
|
||||
DynamicSensitivity(p),
|
||||
SensitivityEvents(p, eal->events),
|
||||
list(eal)
|
||||
{}
|
||||
|
||||
DynamicSensitivityEventAndList::~DynamicSensitivityEventAndList()
|
||||
{
|
||||
if (list->autoDelete) {
|
||||
panic_if(list->busy,
|
||||
"sc_event_and_list can never be busy in gem5 implementation");
|
||||
delete list;
|
||||
}
|
||||
}
|
||||
|
||||
bool
|
||||
DynamicSensitivityEventAndList::notifyWork(Event *e)
|
||||
{
|
||||
|
||||
@@ -274,8 +274,11 @@ class DynamicSensitivityEventOrList :
|
||||
|
||||
DynamicSensitivityEventOrList(
|
||||
Process *p, const sc_core::sc_event_or_list *eol);
|
||||
~DynamicSensitivityEventOrList();
|
||||
|
||||
bool notifyWork(Event *e) override;
|
||||
|
||||
const sc_core::sc_event_or_list *list;
|
||||
};
|
||||
|
||||
//XXX This sensitivity can't be reused. To reset it, it has to be deleted and
|
||||
@@ -290,8 +293,11 @@ class DynamicSensitivityEventAndList :
|
||||
|
||||
DynamicSensitivityEventAndList(
|
||||
Process *p, const sc_core::sc_event_and_list *eal);
|
||||
~DynamicSensitivityEventAndList();
|
||||
|
||||
bool notifyWork(Event *e) override;
|
||||
|
||||
const sc_core::sc_event_and_list *list;
|
||||
};
|
||||
|
||||
} // namespace sc_gem5
|
||||
|
||||
Reference in New Issue
Block a user