Sean Wilson has submitted this change and it was merged. (
https://gem5-review.googlesource.com/3921 )
Change subject: sim, gdb: Refactor some Event subclasses into lambdas
......................................................................
sim, gdb: Refactor some Event subclasses into lambdas
Change-Id: If3e4329204f27eda96b50ec6ac279ebc6ef23d99
Signed-off-by: Sean Wilson <[email protected]>
Reviewed-on: https://gem5-review.googlesource.com/3921
Reviewed-by: Jason Lowe-Power <[email protected]>
Reviewed-by: Andreas Sandberg <[email protected]>
Maintainer: Andreas Sandberg <[email protected]>
---
M src/base/remote_gdb.cc
M src/base/remote_gdb.hh
M src/sim/ticked_object.cc
M src/sim/ticked_object.hh
4 files changed, 26 insertions(+), 53 deletions(-)
Approvals:
Jason Lowe-Power: Looks good to me, approved
Andreas Sandberg: Looks good to me, approved; Looks good to me, approved
diff --git a/src/base/remote_gdb.cc b/src/base/remote_gdb.cc
index 3b436cc..6ed5957 100644
--- a/src/base/remote_gdb.cc
+++ b/src/base/remote_gdb.cc
@@ -289,17 +289,18 @@
}
void
-BaseRemoteGDB::SingleStepEvent::process()
+BaseRemoteGDB::processSingleStepEvent()
{
- if (!gdb->singleStepEvent.scheduled())
- gdb->scheduleInstCommitEvent(&gdb->singleStepEvent, 1);
- gdb->trap(SIGTRAP);
+ if (!singleStepEvent.scheduled())
+ scheduleInstCommitEvent(&singleStepEvent, 1);
+ trap(SIGTRAP);
}
BaseRemoteGDB::BaseRemoteGDB(System *_system, ThreadContext *c) :
- inputEvent(NULL), trapEvent(this), listener(NULL),
- number(-1), fd(-1), active(false), attached(false),
system(_system),
- context(c), singleStepEvent(this)
+ inputEvent(NULL), trapEvent(this), listener(NULL), number(-1),
+ fd(-1), active(false), attached(false), system(_system),
+ context(c),
+ singleStepEvent([this]{ processSingleStepEvent(); }, name())
{
}
@@ -1123,4 +1124,3 @@
*srcp = src;
return r;
}
-
diff --git a/src/base/remote_gdb.hh b/src/base/remote_gdb.hh
index b7de0ae..121faaf 100644
--- a/src/base/remote_gdb.hh
+++ b/src/base/remote_gdb.hh
@@ -260,20 +260,8 @@
return trap(SIGTRAP);
}
- protected:
- class SingleStepEvent : public Event
- {
- protected:
- BaseRemoteGDB *gdb;
-
- public:
- SingleStepEvent(BaseRemoteGDB *g) : gdb(g)
- {}
-
- void process();
- };
-
- SingleStepEvent singleStepEvent;
+ void processSingleStepEvent();
+ EventFunctionWrapper singleStepEvent;
void clearSingleStep();
void setSingleStep();
diff --git a/src/sim/ticked_object.cc b/src/sim/ticked_object.cc
index a9f3ace..1a04dc1 100644
--- a/src/sim/ticked_object.cc
+++ b/src/sim/ticked_object.cc
@@ -46,7 +46,7 @@
Stats::Scalar *imported_num_cycles,
Event::Priority priority) :
object(object_),
- event(*this, priority),
+ event([this]{ processClockEvent(); }, name(), false, priority),
running(false),
lastStopped(0),
/* Allocate numCycles if an external stat wasn't passed in */
@@ -56,6 +56,16 @@
{ }
void
+Ticked::processClockEvent() {
+ ++tickCycles;
+ ++numCycles;
+ countCycles(Cycles(1));
+ evaluate();
+ if (running)
+ object.schedule(event, object.clockEdge(Cycles(1)));
+}
+
+void
Ticked::regStats()
{
if (numCyclesLocal) {
diff --git a/src/sim/ticked_object.hh b/src/sim/ticked_object.hh
index 3ba0045..ad7d6e9 100644
--- a/src/sim/ticked_object.hh
+++ b/src/sim/ticked_object.hh
@@ -60,39 +60,14 @@
class Ticked : public Serializable
{
protected:
- /** An event to call process periodically */
- class ClockEvent : public Event
- {
- public:
- Ticked &owner;
-
- ClockEvent(Ticked &owner_, Priority priority) :
- Event(priority),
- owner(owner_)
- { }
-
- /** Evaluate and reschedule */
- void
- process()
- {
- ++owner.tickCycles;
- ++owner.numCycles;
- owner.countCycles(Cycles(1));
- owner.evaluate();
- if (owner.running) {
- owner.object.schedule(this,
- owner.object.clockEdge(Cycles(1)));
- }
- }
- };
-
- friend class ClockEvent;
-
/** ClockedObject who is responsible for this Ticked's actions/stats */
ClockedObject &object;
- /** The single instance of ClockEvent used */
- ClockEvent event;
+ /** The wrapper for processClockEvent */
+ EventFunctionWrapper event;
+
+ /** Evaluate and reschedule */
+ void processClockEvent();
/** Have I been started? and am not stopped */
bool running;
--
To view, visit https://gem5-review.googlesource.com/3921
To unsubscribe, visit https://gem5-review.googlesource.com/settings
Gerrit-Project: public/gem5
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: If3e4329204f27eda96b50ec6ac279ebc6ef23d99
Gerrit-Change-Number: 3921
Gerrit-PatchSet: 4
Gerrit-Owner: Sean Wilson <[email protected]>
Gerrit-Reviewer: Andreas Sandberg <[email protected]>
Gerrit-Reviewer: Jason Lowe-Power <[email protected]>
Gerrit-Reviewer: Sean Wilson <[email protected]>
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev