Skip to content
This repository was archived by the owner on Jun 24, 2022. It is now read-only.

Commit 4ad47c5

Browse files
[MIPS] Broken build after r267371
https://bugs.webkit.org/show_bug.cgi?id=216893 Patch by Angelos Oikonomopoulos <[email protected]> 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: git-svn-id: http://svn.webkit.org/repository/webkit/trunk@267535 268f45cc-cd09-0410-ab3c-d52691b4dbfc
1 parent dbbc4cc commit 4ad47c5

File tree

3 files changed

+42
-5
lines changed

3 files changed

+42
-5
lines changed

Source/JavaScriptCore/ChangeLog

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,41 @@
1+
2020-09-24 Angelos Oikonomopoulos <[email protected]>
2+
3+
[MIPS] Broken build after r267371
4+
https://bugs.webkit.org/show_bug.cgi?id=216893
5+
6+
Reviewed by Adrian Perez de Castro.
7+
8+
This addresses two issues.
9+
10+
First, the fix in https://bugs.webkit.org/show_bug.cgi?id=216772 was not
11+
getting exercised, because the LabelReference offset was always zero.
12+
13+
The reason the offset was zero is that LabelReference.mapChildren would discard
14+
the offset when generating a new LabelReference to wrap the Label returned by
15+
the code block it yielded to.
16+
17+
The reason this was only an issue on MIPS is because only MIPS was using the
18+
result of calls to LabelReference.mapChildren (in its lowering phase,
19+
assignRegistersToTemporaries -> replaceTemporariesWithRegisters ->
20+
mapChildren). Other archs, e.g. X86_64 only call mapChildren in earlier phases
21+
(specifically, subsequent to a call to isASTErroneous), in which the new
22+
LabelReferences returned by mapChildren are later discarded. Even though ARM
23+
32/64 contains indirect calls to mapChildren, those are made after the
24+
arm{,64}LowerLabelReferences transformation which doesn't leave any
25+
LabelReference nodes around for .mapChildren to be called on.
26+
27+
So this is not an issue for architectures other than MIPS because
28+
(a) AddImmediates.fold correctly constructs a LabelReference with an offset by
29+
calling LabelReference.plusOffset and
30+
(b) they don't call (and therefore don't use the result of)
31+
LabelReference.mapChildren in their lowering code.
32+
33+
Second, the code we generate needs to look up the /label/ in the GOT, not the
34+
computed address. After the lookup, we simply need to add the offset.
35+
36+
* offlineasm/ast.rb:
37+
* offlineasm/mips.rb:
38+
139
2020-09-24 Ross Kirsling <[email protected]>
240

341
%TypedArray%.prototype.fill must only evaluate its argument once

Source/JavaScriptCore/offlineasm/ast.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1163,7 +1163,9 @@ def children
11631163
end
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

11691171
def name

Source/JavaScriptCore/offlineasm/mips.rb

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,12 +1050,9 @@ def lowerMIPS
10501050
when "leai", "leap"
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
10611058
operands[0].mipsEmitLea(operands[1])

0 commit comments

Comments
 (0)