Ignore:
Timestamp:
Aug 11, 2014, 8:20:04 PM (11 years ago)
Author:
[email protected]
Message:

Eliminate {push,pop}CalleeSaves in favor of individual pushes & pops
https://bugs.webkit.org/show_bug.cgi?id=127155

Reviewed by Geoffrey Garen.

Eliminated the offline assembler instructions {push,pop}CalleeSaves as well as the
ARM64 specific {push,pop}LRAndFP and replaced them with individual push and pop
instructions. Where the registers referenced by the added push and pop instructions
are not part of the offline assembler register aliases, used a newly added "emit"
offline assembler instruction which takes a string literal and outputs that
string as a native instruction.

  • llint/LowLevelInterpreter.asm:
  • offlineasm/arm.rb:
  • offlineasm/arm64.rb:
  • offlineasm/ast.rb:
  • offlineasm/cloop.rb:
  • offlineasm/instructions.rb:
  • offlineasm/mips.rb:
  • offlineasm/parser.rb:
  • offlineasm/sh4.rb:
  • offlineasm/transform.rb:
  • offlineasm/x86.rb:
Location:
trunk/Source/JavaScriptCore/offlineasm
Files:
10 edited

Legend:

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

    r167566 r172429  
    467467                $asm.puts "push { #{op.armOperand} }"
    468468            }
    469         when "popCalleeSaves"
    470             if isARMv7
    471                 $asm.puts "pop {r4-r6, r8-r11}"               
    472             else
    473                 $asm.puts "pop {r4-r10}"
    474             end
    475         when "pushCalleeSaves"
    476             if isARMv7
    477                 $asm.puts "push {r4-r6, r8-r11}"
    478             else
    479                 $asm.puts "push {r4-r10}"
    480             end
    481469        when "move"
    482470            if operands[0].immediate?
  • trunk/Source/JavaScriptCore/offlineasm/arm64.rb

    r167094 r172429  
    587587                $asm.puts "stp #{ops[0].arm64Operand(:ptr)}, #{ops[1].arm64Operand(:ptr)}, [sp, #-16]!"
    588588            }
    589         when "popLRAndFP"
    590             $asm.puts "ldp x29, x30, [sp], #16"
    591         when "pushLRAndFP"
    592             $asm.puts "stp x29, x30, [sp, #-16]!"
    593         when "popCalleeSaves"
    594             $asm.puts "ldp x28, x27, [sp], #16"
    595             $asm.puts "ldp x26, x25, [sp], #16"
    596             $asm.puts "ldp x24, x23, [sp], #16"
    597             $asm.puts "ldp x22, x21, [sp], #16"
    598             $asm.puts "ldp x20, x19, [sp], #16"
    599         when "pushCalleeSaves"
    600             $asm.puts "stp x20, x19, [sp, #-16]!"
    601             $asm.puts "stp x22, x21, [sp, #-16]!"
    602             $asm.puts "stp x24, x23, [sp, #-16]!"
    603             $asm.puts "stp x26, x25, [sp, #-16]!"
    604             $asm.puts "stp x28, x27, [sp, #-16]!"
    605589        when "move"
    606590            if operands[0].immediate?
  • trunk/Source/JavaScriptCore/offlineasm/ast.rb

    r167094 r172429  
    581581end
    582582
     583class StringLiteral < NoChildren
     584    attr_reader :value
     585   
     586    def initialize(codeOrigin, value)
     587        super(codeOrigin)
     588        @value = value[1..-2]
     589        raise "Bad string literal #{value.inspect} at #{codeOriginString}" unless value.is_a? String
     590    end
     591   
     592    def dump
     593        "#{value}"
     594    end
     595   
     596    def ==(other)
     597        other.is_a? StringLiteral and other.value == @value
     598    end
     599   
     600    def address?
     601        false
     602    end
     603   
     604    def label?
     605        false
     606    end
     607   
     608    def immediate?
     609        false
     610    end
     611   
     612    def immediateOperand?
     613        false
     614    end
     615       
     616    def register?
     617        false
     618    end
     619end
     620
    583621class RegisterID < NoChildren
    584622    attr_reader :name
     
    890928        when "globalAnnotation"
    891929            $asm.putGlobalAnnotation
     930        when "emit"
     931          $asm.puts "#{operands[0].dump}"
    892932        else
    893933            raise "Unhandled opcode #{opcode} at #{codeOriginString}"
  • trunk/Source/JavaScriptCore/offlineasm/cloop.rb

    r167094 r172429  
    11051105            }
    11061106
    1107         when "pushCalleeSaves"
    1108         when "popCalleeSaves"
    1109 
    11101107
    11111108        # A convenience and compact call to crash because we don't want to use
  • trunk/Source/JavaScriptCore/offlineasm/instructions.rb

    r167566 r172429  
    3131MACRO_INSTRUCTIONS =
    3232    [
     33     "emit",
    3334     "addi",
    3435     "andi",
     
    249250     "leai",
    250251     "leap",
    251      "pushCalleeSaves",
    252      "popCalleeSaves",
    253252     "memfence"
    254253    ]
     
    268267ARM64_INSTRUCTIONS =
    269268    [
    270      "pcrtoaddr",    # Address from PC relative offset - adr instruction
    271      "popLRAndFP",   # ARM64 requires registers to be pushed and popped in pairs,
    272      "pushLRAndFP"   # therefore we do LR (link register) and FP (frame pointer) together.
     269     "pcrtoaddr"    # Address from PC relative offset - adr instruction
    273270    ]
    274271
  • trunk/Source/JavaScriptCore/offlineasm/mips.rb

    r161377 r172429  
    851851                $asm.puts "sw #{op.mipsOperand}, 0($sp)"
    852852            }
    853         when "popCalleeSaves"
    854             $asm.puts "lw $16, 0($sp)"
    855             $asm.puts "lw $17, 4($sp)"
    856             $asm.puts "lw $18, 8($sp)"
    857             $asm.puts "lw $19, 12($sp)"
    858             $asm.puts "lw $20, 16($sp)"
    859             $asm.puts "addiu $sp, $sp, 20"
    860         when "pushCalleeSaves"
    861             $asm.puts "addiu $sp, $sp, -20"
    862             $asm.puts "sw $20, 16($sp)"
    863             $asm.puts "sw $19, 12($sp)"
    864             $asm.puts "sw $18, 8($sp)"
    865             $asm.puts "sw $17, 4($sp)"
    866             $asm.puts "sw $16, 0($sp)"
    867853        when "move", "sxi2p", "zxi2p"
    868854            if operands[0].is_a? Immediate
  • trunk/Source/JavaScriptCore/offlineasm/parser.rb

    r167094 r172429  
    166166        when /\A[:,\(\)\[\]=\+\-~\|&^*]/
    167167            result << Token.new(CodeOrigin.new(fileName, lineNumber), $&)
     168        when /\A".*"/
     169            result << Token.new(CodeOrigin.new(fileName, lineNumber), $&)
    168170        else
    169171            raise "Lexer error at #{CodeOrigin.new(fileName, lineNumber).to_s}, unexpected sequence #{str[0..20].inspect}"
     
    211213def isInteger(token)
    212214    token =~ /\A[0-9]/
     215end
     216
     217def isString(token)
     218    token =~ /\A".*"/
    213219end
    214220
     
    398404            @idx += 1
    399405            result
     406        elsif isString @tokens[@idx]
     407            result = StringLiteral.new(@tokens[@idx].codeOrigin, @tokens[@idx].string)
     408            @idx += 1
     409            result
    400410        elsif isIdentifier @tokens[@idx]
    401411            codeOrigin, names = parseColonColon
     
    439449   
    440450    def couldBeExpression
    441         @tokens[@idx] == "-" or @tokens[@idx] == "~" or @tokens[@idx] == "sizeof" or isInteger(@tokens[@idx]) or isVariable(@tokens[@idx]) or @tokens[@idx] == "("
     451        @tokens[@idx] == "-" or @tokens[@idx] == "~" or @tokens[@idx] == "sizeof" or isInteger(@tokens[@idx]) or isString(@tokens[@idx]) or isVariable(@tokens[@idx]) or @tokens[@idx] == "("
    442452    end
    443453   
  • trunk/Source/JavaScriptCore/offlineasm/sh4.rb

    r167269 r172429  
    10921092                $asm.puts "mov.l #{sh4Operands(operands)}, @-r15"
    10931093            end
    1094         when "popCalleeSaves"
    1095             $asm.puts "mov.l @r15+, r8"
    1096             $asm.puts "mov.l @r15+, r9"
    1097             $asm.puts "mov.l @r15+, r10"
    1098             $asm.puts "mov.l @r15+, r11"
    1099             $asm.puts "mov.l @r15+, r13"
    1100         when "pushCalleeSaves"
    1101             $asm.puts "mov.l r13, @-r15"
    1102             $asm.puts "mov.l r11, @-r15"
    1103             $asm.puts "mov.l r10, @-r15"
    1104             $asm.puts "mov.l r9, @-r15"
    1105             $asm.puts "mov.l r8, @-r15"
    11061094        when "break"
    11071095            # This special opcode always generates an illegal instruction exception.
  • trunk/Source/JavaScriptCore/offlineasm/transform.rb

    r167094 r172429  
    424424end
    425425
     426class StringLiteral
     427    def validate
     428    end
     429end
     430
    426431class RegisterID
    427432    def validate
  • trunk/Source/JavaScriptCore/offlineasm/x86.rb

    r170428 r172429  
    11471147                $asm.puts "push #{op.x86Operand(:ptr)}"
    11481148            }
    1149         when "popCalleeSaves"
    1150             if isX64
    1151                 if isMSVC
    1152                     $asm.puts "pop " + register("rsi")
    1153                     $asm.puts "pop " + register("rdi")
    1154                 end
    1155                 $asm.puts "pop " + register("rbx")
    1156                 $asm.puts "pop " + register("r15")
    1157                 $asm.puts "pop " + register("r14")
    1158                 $asm.puts "pop " + register("r13")
    1159                 $asm.puts "pop " + register("r12")
    1160             else
    1161                 $asm.puts "pop " + register("ebx")
    1162                 $asm.puts "pop " + register("edi")
    1163                 $asm.puts "pop " + register("esi")
    1164             end
    1165         when "pushCalleeSaves"
    1166             if isX64
    1167                 $asm.puts "push " + register("r12")
    1168                 $asm.puts "push " + register("r13")
    1169                 $asm.puts "push " + register("r14")
    1170                 $asm.puts "push " + register("r15")
    1171                 $asm.puts "push " + register("rbx")
    1172                 if isMSVC
    1173                     $asm.puts "push " + register("rdi")
    1174                     $asm.puts "push " + register("rsi")
    1175                 end
    1176             else
    1177                 $asm.puts "push " + register("esi")
    1178                 $asm.puts "push " + register("edi")
    1179                 $asm.puts "push " + register("ebx")
    1180             end
    11811149        when "move"
    11821150            handleMove
Note: See TracChangeset for help on using the changeset viewer.