Title: [149082] trunk/Source/_javascript_Core
Revision
149082
Author
[email protected]
Date
2013-04-24 18:26:35 -0700 (Wed, 24 Apr 2013)

Log Message

Special thunks for math functions should work on ARMv7
https://bugs.webkit.org/show_bug.cgi?id=115144

Reviewed by Gavin Barraclough and Oliver Hunt.
        
The only hard bit here was ensuring that we implemented the very special
"cheap C call" convention on ARMv7.

* assembler/AbstractMacroAssembler.h:
(JSC::isARMv7s):
(JSC):
(JSC::isX86):
* dfg/DFGCommon.h:
* jit/SpecializedThunkJIT.h:
(SpecializedThunkJIT):
(JSC::SpecializedThunkJIT::callDoubleToDoublePreservingReturn):
* jit/ThunkGenerators.cpp:
(JSC::floorThunkGenerator):
(JSC::ceilThunkGenerator):
(JSC::roundThunkGenerator):
(JSC::expThunkGenerator):
(JSC::logThunkGenerator):

Modified Paths

Diff

Modified: trunk/Source/_javascript_Core/ChangeLog (149081 => 149082)


--- trunk/Source/_javascript_Core/ChangeLog	2013-04-25 00:51:29 UTC (rev 149081)
+++ trunk/Source/_javascript_Core/ChangeLog	2013-04-25 01:26:35 UTC (rev 149082)
@@ -1,3 +1,28 @@
+2013-04-24  Filip Pizlo  <[email protected]>
+
+        Special thunks for math functions should work on ARMv7
+        https://bugs.webkit.org/show_bug.cgi?id=115144
+
+        Reviewed by Gavin Barraclough and Oliver Hunt.
+        
+        The only hard bit here was ensuring that we implemented the very special
+        "cheap C call" convention on ARMv7.
+
+        * assembler/AbstractMacroAssembler.h:
+        (JSC::isARMv7s):
+        (JSC):
+        (JSC::isX86):
+        * dfg/DFGCommon.h:
+        * jit/SpecializedThunkJIT.h:
+        (SpecializedThunkJIT):
+        (JSC::SpecializedThunkJIT::callDoubleToDoublePreservingReturn):
+        * jit/ThunkGenerators.cpp:
+        (JSC::floorThunkGenerator):
+        (JSC::ceilThunkGenerator):
+        (JSC::roundThunkGenerator):
+        (JSC::expThunkGenerator):
+        (JSC::logThunkGenerator):
+
 2013-04-24  Julien Brianceau  <[email protected]>
 
         Misc bugfix and cleaning in sh4 base JIT.

Modified: trunk/Source/_javascript_Core/assembler/AbstractMacroAssembler.h (149081 => 149082)


--- trunk/Source/_javascript_Core/assembler/AbstractMacroAssembler.h	2013-04-25 00:51:29 UTC (rev 149081)
+++ trunk/Source/_javascript_Core/assembler/AbstractMacroAssembler.h	2013-04-25 01:26:35 UTC (rev 149082)
@@ -46,6 +46,24 @@
 
 namespace JSC {
 
+inline bool isARMv7s()
+{
+#if CPU(APPLE_ARMV7S)
+    return true;
+#else
+    return false;
+#endif
+}
+
+inline bool isX86()
+{
+#if CPU(X86_64) || CPU(X86)
+    return true;
+#else
+    return false;
+#endif
+}
+
 class JumpReplacementWatchpoint;
 class LinkBuffer;
 class RepatchBuffer;

Modified: trunk/Source/_javascript_Core/dfg/DFGCommon.h (149081 => 149082)


--- trunk/Source/_javascript_Core/dfg/DFGCommon.h	2013-04-25 00:51:29 UTC (rev 149081)
+++ trunk/Source/_javascript_Core/dfg/DFGCommon.h	2013-04-25 01:26:35 UTC (rev 149082)
@@ -100,24 +100,6 @@
     DontRefNode
 };
 
-inline bool isARMv7s()
-{
-#if CPU(APPLE_ARMV7S)
-    return true;
-#else
-    return false;
-#endif
-}
-
-inline bool isX86()
-{
-#if CPU(X86_64) || CPU(X86)
-    return true;
-#else
-    return false;
-#endif
-}
-
 inline bool verboseCompilationEnabled()
 {
 #if DFG_ENABLE(DEBUG_VERBOSE)

Modified: trunk/Source/_javascript_Core/jit/SpecializedThunkJIT.h (149081 => 149082)


--- trunk/Source/_javascript_Core/jit/SpecializedThunkJIT.h	2013-04-25 00:51:29 UTC (rev 149081)
+++ trunk/Source/_javascript_Core/jit/SpecializedThunkJIT.h	2013-04-25 01:26:35 UTC (rev 149082)
@@ -145,6 +145,15 @@
         {
             m_calls.append(std::make_pair(call(), function));
         }
+        
+        void callDoubleToDoublePreservingReturn(FunctionPtr function)
+        {
+            if (!isX86())
+                preserveReturnAddressAfterCall(regT3);
+            callDoubleToDouble(function);
+            if (!isX86())
+                restoreReturnAddressBeforeReturn(regT3);
+        }
 
     private:
 

Modified: trunk/Source/_javascript_Core/jit/ThunkGenerators.cpp (149081 => 149082)


--- trunk/Source/_javascript_Core/jit/ThunkGenerators.cpp	2013-04-25 00:51:29 UTC (rev 149081)
+++ trunk/Source/_javascript_Core/jit/ThunkGenerators.cpp	2013-04-25 01:26:35 UTC (rev 149082)
@@ -507,7 +507,7 @@
 }
 
 }
-    
+
 #if CPU(X86_64) && COMPILER(GCC) && (PLATFORM(MAC) || OS(LINUX))
 
 #define defineUnaryDoubleOpWrapper(function) \
@@ -544,6 +544,30 @@
     } \
     static MathThunk UnaryDoubleOpWrapper(function) = &function##Thunk;
 
+#elif CPU(ARM_THUMB2) && COMPILER(GCC) && PLATFORM(IOS)
+
+#define defineUnaryDoubleOpWrapper(function) \
+    asm( \
+        ".text\n" \
+        ".align 2\n" \
+        ".globl " SYMBOL_STRING(function##Thunk) "\n" \
+        HIDE_SYMBOL(function##Thunk) "\n" \
+        ".thumb\n" \
+        ".thumb_func " THUMB_FUNC_PARAM(function##Thunk) "\n" \
+        SYMBOL_STRING(function##Thunk) ":" "\n" \
+        "sub sp, sp, #16\n" \
+        "str lr, [sp, #0]\n" \
+        "vmov r0, r1, d0\n" \
+        "blx " GLOBAL_REFERENCE(function) "\n" \
+        "vmov d0, r0, r1\n" \
+        "ldr lr, [sp, #0]\n" \
+        "add sp, sp, #16\n" \
+        "bx lr\n" \
+    ); \
+    extern "C" { \
+        MathThunkCallingConvention function##Thunk(MathThunkCallingConvention); \
+    } \
+    static MathThunk UnaryDoubleOpWrapper(function) = &function##Thunk;
 #else
 
 #define defineUnaryDoubleOpWrapper(function) \
@@ -583,7 +607,7 @@
         intResult = jit.jump();
         slowPath.link(&jit);
     }
-    jit.callDoubleToDouble(UnaryDoubleOpWrapper(floor));
+    jit.callDoubleToDoublePreservingReturn(UnaryDoubleOpWrapper(floor));
     jit.branchConvertDoubleToInt32(SpecializedThunkJIT::fpRegT0, SpecializedThunkJIT::regT0, doubleResult, SpecializedThunkJIT::fpRegT1);
     if (jit.supportsFloatingPointTruncate())
         intResult.link(&jit);
@@ -603,7 +627,7 @@
     jit.returnInt32(SpecializedThunkJIT::regT0);
     nonIntJump.link(&jit);
     jit.loadDoubleArgument(0, SpecializedThunkJIT::fpRegT0, SpecializedThunkJIT::regT0);
-    jit.callDoubleToDouble(UnaryDoubleOpWrapper(ceil));
+    jit.callDoubleToDoublePreservingReturn(UnaryDoubleOpWrapper(ceil));
     SpecializedThunkJIT::JumpList doubleResult;
     jit.branchConvertDoubleToInt32(SpecializedThunkJIT::fpRegT0, SpecializedThunkJIT::regT0, doubleResult, SpecializedThunkJIT::fpRegT1);
     jit.returnInt32(SpecializedThunkJIT::regT0);
@@ -636,7 +660,7 @@
         intResult = jit.jump();
         slowPath.link(&jit);
     }
-    jit.callDoubleToDouble(UnaryDoubleOpWrapper(jsRound));
+    jit.callDoubleToDoublePreservingReturn(UnaryDoubleOpWrapper(jsRound));
     jit.branchConvertDoubleToInt32(SpecializedThunkJIT::fpRegT0, SpecializedThunkJIT::regT0, doubleResult, SpecializedThunkJIT::fpRegT1);
     if (jit.supportsFloatingPointTruncate())
         intResult.link(&jit);
@@ -654,7 +678,7 @@
     if (!jit.supportsFloatingPoint())
         return MacroAssemblerCodeRef::createSelfManagedCodeRef(vm->jitStubs->ctiNativeCall(vm));
     jit.loadDoubleArgument(0, SpecializedThunkJIT::fpRegT0, SpecializedThunkJIT::regT0);
-    jit.callDoubleToDouble(UnaryDoubleOpWrapper(exp));
+    jit.callDoubleToDoublePreservingReturn(UnaryDoubleOpWrapper(exp));
     jit.returnDouble(SpecializedThunkJIT::fpRegT0);
     return jit.finalize(*vm, vm->jitStubs->ctiNativeCall(vm), "exp");
 }
@@ -667,7 +691,7 @@
     if (!jit.supportsFloatingPoint())
         return MacroAssemblerCodeRef::createSelfManagedCodeRef(vm->jitStubs->ctiNativeCall(vm));
     jit.loadDoubleArgument(0, SpecializedThunkJIT::fpRegT0, SpecializedThunkJIT::regT0);
-    jit.callDoubleToDouble(UnaryDoubleOpWrapper(log));
+    jit.callDoubleToDoublePreservingReturn(UnaryDoubleOpWrapper(log));
     jit.returnDouble(SpecializedThunkJIT::fpRegT0);
     return jit.finalize(*vm, vm->jitStubs->ctiNativeCall(vm), "log");
 }
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to