Changeset 260310 in webkit
- Timestamp:
- Apr 18, 2020 7:59:11 AM (4 years ago)
- Location:
- trunk/Source/JavaScriptCore
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/JavaScriptCore/ChangeLog
r260309 r260310 1 2020-04-18 Angelos Oikonomopoulos <angelos@igalia.com> 2 3 Fix code origin when lowering offlineasm instructions on MIPS/ARM64E 4 https://bugs.webkit.org/show_bug.cgi?id=207330 5 6 Reviewed by Mark Lam. 7 8 Instruction operands are mapped to RegisterID in RegisterID.forName 9 and the operation is memoized. Therefore, we can't use the codeOrigin 10 of the operand at that point. Use the codeOrigin of the original 11 instruction instead. 12 13 * offlineasm/arm64e.rb: 14 * offlineasm/ast.rb: 15 * offlineasm/mips.rb: 16 * offlineasm/risc.rb: 17 1 18 2020-04-18 Angelos Oikonomopoulos <angelos@igalia.com> 2 19 -
trunk/Source/JavaScriptCore/offlineasm/arm64e.rb
r245064 r260310 45 45 if node.operands.size > 1 46 46 if node.operands[1].is_a? RegisterID 47 tag = risc AsRegister(newList, postInstructions, node.operands[1], "p", false)47 tag = riscLowerOperandToRegister(node, newList, postInstructions, 1, "p", false) 48 48 else 49 49 tag = Tmp.new(codeOrigin, :gpr) 50 50 newList << Instruction.new(codeOrigin, "move", [node.operands[1], tag], annotation) 51 51 end 52 operands = [riscAsRegister(newList, postInstructions, node.operands[0], "p", false), tag] 53 newList << Instruction.new(codeOrigin, node.opcode, operands, annotation) 52 operands = [ 53 riscLowerOperandToRegister(node, newList, postInstructions, 0, "p", false), 54 tag 55 ] 56 newList << Instruction.cloneWithNewOperands(operands) 54 57 wasHandled = true 55 58 end … … 65 68 end 66 69 } 67 newList << Instruction. new(codeOrigin, node.opcode, newOperands, annotation)70 newList << Instruction.cloneWithNewOperands(newOperands) 68 71 wasHandled = true 69 72 end -
trunk/Source/JavaScriptCore/offlineasm/ast.rb
r259990 r260310 918 918 @annotation = annotation 919 919 end 920 920 921 def cloneWithNewOperands(newOperands) 922 Instruction.new(self.codeOrigin, self.opcode, newOperands, self.annotation) 923 end 924 921 925 def children 922 926 operands -
trunk/Source/JavaScriptCore/offlineasm/mips.rb
r260309 r260310 555 555 end 556 556 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 557 class 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 573 578 end 574 579 … … 582 587 case node.opcode 583 588 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) 587 590 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) 591 592 when "slt", "sltu" 592 newList << Instruction.new(node.codeOrigin, 593 node.opcode, 594 riscAsRegisters(newList, [], node.operands, "i")) 593 newList << node.riscCloneWithOperandsLowered(newList, [], "i") 595 594 when "sltub", "sltb" 596 newList << Instruction.new(node.codeOrigin, 597 node.opcode, 598 riscAsRegisters(newList, [], node.operands, "b")) 595 newList << node.riscCloneWithOperandsLowered(newList, [], "b") 599 596 when "andb" 600 597 newList << Instruction.new(node.codeOrigin, 601 598 "andi", 602 riscAsRegisters(newList, [], node.operands, "b")) 599 riscLowerOperandsToRegisters(node, newList, [], "b"), 600 node.annotation) 603 601 when /^(bz|bnz|bs|bo)/ 604 602 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) 608 604 else 609 605 newList << node -
trunk/Source/JavaScriptCore/offlineasm/risc.rb
r260246 r260310 429 429 # 430 430 431 def riscAsRegister(preList, postList, operand, suffix, needStore) 431 def riscLowerOperandToRegister(insn, preList, postList, operandIndex, suffix, needStore) 432 operand = insn.operands[operandIndex] 432 433 return operand unless operand.address? 433 434 tmp = Tmp.new( operand.codeOrigin, if suffix == "d" then :fpr else :gpr end)435 preList << Instruction.new( operand.codeOrigin, "load" + suffix, [operand, tmp])434 435 tmp = Tmp.new(insn.codeOrigin, if suffix == "d" then :fpr else :gpr end) 436 preList << Instruction.new(insn.codeOrigin, "load" + suffix, [operand, tmp]) 436 437 if needStore 437 postList << Instruction.new( operand.codeOrigin, "store" + suffix, [tmp, operand])438 postList << Instruction.new(insn.codeOrigin, "store" + suffix, [tmp, operand]) 438 439 end 439 440 tmp 440 441 end 441 442 442 def risc AsRegisters(preList, postList, operands, suffix)443 def riscLowerOperandsToRegisters(insn, preList, postList, suffix) 443 444 newOperands = [] 444 operands.each_with_index {445 insn.operands.each_with_index { 445 446 | operand, index | 446 newOperands << risc AsRegister(preList, postList, operand, suffix, index ==operands.size - 1)447 newOperands << riscLowerOperandToRegister(insn, preList, postList, index, suffix, index == insn.operands.size - 1) 447 448 } 448 449 newOperands 450 end 451 452 class Instruction 453 def riscCloneWithOperandLowered(preList, postList, operandIndex, suffix, needStore) 454 operand = riscLowerOperandToRegister(self, preList, postList, operandIndex, suffix, needStore) 455 cloneWithNewOperands([operand]) 456 end 457 def riscCloneWithOperandsLowered(preList, postList, suffix) 458 operands = riscLowerOperandsToRegisters(self, preList, postList, suffix) 459 cloneWithNewOperands(operands) 460 end 449 461 end 450 462 … … 465 477 when "addi", "addis", "andi", "lshifti", "muli", "negi", "noti", "ori", "oris", 466 478 "rshifti", "urshifti", "subi", "subis", "xori", /^bi/, /^bti/, /^ci/, /^ti/ 467 newList << Instruction.new(node.codeOrigin, 468 node.opcode, 469 riscAsRegisters(newList, postInstructions, node.operands, "i"), 470 annotation) 479 newList << node.riscCloneWithOperandsLowered(newList, postInstructions, "i") 471 480 when "orh" 472 newList << Instruction.new(node.codeOrigin, 473 node.opcode, 474 riscAsRegisters(newList, postInstructions, node.operands, "h"), 475 annotation) 481 newList << node.riscCloneWithOperandsLowered(newList, postInstructions, "h") 476 482 when "addp", "andp", "lshiftp", "mulp", "negp", "orp", "rshiftp", "urshiftp", 477 483 "subp", "xorp", /^bp/, /^btp/, /^cp/ 478 newList << Instruction.new(node.codeOrigin, 479 node.opcode, 480 riscAsRegisters(newList, postInstructions, node.operands, "p"), 481 annotation) 484 newList << node.riscCloneWithOperandsLowered(newList, postInstructions, "p") 482 485 when "addq", "andq", "lshiftq", "mulq", "negq", "orq", "rshiftq", "urshiftq", 483 486 "subq", "xorq", /^bq/, /^btq/, /^cq/ 484 newList << Instruction.new(node.codeOrigin, 485 node.opcode, 486 riscAsRegisters(newList, postInstructions, node.operands, "q"), 487 annotation) 487 newList << node.riscCloneWithOperandsLowered(newList, postInstructions, "q") 488 488 when "bbeq", "bbneq", "bba", "bbaeq", "bbb", "bbbeq", "btbz", "btbnz", "tbz", "tbnz", 489 489 "cbeq", "cbneq", "cba", "cbaeq", "cbb", "cbbeq" 490 newList << Instruction.new(node.codeOrigin, 491 node.opcode, 492 riscAsRegisters(newList, postInstructions, node.operands, "b"), 493 annotation) 490 newList << node.riscCloneWithOperandsLowered(newList, postInstructions, "b") 494 491 when "bbgt", "bbgteq", "bblt", "bblteq", "btbs", "tbs", "cbgt", "cbgteq", "cblt", "cblteq" 495 newList << Instruction.new(node.codeOrigin, 496 node.opcode, 497 riscAsRegisters(newList, postInstructions, node.operands, "bs"), 498 annotation) 492 newList << node.riscCloneWithOperandsLowered(newList, postInstructions, "bs") 499 493 when "addd", "divd", "subd", "muld", "sqrtd", /^bd/ 500 newList << Instruction.new(node.codeOrigin, 501 node.opcode, 502 riscAsRegisters(newList, postInstructions, node.operands, "d"), 503 annotation) 494 newList << node.riscCloneWithOperandsLowered(newList, postInstructions, "d") 504 495 when "jmp", "call" 505 newList << Instruction.new(node.codeOrigin, 506 node.opcode, 507 [riscAsRegister(newList, postInstructions, node.operands[0], "p", false)], 508 annotation) 496 newList << node.riscCloneWithOperandLowered(newList, postInstructions, 0, "p", false) 509 497 else 510 498 newList << node
Note: See TracChangeset
for help on using the changeset viewer.