Bug 562837 - TM: avoid reboxing when copying a double from one array to another. r=brendan.
authorNicholas Nethercote <nnethercote@mozilla.com>
Mon, 03 May 2010 15:51:57 -0700
changeset 41876 df1837614a6f77f40f3d89f24eea91991b3d29f0
parent 41875 4c3f56a1610c7beb49ee8ac98639317d5e6ba812
child 41877 b7ab81f30d4173126dc1be1054c2204fc75737d3
push id1
push userroot
push dateMon, 20 Oct 2014 17:29:22 +0000
reviewersbrendan
bugs562837
milestone1.9.3a5pre
Bug 562837 - TM: avoid reboxing when copying a double from one array to another. r=brendan.
js/src/jstracer.cpp
--- a/js/src/jstracer.cpp
+++ b/js/src/jstracer.cpp
@@ -12281,31 +12281,35 @@ TraceRecorder::setElem(int lval_spindex,
         // Make sure the array is actually dense.
         if (!guardDenseArray(obj, obj_ins, BRANCH_EXIT))
             return ARECORD_STOP;
 
         // The index was on the stack and is therefore a LIR float. Force it to
         // be an integer.
         idx_ins = makeNumberInt32(idx_ins);
 
-        // Box the value so we can use one builtin instead of having to add one
-        // builtin for every storage type. Special case for integers though,
-        // since they are so common.
+        // Box the value so we can use one builtin instead of having to add
+        // one builtin for every storage type. Special case for integers
+        // though, since they are so common;  but make sure we don't rebox
+        // unnecessarily.
         LIns* res_ins;
         LIns* args[] = { NULL, idx_ins, obj_ins, cx_ins };
         if (isNumber(v)) {
-            if (isPromoteInt(v_ins)) {
+            if (fcallinfo(v_ins) == &js_UnboxDouble_ci) {
+                args[0] = fcallarg(v_ins, 0);
+                res_ins = lir->insCall(&js_Array_dense_setelem_ci, args);
+            } else if (isPromoteInt(v_ins)) {
                 args[0] = demote(lir, v_ins);
                 res_ins = lir->insCall(&js_Array_dense_setelem_int_ci, args);
             } else {
                 args[0] = v_ins;
                 res_ins = lir->insCall(&js_Array_dense_setelem_double_ci, args);
             }
         } else {
-            LIns* args[] = { box_jsval(v, v_ins), idx_ins, obj_ins, cx_ins };
+            args[0] = box_jsval(v, v_ins);
             res_ins = lir->insCall(&js_Array_dense_setelem_ci, args);
         }
         guard(false, lir->insEqI_0(res_ins), MISMATCH_EXIT);
     }
 
     jsbytecode* pc = cx->fp->regs->pc;
     if (*pc == JSOP_SETELEM && pc[JSOP_SETELEM_LENGTH] != JSOP_POP)
         set(&lval, v_ins);