Changeset 214969 in webkit


Ignore:
Timestamp:
Apr 5, 2017 2:00:17 PM (7 years ago)
Author:
commit-queue@webkit.org
Message:

Do not use BLX for immediates (ARM-32)

https://bugs.webkit.org/show_bug.cgi?id=170351

Patch by Guilherme Iscaro <iscaro@profusion.mobi> on 2017-04-05
Reviewed by Mark Lam.

Currently the offline asm generator for 32-bit ARM code translates the
'call' meta-instruction (which may be found in LowLevelInterpreter.asm
and friends) to the ARM's BLX instrunction. The BLX instruction may be
used for labels (immediates) and registers and one side effect of BLX
is that it may switch the processor's instruction set.
A 'BLX register' instruction will change/remain the processor state to
ARM if the register_bit[0] is set to 0 or change/remain to Thumb if
register_bit[0] is set to 1. However, a 'BLX label' instruction will
always switch the processor state. It switches ARM to thumb and vice-versa.
This behaviour is unwanted, since the C++ code and the offlineasm generated code
are both compiled using the same instruction set, thus a instruction
set change will likely produce a crash. In order to fix the problem the
BL instruction can be used for labels. It will branch just like BLX,
but it won't change the instruction set. It's important to note that
Darwin is not affected by this problem, thus to minimize the impact of
this change the BL instruction will only be used on non-darwin targets.

BLX reference: http://infocenter.arm.com/help/topic/com.arm.doc.dui0489i/CIHBJCDC.html?resultof=%22%62%6c%78%22%20

  • offlineasm/arm.rb:
Location:
trunk/Source/JavaScriptCore
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/ChangeLog

    r214950 r214969  
     12017-04-05  Guilherme Iscaro  <iscaro@profusion.mobi>
     2
     3        Do not use BLX for immediates (ARM-32)
     4
     5        https://bugs.webkit.org/show_bug.cgi?id=170351
     6
     7        Reviewed by Mark Lam.
     8
     9        Currently the offline asm generator for 32-bit ARM code translates the
     10        'call' meta-instruction (which may be found in LowLevelInterpreter.asm
     11        and friends) to the ARM's BLX instrunction. The BLX instruction may be
     12        used for labels (immediates) and registers and one side effect of BLX
     13        is that it may switch the processor's instruction set.
     14        A 'BLX register' instruction will change/remain the processor state to
     15        ARM if the  register_bit[0] is set to 0 or change/remain to Thumb if
     16        register_bit[0] is set to 1. However, a 'BLX label' instruction will
     17        always switch the processor state. It switches ARM to thumb and vice-versa.
     18        This behaviour is unwanted, since the C++ code and the offlineasm generated code
     19        are both compiled using the same instruction set, thus a instruction
     20        set change will likely produce a crash. In order to fix the problem the
     21        BL instruction can be used for labels. It will branch just like BLX,
     22        but it won't change the instruction set. It's important to note that
     23        Darwin is not affected by this problem, thus to minimize the impact of
     24        this change the BL instruction will only be used on non-darwin targets.
     25
     26        BLX reference: http://infocenter.arm.com/help/topic/com.arm.doc.dui0489i/CIHBJCDC.html?resultof=%22%62%6c%78%22%20
     27
     28        * offlineasm/arm.rb:
     29
    1302017-04-05  Keith Miller  <keith_miller@apple.com>
    231
  • trunk/Source/JavaScriptCore/offlineasm/arm.rb

    r196541 r214969  
    9595ARM_EXTRA_FPRS = [SpecialRegister.new("d7")]
    9696ARM_SCRATCH_FPR = SpecialRegister.new("d6")
     97OS_DARWIN = ((RUBY_PLATFORM =~ /darwin/i) != nil)
    9798
    9899def armMoveImmediate(value, register)
     
    569570        when "call"
    570571            if operands[0].label?
    571                 $asm.puts "blx #{operands[0].asmLabel}"
     572                if OS_DARWIN
     573                    $asm.puts "blx #{operands[0].asmLabel}"
     574                else
     575                    $asm.puts "bl #{operands[0].asmLabel}"
     576                end
    572577            else
    573578                $asm.puts "blx #{operands[0].armOperand}"
Note: See TracChangeset for help on using the changeset viewer.