Ignore:
Timestamp:
Nov 3, 2014, 11:36:15 PM (11 years ago)
Author:
[email protected]
Message:

Workaround for Cortex-A53 erratum 835769
https://bugs.webkit.org/show_bug.cgi?id=138315

Patch by Akos Kiss <[email protected]> on 2014-11-03
Reviewed by Filip Pizlo.

This patch introduces CMake variable and preprocessor macro
WTF_CPU_ARM64_CORTEXA53 with the aim of enabling Cortex-A53-specific
.:

code paths, if set true.

  • Source/cmake/OptionsCommon.cmake:

Add -mfix-cortex-a53-835769 to the compiler flags if compiler supports
it.

  • Source/cmakeconfig.h.cmake:

#cmakedefine01 for WTF_CPU_ARM64_CORTEXA53

Source/JavaScriptCore:

code paths, if set true. The patch also implements one case where such
code paths are needed: the workaround for Cortex-A53 erratum 835769. If
WTF_CPU_ARM64_CORTEXA53 is set then:

  • CMake checks whether the compiler already has support for a workaround and adds -mfix-cortex-a53-835769 to the compiler flags if so,
  • the ARM64 backend of offlineasm inserts a nop between memory and multiply-accumulate instructions, and
  • the ARM64 assembler also inserts a nop between memory and (64-bit) multiply-accumulate instructions.
  • assembler/ARM64Assembler.h:

(JSC::ARM64Assembler::madd):
Call nopCortexA53Fix835769() to insert a nop if CPU(ARM64_CORTEXA53) and
if necessary.
(JSC::ARM64Assembler::msub): Likewise.
(JSC::ARM64Assembler::smaddl): Likewise.
(JSC::ARM64Assembler::smsubl): Likewise.
(JSC::ARM64Assembler::umaddl): Likewise.
(JSC::ARM64Assembler::umsubl): Likewise.
(JSC::ARM64Assembler::nopCortexA53Fix835769):
Added. Insert a nop if the previously emitted instruction was a load, a
store, or a prefetch, and if the current instruction is 64-bit.

  • offlineasm/arm64.rb:

Add the arm64CortexA53Fix835769 phase and call it from
getModifiedListARM64 to insert nopCortexA53Fix835769 between appropriate
macro instructions. Also, lower nopCortexA53Fix835769 to nop if
CPU(ARM64_CORTEXA53), to nothing otherwise.

  • offlineasm/instructions.rb:

Define macro instruction nopFixCortexA53Err835769.

File:
1 edited

Legend:

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

    r173497 r175514  
    229229end
    230230
     231# Workaround for Cortex-A53 erratum (835769)
     232def arm64CortexA53Fix835769(list)
     233    newList = []
     234    lastOpcodeUnsafe = false
     235
     236    list.each {
     237        | node |
     238        if node.is_a? Instruction
     239            case node.opcode
     240            when /^store/, /^load/
     241                # List all macro instructions that can be lowered to a load, store or prefetch ARM64 assembly instruction
     242                lastOpcodeUnsafe = true
     243            when  "muli", "mulp", "mulq", "smulli"
     244                # List all macro instructions that can be lowered to a 64-bit multiply-accumulate ARM64 assembly instruction
     245                # (defined as one of MADD, MSUB, SMADDL, SMSUBL, UMADDL or UMSUBL).
     246                if lastOpcodeUnsafe
     247                    newList << Instruction.new(node.codeOrigin, "nopCortexA53Fix835769", [])
     248                end
     249                lastOpcodeUnsafe = false
     250            else
     251                lastOpcodeUnsafe = false
     252            end
     253        end
     254        newList << node
     255    }
     256    newList
     257end
     258
    231259class Sequence
    232260    def getModifiedListARM64
     
    285313        result = assignRegistersToTemporaries(result, :gpr, ARM64_EXTRA_GPRS)
    286314        result = assignRegistersToTemporaries(result, :fpr, ARM64_EXTRA_FPRS)
     315        result = arm64CortexA53Fix835769(result)
    287316        return result
    288317    end
     
    838867            $asm.puts "dmb sy"
    839868        when "pcrtoaddr"
    840           $asm.puts "adr #{operands[1].arm64Operand(:ptr)}, #{operands[0].value}"
     869            $asm.puts "adr #{operands[1].arm64Operand(:ptr)}, #{operands[0].value}"
     870        when "nopCortexA53Fix835769"
     871            $asm.putStr("#if CPU(ARM64_CORTEXA53)")
     872            $asm.puts "nop"
     873            $asm.putStr("#endif")
    841874        else
    842875            lowerDefault
Note: See TracChangeset for help on using the changeset viewer.