changeset ba80f7d4f452 in /z/repo/gem5
details: http://repo.gem5.org/gem5?cmd=changeset;node=ba80f7d4f452
description:
        x86, cpu: corrects 270c9a75e91f, take over decoder on cpu switch
        The changes made by the changeset 270c9a75e91f do not work well with 
switching
        of cpus. The problem is that decoder for the old thread context holds 
state
        that is not taken over by the new decoder.

        This patch adds a takeOverFrom() function to Decoder class in each ISA. 
Except
        for x86, functions in other ISAs are blank. For x86, the function 
copies state
        from the old decoder to the new decoder.

diffstat:

 src/arch/alpha/decoder.hh         |   2 ++
 src/arch/arm/decoder.hh           |   2 ++
 src/arch/mips/decoder.hh          |   2 ++
 src/arch/power/decoder.hh         |   3 +++
 src/arch/sparc/decoder.hh         |   2 ++
 src/arch/x86/decoder.hh           |  13 +++++++++++++
 src/cpu/o3/thread_context_impl.hh |   3 +++
 src/cpu/simple_thread.cc          |   1 +
 8 files changed, 28 insertions(+), 0 deletions(-)

diffs (108 lines):

diff -r d0aacc54cee9 -r ba80f7d4f452 src/arch/alpha/decoder.hh
--- a/src/arch/alpha/decoder.hh Mon Jan 21 09:20:18 2013 -0500
+++ b/src/arch/alpha/decoder.hh Tue Jan 22 00:10:10 2013 -0600
@@ -83,6 +83,8 @@
         return instDone;
     }
 
+    void takeOverFrom(Decoder * old) {}
+
   protected:
     /// A cache of decoded instruction objects.
     static GenericISA::BasicDecodeCache defaultCache;
diff -r d0aacc54cee9 -r ba80f7d4f452 src/arch/arm/decoder.hh
--- a/src/arch/arm/decoder.hh   Mon Jan 21 09:20:18 2013 -0500
+++ b/src/arch/arm/decoder.hh   Tue Jan 22 00:10:10 2013 -0600
@@ -116,6 +116,8 @@
         fpscrStride = fpscr.stride;
     }
 
+    void takeOverFrom(Decoder *old) {}
+
   protected:
     /// A cache of decoded instruction objects.
     static GenericISA::BasicDecodeCache defaultCache;
diff -r d0aacc54cee9 -r ba80f7d4f452 src/arch/mips/decoder.hh
--- a/src/arch/mips/decoder.hh  Mon Jan 21 09:20:18 2013 -0500
+++ b/src/arch/mips/decoder.hh  Tue Jan 22 00:10:10 2013 -0600
@@ -83,6 +83,8 @@
         return instDone;
     }
 
+    void takeOverFrom(Decoder *old) {}
+
   protected:
     /// A cache of decoded instruction objects.
     static GenericISA::BasicDecodeCache defaultCache;
diff -r d0aacc54cee9 -r ba80f7d4f452 src/arch/power/decoder.hh
--- a/src/arch/power/decoder.hh Mon Jan 21 09:20:18 2013 -0500
+++ b/src/arch/power/decoder.hh Tue Jan 22 00:10:10 2013 -0600
@@ -89,6 +89,9 @@
     {
         return instDone;
     }
+
+    void takeOverFrom(Decoder *old) {}
+
   protected:
     /// A cache of decoded instruction objects.
     static GenericISA::BasicDecodeCache defaultCache;
diff -r d0aacc54cee9 -r ba80f7d4f452 src/arch/sparc/decoder.hh
--- a/src/arch/sparc/decoder.hh Mon Jan 21 09:20:18 2013 -0500
+++ b/src/arch/sparc/decoder.hh Tue Jan 22 00:10:10 2013 -0600
@@ -97,6 +97,8 @@
         asi = _asi;
     }
 
+    void takeOverFrom(Decoder *old) {}
+
   protected:
     /// A cache of decoded instruction objects.
     static GenericISA::BasicDecodeCache defaultCache;
diff -r d0aacc54cee9 -r ba80f7d4f452 src/arch/x86/decoder.hh
--- a/src/arch/x86/decoder.hh   Mon Jan 21 09:20:18 2013 -0500
+++ b/src/arch/x86/decoder.hh   Tue Jan 22 00:10:10 2013 -0600
@@ -250,6 +250,19 @@
         }
     }
 
+    void takeOverFrom(Decoder *old)
+    {
+        mode = old->mode;
+        submode = old->submode;
+        emi.mode.mode = mode;
+        emi.mode.submode = submode;
+        altOp = old->altOp;
+        defOp = old->defOp;
+        altAddr = old->altAddr;
+        defAddr = old->defAddr;
+        stack = old->stack;
+    }
+
     void reset()
     {
         state = ResetState;
diff -r d0aacc54cee9 -r ba80f7d4f452 src/cpu/o3/thread_context_impl.hh
--- a/src/cpu/o3/thread_context_impl.hh Mon Jan 21 09:20:18 2013 -0500
+++ b/src/cpu/o3/thread_context_impl.hh Tue Jan 22 00:10:10 2013 -0600
@@ -67,6 +67,9 @@
 O3ThreadContext<Impl>::takeOverFrom(ThreadContext *old_context)
 {
     ::takeOverFrom(*this, *old_context);
+    TheISA::Decoder *newDecoder = getDecoderPtr();
+    TheISA::Decoder *oldDecoder = old_context->getDecoderPtr();
+    newDecoder->takeOverFrom(oldDecoder);
 
     thread->kernelStats = old_context->getKernelStats();
     thread->funcExeInst = old_context->readFuncExeInst();
diff -r d0aacc54cee9 -r ba80f7d4f452 src/cpu/simple_thread.cc
--- a/src/cpu/simple_thread.cc  Mon Jan 21 09:20:18 2013 -0500
+++ b/src/cpu/simple_thread.cc  Tue Jan 22 00:10:10 2013 -0600
@@ -108,6 +108,7 @@
 SimpleThread::takeOverFrom(ThreadContext *oldContext)
 {
     ::takeOverFrom(*tc, *oldContext);
+    decoder.takeOverFrom(oldContext->getDecoderPtr());
 
     kernelStats = oldContext->getKernelStats();
     funcExeInst = oldContext->readFuncExeInst();
_______________________________________________
gem5-dev mailing list
[email protected]
http://m5sim.org/mailman/listinfo/gem5-dev

Reply via email to