File: BaselineJITRegisters.h

package info (click to toggle)
webkit2gtk 2.42.2-1~deb12u1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 362,452 kB
  • sloc: cpp: 2,881,971; javascript: 282,447; ansic: 134,088; python: 43,789; ruby: 18,308; perl: 15,872; asm: 14,389; xml: 4,395; yacc: 2,350; sh: 2,074; java: 1,734; lex: 1,323; makefile: 288; pascal: 60
file content (424 lines) | stat: -rw-r--r-- 17,198 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
/*
 * Copyright (C) 2013-2021 Apple Inc. All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions
 * are met:
 * 1. Redistributions of source code must retain the above copyright
 *    notice, this list of conditions and the following disclaimer.
 * 2. Redistributions in binary form must reproduce the above copyright
 *    notice, this list of conditions and the following disclaimer in the
 *    documentation and/or other materials provided with the distribution.
 *
 * THIS SOFTWARE IS PROVIDED BY APPLE INC. ``AS IS'' AND ANY
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
 * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL APPLE INC. OR
 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
 * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
 * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
 * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
 * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
 */

#pragma once

#if ENABLE(JIT)

#include "GPRInfo.h"
#include "JITOperations.h"

namespace JSC {

namespace BaselineJITRegisters {

namespace Call {
    constexpr JSValueRegs calleeJSR { JSRInfo::jsRegT10 };
    constexpr GPRReg calleeGPR { GPRInfo::regT0 };
    constexpr GPRReg callLinkInfoGPR { GPRInfo::regT2 };
}

namespace CallDirectEval {
    namespace SlowPath {
        constexpr GPRReg calleeFrameGPR { GPRInfo::regT0 };
#if USE(JSVALUE64)
        constexpr GPRReg scopeGPR { GPRInfo::regT1 };
        constexpr JSValueRegs thisValueJSR { GPRInfo::regT2 };
#else
        constexpr GPRReg scopeGPR { GPRInfo::regT1 };
        constexpr JSValueRegs thisValueJSR { JSRInfo::jsRegT32 };
#endif
    }
}

namespace CheckTraps {
    constexpr GPRReg bytecodeOffsetGPR { GPRInfo::nonArgGPR0 };
}

namespace Enter {
    constexpr GPRReg canBeOptimizedGPR { GPRInfo::regT0 };
    constexpr GPRReg localsToInitGPR { GPRInfo::regT1 };
}

namespace Instanceof {
    using SlowOperation = decltype(operationInstanceOfOptimize);

    // Registers used on both Fast and Slow paths
    constexpr JSValueRegs resultJSR { JSRInfo::returnValueJSR };
    constexpr JSValueRegs valueJSR { preferredArgumentJSR<SlowOperation, 2>() };
    constexpr JSValueRegs protoJSR { preferredArgumentJSR<SlowOperation, 3>() };

    // Fast path only registers
    namespace FastPath {
        constexpr GPRReg stubInfoGPR { GPRInfo::argumentGPR1 };
        static_assert(noOverlap(valueJSR, protoJSR, stubInfoGPR), "Required for DataIC");
    }

    // Slow path only registers
    namespace SlowPath {
        constexpr GPRReg globalObjectGPR { preferredArgumentGPR<SlowOperation, 0>() };
        constexpr GPRReg stubInfoGPR { preferredArgumentGPR<SlowOperation, 1>() };
        static_assert(noOverlap(globalObjectGPR, stubInfoGPR, valueJSR, protoJSR), "Required for call to slow operation");
    }
}

namespace JFalse {
    constexpr JSValueRegs valueJSR { JSRInfo::jsRegT32 };
}

namespace JTrue {
    constexpr JSValueRegs valueJSR { JSRInfo::jsRegT32 };
}

namespace Throw {
    using SlowOperation = decltype(operationThrow);

    constexpr GPRReg globalObjectGPR { preferredArgumentGPR<SlowOperation, 0>() };
    constexpr JSValueRegs thrownValueJSR { preferredArgumentJSR<SlowOperation, 1>() };
    constexpr GPRReg bytecodeOffsetGPR { GPRInfo::nonArgGPR0 };
    static_assert(noOverlap(thrownValueJSR, bytecodeOffsetGPR), "Required for call to CTI thunk");
    static_assert(noOverlap(globalObjectGPR, thrownValueJSR), "Required for call to slow operation");
}

namespace ResolveScope {
    constexpr GPRReg metadataGPR { GPRInfo::regT2 };
    constexpr GPRReg scopeGPR { GPRInfo::regT0 };
    constexpr GPRReg bytecodeOffsetGPR { GPRInfo::regT3 };
    static_assert(noOverlap(metadataGPR, scopeGPR, bytecodeOffsetGPR), "Required for call to CTI thunk");
}

namespace GetFromScope {
    constexpr GPRReg metadataGPR { GPRInfo::regT4 };
    constexpr GPRReg scopeGPR { GPRInfo::regT2 };
    constexpr GPRReg bytecodeOffsetGPR { GPRInfo::regT3 };
    static_assert(noOverlap(metadataGPR, scopeGPR, bytecodeOffsetGPR), "Required for call to CTI thunk");
}

namespace PutToScope {
    constexpr GPRReg bytecodeOffsetGPR { GPRInfo::argumentGPR2 };
}

namespace GetById {
    // Registers used on both Fast and Slow paths
    constexpr JSValueRegs resultJSR { JSRInfo::returnValueJSR };
    constexpr JSValueRegs baseJSR { JSRInfo::returnValueJSR };

    // Fast path only registers
    namespace FastPath {
        constexpr GPRReg stubInfoGPR { GPRInfo::regT2 };
        constexpr GPRReg scratchGPR { GPRInfo::regT3 };
        constexpr JSValueRegs dontClobberJSR { JSRInfo::jsRegT54 };
        static_assert(noOverlap(baseJSR, stubInfoGPR, scratchGPR, dontClobberJSR), "Required for DataIC");
    }

    // Slow path only registers
    namespace SlowPath {
        constexpr GPRReg globalObjectGPR { GPRInfo::regT2 };
        constexpr GPRReg bytecodeOffsetGPR { globalObjectGPR };
        constexpr GPRReg stubInfoGPR { GPRInfo::regT3 };
        constexpr GPRReg propertyGPR { GPRInfo::regT4 };
        static_assert(noOverlap(baseJSR, bytecodeOffsetGPR, stubInfoGPR, propertyGPR), "Required for call to CTI thunk");
        static_assert(noOverlap(baseJSR, globalObjectGPR, stubInfoGPR, propertyGPR), "Required for call to slow operation");
    }
}

namespace GetByIdWithThis {
    // Registers used on both Fast and Slow paths
    constexpr JSValueRegs resultJSR { JSRInfo::returnValueJSR };
    constexpr JSValueRegs baseJSR { JSRInfo::jsRegT10 };
    constexpr JSValueRegs thisJSR { JSRInfo::jsRegT32 };

    // Fast path only registers
    namespace FastPath {
        constexpr GPRReg stubInfoGPR { GPRInfo::regT4 };
        constexpr GPRReg scratchGPR { GPRInfo::regT5 };
        static_assert(noOverlap(baseJSR, thisJSR, stubInfoGPR, scratchGPR), "Required for DataIC");
    }

    // Slow path only registers
    namespace SlowPath {
        constexpr GPRReg globalObjectGPR { GPRInfo::regT4 };
        constexpr GPRReg bytecodeOffsetGPR { globalObjectGPR };
        constexpr GPRReg stubInfoGPR { GPRInfo::regT5 };
        constexpr GPRReg propertyGPR {
#if USE(JSVALUE64)
            GPRInfo::regT1
#elif USE(JSVALUE32_64)
            GPRInfo::regT6
#endif
        };
        static_assert(noOverlap(baseJSR, thisJSR, bytecodeOffsetGPR, stubInfoGPR, propertyGPR), "Required for call to CTI thunk");
        static_assert(noOverlap(baseJSR, thisJSR, globalObjectGPR, stubInfoGPR, propertyGPR), "Required for call to slow operation");
    }
}

namespace GetByVal {
    // Registers used on both Fast and Slow paths
    constexpr JSValueRegs resultJSR { JSRInfo::returnValueJSR };
    constexpr JSValueRegs baseJSR { JSRInfo::jsRegT10 };
    constexpr JSValueRegs propertyJSR { JSRInfo::jsRegT32 };

    // Fast path only registers
    namespace FastPath {
        constexpr GPRReg stubInfoGPR { GPRInfo::regT4 };
        constexpr GPRReg scratchGPR { GPRInfo::regT5 };
        static_assert(noOverlap(baseJSR, propertyJSR, stubInfoGPR, scratchGPR), "Required for DataIC");
    }

    // Slow path only registers
    namespace SlowPath {
        constexpr GPRReg globalObjectGPR { GPRInfo::regT4 };
        constexpr GPRReg bytecodeOffsetGPR { globalObjectGPR };
        constexpr GPRReg stubInfoGPR { GPRInfo::regT5 };
        constexpr GPRReg profileGPR {
#if USE(JSVALUE64)
            GPRInfo::regT1
#elif USE(JSVALUE32_64)
            GPRInfo::regT6
#endif
        };
        static_assert(noOverlap(baseJSR, propertyJSR, bytecodeOffsetGPR, stubInfoGPR, profileGPR), "Required for call to CTI thunk");
        static_assert(noOverlap(baseJSR, propertyJSR, globalObjectGPR, stubInfoGPR, profileGPR), "Required for call to slow operation");
    }
}

#if USE(JSVALUE64)
namespace EnumeratorGetByVal {
    // We rely on using the same registers when linking a CodeBlock and initializing registers
    // for a GetByVal StubInfo.
    static constexpr JSValueRegs baseJSR { GetByVal::baseJSR };
    static constexpr JSValueRegs propertyJSR { GetByVal::propertyJSR };
    static constexpr JSValueRegs resultJSR { GetByVal::resultJSR };
    static constexpr GPRReg stubInfoGPR { GetByVal::FastPath::stubInfoGPR };
    static constexpr GPRReg scratch1 { GPRInfo::regT1 };
    static constexpr GPRReg scratch2 { GPRInfo::regT3 };
    static constexpr GPRReg scratch3 { GPRInfo::regT5 };
    static_assert(noOverlap(baseJSR, propertyJSR, stubInfoGPR, scratch1, scratch2, scratch3));
}
#endif

#if USE(JSVALUE64)
namespace GetByValWithThis {
    // Registers used on both Fast and Slow paths
    constexpr JSValueRegs resultJSR { JSRInfo::returnValueJSR };
    constexpr JSValueRegs baseJSR { GPRInfo::regT0 };
    constexpr JSValueRegs propertyJSR { GPRInfo::regT1 };
    constexpr JSValueRegs thisJSR { GPRInfo::regT2 };

    // Fast path only registers
    namespace FastPath {
        constexpr GPRReg stubInfoGPR { GPRInfo::regT3 };
        constexpr GPRReg scratchGPR { GPRInfo::regT5 };
        static_assert(noOverlap(baseJSR, propertyJSR, thisJSR, stubInfoGPR, scratchGPR), "Required for DataIC");
    }

    // Slow path only registers
    namespace SlowPath {
        constexpr GPRReg globalObjectGPR { GPRInfo::regT3 };
        constexpr GPRReg bytecodeOffsetGPR { globalObjectGPR };
        constexpr GPRReg stubInfoGPR { GPRInfo::regT4 };
        constexpr GPRReg profileGPR { GPRInfo::regT5 };
        static_assert(noOverlap(baseJSR, propertyJSR, thisJSR, bytecodeOffsetGPR, stubInfoGPR, profileGPR), "Required for call to CTI thunk");
        static_assert(noOverlap(baseJSR, propertyJSR, thisJSR, globalObjectGPR, stubInfoGPR, profileGPR), "Required for call to slow operation");
    }
}
#endif

namespace PutById {
    // Registers used on both Fast and Slow paths
    constexpr JSValueRegs baseJSR { JSRInfo::jsRegT10 };
    constexpr JSValueRegs valueJSR { JSRInfo::jsRegT32 };

    // Fast path only registers
    namespace FastPath {
        constexpr GPRReg stubInfoGPR { GPRInfo::regT4 };
        constexpr GPRReg scratchGPR { GPRInfo::regT5 };
        // Fine to use regT1, which also yields better code size on ARM_THUMB2
        constexpr GPRReg scratch2GPR { GPRInfo::regT1 };
        static_assert(noOverlap(baseJSR, valueJSR, stubInfoGPR, scratchGPR), "Required for DataIC");
        static_assert(noOverlap(baseJSR.payloadGPR(), valueJSR, stubInfoGPR, scratchGPR, scratch2GPR), "Required for DataIC");
    }

    // Slow path only registers
    namespace SlowPath {
        constexpr GPRReg globalObjectGPR {
#if USE(JSVALUE64)
            GPRInfo::regT1
#elif USE(JSVALUE32_64)
            GPRInfo::regT6
#endif
        };
        constexpr GPRReg bytecodeOffsetGPR { globalObjectGPR };
        constexpr GPRReg stubInfoGPR { GPRInfo::regT4 };
        constexpr GPRReg propertyGPR { GPRInfo::regT5 };

        static_assert(noOverlap(baseJSR, valueJSR, bytecodeOffsetGPR, stubInfoGPR, propertyGPR), "Required for call to CTI thunk");
        static_assert(noOverlap(baseJSR, valueJSR, globalObjectGPR, stubInfoGPR, propertyGPR), "Required for call to slow operation");
    }
}

namespace PutByVal {
    constexpr JSValueRegs baseJSR { JSRInfo::jsRegT10 };
    constexpr JSValueRegs propertyJSR { JSRInfo::jsRegT32 };
    constexpr JSValueRegs valueJSR { JSRInfo::jsRegT54 };
    constexpr GPRReg profileGPR {
#if USE(JSVALUE64)
        GPRInfo::regT1
#elif USE(JSVALUE32_64)
        GPRInfo::regT6
#endif
    };
    constexpr GPRReg stubInfoGPR {
#if USE(JSVALUE64)
        GPRInfo::regT3
#elif USE(JSVALUE32_64)
        GPRInfo::regT7
#endif
    };

    static_assert(noOverlap(baseJSR, propertyJSR, valueJSR, profileGPR, stubInfoGPR), "Required for DataIC");

    // Slow path only registers
    namespace SlowPath {
        constexpr GPRReg globalObjectGPR {
#if USE(JSVALUE64)
            GPRInfo::regT5
#elif CPU(ARM_THUMB2)
            // We are a bit short on registers on ARM_THUMB2, but we can just about get away with this
            MacroAssemblerARMv7::s_scratchRegister
#else // Other JSVALUE32_64
            GPRInfo::regT8
#endif
        };
        constexpr GPRReg bytecodeOffsetGPR { globalObjectGPR };
        static_assert(noOverlap(baseJSR, propertyJSR, valueJSR, profileGPR, bytecodeOffsetGPR, stubInfoGPR), "Required for call to CTI thunk");
        static_assert(noOverlap(baseJSR, propertyJSR, valueJSR, profileGPR, globalObjectGPR, stubInfoGPR), "Required for call to slow operation");
    }
}

#if USE(JSVALUE64)
namespace EnumeratorPutByVal {
    // We rely on using the same registers when linking a CodeBlock and initializing registers
    // for a PutByVal StubInfo.
    static constexpr JSValueRegs baseJSR { PutByVal::baseJSR };
    static constexpr JSValueRegs propertyJSR { PutByVal::propertyJSR };
    static constexpr JSValueRegs valueJSR { PutByVal::valueJSR };
    static constexpr GPRReg profileGPR { PutByVal::profileGPR };
    static constexpr GPRReg stubInfoGPR { PutByVal::stubInfoGPR };
    static constexpr GPRReg scratch1 { GPRInfo::regT5 };
    static_assert(noOverlap(baseJSR, propertyJSR, valueJSR, stubInfoGPR, scratch1));
}
#endif

namespace InById {
    constexpr JSValueRegs baseJSR { GetById::baseJSR };
    constexpr JSValueRegs resultJSR { JSRInfo::returnValueJSR };
    constexpr GPRReg stubInfoGPR { GetById::FastPath::stubInfoGPR };
    constexpr GPRReg scratchGPR { GetById::FastPath::scratchGPR };
}

namespace InByVal {
    constexpr JSValueRegs resultJSR { JSRInfo::returnValueJSR };
    constexpr JSValueRegs baseJSR { JSRInfo::jsRegT10 };
    constexpr JSValueRegs propertyJSR { JSRInfo::jsRegT32 };
    constexpr GPRReg stubInfoGPR { GPRInfo::regT4 };
    constexpr GPRReg scratchGPR { GPRInfo::regT5 };
    static_assert(baseJSR == GetByVal::baseJSR);
    static_assert(propertyJSR == GetByVal::propertyJSR);
}

namespace DelById {
    // Registers used on both Fast and Slow paths
    constexpr JSValueRegs baseJSR { JSRInfo::jsRegT32 };

    // Fast path only registers
    namespace FastPath {
        constexpr JSValueRegs resultJSR { JSRInfo::returnValueJSR };
        constexpr GPRReg stubInfoGPR { GPRInfo::regT4 };
        static_assert(noOverlap(baseJSR, stubInfoGPR), "Required for DataIC");
    }

    // Slow path only registers
    namespace SlowPath {
        constexpr GPRReg globalObjectGPR { GPRInfo::regT0 };
        constexpr GPRReg bytecodeOffsetGPR { globalObjectGPR };
        constexpr GPRReg stubInfoGPR { GPRInfo::regT1 };
        constexpr GPRReg propertyGPR { GPRInfo::regT4 };
        constexpr GPRReg ecmaModeGPR { GPRInfo::regT5 };
        static_assert(noOverlap(baseJSR, bytecodeOffsetGPR, stubInfoGPR, propertyGPR, ecmaModeGPR), "Required for call to CTI thunk");
        static_assert(noOverlap(baseJSR, globalObjectGPR, stubInfoGPR, propertyGPR, ecmaModeGPR), "Required for call to slow operation");
    }
}

namespace DelByVal {
    // Registers used on both Fast and Slow paths
    constexpr JSValueRegs baseJSR { JSRInfo::jsRegT32 };
    constexpr JSValueRegs propertyJSR { JSRInfo::jsRegT10 };

    // Fast path only registers
    namespace FastPath {
        constexpr JSValueRegs resultJSR { JSRInfo::returnValueJSR };
        constexpr GPRReg stubInfoGPR { GPRInfo::regT4 };
        static_assert(noOverlap(baseJSR, propertyJSR, stubInfoGPR), "Required for DataIC");
    }

    // Slow path only registers
    namespace SlowPath {
        constexpr GPRReg globalObjectGPR { GPRInfo::regT4 };
        constexpr GPRReg bytecodeOffsetGPR { globalObjectGPR };
        constexpr GPRReg stubInfoGPR { GPRInfo::regT5 };
        constexpr GPRReg ecmaModeGPR {
#if USE(JSVALUE64)
            GPRInfo::regT1
#elif USE(JSVALUE32_64)
            GPRInfo::regT6
#endif
        };
        static_assert(noOverlap(baseJSR, propertyJSR, bytecodeOffsetGPR, stubInfoGPR, ecmaModeGPR), "Required for call to CTI thunk");
        static_assert(noOverlap(baseJSR, propertyJSR, globalObjectGPR, stubInfoGPR, ecmaModeGPR), "Required for call to slow operation");
    }
}

namespace PrivateBrand {
    constexpr JSValueRegs baseJSR { GetByVal::baseJSR }; // Required by shared slow path thunk
    constexpr JSValueRegs brandJSR { GetByVal::propertyJSR }; // Required by shared slow path thunk

    namespace FastPath {
        constexpr GPRReg stubInfoGPR { GetByVal::FastPath::stubInfoGPR };
        static_assert(noOverlap(baseJSR, brandJSR, stubInfoGPR), "Required for DataIC");
    }

    namespace SlowPath {
        constexpr GPRReg bytecodeOffsetGPR { GetByVal::SlowPath::bytecodeOffsetGPR }; // Required by shared slow path thunk
        constexpr GPRReg stubInfoGPR { GetByVal::SlowPath::stubInfoGPR }; // Required by shared slow path thunk
        static_assert(noOverlap(baseJSR, brandJSR, bytecodeOffsetGPR, stubInfoGPR), "Required for call to CTI thunk");
    }
}

} // namespace BaselineJITRegisters

} // namespace JSC

#endif // ENABLE(JIT)