cpu: Avoid unnecessary dynamic_pointer_cast in atomic model
[gem5.git] / src / cpu / thread_state.hh
index 3a35d444a6bc48a57d99a513f99060e30ca49ca1..5cbc3322b1a607426084898afcff1b78689303dc 100644 (file)
@@ -107,6 +107,21 @@ struct ThreadState : public Serializable {
 
     Process *getProcessPtr() { return process; }
 
+    void setProcessPtr(Process *p)
+    {
+        process = p;
+        /**
+         * When the process pointer changes while operating in SE Mode,
+         * the se translating port proxy needs to be reinitialized since it
+         * holds a pointer to the process class.
+         */
+        if (proxy) {
+            delete proxy;
+            proxy = NULL;
+            initMemProxies(NULL);
+        }
+    }
+
     SETranslatingPortProxy &getMemProxy();
 
     /** Reads the number of instructions functionally executed and