Tom Rollet has uploaded this change for review. ( https://gem5-review.googlesource.com/c/public/gem5/+/68299?usp=email )

Change subject: cpu: remove RefCounted from MinorDynInst
......................................................................

cpu: remove RefCounted from MinorDynInst

Change-Id: I5b643cee55cb3a2b22a5e0468e8830133dd6c825
---
M src/cpu/minor/decode.cc
M src/cpu/minor/dyn_inst.cc
M src/cpu/minor/dyn_inst.hh
M src/cpu/minor/fetch2.cc
4 files changed, 20 insertions(+), 10 deletions(-)



diff --git a/src/cpu/minor/decode.cc b/src/cpu/minor/decode.cc
index a4516a0..e8c8120 100644
--- a/src/cpu/minor/decode.cc
+++ b/src/cpu/minor/decode.cc
@@ -185,8 +185,8 @@
                         static_inst->fetchMicroop(
                                 decode_info.microopPC->microPC());

-                    output_inst =
-                        new MinorDynInst(static_micro_inst, inst->id);
+                    output_inst = std::make_shared<MinorDynInst>(
+                            static_micro_inst,inst->id);
                     set(output_inst->pc, decode_info.microopPC);
                     output_inst->fault = NoFault;

diff --git a/src/cpu/minor/dyn_inst.cc b/src/cpu/minor/dyn_inst.cc
index 68415ec..cdcfb25 100644
--- a/src/cpu/minor/dyn_inst.cc
+++ b/src/cpu/minor/dyn_inst.cc
@@ -76,10 +76,8 @@
 }

 MinorDynInstPtr MinorDynInst::bubbleInst = []() {
-    auto *inst = new MinorDynInst(nullStaticInstPtr);
+    auto inst =  std::make_shared<MinorDynInst>(nullStaticInstPtr);
     assert(inst->isBubble());
-    // Make bubbleInst immortal.
-    inst->incref();
     return inst;
 }();

diff --git a/src/cpu/minor/dyn_inst.hh b/src/cpu/minor/dyn_inst.hh
index 9c6d6fd..22b2b7a 100644
--- a/src/cpu/minor/dyn_inst.hh
+++ b/src/cpu/minor/dyn_inst.hh
@@ -47,10 +47,10 @@
 #define __CPU_MINOR_DYN_INST_HH__

 #include <iostream>
+#include <memory>

 #include "arch/generic/isa.hh"
 #include "base/named.hh"
-#include "base/refcnt.hh"
 #include "base/types.hh"
 #include "cpu/inst_seq.hh"
 #include "cpu/minor/buffers.hh"
@@ -68,7 +68,7 @@
 class MinorDynInst;

 /** MinorDynInsts are currently reference counted. */
-typedef RefCountingPtr<MinorDynInst> MinorDynInstPtr;
+using MinorDynInstPtr = std::shared_ptr<MinorDynInst>;

 /** Id for lines and instructions.  This includes all the relevant sequence
  *  numbers and thread ids for all stages of execution. */
@@ -159,7 +159,7 @@
  *  MinorDynInst implements the BubbleIF interface
  *  Has two separate notions of sequence number for pre/post-micro-op
  *  decomposition: fetchSeqNum and execSeqNum */
-class MinorDynInst : public RefCounted
+class MinorDynInst
 {
   private:
/** A prototypical bubble instruction. You must call MinorDynInst::init
@@ -167,6 +167,7 @@
     static MinorDynInstPtr bubbleInst;

   public:
+
     const StaticInstPtr staticInst;

     InstId id;
diff --git a/src/cpu/minor/fetch2.cc b/src/cpu/minor/fetch2.cc
index b02294b..c23fb72 100644
--- a/src/cpu/minor/fetch2.cc
+++ b/src/cpu/minor/fetch2.cc
@@ -356,7 +356,8 @@

                 /* Make a new instruction and pick up the line, stream,
                  *  prediction, thread ids from the incoming line */
- dyn_inst = new MinorDynInst(nullStaticInstPtr, line_in->id); + dyn_inst = std::make_shared<MinorDynInst>(nullStaticInstPtr,
+                    line_in->id);

                 /* Fetch and prediction sequence numbers originate here */
                 dyn_inst->id.fetchSeqNum = fetch_info.fetchSeqNum;
@@ -399,7 +400,8 @@

                     /* Make a new instruction and pick up the line, stream,
                      *  prediction, thread ids from the incoming line */
-                    dyn_inst = new MinorDynInst(decoded_inst, line_in->id);
+                    dyn_inst = std::make_shared<MinorDynInst>(decoded_inst,
+                        line_in->id);

/* Fetch and prediction sequence numbers originate here */
                     dyn_inst->id.fetchSeqNum = fetch_info.fetchSeqNum;

--
To view, visit https://gem5-review.googlesource.com/c/public/gem5/+/68299?usp=email 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: I5b643cee55cb3a2b22a5e0468e8830133dd6c825
Gerrit-Change-Number: 68299
Gerrit-PatchSet: 1
Gerrit-Owner: Tom Rollet <tom.rol...@huawei.com>
Gerrit-MessageType: newchange
_______________________________________________
gem5-dev mailing list -- gem5-dev@gem5.org
To unsubscribe send an email to gem5-dev-le...@gem5.org

Reply via email to