Changeset 199865 in webkit


Ignore:
Timestamp:
Apr 21, 2016 9:29:02 PM (8 years ago)
Author:
benjamin@webkit.org
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):

Location:
trunk/Source/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r199864 r199865  
     12016-04-21  Benjamin Poulain  <benjamin@webkit.org>
     2
     3        [JSC] Improve the absThunkGenerator() for 64bit
     4        https://bugs.webkit.org/show_bug.cgi?id=156888
     5
     6        Reviewed by Michael Saboff.
     7
     8        A few tests spend a lot of time in this abs() with double argument.
     9
     10        This patch adds custom handling for the JSValue64 representation.
     11        In particular:
     12        -Do not load the value twice. Unbox the GPR if it is not an Int32.
     13        -Deal with IntMin inline instead of falling back to the C function call.
     14        -Box the values ourself to avoid a duplicate function tail and return.
     15
     16        * jit/ThunkGenerators.cpp:
     17        (JSC::absThunkGenerator):
     18
    1192016-04-21  Saam barati  <sbarati@apple.com>
    220
  • trunk/Source/JavaScriptCore/jit/ThunkGenerators.cpp

    r199861 r199865  
    929929    if (!jit.supportsFloatingPointAbs())
    930930        return MacroAssemblerCodeRef::createSelfManagedCodeRef(vm->jitStubs->ctiNativeCall(vm));
     931
     932#if USE(JSVALUE64)
     933    unsigned virtualRegisterIndex = CallFrame::argumentOffset(0);
     934    jit.load64(AssemblyHelpers::addressFor(virtualRegisterIndex), GPRInfo::regT0);
     935    MacroAssembler::Jump notInteger = jit.branch64(MacroAssembler::Below, GPRInfo::regT0, GPRInfo::tagTypeNumberRegister);
     936
     937    // Abs Int32.
     938    jit.rshift32(GPRInfo::regT0, MacroAssembler::TrustedImm32(31), GPRInfo::regT1);
     939    jit.add32(GPRInfo::regT1, GPRInfo::regT0);
     940    jit.xor32(GPRInfo::regT1, GPRInfo::regT0);
     941
     942    // IntMin cannot be inverted.
     943    MacroAssembler::Jump integerIsIntMin = jit.branchTest32(MacroAssembler::Signed, GPRInfo::regT0);
     944
     945    // Box and finish.
     946    jit.or64(GPRInfo::tagTypeNumberRegister, GPRInfo::regT0);
     947    MacroAssembler::Jump doneWithIntegers = jit.jump();
     948
     949    // Handle Doubles.
     950    notInteger.link(&jit);
     951    jit.appendFailure(jit.branchTest64(MacroAssembler::Zero, GPRInfo::regT0, GPRInfo::tagTypeNumberRegister));
     952    jit.unboxDoubleWithoutAssertions(GPRInfo::regT0, GPRInfo::regT0, FPRInfo::fpRegT0);
     953    MacroAssembler::Label absFPR0Label = jit.label();
     954    jit.absDouble(FPRInfo::fpRegT0, FPRInfo::fpRegT1);
     955    jit.boxDouble(FPRInfo::fpRegT1, GPRInfo::regT0);
     956
     957    // Tail.
     958    doneWithIntegers.link(&jit);
     959    jit.returnJSValue(GPRInfo::regT0);
     960
     961    // We know the value of regT0 is IntMin. We could load that value from memory but
     962    // it is simpler to just convert it.
     963    integerIsIntMin.link(&jit);
     964    jit.convertInt32ToDouble(GPRInfo::regT0, FPRInfo::fpRegT0);
     965    jit.jump().linkTo(absFPR0Label, &jit);
     966#else
    931967    MacroAssembler::Jump nonIntJump;
    932968    jit.loadInt32Argument(0, SpecializedThunkJIT::regT0, nonIntJump);
     
    941977    jit.absDouble(SpecializedThunkJIT::fpRegT0, SpecializedThunkJIT::fpRegT1);
    942978    jit.returnDouble(SpecializedThunkJIT::fpRegT1);
     979#endif
    943980    return jit.finalize(vm->jitStubs->ctiNativeTailCall(vm), "abs");
    944981}
Note: See TracChangeset for help on using the changeset viewer.