Changeset 149082 in webkit for trunk/Source/JavaScriptCore/jit


Ignore:
Timestamp:
Apr 24, 2013, 6:26:35 PM (12 years ago)
Author:
[email protected]
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):

Location:
trunk/Source/JavaScriptCore/jit
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/jit/SpecializedThunkJIT.h

    r148696 r149082  
    146146            m_calls.append(std::make_pair(call(), function));
    147147        }
     148       
     149        void callDoubleToDoublePreservingReturn(FunctionPtr function)
     150        {
     151            if (!isX86())
     152                preserveReturnAddressAfterCall(regT3);
     153            callDoubleToDouble(function);
     154            if (!isX86())
     155                restoreReturnAddressBeforeReturn(regT3);
     156        }
    148157
    149158    private:
  • trunk/Source/JavaScriptCore/jit/ThunkGenerators.cpp

    r148696 r149082  
    508508
    509509}
    510    
     510
    511511#if CPU(X86_64) && COMPILER(GCC) && (PLATFORM(MAC) || OS(LINUX))
    512512
     
    545545    static MathThunk UnaryDoubleOpWrapper(function) = &function##Thunk;
    546546
     547#elif CPU(ARM_THUMB2) && COMPILER(GCC) && PLATFORM(IOS)
     548
     549#define defineUnaryDoubleOpWrapper(function) \
     550    asm( \
     551        ".text\n" \
     552        ".align 2\n" \
     553        ".globl " SYMBOL_STRING(function##Thunk) "\n" \
     554        HIDE_SYMBOL(function##Thunk) "\n" \
     555        ".thumb\n" \
     556        ".thumb_func " THUMB_FUNC_PARAM(function##Thunk) "\n" \
     557        SYMBOL_STRING(function##Thunk) ":" "\n" \
     558        "sub sp, sp, #16\n" \
     559        "str lr, [sp, #0]\n" \
     560        "vmov r0, r1, d0\n" \
     561        "blx " GLOBAL_REFERENCE(function) "\n" \
     562        "vmov d0, r0, r1\n" \
     563        "ldr lr, [sp, #0]\n" \
     564        "add sp, sp, #16\n" \
     565        "bx lr\n" \
     566    ); \
     567    extern "C" { \
     568        MathThunkCallingConvention function##Thunk(MathThunkCallingConvention); \
     569    } \
     570    static MathThunk UnaryDoubleOpWrapper(function) = &function##Thunk;
    547571#else
    548572
     
    584608        slowPath.link(&jit);
    585609    }
    586     jit.callDoubleToDouble(UnaryDoubleOpWrapper(floor));
     610    jit.callDoubleToDoublePreservingReturn(UnaryDoubleOpWrapper(floor));
    587611    jit.branchConvertDoubleToInt32(SpecializedThunkJIT::fpRegT0, SpecializedThunkJIT::regT0, doubleResult, SpecializedThunkJIT::fpRegT1);
    588612    if (jit.supportsFloatingPointTruncate())
     
    604628    nonIntJump.link(&jit);
    605629    jit.loadDoubleArgument(0, SpecializedThunkJIT::fpRegT0, SpecializedThunkJIT::regT0);
    606     jit.callDoubleToDouble(UnaryDoubleOpWrapper(ceil));
     630    jit.callDoubleToDoublePreservingReturn(UnaryDoubleOpWrapper(ceil));
    607631    SpecializedThunkJIT::JumpList doubleResult;
    608632    jit.branchConvertDoubleToInt32(SpecializedThunkJIT::fpRegT0, SpecializedThunkJIT::regT0, doubleResult, SpecializedThunkJIT::fpRegT1);
     
    637661        slowPath.link(&jit);
    638662    }
    639     jit.callDoubleToDouble(UnaryDoubleOpWrapper(jsRound));
     663    jit.callDoubleToDoublePreservingReturn(UnaryDoubleOpWrapper(jsRound));
    640664    jit.branchConvertDoubleToInt32(SpecializedThunkJIT::fpRegT0, SpecializedThunkJIT::regT0, doubleResult, SpecializedThunkJIT::fpRegT1);
    641665    if (jit.supportsFloatingPointTruncate())
     
    655679        return MacroAssemblerCodeRef::createSelfManagedCodeRef(vm->jitStubs->ctiNativeCall(vm));
    656680    jit.loadDoubleArgument(0, SpecializedThunkJIT::fpRegT0, SpecializedThunkJIT::regT0);
    657     jit.callDoubleToDouble(UnaryDoubleOpWrapper(exp));
     681    jit.callDoubleToDoublePreservingReturn(UnaryDoubleOpWrapper(exp));
    658682    jit.returnDouble(SpecializedThunkJIT::fpRegT0);
    659683    return jit.finalize(*vm, vm->jitStubs->ctiNativeCall(vm), "exp");
     
    668692        return MacroAssemblerCodeRef::createSelfManagedCodeRef(vm->jitStubs->ctiNativeCall(vm));
    669693    jit.loadDoubleArgument(0, SpecializedThunkJIT::fpRegT0, SpecializedThunkJIT::regT0);
    670     jit.callDoubleToDouble(UnaryDoubleOpWrapper(log));
     694    jit.callDoubleToDoublePreservingReturn(UnaryDoubleOpWrapper(log));
    671695    jit.returnDouble(SpecializedThunkJIT::fpRegT0);
    672696    return jit.finalize(*vm, vm->jitStubs->ctiNativeCall(vm), "log");
Note: See TracChangeset for help on using the changeset viewer.