Ignore:
Timestamp:
Jun 28, 2021, 10:55:12 AM (4 years ago)
Author:
[email protected]
Message:

Add LLInt fast path for less, lesseq, greater and greatereq
https://bugs.webkit.org/show_bug.cgi?id=226266

Patch by Mikhail R. Gadelha <Mikhail R. Gadelha> on 2021-06-28
Reviewed by Tadeu Zagallo.

The motivation is to add fast path for integers and doubles
in LLInt, so we don't need to go to slow path for those cases.

This patch implements the less, lesseq, greater, greatereq
instruction for ARMv7, MIPS and CLoop.

Microbenchmarking results:

  • x86_64: number-comparison-inline definitely 1.3520x faster
  • ARMv7: number-comparison-inline definitely 1.3520x faster

JetStream2 results:

  • x86_64 jit: 1.015 times better
  • x86_64 no-jit: 1.018 times better
  • ARMv7 no-jit: 1.004 times worse
  • llint/LowLevelInterpreter.asm:
  • llint/LowLevelInterpreter32_64.asm:
  • llint/LowLevelInterpreter64.asm:
  • offlineasm/arm.rb:
  • offlineasm/cloop.rb:
  • offlineasm/mips.rb:
Location:
trunk/Source/JavaScriptCore/offlineasm
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/offlineasm/arm.rb

    r267371 r279343  
    373373        $asm.puts "tst #{value.armOperand}, #{mask.armOperand}"
    374374    end
     375end
     376
     377def emitArmDoubleCompare(operands, code)
     378    $asm.puts "mov #{operands[2].armOperand}, \#0"
     379    $asm.puts "vcmpe.f64 #{armOperands(operands[0..1])}"
     380    $asm.puts "vmrs APSR_nzcv, FPSCR"
     381    $asm.puts "it #{code}"
     382    $asm.puts "mov#{code} #{operands[2].armOperand}, \#1"
    375383end
    376384
     
    642650        when "cilteq", "cplteq", "cblteq"
    643651            emitArmCompare(operands, "le")
     652        when "cdgt"
     653            emitArmDoubleCompare(operands, "gt")
     654        when "cdgteq"
     655            emitArmDoubleCompare(operands, "ge")
     656        when "cdlt"
     657            emitArmDoubleCompare(operands, "mi")
     658        when "cdlteq"
     659            emitArmDoubleCompare(operands, "ls")
    644660        when "tis", "tbs", "tps"
    645661            emitArmTestSet(operands, "mi")
  • trunk/Source/JavaScriptCore/offlineasm/cloop.rb

    r270265 r279343  
    959959        when "cpgt"
    960960            cloopEmitCompareAndSet(operands, :intptr, ">")
     961        when "cdgt"
     962            cloopEmitCompareAndSet(operands, :double, ">")
    961963
    962964        when "cbgteq"
     
    968970        when "cpgteq"
    969971            cloopEmitCompareAndSet(operands, :intptr, ">=")
     972        when "cdgteq"
     973            cloopEmitCompareAndSet(operands, :double, ">=")
    970974
    971975        when "cblt"
     
    977981        when "cplt"
    978982            cloopEmitCompareAndSet(operands, :intptr, "<")
     983        when "cdlt"
     984            cloopEmitCompareAndSet(operands, :double, "<")
    979985
    980986        when "cblteq"
     
    986992        when "cplteq"
    987993            cloopEmitCompareAndSet(operands, :intptr, "<=")
     994        when "cdlteq"
     995            cloopEmitCompareAndSet(operands, :double, "<=")
    988996
    989997        when "tbs"
  • trunk/Source/JavaScriptCore/offlineasm/mips.rb

    r269349 r279343  
    805805        raise unless operands.size == 2
    806806        $asm.puts "#{opcode} #{operands[1].mipsOperand}, #{operands[1].mipsOperand}, #{operands[0].mipsOperand}"
     807    end
     808end
     809
     810def emitMIPSDoubleCompare(branchOpcode, neg, operands)
     811    mipsMoveImmediate(1, operands[2])
     812    $asm.puts "c.#{branchOpcode}.d $fcc0, #{mipsOperands(operands[0..1])}"
     813    if (!neg)
     814        $asm.puts "movf #{operands[2].mipsOperand}, $zero, $fcc0"
     815    else
     816        $asm.puts "movt #{operands[2].mipsOperand}, $zero, $fcc0"
    807817    end
    808818end
     
    10121022            $asm.puts "slt #{operands[2].mipsOperand}, #{operands[1].mipsOperand}, #{operands[0].mipsOperand}"
    10131023            $asm.puts "xori #{operands[2].mipsOperand}, 1"
     1024        when "cdgt"
     1025            emitMIPSDoubleCompare("ule", true, operands)
     1026        when "cdgteq"
     1027            emitMIPSDoubleCompare("ult", true, operands)
     1028        when "cdlt"
     1029            emitMIPSDoubleCompare("olt", false, operands)
     1030        when "cdlteq"
     1031            emitMIPSDoubleCompare("ole", false, operands)
    10141032        when "peek"
    10151033            $asm.puts "lw #{operands[1].mipsOperand}, #{operands[0].value * 4}($sp)"
Note: See TracChangeset for help on using the changeset viewer.