Modified: branches/safari-604-branch/Source/_javascript_Core/offlineasm/arm64.rb (226156 => 226157)
--- branches/safari-604-branch/Source/_javascript_Core/offlineasm/arm64.rb 2017-12-20 00:07:31 UTC (rev 226156)
+++ branches/safari-604-branch/Source/_javascript_Core/offlineasm/arm64.rb 2017-12-20 00:12:38 UTC (rev 226157)
@@ -260,6 +260,31 @@
newList
end
+def arm64LowerLabelReferences(list)
+ newList = []
+ list.each {
+ | node |
+ if node.is_a? Instruction
+ case node.opcode
+ when "loadi", "loadis", "loadp", "loadq", "loadb", "loadbs", "loadh", "loadhs"
+ labelRef = node.operands[0]
+ if labelRef.is_a? LabelReference
+ tmp = Tmp.new(node.codeOrigin, :gpr)
+ newList << Instruction.new(codeOrigin, "globaladdr", [LabelReference.new(node.codeOrigin, labelRef.label), tmp])
+ newList << Instruction.new(codeOrigin, node.opcode, [Address.new(node.codeOrigin, tmp, Immediate.new(node.codeOrigin, labelRef.offset)), node.operands[1]])
+ else
+ newList << node
+ end
+ else
+ newList << node
+ end
+ else
+ newList << node
+ end
+ }
+ newList
+end
+
# Workaround for Cortex-A53 erratum (835769)
def arm64CortexA53Fix835769(list)
newList = []
@@ -296,6 +321,7 @@
result = riscLowerHardBranchOps64(result)
result = riscLowerShiftOps(result)
result = arm64LowerMalformedLoadStoreAddresses(result)
+ result = arm64LowerLabelReferences(result)
result = riscLowerMalformedAddresses(result) {
| node, address |
case node.opcode
@@ -904,6 +930,15 @@
$asm.putStr("#if CPU(ARM64_CORTEXA53)")
$asm.puts "nop"
$asm.putStr("#endif")
+ when "globaladdr"
+ uid = $asm.newUID
+ $asm.puts "L_offlineasm_loh_adrp_#{uid}:"
+ $asm.puts "adrp #{operands[1].arm64Operand(:ptr)}, #{operands[0].asmLabel}@GOTPAGE"
+ $asm.puts "L_offlineasm_loh_ldr_#{uid}:"
+ $asm.puts "ldr #{operands[1].arm64Operand(:ptr)}, [#{operands[1].arm64Operand(:ptr)}, #{operands[0].asmLabel}@GOTPAGEOFF]"
+ $asm.deferAction {
+ $asm.puts ".loh AdrpLdrGot L_offlineasm_loh_adrp_#{uid}, L_offlineasm_loh_ldr_#{uid}"
+ }
else
lowerDefault
end
Modified: branches/safari-604-branch/Source/_javascript_Core/offlineasm/asm.rb (226156 => 226157)
--- branches/safari-604-branch/Source/_javascript_Core/offlineasm/asm.rb 2017-12-20 00:07:31 UTC (rev 226156)
+++ branches/safari-604-branch/Source/_javascript_Core/offlineasm/asm.rb 2017-12-20 00:12:38 UTC (rev 226157)
@@ -46,6 +46,8 @@
@codeOrigin = nil
@numLocalLabels = 0
@numGlobalLabels = 0
+ @deferredActions = []
+ @count = 0
@newlineSpacerState = :none
@lastlabel = ""
@@ -73,10 +75,23 @@
putsProcEndIfNeeded
end
putsLastComment
+ @deferredActions.each {
+ | action |
+ action.call()
+ }
@outp.puts "OFFLINE_ASM_END" if !$emitWinAsm
@state = :cpp
end
+ def deferAction(&proc)
+ @deferredActions << proc
+ end
+
+ def newUID
+ @count += 1
+ @count
+ end
+
def inAsm
enterAsm
yield
Modified: branches/safari-604-branch/Source/_javascript_Core/offlineasm/instructions.rb (226156 => 226157)
--- branches/safari-604-branch/Source/_javascript_Core/offlineasm/instructions.rb 2017-12-20 00:07:31 UTC (rev 226156)
+++ branches/safari-604-branch/Source/_javascript_Core/offlineasm/instructions.rb 2017-12-20 00:12:38 UTC (rev 226157)
@@ -267,7 +267,8 @@
ARM64_INSTRUCTIONS =
[
"pcrtoaddr", # Address from PC relative offset - adr instruction
- "nopFixCortexA53Err835769" # nop on Cortex-A53 (nothing otherwise)
+ "nopFixCortexA53Err835769", # nop on Cortex-A53 (nothing otherwise)
+ "globaladdr"
]
RISC_INSTRUCTIONS =