2010-08-18 Andreas Kling <andreas.kling@nokia.com>
authorandreas.kling@nokia.com <andreas.kling@nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Aug 2010 05:56:30 +0000 (05:56 +0000)
committerandreas.kling@nokia.com <andreas.kling@nokia.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 19 Aug 2010 05:56:30 +0000 (05:56 +0000)
        Reviewed by Geoffrey Garen.

        REGRESSION(r58469): Math.pow() always returns double-backed JSValue which is extremely slow as array subscript
        https://bugs.webkit.org/show_bug.cgi?id=43742

        Add codegen for pow() to return Int32 values when possible.

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

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

JavaScriptCore/ChangeLog
JavaScriptCore/jit/ThunkGenerators.cpp

index 1c7f689..a704d2f 100644 (file)
@@ -1,3 +1,15 @@
+2010-08-18  Andreas Kling  <andreas.kling@nokia.com>
+
+        Reviewed by Geoffrey Garen.
+
+        REGRESSION(r58469): Math.pow() always returns double-backed JSValue which is extremely slow as array subscript
+        https://bugs.webkit.org/show_bug.cgi?id=43742
+
+        Add codegen for pow() to return Int32 values when possible.
+
+        * jit/ThunkGenerators.cpp:
+        (JSC::powThunkGenerator):
+
 2010-08-18  Gabor Loki  <loki@webkit.org>
 
         Reviewed by Gavin Barraclough.
 2010-08-18  Gabor Loki  <loki@webkit.org>
 
         Reviewed by Gavin Barraclough.
index 20857cb..4c7a354 100644 (file)
@@ -134,7 +134,14 @@ MacroAssemblerCodePtr powThunkGenerator(JSGlobalData* globalData, ExecutablePool
     jit.branchTest32(MacroAssembler::NonZero, SpecializedThunkJIT::regT0).linkTo(startLoop, &jit);
 
     exponentIsZero.link(&jit);
     jit.branchTest32(MacroAssembler::NonZero, SpecializedThunkJIT::regT0).linkTo(startLoop, &jit);
 
     exponentIsZero.link(&jit);
-    jit.returnDouble(SpecializedThunkJIT::fpRegT1);
+
+    {
+        SpecializedThunkJIT::JumpList doubleResult;
+        jit.branchConvertDoubleToInt32(SpecializedThunkJIT::fpRegT1, SpecializedThunkJIT::regT0, doubleResult, SpecializedThunkJIT::fpRegT0);
+        jit.returnInt32(SpecializedThunkJIT::regT0);
+        doubleResult.link(&jit);
+        jit.returnDouble(SpecializedThunkJIT::fpRegT1);
+    }
 
     if (jit.supportsFloatingPointSqrt()) {
         nonIntExponent.link(&jit);
 
     if (jit.supportsFloatingPointSqrt()) {
         nonIntExponent.link(&jit);
@@ -144,6 +151,11 @@ MacroAssemblerCodePtr powThunkGenerator(JSGlobalData* globalData, ExecutablePool
         jit.appendFailure(jit.branchDouble(MacroAssembler::DoubleNotEqualOrUnordered, SpecializedThunkJIT::fpRegT2, SpecializedThunkJIT::fpRegT3));
         jit.sqrtDouble(SpecializedThunkJIT::fpRegT0, SpecializedThunkJIT::fpRegT0);
         jit.divDouble(SpecializedThunkJIT::fpRegT0, SpecializedThunkJIT::fpRegT1);
         jit.appendFailure(jit.branchDouble(MacroAssembler::DoubleNotEqualOrUnordered, SpecializedThunkJIT::fpRegT2, SpecializedThunkJIT::fpRegT3));
         jit.sqrtDouble(SpecializedThunkJIT::fpRegT0, SpecializedThunkJIT::fpRegT0);
         jit.divDouble(SpecializedThunkJIT::fpRegT0, SpecializedThunkJIT::fpRegT1);
+
+        SpecializedThunkJIT::JumpList doubleResult;
+        jit.branchConvertDoubleToInt32(SpecializedThunkJIT::fpRegT1, SpecializedThunkJIT::regT0, doubleResult, SpecializedThunkJIT::fpRegT0);
+        jit.returnInt32(SpecializedThunkJIT::regT0);
+        doubleResult.link(&jit);
         jit.returnDouble(SpecializedThunkJIT::fpRegT1);
     } else
         jit.appendFailure(nonIntExponent);
         jit.returnDouble(SpecializedThunkJIT::fpRegT1);
     } else
         jit.appendFailure(nonIntExponent);