Bug 1104199 - Don't require LUnbox operand to be in a register on x64. r=sunfish
authorJan de Mooij <jdemooij@mozilla.com>
Fri, 28 Nov 2014 17:25:32 -0800
changeset 243913 6d64e1e46eb1efeb6e5a5bb39936d4c713f1820f
parent 243912 c213f97e0eec2b0ded9fa2ccb14877b8705f95cc
child 243914 9902a6ce983179a15a06f69573465c45b34e9168
push id4489
push userraliiev@mozilla.com
push dateMon, 23 Feb 2015 15:17:55 +0000
treeherdermozilla-beta@fd7c3dc24146 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssunfish
bugs1104199
milestone37.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1104199 - Don't require LUnbox operand to be in a register on x64. r=sunfish
js/src/jit/x64/CodeGenerator-x64.cpp
js/src/jit/x64/Lowering-x64.cpp
--- a/js/src/jit/x64/CodeGenerator-x64.cpp
+++ b/js/src/jit/x64/CodeGenerator-x64.cpp
@@ -82,21 +82,20 @@ CodeGeneratorX64::visitBox(LBox *box)
         masm.boxValue(ValueTypeFromMIRType(box->type()), ToRegister(in), ToRegister(result));
     }
     return true;
 }
 
 bool
 CodeGeneratorX64::visitUnbox(LUnbox *unbox)
 {
-    const ValueOperand value = ToValue(unbox, LUnbox::Input);
-    const LDefinition *result = unbox->output();
     MUnbox *mir = unbox->mir();
 
     if (mir->fallible()) {
+        const ValueOperand value = ToValue(unbox, LUnbox::Input);
         Assembler::Condition cond;
         switch (mir->type()) {
           case MIRType_Int32:
             cond = masm.testInt32(Assembler::NotEqual, value);
             break;
           case MIRType_Boolean:
             cond = masm.testBoolean(Assembler::NotEqual, value);
             break;
@@ -111,31 +110,33 @@ CodeGeneratorX64::visitUnbox(LUnbox *unb
             break;
           default:
             MOZ_CRASH("Given MIRType cannot be unboxed.");
         }
         if (!bailoutIf(cond, unbox->snapshot()))
             return false;
     }
 
+    Operand input = ToOperand(unbox->getOperand(LUnbox::Input));
+    Register result = ToRegister(unbox->output());
     switch (mir->type()) {
       case MIRType_Int32:
-        masm.unboxInt32(value, ToRegister(result));
+        masm.unboxInt32(input, result);
         break;
       case MIRType_Boolean:
-        masm.unboxBoolean(value, ToRegister(result));
+        masm.unboxBoolean(input, result);
         break;
       case MIRType_Object:
-        masm.unboxObject(value, ToRegister(result));
+        masm.unboxObject(input, result);
         break;
       case MIRType_String:
-        masm.unboxString(value, ToRegister(result));
+        masm.unboxString(input, result);
         break;
       case MIRType_Symbol:
-        masm.unboxSymbol(value, ToRegister(result));
+        masm.unboxSymbol(input, result);
         break;
       default:
         MOZ_CRASH("Given MIRType cannot be unboxed.");
     }
 
     return true;
 }
 
--- a/js/src/jit/x64/Lowering-x64.cpp
+++ b/js/src/jit/x64/Lowering-x64.cpp
@@ -79,20 +79,25 @@ LIRGeneratorX64::visitBox(MBox *box)
 
 bool
 LIRGeneratorX64::visitUnbox(MUnbox *unbox)
 {
     MDefinition *box = unbox->getOperand(0);
     MOZ_ASSERT(box->type() == MIRType_Value);
 
     LUnboxBase *lir;
-    if (IsFloatingPointType(unbox->type()))
+    if (IsFloatingPointType(unbox->type())) {
         lir = new(alloc()) LUnboxFloatingPoint(useRegisterAtStart(box), unbox->type());
-    else
+    } else if (unbox->fallible()) {
+        // If the unbox is fallible, load the Value in a register first to
+        // avoid multiple loads.
         lir = new(alloc()) LUnbox(useRegisterAtStart(box));
+    } else {
+        lir = new(alloc()) LUnbox(useAtStart(box));
+    }
 
     if (unbox->fallible() && !assignSnapshot(lir, unbox->bailoutKind()))
         return false;
 
     return define(lir, unbox);
 }
 
 bool