Bug 1381423 - Part 0: Fix branchTestMagic with an Address operand for 32-bit targets. r=jandem
authorAndré Bargull <andre.bargull@gmail.com>
Wed, 19 Jul 2017 03:12:37 -0700
changeset 418401 ba918d2bbf4633b7b1bcbf4c143153204f03865a
parent 418400 638c3681d5c34cbe777f858653b85bba2cdd8dd8
child 418402 e52913f1812418d26a66cd9743215bea9cba9213
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjandem
bugs1381423
milestone56.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 1381423 - Part 0: Fix branchTestMagic with an Address operand for 32-bit targets. r=jandem
js/src/jit/arm/MacroAssembler-arm-inl.h
js/src/jit/mips32/MacroAssembler-mips32-inl.h
js/src/jit/x86/MacroAssembler-x86-inl.h
--- a/js/src/jit/arm/MacroAssembler-arm-inl.h
+++ b/js/src/jit/arm/MacroAssembler-arm-inl.h
@@ -2048,18 +2048,26 @@ MacroAssembler::branchTestMagicImpl(Cond
 {
     cond = testMagic(cond, t);
     ma_b(label, cond);
 }
 
 void
 MacroAssembler::branchTestMagic(Condition cond, const Address& valaddr, JSWhyMagic why, Label* label)
 {
-    branchTestMagic(cond, valaddr, label);
+    MOZ_ASSERT(cond == Assembler::Equal || cond == Assembler::NotEqual);
+
+    Label notMagic;
+    if (cond == Assembler::Equal)
+        branchTestMagic(Assembler::NotEqual, valaddr, &notMagic);
+    else
+        branchTestMagic(Assembler::NotEqual, valaddr, label);
+
     branch32(cond, ToPayload(valaddr), Imm32(why), label);
+    bind(&notMagic);
 }
 
 void
 MacroAssembler::branchToComputedAddress(const BaseIndex& addr)
 {
     MOZ_ASSERT(addr.base == pc, "Unsupported jump from any other addresses.");
     MOZ_ASSERT(addr.offset == 0, "NYI: offsets from pc should be shifted by the number of instructions.");
 
--- a/js/src/jit/mips32/MacroAssembler-mips32-inl.h
+++ b/js/src/jit/mips32/MacroAssembler-mips32-inl.h
@@ -998,18 +998,26 @@ void
 MacroAssembler::branchTestMagic(Condition cond, const ValueOperand& value, L label)
 {
     ma_b(value.typeReg(), ImmTag(JSVAL_TAG_MAGIC), label, cond);
 }
 
 void
 MacroAssembler::branchTestMagic(Condition cond, const Address& valaddr, JSWhyMagic why, Label* label)
 {
-    branchTestMagic(cond, valaddr, label);
+    MOZ_ASSERT(cond == Assembler::Equal || cond == Assembler::NotEqual);
+
+    Label notMagic;
+    if (cond == Assembler::Equal)
+        branchTestMagic(Assembler::NotEqual, valaddr, &notMagic);
+    else
+        branchTestMagic(Assembler::NotEqual, valaddr, label);
+
     branch32(cond, ToPayload(valaddr), Imm32(why), label);
+    bind(&notMagic);
 }
 
 // ========================================================================
 // Memory access primitives.
 void
 MacroAssembler::storeUncanonicalizedDouble(FloatRegister src, const Address& addr)
 {
     ma_sd(src, addr);
--- a/js/src/jit/x86/MacroAssembler-x86-inl.h
+++ b/js/src/jit/x86/MacroAssembler-x86-inl.h
@@ -913,18 +913,26 @@ MacroAssembler::branchTestBooleanTruthy(
 {
     test32(value.payloadReg(), value.payloadReg());
     j(truthy ? NonZero : Zero, label);
 }
 
 void
 MacroAssembler::branchTestMagic(Condition cond, const Address& valaddr, JSWhyMagic why, Label* label)
 {
-    branchTestMagic(cond, valaddr, label);
+    MOZ_ASSERT(cond == Assembler::Equal || cond == Assembler::NotEqual);
+
+    Label notMagic;
+    if (cond == Assembler::Equal)
+        branchTestMagic(Assembler::NotEqual, valaddr, &notMagic);
+    else
+        branchTestMagic(Assembler::NotEqual, valaddr, label);
+
     branch32(cond, ToPayload(valaddr), Imm32(why), label);
+    bind(&notMagic);
 }
 
 void
 MacroAssembler::branchToComputedAddress(const BaseIndex& addr)
 {
     jmp(Operand(addr));
 }