my turn to merge; had to happen eventually
authorshaver@mozilla.org
Thu, 10 Jul 2008 21:44:41 -0400
changeset 17601 77003ad3dd063933d2b93b9990b477b195646ca5
parent 17600 75f3b00302ed7e0d9e05e6bf197f75c1523192eb (current diff)
parent 17596 bd78d1eedabe55ca8d7acc77af796ece9e0619d1 (diff)
child 17602 2b54939fcc2140189604fa264c6dae5bb89eff51
push id1452
push usershaver@mozilla.com
push dateFri, 22 Aug 2008 00:08:22 +0000
treeherdermozilla-central@d13bb0868596 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
milestone1.9.1a1pre
my turn to merge; had to happen eventually
js/src/jstracer.cpp
--- a/js/src/jstracer.cpp
+++ b/js/src/jstracer.cpp
@@ -57,83 +57,81 @@
 #endif
 
 using namespace avmplus;
 using namespace nanojit;
 
 static GC gc = GC();
 static avmplus::AvmCore* core = new (&gc) avmplus::AvmCore();
 
-template<typename T>
-Tracker<T>::Tracker()
+Tracker::Tracker()
 {
     pagelist = 0;
 }
 
-template<typename T>
-Tracker<T>::~Tracker()
+Tracker::~Tracker()
 {
     clear();
 }
 
-template<typename T> jsuword
-Tracker<T>::getPageBase(const void* v) const
+jsuword
+Tracker::getPageBase(const void* v) const
 {
     return jsuword(v) & ~jsuword(NJ_PAGE_SIZE-1);
 }
 
-template<typename T> struct Tracker<T>::Page*
-Tracker<T>::findPage(const void* v) const
+struct Tracker::Page*
+Tracker::findPage(const void* v) const
 {
     jsuword base = getPageBase(v);
-    struct Tracker<T>::Page* p = pagelist;
+    struct Tracker::Page* p = pagelist;
     while (p) {
         if (p->base == base) {
             return p;
         }
         p = p->next;
     }
     return 0;
 }
 
-template <typename T> struct Tracker<T>::Page*
-Tracker<T>::addPage(const void* v) {
+struct Tracker::Page*
+Tracker::addPage(const void* v) {
     jsuword base = getPageBase(v);
     struct Tracker::Page* p = (struct Tracker::Page*)
-        GC::Alloc(sizeof(*p) - sizeof(p->map) + (NJ_PAGE_SIZE >> 2) * sizeof(T));
+        GC::Alloc(sizeof(*p) - sizeof(p->map) + (NJ_PAGE_SIZE >> 2) * sizeof(LIns*));
     p->base = base;
     p->next = pagelist;
     pagelist = p;
     return p;
 }
 
-template <typename T> void
-Tracker<T>::clear()
+void
+Tracker::clear()
 {
     while (pagelist) {
         Page* p = pagelist;
         pagelist = pagelist->next;
         GC::Free(p);
     }
 }
 
-template <typename T> T
-Tracker<T>::get(const void* v) const
+LIns* 
+Tracker::get(const void* v) const
 {
-    struct Tracker<T>::Page* p = findPage(v);
+    struct Tracker::Page* p = findPage(v);
     JS_ASSERT(p != 0); /* we must have a page for the slot we are looking for */
-    T i = p->map[(jsuword(v) & 0xfff) >> 2];
+    LIns* i = p->map[(jsuword(v) & 0xfff) >> 2];
     JS_ASSERT(i != 0);
     return i;
 }
 
-template <typename T> void
-Tracker<T>::set(const void* v, T i)
+void
+Tracker::set(const void* v, LIns* i)
 {
-    struct Tracker<T>::Page* p = findPage(v);
+    struct Tracker::Page* p = findPage(v);
     if (!p)
         p = addPage(v);
     p->map[(jsuword(v) & 0xfff) >> 2] = i;
 }
 
 /*
  * Return the coerced type of a value. If it's a number, we always return JSVAL_DOUBLE, no matter
  * whether it's represented as an int or as a double.
@@ -1267,20 +1265,19 @@ TraceRecorder::cmp(LOpcode op, bool nega
             break;
           default:
             JS_ASSERT(op == LIR_feq);
             cond = asNumber(l) == asNumber(r);
             break;
         }
         /* The interpreter fuses comparisons and the following branch,
            so we have to do that here as well. */
-        if (cx->fp->regs->pc[1] == ::JSOP_IFEQ)
+        if (cx->fp->regs->pc[1] == ::JSOP_IFEQ
+            || cx->fp->regs->pc[1] == ::JSOP_IFNE)
             guard(cond, x);
-        else if (cx->fp->regs->pc[1] == ::JSOP_IFNE)
-            guard(!cond, x);
         /* We update the stack after the guard. This is safe since
            the guard bails out at the comparison and the interpreter
            will this re-execute the comparison. This way the
            value of the condition doesn't have to be calculated and
            saved on the stack in most cases. */
         set(&l, x);
         return true;
     }
--- a/js/src/jstracer.h
+++ b/js/src/jstracer.h
@@ -61,34 +61,33 @@
  * error.
  */
 #define INT32_ERROR_COOKIE 0xffffabcd
 
 /*
  * Tracker is used to keep track of values being manipulated by the interpreter
  * during trace recording.
  */
-template <typename T>
 class Tracker {
     struct Page {
         struct Page*    next;
         jsuword         base;
-        T               map[1];
+        nanojit::LIns*  map[1];
     };
     struct Page* pagelist;
 
     jsuword         getPageBase(const void* v) const;
     struct Page*    findPage(const void* v) const;
     struct Page*    addPage(const void* v);
 public:
     Tracker();
     ~Tracker();
 
-    T               get(const void* v) const;
-    void            set(const void* v, T ins);
+    nanojit::LIns*  get(const void* v) const;
+    void            set(const void* v, nanojit::LIns* ins);
     void            clear();
 };
 
 struct VMFragmentInfo {
     unsigned                entryNativeFrameSlots;
     unsigned                maxNativeFrameSlots;
     size_t                  nativeStackBase;
     uint8                   typeMap[1];
@@ -104,17 +103,17 @@ extern struct nanojit::CallInfo builtins
 #define TYPEMAP_TYPE_ANY            7
 
 #define TYPEMAP_FLAG_DEMOTE 0x10 /* try to record as int */
 #define TYPEMAP_FLAG_DONT_DEMOTE 0x20 /* do not try to record as int */
 
 class TraceRecorder {
     JSContext*              cx;
     JSStackFrame*           global;
-    Tracker<nanojit::LIns*> tracker;
+    Tracker                 tracker;
     char*                   entryTypeMap;
     struct JSStackFrame*    entryFrame;
     struct JSFrameRegs      entryRegs;
     nanojit::Fragment*      fragment;
     VMFragmentInfo*         fragmentInfo;
     nanojit::LirBuffer*     lirbuf;
     nanojit::LirWriter*     lir;
     nanojit::LirBufWriter*  lir_buf_writer;
--- a/js/src/trace-test.js
+++ b/js/src/trace-test.js
@@ -119,9 +119,8 @@ function ursh(n)
 {
   var r;
   for (var i = 0; i < 35; i++)
     r = -55 >>> n;
   return r;
 }
 test("ursh(8)", ursh(8), 16777215);
 // test("ursh(33)", ursh(33), 2147483620);
-