Ignore:
Timestamp:
Apr 18, 2020, 7:59:11 AM (5 years ago)
Author:
[email protected]
Message:

Fix code origin when lowering offlineasm instructions on MIPS/ARM64E
https://bugs.webkit.org/show_bug.cgi?id=207330

Patch by Angelos Oikonomopoulos <Angelos Oikonomopoulos> on 2020-04-18
Reviewed by Mark Lam.

Instruction operands are mapped to RegisterID in RegisterID.forName
and the operation is memoized. Therefore, we can't use the codeOrigin
of the operand at that point. Use the codeOrigin of the original
instruction instead.

  • offlineasm/arm64e.rb:
  • offlineasm/ast.rb:
  • offlineasm/mips.rb:
  • offlineasm/risc.rb:
File:
1 edited

Legend:

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

    r260309 r260310  
    555555end
    556556
    557 def mipsAsRegister(preList, postList, operand, needRestore)
    558     tmp = MIPS_CALL_REG
    559     if operand.address?
    560         preList << Instruction.new(operand.codeOrigin, "loadp", [operand, MIPS_CALL_REG])
    561     elsif operand.is_a? LabelReference
    562         preList << Instruction.new(operand.codeOrigin, "la", [operand, MIPS_CALL_REG])
    563     elsif operand.register? and operand != MIPS_CALL_REG
    564         preList << Instruction.new(operand.codeOrigin, "move", [operand, MIPS_CALL_REG])
    565     else
    566         needRestore = false
    567         tmp = operand
    568     end
    569     if needRestore
    570         postList << Instruction.new(operand.codeOrigin, "move", [MIPS_GPSAVE_REG, MIPS_GP_REG])
    571     end
    572     tmp
     557class Instruction
     558    # Replace operands with a single register operand.
     559    # Note: in contrast to the risc version, this method drops all other operands.
     560    def mipsCloneWithOperandLowered(preList, postList, operandIndex, needRestore)
     561        operand = self.operands[operandIndex]
     562        tmp = MIPS_CALL_REG
     563        if operand.address?
     564            preList << Instruction.new(self.codeOrigin, "loadp", [operand, MIPS_CALL_REG])
     565        elsif operand.is_a? LabelReference
     566            preList << Instruction.new(self.codeOrigin, "la", [operand, MIPS_CALL_REG])
     567        elsif operand.register? and operand != MIPS_CALL_REG
     568            preList << Instruction.new(self.codeOrigin, "move", [operand, MIPS_CALL_REG])
     569        else
     570            needRestore = false
     571            tmp = operand
     572        end
     573        if needRestore
     574            postList << Instruction.new(self.codeOrigin, "move", [MIPS_GPSAVE_REG, MIPS_GP_REG])
     575        end
     576        cloneWithNewOperands([tmp])
     577    end
    573578end
    574579
     
    582587            case node.opcode
    583588            when "jmp"
    584                 newList << Instruction.new(node.codeOrigin,
    585                                            node.opcode,
    586                                            [mipsAsRegister(newList, [], node.operands[0], false)])
     589                newList << node.mipsCloneWithOperandLowered(newList, [], 0, false)
    587590            when "call"
    588                 newList << Instruction.new(node.codeOrigin,
    589                                            node.opcode,
    590                                            [mipsAsRegister(newList, postInstructions, node.operands[0], true)])
     591                newList << node.mipsCloneWithOperandLowered(newList, postInstructions, 0, true)
    591592            when "slt", "sltu"
    592                 newList << Instruction.new(node.codeOrigin,
    593                                            node.opcode,
    594                                            riscAsRegisters(newList, [], node.operands, "i"))
     593                newList << node.riscCloneWithOperandsLowered(newList, [], "i")
    595594            when "sltub", "sltb"
    596                 newList << Instruction.new(node.codeOrigin,
    597                                            node.opcode,
    598                                            riscAsRegisters(newList, [], node.operands, "b"))
     595                newList << node.riscCloneWithOperandsLowered(newList, [], "b")
    599596            when "andb"
    600597                newList << Instruction.new(node.codeOrigin,
    601598                                           "andi",
    602                                            riscAsRegisters(newList, [], node.operands, "b"))
     599                                           riscLowerOperandsToRegisters(node, newList, [], "b"),
     600                                           node.annotation)
    603601            when /^(bz|bnz|bs|bo)/
    604602                tl = $~.post_match == "" ? "i" : $~.post_match
    605                 newList << Instruction.new(node.codeOrigin,
    606                                            node.opcode,
    607                                            riscAsRegisters(newList, [], node.operands, tl))
     603                newList << node.riscCloneWithOperandsLowered(newList, [], tl)
    608604            else
    609605                newList << node
Note: See TracChangeset for help on using the changeset viewer.