Ignore:
Timestamp:
Oct 30, 2018, 11:14:04 PM (7 years ago)
Author:
[email protected]
Message:

[JSC][LLInt] Compact LLInt ASM code by removing unnecessary instructions
https://bugs.webkit.org/show_bug.cgi?id=191092

Reviewed by Saam Barati.

Looking through LLIntAssembly.h, we can find several inefficiencies. This patch fixes the
following things to tighten LLInt ASM code.

  1. Remove unnecessary load instructions. Use jmp with BaseIndex directly.
  2. Introduce strength reduction for mul instructions in offlineasm layer. This is now critical

since mul instruction is executed in metadata operation in LLInt. If the given immediate is
a power of two, we convert it to lshift instruction.

  • llint/LowLevelInterpreter32_64.asm:
  • llint/LowLevelInterpreter64.asm:
  • offlineasm/arm64.rb:
  • offlineasm/instructions.rb:
  • offlineasm/x86.rb:
File:
1 edited

Legend:

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

    r237547 r237627  
    799799        if operands.size == 3 and operands[0].is_a? Immediate
    800800            $asm.puts "imul#{x86Suffix(kind)} #{x86Operands(kind, kind, kind)}"
    801         else
    802             # FIXME: could do some peephole in case the left operand is immediate and it's
    803             # a power of two.
    804             handleX86Op("imul#{x86Suffix(kind)}", kind)
    805         end
     801            return
     802        end
     803
     804        if operands.size == 2 and operands[0].is_a? Immediate
     805            imm = operands[0].value
     806            if imm > 0 and isPowerOfTwo(imm)
     807                $asm.puts "sal#{x86Suffix(kind)} #{orderOperands(Immediate.new(nil, Math.log2(imm).to_i).x86Operand(kind), operands[1].x86Operand(kind))}"
     808                return
     809            end
     810        end
     811
     812        handleX86Op("imul#{x86Suffix(kind)}", kind)
    806813    end
    807814   
Note: See TracChangeset for help on using the changeset viewer.