Changeset 172429 in webkit


Ignore:
Timestamp:
Aug 11, 2014 8:20:04 PM (10 years ago)
Author:
msaboff@apple.com
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
Files:
12 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r172413 r172429  
     12014-08-11  Michael Saboff  <msaboff@apple.com>
     2
     3        Eliminate {push,pop}CalleeSaves in favor of individual pushes & pops
     4        https://bugs.webkit.org/show_bug.cgi?id=127155
     5
     6        Reviewed by Geoffrey Garen.
     7
     8        Eliminated the offline assembler instructions {push,pop}CalleeSaves as well as the
     9        ARM64 specific {push,pop}LRAndFP and replaced them with individual push and pop
     10        instructions. Where the registers referenced by the added push and pop instructions
     11        are not part of the offline assembler register aliases, used a newly added "emit"
     12        offline assembler instruction which takes a string literal and outputs that
     13        string as a native instruction.
     14
     15        * llint/LowLevelInterpreter.asm:
     16        * offlineasm/arm.rb:
     17        * offlineasm/arm64.rb:
     18        * offlineasm/ast.rb:
     19        * offlineasm/cloop.rb:
     20        * offlineasm/instructions.rb:
     21        * offlineasm/mips.rb:
     22        * offlineasm/parser.rb:
     23        * offlineasm/sh4.rb:
     24        * offlineasm/transform.rb:
     25        * offlineasm/x86.rb:
     26
    1272014-08-11  Mark Lam  <mark.lam@apple.com>
    228
  • trunk/Source/JavaScriptCore/llint/LowLevelInterpreter.asm

    r172176 r172429  
    247247end
    248248
     249macro pushCalleeSaves()
     250    if C_LOOP
     251    elsif ARM or ARMv7_TRADITIONAL
     252        emit "push {r4-r10}"
     253    elsif ARMv7
     254        emit "push {r4-r6, r8-r11}"
     255    elsif ARM64
     256        emit "stp x20, x19, [sp, #-16]!"
     257        emit "stp x22, x21, [sp, #-16]!"
     258        emit "stp x24, x23, [sp, #-16]!"
     259        emit "stp x26, x25, [sp, #-16]!"
     260        emit "stp x28, x27, [sp, #-16]!"
     261    elsif MIPS
     262        emit "addiu $sp, $sp, -20"
     263        emit "sw $20, 16($sp)"
     264        emit "sw $19, 12($sp)"
     265        emit "sw $18, 8($sp)"
     266        emit "sw $17, 4($sp)"
     267        emit "sw $16, 0($sp)"
     268    elsif SH4
     269        emit "mov.l r13, @-r15"
     270        emit "mov.l r11, @-r15"
     271        emit "mov.l r10, @-r15"
     272        emit "mov.l r9, @-r15"
     273        emit "mov.l r8, @-r15"
     274    elsif X86
     275        emit "push %esi"
     276        emit "push %edi"
     277        emit "push %ebx"
     278    elsif X86_WIN
     279        emit "push esi"
     280        emit "push edi"
     281        emit "push ebx"
     282    elsif X86_64
     283        emit "push %r12"
     284        emit "push %r13"
     285        emit "push %r14"
     286        emit "push %r15"
     287        emit "push %rbx"
     288    elsif X86_64_WIN
     289        emit "push r12"
     290        emit "push r13"
     291        emit "push r14"
     292        emit "push r15"
     293        emit "push rbx"
     294        emit "push rdi"
     295        emit "push rsi"
     296    end
     297end
     298
     299macro popCalleeSaves()
     300    if C_LOOP
     301    elsif ARM or ARMv7_TRADITIONAL
     302        emit "pop {r4-r10}"
     303    elsif ARMv7
     304        emit "pop {r4-r6, r8-r11}"
     305    elsif ARM64
     306        emit "ldp x28, x27, [sp], #16"
     307        emit "ldp x26, x25, [sp], #16"
     308        emit "ldp x24, x23, [sp], #16"
     309        emit "ldp x22, x21, [sp], #16"
     310        emit "ldp x20, x19, [sp], #16"
     311    elsif MIPS
     312        emit "lw $16, 0($sp)"
     313        emit "lw $17, 4($sp)"
     314        emit "lw $18, 8($sp)"
     315        emit "lw $19, 12($sp)"
     316        emit "lw $20, 16($sp)"
     317        emit "addiu $sp, $sp, 20"
     318    elsif SH4
     319        emit "mov.l @r15+, r8"
     320        emit "mov.l @r15+, r9"
     321        emit "mov.l @r15+, r10"
     322        emit "mov.l @r15+, r11"
     323        emit "mov.l @r15+, r13"
     324    elsif X86
     325        emit "pop %ebx"
     326        emit "pop %edi"
     327        emit "pop %esi"
     328    elsif X86_WIN
     329        emit "pop ebx"
     330        emit "pop edi"
     331        emit "pop esi"
     332    elsif X86_64
     333        emit "pop %rbx"
     334        emit "pop %r15"
     335        emit "pop %r14"
     336        emit "pop %r13"
     337        emit "pop %r12"
     338    elsif X86_64_WIN
     339        emit "pop rsi"
     340        emit "pop rdi"
     341        emit "pop rbx"
     342        emit "pop r15"
     343        emit "pop r14"
     344        emit "pop r13"
     345        emit "pop r12"
     346    end
     347end
     348
    249349macro preserveCallerPCAndCFR()
    250350    if C_LOOP or ARM or ARMv7 or ARMv7_TRADITIONAL or MIPS or SH4
     
    254354        push cfr
    255355    elsif ARM64
    256         pushLRAndFP
     356        push cfr, lr
    257357    else
    258358        error
     
    269369        pop cfr
    270370    elsif ARM64
    271         popLRAndFP
     371        pop lr, cfr
    272372    end
    273373end
     
    299399        push cfr
    300400    elsif ARM64
    301         pushLRAndFP
     401        push cfr, lr
    302402    elsif C_LOOP or ARM or ARMv7 or ARMv7_TRADITIONAL or MIPS or SH4
    303403        push lr
     
    311411        pop cfr
    312412    elsif ARM64
    313         popLRAndFP
     413        pop lr, cfr
    314414    elsif C_LOOP or ARM or ARMv7 or ARMv7_TRADITIONAL or MIPS or SH4
    315415        pop cfr
     
    325425        push cfr
    326426    elsif ARM64
    327         pushLRAndFP
     427        push cfr, lr
    328428    elsif C_LOOP or ARM or ARMv7 or ARMv7_TRADITIONAL or MIPS or SH4
    329429        push lr
    330430        push cfr
    331431    end
    332     pushCalleeSaves
     432    pushCalleeSaves()
    333433    if X86
    334434        subp 12, sp
     
    373473    end
    374474
    375     popCalleeSaves
     475    popCalleeSaves()
    376476    if X86_64 or X86_64_WIN
    377477        pop t2
     
    380480        pop cfr
    381481    elsif ARM64
    382         popLRAndFP
     482        pop lr, cfr
    383483    elsif C_LOOP or ARM or ARMv7 or ARMv7_TRADITIONAL or MIPS or SH4
    384484        pop cfr
     
    527627    # pop the callerFrame since we will jump to a function that wants to save it
    528628    if ARM64
    529         popLRAndFP
     629        pop lr, cfr
    530630    elsif ARM or ARMv7 or ARMv7_TRADITIONAL or MIPS or SH4
    531631        pop cfr
     
    764864_llint_entry:
    765865    functionPrologue()
    766     pushCalleeSaves
     866    pushCalleeSaves()
    767867    initPCRelative(t1)
    768868
     
    770870    include InitBytecodes
    771871
    772     popCalleeSaves
     872    popCalleeSaves()
    773873    functionEpilogue()
    774874    ret
  • 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.