Title: [199865] trunk/Source/_javascript_Core
Revision
199865
Author
benja...@webkit.org
Date
2016-04-21 21:29:02 -0700 (Thu, 21 Apr 2016)

Log Message

[JSC] Improve the absThunkGenerator() for 64bit
https://bugs.webkit.org/show_bug.cgi?id=156888

Reviewed by Michael Saboff.

A few tests spend a lot of time in this abs() with double argument.

This patch adds custom handling for the JSValue64 representation.
In particular:
-Do not load the value twice. Unbox the GPR if it is not an Int32.
-Deal with IntMin inline instead of falling back to the C function call.
-Box the values ourself to avoid a duplicate function tail and return.

* jit/ThunkGenerators.cpp:
(JSC::absThunkGenerator):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (199864 => 199865)


--- trunk/Source/_javascript_Core/ChangeLog	2016-04-22 04:26:09 UTC (rev 199864)
+++ trunk/Source/_javascript_Core/ChangeLog	2016-04-22 04:29:02 UTC (rev 199865)
@@ -1,3 +1,21 @@
+2016-04-21  Benjamin Poulain  <benja...@webkit.org>
+
+        [JSC] Improve the absThunkGenerator() for 64bit
+        https://bugs.webkit.org/show_bug.cgi?id=156888
+
+        Reviewed by Michael Saboff.
+
+        A few tests spend a lot of time in this abs() with double argument.
+
+        This patch adds custom handling for the JSValue64 representation.
+        In particular:
+        -Do not load the value twice. Unbox the GPR if it is not an Int32.
+        -Deal with IntMin inline instead of falling back to the C function call.
+        -Box the values ourself to avoid a duplicate function tail and return.
+
+        * jit/ThunkGenerators.cpp:
+        (JSC::absThunkGenerator):
+
 2016-04-21  Saam barati  <sbar...@apple.com>
 
         LLInt CallSiteIndex off by 1

Modified: trunk/Source/_javascript_Core/jit/ThunkGenerators.cpp (199864 => 199865)


--- trunk/Source/_javascript_Core/jit/ThunkGenerators.cpp	2016-04-22 04:26:09 UTC (rev 199864)
+++ trunk/Source/_javascript_Core/jit/ThunkGenerators.cpp	2016-04-22 04:29:02 UTC (rev 199865)
@@ -928,6 +928,42 @@
     SpecializedThunkJIT jit(vm, 1);
     if (!jit.supportsFloatingPointAbs())
         return MacroAssemblerCodeRef::createSelfManagedCodeRef(vm->jitStubs->ctiNativeCall(vm));
+
+#if USE(JSVALUE64)
+    unsigned virtualRegisterIndex = CallFrame::argumentOffset(0);
+    jit.load64(AssemblyHelpers::addressFor(virtualRegisterIndex), GPRInfo::regT0);
+    MacroAssembler::Jump notInteger = jit.branch64(MacroAssembler::Below, GPRInfo::regT0, GPRInfo::tagTypeNumberRegister);
+
+    // Abs Int32.
+    jit.rshift32(GPRInfo::regT0, MacroAssembler::TrustedImm32(31), GPRInfo::regT1);
+    jit.add32(GPRInfo::regT1, GPRInfo::regT0);
+    jit.xor32(GPRInfo::regT1, GPRInfo::regT0);
+
+    // IntMin cannot be inverted.
+    MacroAssembler::Jump integerIsIntMin = jit.branchTest32(MacroAssembler::Signed, GPRInfo::regT0);
+
+    // Box and finish.
+    jit.or64(GPRInfo::tagTypeNumberRegister, GPRInfo::regT0);
+    MacroAssembler::Jump doneWithIntegers = jit.jump();
+
+    // Handle Doubles.
+    notInteger.link(&jit);
+    jit.appendFailure(jit.branchTest64(MacroAssembler::Zero, GPRInfo::regT0, GPRInfo::tagTypeNumberRegister));
+    jit.unboxDoubleWithoutAssertions(GPRInfo::regT0, GPRInfo::regT0, FPRInfo::fpRegT0);
+    MacroAssembler::Label absFPR0Label = jit.label();
+    jit.absDouble(FPRInfo::fpRegT0, FPRInfo::fpRegT1);
+    jit.boxDouble(FPRInfo::fpRegT1, GPRInfo::regT0);
+
+    // Tail.
+    doneWithIntegers.link(&jit);
+    jit.returnJSValue(GPRInfo::regT0);
+
+    // We know the value of regT0 is IntMin. We could load that value from memory but
+    // it is simpler to just convert it.
+    integerIsIntMin.link(&jit);
+    jit.convertInt32ToDouble(GPRInfo::regT0, FPRInfo::fpRegT0);
+    jit.jump().linkTo(absFPR0Label, &jit);
+#else
     MacroAssembler::Jump nonIntJump;
     jit.loadInt32Argument(0, SpecializedThunkJIT::regT0, nonIntJump);
     jit.rshift32(SpecializedThunkJIT::regT0, MacroAssembler::TrustedImm32(31), SpecializedThunkJIT::regT1);
@@ -940,6 +976,7 @@
     jit.loadDoubleArgument(0, SpecializedThunkJIT::fpRegT0, SpecializedThunkJIT::regT0);
     jit.absDouble(SpecializedThunkJIT::fpRegT0, SpecializedThunkJIT::fpRegT1);
     jit.returnDouble(SpecializedThunkJIT::fpRegT1);
+#endif
     return jit.finalize(vm->jitStubs->ctiNativeTailCall(vm), "abs");
 }
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to