Bug 1324810 - Part 0: Add MacroAssembler::{storeCallBoolResult,storeCallWordResult}. r=jandem, a=lizzard
authorTooru Fujisawa <arai_a@mac.com>
Thu, 22 Dec 2016 23:01:41 +0900
changeset 353280 fe80ac73a1121b8ba7a6c7040a1f25d19b030739
parent 353279 0eeed34e22e43b12834f6619689827896b41a50c
child 353281 1458ff2725619c3db4b1dcb4f057f26a60208873
push id6795
push userjlund@mozilla.com
push dateMon, 23 Jan 2017 14:19:46 +0000
treeherdermozilla-esr52@76101b503191 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem, lizzard
bugs1324810
milestone52.0a2
Bug 1324810 - Part 0: Add MacroAssembler::{storeCallBoolResult,storeCallWordResult}. r=jandem, a=lizzard
js/src/irregexp/NativeRegExpMacroAssembler.cpp
js/src/jit/CodeGenerator.cpp
js/src/jit/MacroAssembler-inl.h
js/src/jit/MacroAssembler.cpp
js/src/jit/MacroAssembler.h
js/src/jit/SharedIC.cpp
js/src/jit/shared/CodeGenerator-shared.h
js/src/jit/x86/CodeGenerator-x86.cpp
--- a/js/src/irregexp/NativeRegExpMacroAssembler.cpp
+++ b/js/src/irregexp/NativeRegExpMacroAssembler.cpp
@@ -442,17 +442,17 @@ NativeRegExpMacroAssembler::GenerateCode
 #endif
         volatileRegs.takeUnchecked(temp0);
         volatileRegs.takeUnchecked(temp1);
         masm.PushRegsInMask(volatileRegs);
 
         masm.setupUnalignedABICall(temp0);
         masm.passABIArg(temp1);
         masm.callWithABI(JS_FUNC_TO_DATA_PTR(void*, GrowBacktrackStack));
-        masm.storeCallResult(temp0);
+        masm.storeCallWordResult(temp0);
 
         masm.PopRegsInMask(volatileRegs);
 
         // If return false, we have failed to grow the stack, and
         // must exit with a stack-overflow exception. Do this in the caller
         // so that the stack is adjusted by our return instruction.
         Label return_from_overflow_handler;
         masm.branchTest32(Assembler::Zero, temp0, temp0, &return_from_overflow_handler);
@@ -861,17 +861,17 @@ NativeRegExpMacroAssembler::CheckNotBack
         masm.passABIArg(temp1);
         if (!unicode) {
             int (*fun)(const char16_t*, const char16_t*, size_t) = CaseInsensitiveCompareStrings;
             masm.callWithABI(JS_FUNC_TO_DATA_PTR(void*, fun));
         } else {
             int (*fun)(const char16_t*, const char16_t*, size_t) = CaseInsensitiveCompareUCStrings;
             masm.callWithABI(JS_FUNC_TO_DATA_PTR(void*, fun));
         }
-        masm.storeCallResult(temp0);
+        masm.storeCallWordResult(temp0);
 
         masm.PopRegsInMask(volatileRegs);
 
         // Check if function returned non-zero for success or zero for failure.
         masm.branchTest32(Assembler::Zero, temp0, temp0, BranchOrBacktrack(on_no_match));
 
         // On success, increment position by length of capture.
         masm.addPtr(temp1, current_position);
--- a/js/src/jit/CodeGenerator.cpp
+++ b/js/src/jit/CodeGenerator.cpp
@@ -390,17 +390,17 @@ CodeGenerator::emitOOLTestObject(Registe
                                  Label* ifEmulatesUndefined,
                                  Label* ifDoesntEmulateUndefined,
                                  Register scratch)
 {
     saveVolatile(scratch);
     masm.setupUnalignedABICall(scratch);
     masm.passABIArg(objreg);
     masm.callWithABI(JS_FUNC_TO_DATA_PTR(void*, js::EmulatesUndefined));
-    masm.storeCallResult(scratch);
+    masm.storeCallBoolResult(scratch);
     restoreVolatile(scratch);
 
     masm.branchIfTrueBool(scratch, ifEmulatesUndefined);
     masm.jump(ifDoesntEmulateUndefined);
 }
 
 // Base out-of-line code generator for all tests of the truthiness of an
 // object, where the object might not be truthy.  (Recall that per spec all
@@ -1403,17 +1403,17 @@ CreateDependentString::generateFallback(
         masm.PushRegsInMask(regsToSave);
 
         masm.setupUnalignedABICall(string_);
         masm.loadJSContext(string_);
         masm.passABIArg(string_);
         masm.callWithABI(kind == FallbackKind::FatInlineString
                          ? JS_FUNC_TO_DATA_PTR(void*, AllocateFatInlineString)
                          : JS_FUNC_TO_DATA_PTR(void*, AllocateString));
-        masm.storeCallResult(string_);
+        masm.storeCallWordResult(string_);
 
         masm.PopRegsInMask(regsToSave);
 
         masm.branchPtr(Assembler::Equal, string_, ImmWord(0), failure_);
 
         masm.jump(&joins_[kind]);
     }
 }
@@ -1441,17 +1441,17 @@ CreateMatchResultFallback(MacroAssembler
 
     masm.loadJSContext(object);
     masm.passABIArg(object);
     masm.move32(Imm32(int32_t(templateObj->asTenured().getAllocKind())), temp2);
     masm.passABIArg(temp2);
     masm.move32(Imm32(int32_t(templateObj->as<NativeObject>().numDynamicSlots())), temp5);
     masm.passABIArg(temp5);
     masm.callWithABI(JS_FUNC_TO_DATA_PTR(void*, CreateMatchResultFallbackFunc));
-    masm.storeCallResult(object);
+    masm.storeCallWordResult(object);
 
     masm.PopRegsInMask(regsToSave);
 
     masm.branchPtr(Assembler::Equal, object, ImmWord(0), fail);
 
     masm.initGCThing(object, temp2, templateObj, true, false);
 }
 
@@ -7569,17 +7569,17 @@ JitRuntime::generateMallocStub(JSContext
     const Register regRuntime = regTemp;
     MOZ_ASSERT(regTemp != regNBytes);
 
     masm.setupUnalignedABICall(regTemp);
     masm.movePtr(ImmPtr(cx->runtime()), regRuntime);
     masm.passABIArg(regRuntime);
     masm.passABIArg(regNBytes);
     masm.callWithABI(JS_FUNC_TO_DATA_PTR(void*, MallocWrapper));
-    masm.storeCallResult(regReturn);
+    masm.storeCallWordResult(regReturn);
 
     masm.PopRegsInMask(save);
     masm.ret();
 
     Linker linker(masm);
     AutoFlushICache afc("MallocStub");
     JitCode* code = linker.newCode<NoGC>(cx, OTHER_CODE);
 
@@ -10450,17 +10450,17 @@ CodeGenerator::visitOutOfLineTypeOfV(Out
     Register obj = masm.extractObject(input, temp);
 
     saveVolatile(output);
     masm.setupUnalignedABICall(output);
     masm.passABIArg(obj);
     masm.movePtr(ImmPtr(GetJitContext()->runtime), output);
     masm.passABIArg(output);
     masm.callWithABI(JS_FUNC_TO_DATA_PTR(void*, js::TypeOfObjectOperation));
-    masm.storeCallResult(output);
+    masm.storeCallWordResult(output);
     restoreVolatile(output);
 
     masm.jump(ool->rejoin());
 }
 
 typedef JSObject* (*ToAsyncFn)(JSContext*, HandleFunction);
 static const VMFunction ToAsyncInfo = FunctionInfo<ToAsyncFn>(js::WrapAsyncFunction, "ToAsync");
 
@@ -11356,20 +11356,17 @@ CodeGenerator::visitOutOfLineIsCallable(
     LIsCallable* ins = ool->ins();
     Register object = ToRegister(ins->object());
     Register output = ToRegister(ins->output());
 
     saveVolatile(output);
     masm.setupUnalignedABICall(output);
     masm.passABIArg(object);
     masm.callWithABI(JS_FUNC_TO_DATA_PTR(void*, ObjectIsCallable));
-    masm.storeCallResult(output);
-    // C++ compilers like to only use the bottom byte for bools, but we need to maintain the entire
-    // register.
-    masm.and32(Imm32(0xFF), output);
+    masm.storeCallBoolResult(output);
     restoreVolatile(output);
     masm.jump(ool->rejoin());
 }
 
 class OutOfLineIsConstructor : public OutOfLineCodeBase<CodeGenerator>
 {
     LIsConstructor* ins_;
 
@@ -11435,20 +11432,17 @@ CodeGenerator::visitOutOfLineIsConstruct
     LIsConstructor* ins = ool->ins();
     Register object = ToRegister(ins->object());
     Register output = ToRegister(ins->output());
 
     saveVolatile(output);
     masm.setupUnalignedABICall(output);
     masm.passABIArg(object);
     masm.callWithABI(JS_FUNC_TO_DATA_PTR(void*, ObjectIsConstructor));
-    masm.storeCallResult(output);
-    // C++ compilers like to only use the bottom byte for bools, but we need to maintain the entire
-    // register.
-    masm.and32(Imm32(0xFF), output);
+    masm.storeCallBoolResult(output);
     restoreVolatile(output);
     masm.jump(ool->rejoin());
 }
 
 void
 CodeGenerator::visitIsObject(LIsObject* ins)
 {
     Register output = ToRegister(ins->output());
--- a/js/src/jit/MacroAssembler-inl.h
+++ b/js/src/jit/MacroAssembler-inl.h
@@ -760,16 +760,26 @@ MacroAssembler::assertStackAlignment(uin
 
     bind(&bad);
     breakpoint();
     bind(&ok);
 #endif
 }
 
 void
+MacroAssembler::storeCallBoolResult(Register reg)
+{
+    if (reg != ReturnReg)
+        mov(ReturnReg, reg);
+    // C++ compilers like to only use the bottom byte for bools, but we
+    // need to maintain the entire register.
+    and32(Imm32(0xFF), reg);
+}
+
+void
 MacroAssembler::storeCallResultValue(AnyRegister dest)
 {
     unboxValue(JSReturnOperand, dest);
 }
 
 void
 MacroAssembler::storeCallResultValue(TypedOrValueRegister dest)
 {
--- a/js/src/jit/MacroAssembler.cpp
+++ b/js/src/jit/MacroAssembler.cpp
@@ -1974,17 +1974,17 @@ MacroAssembler::outOfLineTruncateSlow(Fl
     MOZ_ASSERT(src.isDouble());
 
     setupUnalignedABICall(dest);
     passABIArg(src, MoveOp::DOUBLE);
     if (compilingWasm)
         callWithABI(wasm::SymbolicAddress::ToInt32);
     else
         callWithABI(mozilla::BitwiseCast<void*, int32_t(*)(double)>(JS::ToInt32));
-    storeCallResult(dest);
+    storeCallWordResult(dest);
 
 #if defined(JS_CODEGEN_ARM) || defined(JS_CODEGEN_ARM64) || \
     defined(JS_CODEGEN_MIPS32) || defined(JS_CODEGEN_MIPS64)
     // Nothing
 #elif defined(JS_CODEGEN_X86) || defined(JS_CODEGEN_X64)
     if (widenFloatToDouble)
         pop(srcSingle);
 #else
--- a/js/src/jit/MacroAssembler.h
+++ b/js/src/jit/MacroAssembler.h
@@ -1492,21 +1492,23 @@ class MacroAssembler : public MacroAssem
     template <typename T>
     void storeConstantOrRegister(const ConstantOrRegister& src, const T& dest) {
         if (src.constant())
             storeValue(src.value(), dest);
         else
             storeTypedOrValue(src.reg(), dest);
     }
 
-    void storeCallResult(Register reg) {
+    void storeCallWordResult(Register reg) {
         if (reg != ReturnReg)
             mov(ReturnReg, reg);
     }
 
+    inline void storeCallBoolResult(Register reg);
+
     void storeCallFloatResult(FloatRegister reg) {
         if (reg != ReturnDoubleReg)
             moveDouble(ReturnDoubleReg, reg);
     }
 
     inline void storeCallResultValue(AnyRegister dest);
 
     void storeCallResultValue(ValueOperand dest) {
--- a/js/src/jit/SharedIC.cpp
+++ b/js/src/jit/SharedIC.cpp
@@ -1420,17 +1420,17 @@ ICBinaryArith_DoubleWithInt32::Compiler:
         masm.branchTruncateDoubleMaybeModUint32(FloatReg0, scratchReg, &truncateABICall);
         masm.jump(&doneTruncate);
 
         masm.bind(&truncateABICall);
         masm.push(intReg);
         masm.setupUnalignedABICall(scratchReg);
         masm.passABIArg(FloatReg0, MoveOp::DOUBLE);
         masm.callWithABI(mozilla::BitwiseCast<void*, int32_t(*)(double)>(JS::ToInt32));
-        masm.storeCallResult(scratchReg);
+        masm.storeCallWordResult(scratchReg);
         masm.pop(intReg);
 
         masm.bind(&doneTruncate);
     }
 
     Register intReg2 = scratchReg;
     // All handled ops commute, so no need to worry about ordering.
     switch(op) {
@@ -1573,17 +1573,17 @@ ICUnaryArith_Double::Compiler::generateS
         Label truncateABICall;
         masm.branchTruncateDoubleMaybeModUint32(FloatReg0, scratchReg, &truncateABICall);
         masm.jump(&doneTruncate);
 
         masm.bind(&truncateABICall);
         masm.setupUnalignedABICall(scratchReg);
         masm.passABIArg(FloatReg0, MoveOp::DOUBLE);
         masm.callWithABI(BitwiseCast<void*, int32_t(*)(double)>(JS::ToInt32));
-        masm.storeCallResult(scratchReg);
+        masm.storeCallWordResult(scratchReg);
 
         masm.bind(&doneTruncate);
         masm.not32(scratchReg);
         masm.tagValue(JSVAL_TYPE_INT32, scratchReg, R0);
     }
 
     EmitReturnFromIC(masm);
 
--- a/js/src/jit/shared/CodeGenerator-shared.h
+++ b/js/src/jit/shared/CodeGenerator-shared.h
@@ -433,17 +433,17 @@ class CodeGeneratorShared : public LElem
     void pushArg(const T& t) {
         masm.Push(t);
 #ifdef DEBUG
         pushedArgs_++;
 #endif
     }
 
     void storeResultTo(Register reg) {
-        masm.storeCallResult(reg);
+        masm.storeCallWordResult(reg);
     }
 
     void storeFloatResultTo(FloatRegister reg) {
         masm.storeCallFloatResult(reg);
     }
 
     template <typename T>
     void storeResultValueTo(const T& t) {
--- a/js/src/jit/x86/CodeGenerator-x86.cpp
+++ b/js/src/jit/x86/CodeGenerator-x86.cpp
@@ -861,17 +861,17 @@ CodeGeneratorX86::visitOutOfLineTruncate
         saveVolatile(output);
 
         masm.setupUnalignedABICall(output);
         masm.passABIArg(input, MoveOp::DOUBLE);
         if (gen->compilingWasm())
             masm.callWithABI(wasm::SymbolicAddress::ToInt32);
         else
             masm.callWithABI(BitwiseCast<void*, int32_t(*)(double)>(JS::ToInt32));
-        masm.storeCallResult(output);
+        masm.storeCallWordResult(output);
 
         restoreVolatile(output);
     }
 
     masm.jump(ool->rejoin());
 }
 
 void
@@ -946,17 +946,17 @@ CodeGeneratorX86::visitOutOfLineTruncate
         masm.vcvtss2sd(input, input, input);
         masm.passABIArg(input.asDouble(), MoveOp::DOUBLE);
 
         if (gen->compilingWasm())
             masm.callWithABI(wasm::SymbolicAddress::ToInt32);
         else
             masm.callWithABI(BitwiseCast<void*, int32_t(*)(double)>(JS::ToInt32));
 
-        masm.storeCallResult(output);
+        masm.storeCallWordResult(output);
         masm.pop(input);
 
         restoreVolatile(output);
     }
 
     masm.jump(ool->rejoin());
 }