x86, cpu: corrects 270c9a75e91f, take over decoder on cpu switch
authorNilay Vaish <nilay@cs.wisc.edu>
Tue, 22 Jan 2013 06:10:10 +0000 (00:10 -0600)
committerNilay Vaish <nilay@cs.wisc.edu>
Tue, 22 Jan 2013 06:10:10 +0000 (00:10 -0600)
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.

src/arch/alpha/decoder.hh
src/arch/arm/decoder.hh
src/arch/mips/decoder.hh
src/arch/power/decoder.hh
src/arch/sparc/decoder.hh
src/arch/x86/decoder.hh
src/cpu/o3/thread_context_impl.hh
src/cpu/simple_thread.cc

index 45e737e529a9225ad390d1dbb1561b4cbefd5b87..d3372286770a8112ce04629b5f1f16f3afd7748b 100644 (file)
@@ -83,6 +83,8 @@ class Decoder
         return instDone;
     }
 
+    void takeOverFrom(Decoder * old) {}
+
   protected:
     /// A cache of decoded instruction objects.
     static GenericISA::BasicDecodeCache defaultCache;
index 83a16da4c3fcae9f5deebce3db71647c2a5e8e42..72776bcfd792524c6b89eed8d2c5bda0e4ab259c 100644 (file)
@@ -116,6 +116,8 @@ class Decoder
         fpscrStride = fpscr.stride;
     }
 
+    void takeOverFrom(Decoder *old) {}
+
   protected:
     /// A cache of decoded instruction objects.
     static GenericISA::BasicDecodeCache defaultCache;
index 080614dee995902bd9af2ff2543feebfe70e03d9..a3a68ad07477be87aef7b7befb07a4cee8c5e8e9 100644 (file)
@@ -83,6 +83,8 @@ class Decoder
         return instDone;
     }
 
+    void takeOverFrom(Decoder *old) {}
+
   protected:
     /// A cache of decoded instruction objects.
     static GenericISA::BasicDecodeCache defaultCache;
index 830636aed103bd1ee1733d8e576f9fd8a09439a4..a70802cedcc8f6c36f087e6d479f7c489afb48a0 100644 (file)
@@ -89,6 +89,9 @@ class Decoder
     {
         return instDone;
     }
+
+    void takeOverFrom(Decoder *old) {}
+
   protected:
     /// A cache of decoded instruction objects.
     static GenericISA::BasicDecodeCache defaultCache;
index e7a806d81bd920df54645dcbf0cce7a6c4a6f1de..b87ee682e4bdd28d431b4be64399549abcc89678 100644 (file)
@@ -97,6 +97,8 @@ class Decoder
         asi = _asi;
     }
 
+    void takeOverFrom(Decoder *old) {}
+
   protected:
     /// A cache of decoded instruction objects.
     static GenericISA::BasicDecodeCache defaultCache;
index 6f55ab26f8c97ddf39fc3abfa287680b76df584e..ca7ef96fe01403e419154fce71c573f88e3693e2 100644 (file)
@@ -250,6 +250,19 @@ class Decoder
         }
     }
 
+    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;
index 6de5c573178c6c53674d0ade0b922fe5250d8ba6..f818cc3dc79c85c326d1ef5c47629bb9c231f973 100755 (executable)
@@ -67,6 +67,9 @@ void
 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();
index 77569aa68d91ec3f71765045c095c2d28e1c046b..de01124e035a8453a9bf8fa177fd47b445b3f39c 100644 (file)
@@ -108,6 +108,7 @@ void
 SimpleThread::takeOverFrom(ThreadContext *oldContext)
 {
     ::takeOverFrom(*tc, *oldContext);
+    decoder.takeOverFrom(oldContext->getDecoderPtr());
 
     kernelStats = oldContext->getKernelStats();
     funcExeInst = oldContext->readFuncExeInst();