[JSC] Clean up Math.floor thunk and use SSE round instruction
authorutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Mar 2016 01:35:04 +0000 (01:35 +0000)
committerutatane.tea@gmail.com <utatane.tea@gmail.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Tue, 22 Mar 2016 01:35:04 +0000 (01:35 +0000)
https://bugs.webkit.org/show_bug.cgi?id=155705

Reviewed by Geoffrey Garen.

SSE now allow us to use round instruction to implement Math.floor.
MacroAssembler's floorDouble is now only used in ARM64, but it can be allowed in x86 SSE.

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

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@198513 268f45cc-cd09-0410-ab3c-d52691b4dbfc

Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/jit/ThunkGenerators.cpp

index a7d6ccb..e78dad8 100644 (file)
@@ -1,3 +1,16 @@
+2016-03-21  Yusuke Suzuki  <utatane.tea@gmail.com>
+
+        [JSC] Clean up Math.floor thunk and use SSE round instruction
+        https://bugs.webkit.org/show_bug.cgi?id=155705
+
+        Reviewed by Geoffrey Garen.
+
+        SSE now allow us to use round instruction to implement Math.floor.
+        MacroAssembler's floorDouble is now only used in ARM64, but it can be allowed in x86 SSE.
+
+        * jit/ThunkGenerators.cpp:
+        (JSC::floorThunkGenerator):
+
 2016-03-21  Konstantin Tokarev  <annulen@yandex.ru>
 
         Fixed compilation with GCC 4.8.
index 4a71dfe..25d0014 100644 (file)
@@ -786,14 +786,17 @@ MacroAssemblerCodeRef floorThunkGenerator(VM* vm)
     jit.returnInt32(SpecializedThunkJIT::regT0);
     nonIntJump.link(&jit);
     jit.loadDoubleArgument(0, SpecializedThunkJIT::fpRegT0, SpecializedThunkJIT::regT0);
-#if CPU(ARM64)
-    SpecializedThunkJIT::JumpList doubleResult;
-    jit.floorDouble(SpecializedThunkJIT::fpRegT0, SpecializedThunkJIT::fpRegT0);
-    jit.branchConvertDoubleToInt32(SpecializedThunkJIT::fpRegT0, SpecializedThunkJIT::regT0, doubleResult, SpecializedThunkJIT::fpRegT1);
-    jit.returnInt32(SpecializedThunkJIT::regT0);
-    doubleResult.link(&jit);
-    jit.returnDouble(SpecializedThunkJIT::fpRegT0);
-#else
+
+    if (jit.supportsFloatingPointRounding()) {
+        SpecializedThunkJIT::JumpList doubleResult;
+        jit.floorDouble(SpecializedThunkJIT::fpRegT0, SpecializedThunkJIT::fpRegT0);
+        jit.branchConvertDoubleToInt32(SpecializedThunkJIT::fpRegT0, SpecializedThunkJIT::regT0, doubleResult, SpecializedThunkJIT::fpRegT1);
+        jit.returnInt32(SpecializedThunkJIT::regT0);
+        doubleResult.link(&jit);
+        jit.returnDouble(SpecializedThunkJIT::fpRegT0);
+        return jit.finalize(vm->jitStubs->ctiNativeTailCall(vm), "floor");
+    }
+
     SpecializedThunkJIT::Jump intResult;
     SpecializedThunkJIT::JumpList doubleResult;
     if (jit.supportsFloatingPointTruncate()) {
@@ -813,7 +816,6 @@ MacroAssemblerCodeRef floorThunkGenerator(VM* vm)
     jit.returnInt32(SpecializedThunkJIT::regT0);
     doubleResult.link(&jit);
     jit.returnDouble(SpecializedThunkJIT::fpRegT0);
-#endif // CPU(ARM64)
     return jit.finalize(vm->jitStubs->ctiNativeTailCall(vm), "floor");
 }