Ignore:
Timestamp:
Sep 24, 2020, 9:16:59 AM (5 years ago)
Author:
[email protected]
Message:

[MIPS] Broken build after r267371
https://bugs.webkit.org/show_bug.cgi?id=216893

Patch by Angelos Oikonomopoulos <Angelos Oikonomopoulos> on 2020-09-24
Reviewed by Adrian Perez de Castro.

This addresses two issues.

First, the fix in https://bugs.webkit.org/show_bug.cgi?id=216772 was not
getting exercised, because the LabelReference offset was always zero.

The reason the offset was zero is that LabelReference.mapChildren would discard
the offset when generating a new LabelReference to wrap the Label returned by
the code block it yielded to.

The reason this was only an issue on MIPS is because only MIPS was using the
result of calls to LabelReference.mapChildren (in its lowering phase,
assignRegistersToTemporaries -> replaceTemporariesWithRegisters ->
mapChildren). Other archs, e.g. X86_64 only call mapChildren in earlier phases
(specifically, subsequent to a call to isASTErroneous), in which the new
LabelReferences returned by mapChildren are later discarded. Even though ARM
32/64 contains indirect calls to mapChildren, those are made after the
arm{,64}LowerLabelReferences transformation which doesn't leave any
LabelReference nodes around for .mapChildren to be called on.

So this is not an issue for architectures other than MIPS because
(a) AddImmediates.fold correctly constructs a LabelReference with an offset by
calling LabelReference.plusOffset and
(b) they don't call (and therefore don't use the result of)
LabelReference.mapChildren in their lowering code.

Second, the code we generate needs to look up the /label/ in the GOT, not the
computed address. After the lookup, we simply need to add the offset.

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

Legend:

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

    r260310 r267535  
    11641164   
    11651165    def mapChildren
    1166         LabelReference.new(codeOrigin, (yield @label))
     1166        result = LabelReference.new(codeOrigin, (yield @label))
     1167        result.offset = @offset
     1168        result
    11671169    end
    11681170   
  • trunk/Source/JavaScriptCore/offlineasm/mips.rb

    r267395 r267535  
    10511051            if operands[0].is_a? LabelReference
    10521052                labelRef = operands[0]
     1053                $asm.puts "lw #{operands[1].mipsOperand}, %got(#{labelRef.asmLabel})($gp)"
    10531054                if labelRef.offset > 0
    1054                     $asm.puts "li #{operands[1].mipsOperand}, #{labelRef.asmLabel}"
    10551055                    $asm.puts "addu #{operands[1].mipsOperand}, #{operands[1].mipsOperand}, #{labelRef.offset}"
    1056                     $asm.puts "lw #{operands[1].mipsOperand}, %got(#{operands[1].mipsOperand})($gp)"
    1057                 else
    1058                     $asm.puts "lw #{operands[1].mipsOperand}, %got(#{labelRef.asmLabel})($gp)"
    10591056                end
    10601057            else
Note: See TracChangeset for help on using the changeset viewer.