source: webkit/trunk/Source/JavaScriptCore/offlineasm/backends.rb

Last change on this file was 294787, checked in by [email protected], 3 years ago

Use jsc_llint as a LLInt local label prefix instead of _offlineasm.
https://bugs.webkit.org/show_bug.cgi?id=240885

Reviewed by Geoffrey Garen.

Code generated by the offlineasm is tightly coupled with JSC anyway. Might as well
make the local labels more informative about where the code came from in crash traces.

So, instead of this:

JavaScriptCore`vmEntryToJavaScript:

0x1028b5d90 <+0 >: pacibsp
0x1028b5d94 <+4 >: stp x29, x30, [sp, #-0x10]!
0x1028b5d98 <+8 >: mov x29, sp
0x1028b5d9c <+12 >: sub sp, x29, #0xb0
0x1028b5da0 <+16 >: mov x13, #0xc800
0x1028b5da4 <+20 >: add x17, x1, x13
0x1028b5da8 <+24 >: ldr w4, [x17]
0x1028b5dac <+28 >: cbnz w4, 0x1028b5f34 ; _offlineasm_doVMEntrycheckVMEntryPermission
0x1028b5db0 <+32 >: str x1, [sp]
0x1028b5db4 <+36 >: mov x17, #0x9e78
...
0x1028b5de8 <+88 >: sub x3, sp, x4
0x1028b5dec <+92 >: cmp sp, x3
0x1028b5df0 <+96 >: b.ls 0x1028b5ef4 ; _offlineasm_doVMEntry
throwStackOverflow
0x1028b5df4 <+100 >: mov x17, #0xca00
0x1028b5df8 <+104 >: add x13, x1, x17
0x1028b5dfc <+108 >: ldr x17, [x13]
0x1028b5e00 <+112 >: cmp x3, x17
0x1028b5e04 <+116 >: b.lo 0x1028b5ef4 ; _offlineasm_doVMEntrythrowStackOverflow

JavaScriptCore`_offlineasm_doVMEntrystackHeightOK:

0x1028b5e08 <+0 >: mov sp, x3
0x1028b5e0c <+4 >: mov x3, #0x4

JavaScriptCore`_offlineasm_doVMEntrycopyHeaderLoop:

0x1028b5e10 <+0 >: sub w3, w3, #0x1
0x1028b5e14 <+4 >: add x17, x2, x3, lsl #3
0x1028b5e18 <+8 >: ldr x5, [x17]

We now get this:

JavaScriptCore`vmEntryToJavaScript:

0x1028cdd90 <+0>: pacibsp
0x1028cdd94 <+4>: stp x29, x30, [sp, #-0x10]!
0x1028cdd98 <+8>: mov x29, sp
0x1028cdd9c <+12>: sub sp, x29, #0xb0
0x1028cdda0 <+16>: mov x13, #0xc800
0x1028cdda4 <+20>: add x17, x1, x13
0x1028cdda8 <+24>: ldr w4, [x17]
0x1028cddac <+28>: cbnz w4, 0x1028cdf34 ; jsc_llint_doVMEntrycheckVMEntryPermission
0x1028cddb0 <+32>: str x1, [sp]
0x1028cddb4 <+36>: mov x17, #0x9e78
...
0x1028cdde8 <+88>: sub x3, sp, x4
0x1028cddec <+92>: cmp sp, x3
0x1028cddf0 <+96>: b.ls 0x1028cdef4 ; jsc_llint_doVMEntry
throwStackOverflow
0x1028cddf4 <+100>: mov x17, #0xca00
0x1028cddf8 <+104>: add x13, x1, x17
0x1028cddfc <+108>: ldr x17, [x13]
0x1028cde00 <+112>: cmp x3, x17
0x1028cde04 <+116>: b.lo 0x1028cdef4 ; jsc_llint_doVMEntrythrowStackOverflow

JavaScriptCore`jsc_llint_doVMEntrystackHeightOK:

0x1028cde08 <+0>: mov sp, x3
0x1028cde0c <+4>: mov x3, #0x4

JavaScriptCore`jsc_llint_doVMEntrycopyHeaderLoop:

0x1028cde10 <+0>: sub w3, w3, #0x1
0x1028cde14 <+4>: add x17, x2, x3, lsl #3
0x1028cde18 <+8>: ldr x5, [x17]

  • Source/JavaScriptCore/offlineasm/arm.rb:
  • Source/JavaScriptCore/offlineasm/arm64.rb:
  • Source/JavaScriptCore/offlineasm/backends.rb:
  • Source/JavaScriptCore/offlineasm/config.rb:

Canonical link: https://commits.webkit.org/250946@main

File size: 5.2 KB
Line 
1# Copyright (C) 2011-2022 Apple Inc. All rights reserved.
2#
3# Redistribution and use in source and binary forms, with or without
4# modification, are permitted provided that the following conditions
5# are met:
6# 1. Redistributions of source code must retain the above copyright
7# notice, this list of conditions and the following disclaimer.
8# 2. Redistributions in binary form must reproduce the above copyright
9# notice, this list of conditions and the following disclaimer in the
10# documentation and/or other materials provided with the distribution.
11#
12# THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
13# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
14# THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
15# PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
16# BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
17# CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
18# SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
19# INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
20# CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
21# ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
22# THE POSSIBILITY OF SUCH DAMAGE.
23
24require "config"
25require "arm"
26require "arm64"
27require "ast"
28require "x86"
29require "mips"
30require "riscv64"
31require "cloop"
32
33begin
34 require "arm64e"
35rescue LoadError
36end
37
38BACKENDS =
39 [
40 "X86",
41 "X86_WIN",
42 "X86_64",
43 "X86_64_WIN",
44 "ARMv7",
45 "ARM64",
46 "ARM64E",
47 "MIPS",
48 "RISCV64",
49 "C_LOOP",
50 "C_LOOP_WIN"
51 ]
52
53# Keep the set of working backends separate from the set of backends that might be
54# supported. This is great because the BACKENDS list is almost like a reserved
55# words list, in that it causes settings resolution to treat those words specially.
56# Hence this lets us set aside the name of a backend we might want to support in
57# the future while not actually supporting the backend yet.
58WORKING_BACKENDS =
59 [
60 "X86",
61 "X86_WIN",
62 "X86_64",
63 "X86_64_WIN",
64 "ARMv7",
65 "ARM64",
66 "ARM64E",
67 "MIPS",
68 "RISCV64",
69 "C_LOOP",
70 "C_LOOP_WIN"
71 ]
72
73BACKEND_PATTERN = Regexp.new('\\A(' + BACKENDS.join(')|(') + ')\\Z')
74
75$allBackends = {}
76$validBackends = {}
77BACKENDS.each {
78 | backend |
79 $validBackends[backend] = true
80 $allBackends[backend] = true
81}
82
83def canonicalizeBackendNames(backendNames)
84 newBackendNames = []
85 backendNames.each {
86 | backendName |
87 backendName = backendName.upcase
88 if backendName =~ /ARM.*/
89 backendName.sub!(/ARMV7([KS]?)(.*)/) { | _ | 'ARMv7' + $1.downcase + $2 }
90 backendName = "ARM64" if backendName == "ARM64_32"
91 end
92 backendName = "X86" if backendName == "I386"
93 newBackendNames << backendName
94 newBackendNames << "ARMv7" if backendName.start_with?("ARMv7")
95 }
96 newBackendNames.uniq
97end
98
99def includeOnlyBackends(list)
100 newValidBackends = {}
101 list.each {
102 | backend |
103 if $validBackends[backend]
104 newValidBackends[backend] = true
105 end
106 }
107 $validBackends = newValidBackends
108end
109
110def isBackend?(backend)
111 $allBackends[backend]
112end
113
114def isValidBackend?(backend)
115 $validBackends[backend]
116end
117
118def validBackends
119 $validBackends.keys
120end
121
122class LoweringError < StandardError
123 attr_reader :originString
124
125 def initialize(e, originString)
126 super "#{e} (due to #{originString})"
127 @originString = originString
128 set_backtrace e.backtrace
129 end
130end
131
132class Node
133 def lower(name)
134 begin
135 $activeBackend = name
136 send("prepareToLower", name)
137 send("lower#{name}")
138 rescue => e
139 raise LoweringError.new(e, codeOriginString)
140 end
141 end
142end
143
144# Overrides for lower() for those nodes that are backend-agnostic
145
146class Label
147 def lower(name)
148 $asm.debugAnnotation codeOrigin.debugDirective if $enableDebugAnnotations
149 $asm.putsLabel(self.name[1..-1], @global)
150 end
151end
152
153class LocalLabel
154 def lower(name)
155 $asm.putsLocalLabel "jsc_llint_#{self.name[1..-1]}"
156 end
157end
158
159class LabelReference
160 def asmLabel
161 if extern?
162 Assembler.externLabelReference(name[1..-1])
163 else
164 Assembler.labelReference(name[1..-1])
165 end
166 end
167
168 def cLabel
169 Assembler.cLabelReference(name[1..-1])
170 end
171end
172
173class LocalLabelReference
174 def asmLabel
175 Assembler.localLabelReference("jsc_llint_"+name[1..-1])
176 end
177
178 def cLabel
179 Assembler.cLocalLabelReference("jsc_llint_"+name[1..-1])
180 end
181end
182
183class Skip
184 def lower(name)
185 end
186end
187
188class Sequence
189 def lower(name)
190 $activeBackend = name
191 if respond_to? "getModifiedList#{name}"
192 newList = send("getModifiedList#{name}")
193 newList.each {
194 | node |
195 node.lower(name)
196 }
197 elsif respond_to? "lower#{name}"
198 send("lower#{name}")
199 else
200 @list.each {
201 | node |
202 node.lower(name)
203 }
204 end
205 end
206end
207
Note: See TracBrowser for help on using the repository browser.