| 1 |
/* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 2 -*- |
| 2 |
* vim: set ts=8 sts=2 et sw=2 tw=80: |
| 3 |
* This Source Code Form is subject to the terms of the Mozilla Public |
| 4 |
* License, v. 2.0. If a copy of the MPL was not distributed with this |
| 5 |
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */ |
| 6 |
|
| 7 |
#ifndef jit_MacroAssembler_h |
| 8 |
#define jit_MacroAssembler_h |
| 9 |
|
| 10 |
#include "mozilla/EndianUtils.h" |
| 11 |
#include "mozilla/MacroForEach.h" |
| 12 |
#include "mozilla/MathAlgorithms.h" |
| 13 |
#include "mozilla/Maybe.h" |
| 14 |
#include "mozilla/Variant.h" |
| 15 |
|
| 16 |
#include <utility> |
| 17 |
|
| 18 |
#if defined(JS_CODEGEN_X86) |
| 19 |
# include "jit/x86/MacroAssembler-x86.h" |
| 20 |
#elif defined(JS_CODEGEN_X64) |
| 21 |
# include "jit/x64/MacroAssembler-x64.h" |
| 22 |
#elif defined(JS_CODEGEN_ARM) |
| 23 |
# include "jit/arm/MacroAssembler-arm.h" |
| 24 |
#elif defined(JS_CODEGEN_ARM64) |
| 25 |
# include "jit/arm64/MacroAssembler-arm64.h" |
| 26 |
#elif defined(JS_CODEGEN_MIPS64) |
| 27 |
# include "jit/mips64/MacroAssembler-mips64.h" |
| 28 |
#elif defined(JS_CODEGEN_LOONG64) |
| 29 |
# include "jit/loong64/MacroAssembler-loong64.h" |
| 30 |
#elif defined(JS_CODEGEN_RISCV64) |
| 31 |
# include "jit/riscv64/MacroAssembler-riscv64.h" |
| 32 |
#elif defined(JS_CODEGEN_WASM32) |
| 33 |
# include "jit/wasm32/MacroAssembler-wasm32.h" |
| 34 |
#elif defined(JS_CODEGEN_NONE) |
| 35 |
# include "jit/none/MacroAssembler-none.h" |
| 36 |
#else |
| 37 |
# error "Unknown architecture!" |
| 38 |
#endif |
| 39 |
#include "jit/ABIArgGenerator.h" |
| 40 |
#include "jit/ABIFunctions.h" |
| 41 |
#include "jit/AtomicOp.h" |
| 42 |
#include "jit/IonTypes.h" |
| 43 |
#include "jit/MoveResolver.h" |
| 44 |
#include "jit/VMFunctions.h" |
| 45 |
#include "js/ScalarType.h" // js::Scalar::Type |
| 46 |
#include "util/Memory.h" |
| 47 |
#include "vm/FunctionFlags.h" |
| 48 |
#include "vm/Opcodes.h" |
| 49 |
#include "vm/RealmFuses.h" |
| 50 |
#include "wasm/WasmAnyRef.h" |
| 51 |
|
| 52 |
// [SMDOC] MacroAssembler multi-platform overview |
| 53 |
// |
| 54 |
// * How to read/write MacroAssembler method declarations: |
| 55 |
// |
| 56 |
// The following macros are made to avoid #ifdef around each method declarations |
| 57 |
// of the Macro Assembler, and they are also used as an hint on the location of |
| 58 |
// the implementations of each method. For example, the following declaration |
| 59 |
// |
| 60 |
// void Pop(FloatRegister t) DEFINED_ON(x86_shared, arm); |
| 61 |
// |
| 62 |
// suggests the MacroAssembler::Pop(FloatRegister) method is implemented in |
| 63 |
// x86-shared/MacroAssembler-x86-shared.h, and also in arm/MacroAssembler-arm.h. |
| 64 |
// |
| 65 |
// - If there is no annotation, then there is only one generic definition in |
| 66 |
// MacroAssembler.cpp. |
| 67 |
// |
| 68 |
// - If the declaration is "inline", then the method definition(s) would be in |
| 69 |
// the "-inl.h" variant of the same file(s). |
| 70 |
// |
| 71 |
// The script check_macroassembler_style.py (which runs on every build) is |
| 72 |
// used to verify that method definitions match the annotation on the method |
| 73 |
// declarations. If there is any difference, then you either forgot to define |
| 74 |
// the method in one of the macro assembler, or you forgot to update the |
| 75 |
// annotation of the macro assembler declaration. |
| 76 |
// |
| 77 |
// Some convenient short-cuts are used to avoid repeating the same list of |
| 78 |
// architectures on each method declaration, such as PER_ARCH and |
| 79 |
// PER_SHARED_ARCH. |
| 80 |
// |
| 81 |
// Functions that are architecture-agnostic and are the same for all |
| 82 |
// architectures, that it's necessary to define inline *in this header* to |
| 83 |
// avoid used-before-defined warnings/errors that would occur if the |
| 84 |
// definitions were in MacroAssembler-inl.h, should use the OOL_IN_HEADER |
| 85 |
// marker at end of the declaration: |
| 86 |
// |
| 87 |
// inline uint32_t framePushed() const OOL_IN_HEADER; |
| 88 |
// |
| 89 |
// Such functions should then be defined immediately after MacroAssembler's |
| 90 |
// definition, for example: |
| 91 |
// |
| 92 |
// //{{{ check_macroassembler_style |
| 93 |
// inline uint32_t |
| 94 |
// MacroAssembler::framePushed() const |
| 95 |
// { |
| 96 |
// return framePushed_; |
| 97 |
// } |
| 98 |
// ////}}} check_macroassembler_style |
| 99 |
|
| 100 |
#define ALL_ARCH mips64, arm, arm64, x86, x64, loong64, riscv64, wasm32 |
| 101 |
#define ALL_SHARED_ARCH arm, arm64, loong64, mips64, riscv64, x86_shared, wasm32 |
| 102 |
|
| 103 |
// * How this macro works: |
| 104 |
// |
| 105 |
// DEFINED_ON is a macro which check if, for the current architecture, the |
| 106 |
// method is defined on the macro assembler or not. |
| 107 |
// |
| 108 |
// For each architecture, we have a macro named DEFINED_ON_arch. This macro is |
| 109 |
// empty if this is not the current architecture. Otherwise it must be either |
| 110 |
// set to "define" or "crash" (only used for the none target so far). |
| 111 |
// |
| 112 |
// The DEFINED_ON macro maps the list of architecture names given as arguments |
| 113 |
// to a list of macro names. For example, |
| 114 |
// |
| 115 |
// DEFINED_ON(arm, x86_shared) |
| 116 |
// |
| 117 |
// is expanded to |
| 118 |
// |
| 119 |
// DEFINED_ON_none DEFINED_ON_arm DEFINED_ON_x86_shared |
| 120 |
// |
| 121 |
// which are later expanded on ARM, x86, x64 by DEFINED_ON_EXPAND_ARCH_RESULTS |
| 122 |
// to |
| 123 |
// |
| 124 |
// define |
| 125 |
// |
| 126 |
// or if the JIT is disabled or set to no architecture to |
| 127 |
// |
| 128 |
// crash |
| 129 |
// |
| 130 |
// or to nothing, if the current architecture is not listed in the list of |
| 131 |
// arguments of DEFINED_ON. Note, only one of the DEFINED_ON_arch macro |
| 132 |
// contributes to the non-empty result, which is the macro of the current |
| 133 |
// architecture if it is listed in the arguments of DEFINED_ON. |
| 134 |
// |
| 135 |
// This result is appended to DEFINED_ON_RESULT_ before expanding the macro, |
| 136 |
// which results in either no annotation, a MOZ_CRASH(), or a "= delete" |
| 137 |
// annotation on the method declaration. |
| 138 |
|
| 139 |
#define DEFINED_ON_x86 |
| 140 |
#define DEFINED_ON_x64 |
| 141 |
#define DEFINED_ON_x86_shared |
| 142 |
#define DEFINED_ON_arm |
| 143 |
#define DEFINED_ON_arm64 |
| 144 |
#define DEFINED_ON_mips64 |
| 145 |
#define DEFINED_ON_loong64 |
| 146 |
#define DEFINED_ON_riscv64 |
| 147 |
#define DEFINED_ON_wasm32 |
| 148 |
#define DEFINED_ON_none |
| 149 |
|
| 150 |
// Specialize for each architecture. |
| 151 |
#if defined(JS_CODEGEN_X86) |
| 152 |
# undef DEFINED_ON_x86 |
| 153 |
# define DEFINED_ON_x86 define |
| 154 |
# undef DEFINED_ON_x86_shared |
| 155 |
# define DEFINED_ON_x86_shared define |
| 156 |
#elif defined(JS_CODEGEN_X64) |
| 157 |
# undef DEFINED_ON_x64 |
| 158 |
# define DEFINED_ON_x64 define |
| 159 |
# undef DEFINED_ON_x86_shared |
| 160 |
# define DEFINED_ON_x86_shared define |
| 161 |
#elif defined(JS_CODEGEN_ARM) |
| 162 |
# undef DEFINED_ON_arm |
| 163 |
# define DEFINED_ON_arm define |
| 164 |
#elif defined(JS_CODEGEN_ARM64) |
| 165 |
# undef DEFINED_ON_arm64 |
| 166 |
# define DEFINED_ON_arm64 define |
| 167 |
#elif defined(JS_CODEGEN_MIPS64) |
| 168 |
# undef DEFINED_ON_mips64 |
| 169 |
# define DEFINED_ON_mips64 define |
| 170 |
#elif defined(JS_CODEGEN_LOONG64) |
| 171 |
# undef DEFINED_ON_loong64 |
| 172 |
# define DEFINED_ON_loong64 define |
| 173 |
#elif defined(JS_CODEGEN_RISCV64) |
| 174 |
# undef DEFINED_ON_riscv64 |
| 175 |
# define DEFINED_ON_riscv64 define |
| 176 |
#elif defined(JS_CODEGEN_WASM32) |
| 177 |
# undef DEFINED_ON_wasm32 |
| 178 |
# define DEFINED_ON_wasm32 define |
| 179 |
#elif defined(JS_CODEGEN_NONE) |
| 180 |
# undef DEFINED_ON_none |
| 181 |
# define DEFINED_ON_none crash |
| 182 |
#else |
| 183 |
# error "Unknown architecture!" |
| 184 |
#endif |
| 185 |
|
| 186 |
#define DEFINED_ON_RESULT_crash \ |
| 187 |
{ \ |
| 188 |
MOZ_CRASH(); \ |
| 189 |
} |
| 190 |
#define DEFINED_ON_RESULT_define |
| 191 |
#define DEFINED_ON_RESULT_ = delete |
| 192 |
|
| 193 |
#define DEFINED_ON_DISPATCH_RESULT_2(Macro, Result) Macro##Result |
| 194 |
#define DEFINED_ON_DISPATCH_RESULT(...) \ |
| 195 |
DEFINED_ON_DISPATCH_RESULT_2(DEFINED_ON_RESULT_, __VA_ARGS__) |
| 196 |
|
| 197 |
// We need to let the evaluation of MOZ_FOR_EACH terminates. |
| 198 |
#define DEFINED_ON_EXPAND_ARCH_RESULTS_3(ParenResult) \ |
| 199 |
DEFINED_ON_DISPATCH_RESULT ParenResult |
| 200 |
#define DEFINED_ON_EXPAND_ARCH_RESULTS_2(ParenResult) \ |
| 201 |
DEFINED_ON_EXPAND_ARCH_RESULTS_3(ParenResult) |
| 202 |
#define DEFINED_ON_EXPAND_ARCH_RESULTS(ParenResult) \ |
| 203 |
DEFINED_ON_EXPAND_ARCH_RESULTS_2(ParenResult) |
| 204 |
|
| 205 |
#define DEFINED_ON_FWDARCH(Arch) DEFINED_ON_##Arch |
| 206 |
#define DEFINED_ON_MAP_ON_ARCHS(ArchList) \ |
| 207 |
DEFINED_ON_EXPAND_ARCH_RESULTS( \ |
| 208 |
(MOZ_FOR_EACH(DEFINED_ON_FWDARCH, (), ArchList))) |
| 209 |
|
| 210 |
#define DEFINED_ON(...) DEFINED_ON_MAP_ON_ARCHS((none, __VA_ARGS__)) |
| 211 |
|
| 212 |
#define PER_ARCH DEFINED_ON(ALL_ARCH) |
| 213 |
#define PER_SHARED_ARCH DEFINED_ON(ALL_SHARED_ARCH) |
| 214 |
#define OOL_IN_HEADER |
| 215 |
|
| 216 |
class JSLinearString; |
| 217 |
|
| 218 |
namespace JS { |
| 219 |
struct ExpandoAndGeneration; |
| 220 |
} |
| 221 |
|
| 222 |
namespace js { |
| 223 |
|
| 224 |
class StaticStrings; |
| 225 |
class FixedLengthTypedArrayObject; |
| 226 |
|
| 227 |
enum class NativeIteratorIndices : uint32_t; |
| 228 |
|
| 229 |
namespace wasm { |
| 230 |
class CalleeDesc; |
| 231 |
class CallSiteDesc; |
| 232 |
class BytecodeOffset; |
| 233 |
class MemoryAccessDesc; |
| 234 |
|
| 235 |
enum class FailureMode : uint8_t; |
| 236 |
enum class SimdOp; |
| 237 |
enum class SymbolicAddress; |
| 238 |
enum class Trap; |
| 239 |
} // namespace wasm |
| 240 |
|
| 241 |
namespace jit { |
| 242 |
|
| 243 |
// Defined in JitFrames.h |
| 244 |
enum class ExitFrameType : uint8_t; |
| 245 |
|
| 246 |
class AutoSaveLiveRegisters; |
| 247 |
class CompileZone; |
| 248 |
class TemplateNativeObject; |
| 249 |
class TemplateObject; |
| 250 |
|
| 251 |
enum class CheckUnsafeCallWithABI { |
| 252 |
// Require the callee to use AutoUnsafeCallWithABI. |
| 253 |
Check, |
| 254 |
|
| 255 |
// We pushed an exit frame so this callWithABI can safely GC and walk the |
| 256 |
// stack. |
| 257 |
DontCheckHasExitFrame, |
| 258 |
|
| 259 |
// Don't check this callWithABI uses AutoUnsafeCallWithABI, for instance |
| 260 |
// because we're calling a simple helper function (like malloc or js_free) |
| 261 |
// that we can't change and/or that we know won't GC. |
| 262 |
DontCheckOther, |
| 263 |
}; |
| 264 |
|
| 265 |
// This is a global function made to create the DynFn type in a controlled |
| 266 |
// environment which would check if the function signature has been registered |
| 267 |
// as an ABI function signature. |
| 268 |
template <typename Sig> |
| 269 |
static inline DynFn DynamicFunction(Sig fun); |
| 270 |
|
| 271 |
enum class CharEncoding { Latin1, TwoByte }; |
| 272 |
|
| 273 |
constexpr uint32_t WasmCallerInstanceOffsetBeforeCall = |
| 274 |
wasm::FrameWithInstances::callerInstanceOffsetWithoutFrame(); |
| 275 |
constexpr uint32_t WasmCalleeInstanceOffsetBeforeCall = |
| 276 |
wasm::FrameWithInstances::calleeInstanceOffsetWithoutFrame(); |
| 277 |
|
| 278 |
// Allocation sites may be passed to GC thing allocation methods either via a |
| 279 |
// register (for baseline compilation) or an enum indicating one of the |
| 280 |
// catch-all allocation sites (for optimized compilation). |
| 281 |
struct AllocSiteInput |
| 282 |
: public mozilla::Variant<Register, gc::CatchAllAllocSite> { |
| 283 |
using Base = mozilla::Variant<Register, gc::CatchAllAllocSite>; |
| 284 |
AllocSiteInput() : Base(gc::CatchAllAllocSite::Unknown) {} |
| 285 |
explicit AllocSiteInput(gc::CatchAllAllocSite catchAll) : Base(catchAll) {} |
| 286 |
explicit AllocSiteInput(Register reg) : Base(reg) {} |
| 287 |
}; |
| 288 |
|
| 289 |
// Instance slots (including ShadowStackArea) and arguments size information |
| 290 |
// from two neighboring frames. |
| 291 |
// Used in Wasm tail calls to remove frame. |
| 292 |
struct ReturnCallAdjustmentInfo { |
| 293 |
uint32_t newSlotsAndStackArgBytes; |
| 294 |
uint32_t oldSlotsAndStackArgBytes; |
| 295 |
|
| 296 |
ReturnCallAdjustmentInfo(uint32_t newSlotsAndStackArgBytes, |
| 297 |
uint32_t oldSlotsAndStackArgBytes) |
| 298 |
: newSlotsAndStackArgBytes(newSlotsAndStackArgBytes), |
| 299 |
oldSlotsAndStackArgBytes(oldSlotsAndStackArgBytes) {} |
| 300 |
}; |
| 301 |
|
| 302 |
struct BranchWasmRefIsSubtypeRegisters { |
| 303 |
bool needSuperSTV; |
| 304 |
bool needScratch1; |
| 305 |
bool needScratch2; |
| 306 |
}; |
| 307 |
|
| 308 |
// [SMDOC] Code generation invariants (incomplete) |
| 309 |
// |
| 310 |
// ## 64-bit GPRs carrying 32-bit values |
| 311 |
// |
| 312 |
// At least at the end of every JS or Wasm operation (= SpiderMonkey bytecode or |
| 313 |
// Wasm bytecode; this is necessarily a little vague), if a 64-bit GPR has a |
| 314 |
// 32-bit value, then the upper 32 bits of the register may be predictable in |
| 315 |
// accordance with platform-specific rules, as follows. |
| 316 |
// |
| 317 |
// - On x64 and arm64, the upper bits are zero |
| 318 |
// - On mips64 and loongarch64 the upper bits are the sign extension of the |
| 319 |
// lower bits |
| 320 |
// - (On risc-v we have no rule, having no port yet. Sign extension is the most |
| 321 |
// likely rule, but "unpredictable" is an option.) |
| 322 |
// |
| 323 |
// In most cases no extra work needs to be done to maintain the invariant: |
| 324 |
// |
| 325 |
// - 32-bit operations on x64 and arm64 zero-extend the result to 64 bits. |
| 326 |
// These operations ignore the upper bits of the inputs. |
| 327 |
// - 32-bit operations on mips64 sign-extend the result to 64 bits (even many |
| 328 |
// that are labeled as "unsigned", eg ADDU, though not all, eg LU). |
| 329 |
// Additionally, the inputs to many 32-bit operations must be properly |
| 330 |
// sign-extended to avoid "unpredictable" behavior, and our simulators check |
| 331 |
// that inputs conform. |
| 332 |
// - (32-bit operations on risc-v and loongarch64 sign-extend, much as mips, but |
| 333 |
// appear to ignore the upper bits of the inputs.) |
| 334 |
// |
| 335 |
// The upshot of these invariants is, among other things, that: |
| 336 |
// |
| 337 |
// - No code needs to be generated when a 32-bit value is extended to 64 bits |
| 338 |
// or a 64-bit value is wrapped to 32 bits, if the upper bits are known to be |
| 339 |
// correct because they resulted from an operation that produced them |
| 340 |
// predictably. |
| 341 |
// - Literal loads must be careful to avoid instructions that might extend the |
| 342 |
// literal in the wrong way. |
| 343 |
// - Code that produces values using intermediate values with non-canonical |
| 344 |
// extensions must extend according to platform conventions before being |
| 345 |
// "done". |
| 346 |
// |
| 347 |
// All optimizations are necessarily platform-specific and should only be used |
| 348 |
// in platform-specific code. We may add architectures in the future that do |
| 349 |
// not follow the patterns of the few architectures we already have. |
| 350 |
// |
| 351 |
// Also see MacroAssembler::debugAssertCanonicalInt32(). |
| 352 |
|
| 353 |
// The public entrypoint for emitting assembly. Note that a MacroAssembler can |
| 354 |
// use cx->lifoAlloc, so take care not to interleave masm use with other |
| 355 |
// lifoAlloc use if one will be destroyed before the other. |
| 356 |
class MacroAssembler : public MacroAssemblerSpecific { |
| 357 |
private: |
| 358 |
// Information about the current JSRuntime. This is nullptr only for Wasm |
| 359 |
// compilations. |
| 360 |
CompileRuntime* maybeRuntime_ = nullptr; |
| 361 |
|
| 362 |
// Information about the current Realm. This is nullptr for Wasm compilations |
| 363 |
// and when compiling JitRuntime trampolines. |
| 364 |
CompileRealm* maybeRealm_ = nullptr; |
| 365 |
|
| 366 |
// Labels for handling exceptions and failures. |
| 367 |
NonAssertingLabel failureLabel_; |
| 368 |
|
| 369 |
protected: |
| 370 |
// Constructor is protected. Use one of the derived classes! |
| 371 |
explicit MacroAssembler(TempAllocator& alloc, |
| 372 |
CompileRuntime* maybeRuntime = nullptr, |
| 373 |
CompileRealm* maybeRealm = nullptr); |
| 374 |
|
| 375 |
public: |
| 376 |
MoveResolver& moveResolver() { |
| 377 |
// As an optimization, the MoveResolver is a persistent data structure |
| 378 |
// shared between visitors in the CodeGenerator. This assertion |
| 379 |
// checks that state is not leaking from visitor to visitor |
| 380 |
// via an unresolved addMove(). |
| 381 |
MOZ_ASSERT(moveResolver_.hasNoPendingMoves()); |
| 382 |
return moveResolver_; |
| 383 |
} |
| 384 |
|
| 385 |
size_t instructionsSize() const { return size(); } |
| 386 |
|
| 387 |
CompileRealm* realm() const { |
| 388 |
MOZ_ASSERT(maybeRealm_); |
| 389 |
return maybeRealm_; |
| 390 |
} |
| 391 |
CompileRuntime* runtime() const { |
| 392 |
MOZ_ASSERT(maybeRuntime_); |
| 393 |
return maybeRuntime_; |
| 394 |
} |
| 395 |
|
| 396 |
#ifdef JS_HAS_HIDDEN_SP |
| 397 |
void Push(RegisterOrSP reg); |
| 398 |
#endif |
| 399 |
|
| 400 |
#ifdef ENABLE_WASM_SIMD |
| 401 |
// `op` should be a shift operation. Return true if a variable-width shift |
| 402 |
// operation on this architecture should pre-mask the shift count, and if so, |
| 403 |
// return the mask in `*mask`. |
| 404 |
static bool MustMaskShiftCountSimd128(wasm::SimdOp op, int32_t* mask); |
| 405 |
#endif |
| 406 |
|
| 407 |
//{{{ check_macroassembler_decl_style |
| 408 |
public: |
| 409 |
// =============================================================== |
| 410 |
// MacroAssembler high-level usage. |
| 411 |
|
| 412 |
// Flushes the assembly buffer, on platforms that need it. |
| 413 |
void flush() PER_SHARED_ARCH; |
| 414 |
|
| 415 |
// Add a comment that is visible in the pretty printed assembly code. |
| 416 |
void comment(const char* msg) PER_SHARED_ARCH; |
| 417 |
|
| 418 |
// =============================================================== |
| 419 |
// Frame manipulation functions. |
| 420 |
|
| 421 |
inline uint32_t framePushed() const OOL_IN_HEADER; |
| 422 |
inline void setFramePushed(uint32_t framePushed) OOL_IN_HEADER; |
| 423 |
inline void adjustFrame(int32_t value) OOL_IN_HEADER; |
| 424 |
|
| 425 |
// Adjust the frame, to account for implicit modification of the stack |
| 426 |
// pointer, such that callee can remove arguments on the behalf of the |
| 427 |
// caller. |
| 428 |
inline void implicitPop(uint32_t bytes) OOL_IN_HEADER; |
| 429 |
|
| 430 |
private: |
| 431 |
// This field is used to statically (at compilation time) emulate a frame |
| 432 |
// pointer by keeping track of stack manipulations. |
| 433 |
// |
| 434 |
// It is maintained by all stack manipulation functions below. |
| 435 |
uint32_t framePushed_; |
| 436 |
|
| 437 |
public: |
| 438 |
// =============================================================== |
| 439 |
// Stack manipulation functions -- sets of registers. |
| 440 |
|
| 441 |
// Approximately speaking, the following routines must use the same memory |
| 442 |
// layout. Any inconsistencies will certainly lead to crashing in generated |
| 443 |
// code: |
| 444 |
// |
| 445 |
// MacroAssembler::PushRegsInMaskSizeInBytes |
| 446 |
// MacroAssembler::PushRegsInMask |
| 447 |
// MacroAssembler::storeRegsInMask |
| 448 |
// MacroAssembler::PopRegsInMask |
| 449 |
// MacroAssembler::PopRegsInMaskIgnore |
| 450 |
// FloatRegister::getRegisterDumpOffsetInBytes |
| 451 |
// (no class) PushRegisterDump |
| 452 |
// (union) RegisterContent |
| 453 |
// JitRuntime::generateInvalidator |
| 454 |
// JitRuntime::generateBailoutHandler |
| 455 |
// JSJitFrameIter::machineState |
| 456 |
// |
| 457 |
// To be more exact, the invariants are: |
| 458 |
// |
| 459 |
// * The save area is conceptually viewed as starting at a highest address |
| 460 |
// (really, at "highest address - 1") and working down to some lower |
| 461 |
// address. |
| 462 |
// |
| 463 |
// * PushRegsInMask, storeRegsInMask and PopRegsInMask{Ignore} must use |
| 464 |
// exactly the same memory layout, when starting from the abovementioned |
| 465 |
// highest address. |
| 466 |
// |
| 467 |
// * PushRegsInMaskSizeInBytes must produce a value which is exactly equal |
| 468 |
// to the change in the machine's stack pointer register as a result of |
| 469 |
// calling PushRegsInMask or PopRegsInMask{Ignore}. This value must be at |
| 470 |
// least uintptr_t-aligned on the target, and may be more aligned than that. |
| 471 |
// |
| 472 |
// * PushRegsInMaskSizeInBytes must produce a value which is greater than or |
| 473 |
// equal to the amount of space used by storeRegsInMask. |
| 474 |
// |
| 475 |
// * Hence, regardless of whether the save area is created with |
| 476 |
// storeRegsInMask or PushRegsInMask, it is guaranteed to fit inside an |
| 477 |
// area of size calculated by PushRegsInMaskSizeInBytes. |
| 478 |
// |
| 479 |
// * For the `ignore` argument of PopRegsInMaskIgnore, equality checking |
| 480 |
// for the floating point/SIMD registers is done on the basis of the |
| 481 |
// underlying physical register, regardless of width. For example, if the |
| 482 |
// to-restore set contains v17 (the SIMD register with encoding 17) and |
| 483 |
// the ignore set contains d17 (the double register with encoding 17) then |
| 484 |
// no part of the physical register with encoding 17 will be restored. |
| 485 |
// (This is probably not true on arm32, since that has aliased float32 |
| 486 |
// registers; but none of our other targets do.) |
| 487 |
// |
| 488 |
// * {Push,store}RegsInMask/storeRegsInMask are further constrained as |
| 489 |
// follows: when given the argument AllFloatRegisters, the resulting |
| 490 |
// memory area must contain exactly all the SIMD/FP registers for the |
| 491 |
// target at their widest width (that we care about). [We have no targets |
| 492 |
// where the SIMD registers and FP register sets are disjoint.] They must |
| 493 |
// be packed end-to-end with no holes, with the register with the lowest |
| 494 |
// encoding number (0), as returned by FloatRegister::encoding(), at the |
| 495 |
// abovementioned highest address, register 1 just below that, etc. |
| 496 |
// |
| 497 |
// Furthermore the sizeof(RegisterContent) must equal the size of a SIMD |
| 498 |
// register in the abovementioned array. |
| 499 |
// |
| 500 |
// Furthermore the value returned by |
| 501 |
// FloatRegister::getRegisterDumpOffsetInBytes must be a correct index |
| 502 |
// into the abovementioned array. Given the constraints, the only correct |
| 503 |
// value is `reg.encoding() * sizeof(RegisterContent)`. |
| 504 |
// |
| 505 |
// Note that some of the routines listed above are JS-only, and do not support |
| 506 |
// SIMD registers. They are otherwise part of the same equivalence class. |
| 507 |
// Register spilling for e.g. OOL VM calls is implemented using |
| 508 |
// PushRegsInMask, and recovered on bailout using machineState. This requires |
| 509 |
// the same layout to be used in machineState, and therefore in all other code |
| 510 |
// that can spill registers that are recovered on bailout. Implementations of |
| 511 |
// JitRuntime::generate{Invalidator,BailoutHandler} should either call |
| 512 |
// PushRegsInMask, or check carefully to be sure that they generate the same |
| 513 |
// layout. |
| 514 |
|
| 515 |
// The size of the area used by PushRegsInMask. |
| 516 |
static size_t PushRegsInMaskSizeInBytes(LiveRegisterSet set) PER_SHARED_ARCH; |
| 517 |
|
| 518 |
void PushRegsInMask(LiveRegisterSet set) PER_SHARED_ARCH; |
| 519 |
void PushRegsInMask(LiveGeneralRegisterSet set); |
| 520 |
|
| 521 |
// Like PushRegsInMask, but instead of pushing the registers, store them to |
| 522 |
// |dest|. |dest| should point to the end of the reserved space, so the |
| 523 |
// first register will be stored at |dest.offset - sizeof(register)|. It is |
| 524 |
// required that |dest.offset| is at least as large as the value computed by |
| 525 |
// PushRegsInMaskSizeInBytes for this |set|. In other words, |dest.base| |
| 526 |
// must point to either the lowest address in the save area, or some address |
| 527 |
// below that. |
| 528 |
void storeRegsInMask(LiveRegisterSet set, Address dest, |
| 529 |
Register scratch) PER_SHARED_ARCH; |
| 530 |
|
| 531 |
void PopRegsInMask(LiveRegisterSet set); |
| 532 |
void PopRegsInMask(LiveGeneralRegisterSet set); |
| 533 |
void PopRegsInMaskIgnore(LiveRegisterSet set, |
| 534 |
LiveRegisterSet ignore) PER_SHARED_ARCH; |
| 535 |
|
| 536 |
// =============================================================== |
| 537 |
// Stack manipulation functions -- single registers/values. |
| 538 |
|
| 539 |
void Push(const Operand op) DEFINED_ON(x86_shared); |
| 540 |
void Push(Register reg) PER_SHARED_ARCH; |
| 541 |
void Push(Register reg1, Register reg2, Register reg3, Register reg4) |
| 542 |
DEFINED_ON(arm64); |
| 543 |
void Push(const Imm32 imm) PER_SHARED_ARCH; |
| 544 |
void Push(const ImmWord imm) PER_SHARED_ARCH; |
| 545 |
void Push(const ImmPtr imm) PER_SHARED_ARCH; |
| 546 |
void Push(const ImmGCPtr ptr) PER_SHARED_ARCH; |
| 547 |
void Push(FloatRegister reg) PER_SHARED_ARCH; |
| 548 |
void PushBoxed(FloatRegister reg) PER_ARCH; |
| 549 |
void PushFlags() DEFINED_ON(x86_shared); |
| 550 |
void Push(PropertyKey key, Register scratchReg); |
| 551 |
void Push(const Address& addr); |
| 552 |
void Push(TypedOrValueRegister v); |
| 553 |
void Push(const ConstantOrRegister& v); |
| 554 |
void Push(const ValueOperand& val); |
| 555 |
void Push(const Value& val); |
| 556 |
void Push(JSValueType type, Register reg); |
| 557 |
void Push(const Register64 reg); |
| 558 |
void PushEmptyRooted(VMFunctionData::RootType rootType); |
| 559 |
inline CodeOffset PushWithPatch(ImmWord word); |
| 560 |
inline CodeOffset PushWithPatch(ImmPtr imm); |
| 561 |
|
| 562 |
void Pop(const Operand op) DEFINED_ON(x86_shared); |
| 563 |
void Pop(Register reg) PER_SHARED_ARCH; |
| 564 |
void Pop(FloatRegister t) PER_SHARED_ARCH; |
| 565 |
void Pop(const ValueOperand& val) PER_SHARED_ARCH; |
| 566 |
void Pop(const Register64 reg); |
| 567 |
void PopFlags() DEFINED_ON(x86_shared); |
| 568 |
void PopStackPtr() |
| 569 |
DEFINED_ON(arm, mips64, x86_shared, loong64, riscv64, wasm32); |
| 570 |
|
| 571 |
// Move the stack pointer based on the requested amount. |
| 572 |
void adjustStack(int amount); |
| 573 |
void freeStack(uint32_t amount); |
| 574 |
|
| 575 |
// Move the stack pointer to the specified position. It assumes the SP |
| 576 |
// register is not valid -- it uses FP to set the position. |
| 577 |
void freeStackTo(uint32_t framePushed) PER_SHARED_ARCH; |
| 578 |
|
| 579 |
private: |
| 580 |
// =============================================================== |
| 581 |
// Register allocation fields. |
| 582 |
#ifdef DEBUG |
| 583 |
friend AutoRegisterScope; |
| 584 |
friend AutoFloatRegisterScope; |
| 585 |
// Used to track register scopes for debug builds. |
| 586 |
// Manipulated by the AutoGenericRegisterScope class. |
| 587 |
AllocatableRegisterSet debugTrackedRegisters_; |
| 588 |
#endif // DEBUG |
| 589 |
|
| 590 |
public: |
| 591 |
// =============================================================== |
| 592 |
// Simple call functions. |
| 593 |
|
| 594 |
// The returned CodeOffset is the assembler offset for the instruction |
| 595 |
// immediately following the call; that is, for the return point. |
| 596 |
CodeOffset call(Register reg) PER_SHARED_ARCH; |
| 597 |
CodeOffset call(Label* label) PER_SHARED_ARCH; |
| 598 |
|
| 599 |
void call(const Address& addr) PER_SHARED_ARCH; |
| 600 |
void call(ImmWord imm) PER_SHARED_ARCH; |
| 601 |
// Call a target native function, which is neither traceable nor movable. |
| 602 |
void call(ImmPtr imm) PER_SHARED_ARCH; |
| 603 |
CodeOffset call(wasm::SymbolicAddress imm) PER_SHARED_ARCH; |
| 604 |
inline CodeOffset call(const wasm::CallSiteDesc& desc, |
| 605 |
wasm::SymbolicAddress imm); |
| 606 |
|
| 607 |
// Call a target JitCode, which must be traceable, and may be movable. |
| 608 |
void call(JitCode* c) PER_SHARED_ARCH; |
| 609 |
|
| 610 |
inline void call(TrampolinePtr code); |
| 611 |
|
| 612 |
inline CodeOffset call(const wasm::CallSiteDesc& desc, const Register reg); |
| 613 |
inline CodeOffset call(const wasm::CallSiteDesc& desc, uint32_t funcDefIndex); |
| 614 |
inline void call(const wasm::CallSiteDesc& desc, wasm::Trap trap); |
| 615 |
|
| 616 |
CodeOffset callWithPatch() PER_SHARED_ARCH; |
| 617 |
void patchCall(uint32_t callerOffset, uint32_t calleeOffset) PER_SHARED_ARCH; |
| 618 |
|
| 619 |
// Push the return address and make a call. On platforms where this function |
| 620 |
// is not defined, push the link register (pushReturnAddress) at the entry |
| 621 |
// point of the callee. |
| 622 |
void callAndPushReturnAddress(Register reg) DEFINED_ON(x86_shared); |
| 623 |
void callAndPushReturnAddress(Label* label) DEFINED_ON(x86_shared); |
| 624 |
|
| 625 |
// These do not adjust framePushed(). |
| 626 |
void pushReturnAddress() |
| 627 |
DEFINED_ON(mips64, arm, arm64, loong64, riscv64, wasm32); |
| 628 |
void popReturnAddress() |
| 629 |
DEFINED_ON(mips64, arm, arm64, loong64, riscv64, wasm32); |
| 630 |
|
| 631 |
// Useful for dealing with two-valued returns. |
| 632 |
void moveRegPair(Register src0, Register src1, Register dst0, Register dst1, |
| 633 |
MoveOp::Type type = MoveOp::GENERAL); |
| 634 |
|
| 635 |
void reserveVMFunctionOutParamSpace(const VMFunctionData& f); |
| 636 |
void loadVMFunctionOutParam(const VMFunctionData& f, const Address& addr); |
| 637 |
|
| 638 |
public: |
| 639 |
// =============================================================== |
| 640 |
// Patchable near/far jumps. |
| 641 |
|
| 642 |
// "Far jumps" provide the ability to jump to any uint32_t offset from any |
| 643 |
// other uint32_t offset without using a constant pool (thus returning a |
| 644 |
// simple CodeOffset instead of a CodeOffsetJump). |
| 645 |
CodeOffset farJumpWithPatch() PER_SHARED_ARCH; |
| 646 |
void patchFarJump(CodeOffset farJump, uint32_t targetOffset) PER_SHARED_ARCH; |
| 647 |
static void patchFarJump(uint8_t* farJump, uint8_t* target) |
| 648 |
DEFINED_ON(arm, arm64, x86_shared, loong64, mips64, riscv64); |
| 649 |
|
| 650 |
// Emit a nop that can be patched to and from a nop and a call with int32 |
| 651 |
// relative displacement. |
| 652 |
CodeOffset nopPatchableToCall() PER_SHARED_ARCH; |
| 653 |
void nopPatchableToCall(const wasm::CallSiteDesc& desc); |
| 654 |
static void patchNopToCall(uint8_t* callsite, |
| 655 |
uint8_t* target) PER_SHARED_ARCH; |
| 656 |
static void patchCallToNop(uint8_t* callsite) PER_SHARED_ARCH; |
| 657 |
|
| 658 |
// These methods are like movWithPatch/PatchDataWithValueCheck but allow |
| 659 |
// using pc-relative addressing on certain platforms (RIP-relative LEA on x64, |
| 660 |
// ADR instruction on arm64). |
| 661 |
// |
| 662 |
// Note: "Near" applies to ARM64 where the target must be within 1 MB (this is |
| 663 |
// release-asserted). |
| 664 |
CodeOffset moveNearAddressWithPatch(Register dest) PER_ARCH; |
| 665 |
static void patchNearAddressMove(CodeLocationLabel loc, |
| 666 |
CodeLocationLabel target) PER_ARCH; |
| 667 |
|
| 668 |
// Creates a move of a patchable 32-bit value into `dest`. On 64-bit |
| 669 |
// targets, the value (`n`) is extended to 64 bits using the target |
| 670 |
// architecture's standard 32-to-64 extension rule. Hence consistent cross |
| 671 |
// target behaviour is only provided for `n` in the range 0 .. 2^31-1 |
| 672 |
// inclusive. |
| 673 |
CodeOffset move32WithPatch(Register dest) |
| 674 |
DEFINED_ON(x86_shared, arm, arm64, loong64, mips64, riscv64); |
| 675 |
void patchMove32(CodeOffset offset, Imm32 n) |
| 676 |
DEFINED_ON(x86_shared, arm, arm64, loong64, mips64, riscv64); |
| 677 |
|
| 678 |
public: |
| 679 |
// =============================================================== |
| 680 |
// [SMDOC] JIT-to-C++ Function Calls (callWithABI) |
| 681 |
// |
| 682 |
// callWithABI is used to make a call using the standard C/C++ system ABI. |
| 683 |
// |
| 684 |
// callWithABI is a low level interface for making calls, as such every call |
| 685 |
// made with callWithABI should be organized with 6 steps: spilling live |
| 686 |
// registers, aligning the stack, listing arguments of the called function, |
| 687 |
// calling a function pointer, extracting the returned value and restoring |
| 688 |
// live registers. |
| 689 |
// |
| 690 |
// A more detailed example of the six stages: |
| 691 |
// |
| 692 |
// 1) Saving of registers that are live. This will vary depending on which |
| 693 |
// SpiderMonkey compiler you are working on. Registers that shouldn't be |
| 694 |
// restored can be excluded. |
| 695 |
// |
| 696 |
// LiveRegisterSet volatileRegs(...); |
| 697 |
// volatileRegs.take(scratch); |
| 698 |
// masm.PushRegsInMask(volatileRegs); |
| 699 |
// |
| 700 |
// 2) Align the stack to perform the call with the correct stack alignment. |
| 701 |
// |
| 702 |
// When the stack pointer alignment is unknown and cannot be corrected |
| 703 |
// when generating the code, setupUnalignedABICall must be used to |
| 704 |
// dynamically align the stack pointer to the expectation of the ABI. |
| 705 |
// When the stack pointer is known at JIT compilation time, the stack can |
| 706 |
// be fixed manually and setupAlignedABICall and setupWasmABICall can be |
| 707 |
// used. |
| 708 |
// |
| 709 |
// setupWasmABICall is a special case of setupAlignedABICall as |
| 710 |
// SpiderMonkey's WebAssembly implementation mostly follow the system |
| 711 |
// ABI, except for float/double arguments, which always use floating |
| 712 |
// point registers, even if this is not supported by the system ABI. |
| 713 |
// |
| 714 |
// masm.setupUnalignedABICall(scratch); |
| 715 |
// |
| 716 |
// 3) Passing arguments. Arguments are passed left-to-right. |
| 717 |
// |
| 718 |
// masm.passABIArg(scratch); |
| 719 |
// masm.passABIArg(FloatOp0, ABIType::Float64); |
| 720 |
// |
| 721 |
// Note how float register arguments are annotated with ABIType::Float64. |
| 722 |
// |
| 723 |
// Concerning stack-relative address, see the note on passABIArg. |
| 724 |
// |
| 725 |
// 4) Make the call: |
| 726 |
// |
| 727 |
// using Fn = int32_t (*)(int32_t) |
| 728 |
// masm.callWithABI<Fn, Callee>(); |
| 729 |
// |
| 730 |
// In the case where the call returns a double, that needs to be |
| 731 |
// indicated to the callWithABI like this: |
| 732 |
// |
| 733 |
// using Fn = double (*)(int32_t) |
| 734 |
// masm.callWithABI<Fn, Callee>(ABIType::Float64); |
| 735 |
// |
| 736 |
// There are overloads to allow calls to registers and addresses. |
| 737 |
// |
| 738 |
// 5) Take care of the result |
| 739 |
// |
| 740 |
// masm.storeCallPointerResult(scratch1); |
| 741 |
// masm.storeCallBoolResult(scratch1); |
| 742 |
// masm.storeCallInt32Result(scratch1); |
| 743 |
// masm.storeCallFloatResult(scratch1); |
| 744 |
// |
| 745 |
// 6) Restore the potentially clobbered volatile registers |
| 746 |
// |
| 747 |
// masm.PopRegsInMask(volatileRegs); |
| 748 |
// |
| 749 |
// If expecting a returned value, this call should use |
| 750 |
// PopRegsInMaskIgnore to filter out the registers which are containing |
| 751 |
// the returned value. |
| 752 |
// |
| 753 |
// Unless an exit frame is pushed prior to the setupABICall, the callee |
| 754 |
// should not GC. To ensure this is the case callWithABI is instrumented to |
| 755 |
// make sure that in the default case callees are annotated with an |
| 756 |
// AutoUnsafeCallWithABI on the stack. |
| 757 |
// |
| 758 |
// A callWithABI can opt out of checking, if for example it is known there |
| 759 |
// is an exit frame, or the callee is known not to GC. |
| 760 |
// |
| 761 |
// If your callee needs to be able to GC, consider using a VMFunction, or |
| 762 |
// create a fake exit frame, and instrument the TraceJitExitFrame |
| 763 |
// accordingly. |
| 764 |
|
| 765 |
// Setup a call to C/C++ code, given the assumption that the framePushed |
| 766 |
// accurately defines the state of the stack, and that the top of the stack |
| 767 |
// was properly aligned. Note that this only supports cdecl. |
| 768 |
// |
| 769 |
// As a rule of thumb, this can be used in CodeGenerator but not in CacheIR or |
| 770 |
// Baseline code (because the stack is not aligned to ABIStackAlignment). |
| 771 |
void setupAlignedABICall(); |
| 772 |
|
| 773 |
// As setupAlignedABICall, but for WebAssembly native ABI calls, which pass |
| 774 |
// through a builtin thunk that uses the wasm ABI. All the wasm ABI calls |
| 775 |
// can be native, since we always know the stack alignment a priori. |
| 776 |
void setupWasmABICall(); |
| 777 |
|
| 778 |
// Setup an ABI call for when the alignment is not known. This may need a |
| 779 |
// scratch register. |
| 780 |
void setupUnalignedABICall(Register scratch) PER_ARCH; |
| 781 |
|
| 782 |
// Like setupUnalignedABICall, but more efficient because it doesn't push/pop |
| 783 |
// the unaligned stack pointer. The caller is responsible for restoring SP |
| 784 |
// after the callWithABI, for example using the frame pointer register. |
| 785 |
void setupUnalignedABICallDontSaveRestoreSP(); |
| 786 |
|
| 787 |
// Arguments must be assigned to a C/C++ call in order. They are moved |
| 788 |
// in parallel immediately before performing the call. This process may |
| 789 |
// temporarily use more stack, in which case esp-relative addresses will be |
| 790 |
// automatically adjusted. It is extremely important that esp-relative |
| 791 |
// addresses are computed *after* setupABICall(). Furthermore, no |
| 792 |
// operations should be emitted while setting arguments. |
| 793 |
void passABIArg(const MoveOperand& from, ABIType type); |
| 794 |
inline void passABIArg(Register reg); |
| 795 |
inline void passABIArg(FloatRegister reg, ABIType type); |
| 796 |
|
| 797 |
inline void callWithABI( |
| 798 |
DynFn fun, ABIType result = ABIType::General, |
| 799 |
CheckUnsafeCallWithABI check = CheckUnsafeCallWithABI::Check); |
| 800 |
template <typename Sig, Sig fun> |
| 801 |
inline void callWithABI( |
| 802 |
ABIType result = ABIType::General, |
| 803 |
CheckUnsafeCallWithABI check = CheckUnsafeCallWithABI::Check); |
| 804 |
inline void callWithABI(Register fun, ABIType result = ABIType::General); |
| 805 |
inline void callWithABI(const Address& fun, |
| 806 |
ABIType result = ABIType::General); |
| 807 |
|
| 808 |
CodeOffset callWithABI(wasm::BytecodeOffset offset, wasm::SymbolicAddress fun, |
| 809 |
mozilla::Maybe<int32_t> instanceOffset, |
| 810 |
ABIType result = ABIType::General); |
| 811 |
void callDebugWithABI(wasm::SymbolicAddress fun, |
| 812 |
ABIType result = ABIType::General); |
| 813 |
|
| 814 |
private: |
| 815 |
// Reinitialize the variables which have to be cleared before making a call |
| 816 |
// with callWithABI. |
| 817 |
template <class ABIArgGeneratorT> |
| 818 |
void setupABICallHelper(); |
| 819 |
|
| 820 |
// Reinitialize the variables which have to be cleared before making a call |
| 821 |
// with native abi. |
| 822 |
void setupNativeABICall(); |
| 823 |
|
| 824 |
// Reserve the stack and resolve the arguments move. |
| 825 |
void callWithABIPre(uint32_t* stackAdjust, |
| 826 |
bool callFromWasm = false) PER_ARCH; |
| 827 |
|
| 828 |
// Emits a call to a C/C++ function, resolving all argument moves. |
| 829 |
void callWithABINoProfiler(void* fun, ABIType result, |
| 830 |
CheckUnsafeCallWithABI check); |
| 831 |
void callWithABINoProfiler(Register fun, ABIType result) PER_ARCH; |
| 832 |
void callWithABINoProfiler(const Address& fun, ABIType result) PER_ARCH; |
| 833 |
|
| 834 |
// Restore the stack to its state before the setup function call. |
| 835 |
void callWithABIPost(uint32_t stackAdjust, ABIType result, |
| 836 |
bool callFromWasm = false) PER_ARCH; |
| 837 |
|
| 838 |
// Create the signature to be able to decode the arguments of a native |
| 839 |
// function, when calling a function within the simulator. |
| 840 |
inline void appendSignatureType(ABIType type); |
| 841 |
inline ABIFunctionType signature() const; |
| 842 |
|
| 843 |
// Private variables used to handle moves between registers given as |
| 844 |
// arguments to passABIArg and the list of ABI registers expected for the |
| 845 |
// signature of the function. |
| 846 |
MoveResolver moveResolver_; |
| 847 |
|
| 848 |
// Architecture specific implementation which specify how registers & stack |
| 849 |
// offsets are used for calling a function. |
| 850 |
ABIArgGenerator abiArgs_; |
| 851 |
|
| 852 |
#ifdef DEBUG |
| 853 |
// Flag use to assert that we use ABI function in the right context. |
| 854 |
bool inCall_; |
| 855 |
#endif |
| 856 |
|
| 857 |
// If set by setupUnalignedABICall then callWithABI will pop the stack |
| 858 |
// register which is on the stack. |
| 859 |
bool dynamicAlignment_; |
| 860 |
|
| 861 |
#ifdef JS_SIMULATOR |
| 862 |
// The signature is used to accumulate all types of arguments which are used |
| 863 |
// by the caller. This is used by the simulators to decode the arguments |
| 864 |
// properly, and cast the function pointer to the right type. |
| 865 |
uint32_t signature_; |
| 866 |
#endif |
| 867 |
|
| 868 |
public: |
| 869 |
// =============================================================== |
| 870 |
// Jit Frames. |
| 871 |
// |
| 872 |
// These functions are used to build the content of the Jit frames. See |
| 873 |
// CommonFrameLayout class, and all its derivatives. The content should be |
| 874 |
// pushed in the opposite order as the fields of the structures, such that |
| 875 |
// the structures can be used to interpret the content of the stack. |
| 876 |
|
| 877 |
// Call the Jit function, and push the return address (or let the callee |
| 878 |
// push the return address). |
| 879 |
// |
| 880 |
// These functions return the offset of the return address, in order to use |
| 881 |
// the return address to index the safepoints, which are used to list all |
| 882 |
// live registers. |
| 883 |
inline uint32_t callJitNoProfiler(Register callee); |
| 884 |
inline uint32_t callJit(Register callee); |
| 885 |
inline uint32_t callJit(JitCode* code); |
| 886 |
inline uint32_t callJit(TrampolinePtr code); |
| 887 |
inline uint32_t callJit(ImmPtr callee); |
| 888 |
|
| 889 |
// The frame descriptor is the second field of all Jit frames, pushed before |
| 890 |
// calling the Jit function. See CommonFrameLayout::descriptor_. |
| 891 |
inline void pushFrameDescriptor(FrameType type); |
| 892 |
inline void PushFrameDescriptor(FrameType type); |
| 893 |
|
| 894 |
// For JitFrameLayout, the descriptor also stores the number of arguments |
| 895 |
// passed by the caller. See MakeFrameDescriptorForJitCall. |
| 896 |
inline void pushFrameDescriptorForJitCall(FrameType type, uint32_t argc); |
| 897 |
inline void pushFrameDescriptorForJitCall(FrameType type, Register argc, |
| 898 |
Register scratch); |
| 899 |
inline void PushFrameDescriptorForJitCall(FrameType type, uint32_t argc); |
| 900 |
inline void PushFrameDescriptorForJitCall(FrameType type, Register argc, |
| 901 |
Register scratch); |
| 902 |
|
| 903 |
// Load the number of actual arguments from the frame's JitFrameLayout. |
| 904 |
inline void loadNumActualArgs(Register framePtr, Register dest); |
| 905 |
|
| 906 |
// Push the callee token of a JSFunction which pointer is stored in the |
| 907 |
// |callee| register. The callee token is packed with a |constructing| flag |
| 908 |
// which correspond to the fact that the JS function is called with "new" or |
| 909 |
// not. |
| 910 |
inline void PushCalleeToken(Register callee, bool constructing); |
| 911 |
|
| 912 |
// Unpack a callee token located at the |token| address, and return the |
| 913 |
// JSFunction pointer in the |dest| register. |
| 914 |
inline void loadFunctionFromCalleeToken(Address token, Register dest); |
| 915 |
|
| 916 |
// This function emulates a call by pushing an exit frame on the stack, |
| 917 |
// except that the fake-function is inlined within the body of the caller. |
| 918 |
// |
| 919 |
// This function assumes that the current frame is an IonJS frame. |
| 920 |
// |
| 921 |
// This function returns the offset of the /fake/ return address, in order to |
| 922 |
// use the return address to index the safepoints, which are used to list all |
| 923 |
// live registers. |
| 924 |
// |
| 925 |
// This function should be balanced with a call to adjustStack, to pop the |
| 926 |
// exit frame and emulate the return statement of the inlined function. |
| 927 |
inline uint32_t buildFakeExitFrame(Register scratch); |
| 928 |
|
| 929 |
private: |
| 930 |
// This function is used by buildFakeExitFrame to push a fake return address |
| 931 |
// on the stack. This fake return address should never be used for resuming |
| 932 |
// any execution, and can even be an invalid pointer into the instruction |
| 933 |
// stream, as long as it does not alias any other. |
| 934 |
uint32_t pushFakeReturnAddress(Register scratch) PER_SHARED_ARCH; |
| 935 |
|
| 936 |
public: |
| 937 |
// =============================================================== |
| 938 |
// Exit frame footer. |
| 939 |
// |
| 940 |
// When calling outside the Jit we push an exit frame. To mark the stack |
| 941 |
// correctly, we have to push additional information, called the Exit frame |
| 942 |
// footer, which is used to identify how the stack is marked. |
| 943 |
// |
| 944 |
// See JitFrames.h, and TraceJitExitFrame in JitFrames.cpp. |
| 945 |
|
| 946 |
// Links the exit frame and pushes the ExitFooterFrame. |
| 947 |
inline void enterExitFrame(Register cxreg, Register scratch, VMFunctionId f); |
| 948 |
|
| 949 |
// Push an exit frame token to identify which fake exit frame this footer |
| 950 |
// corresponds to. |
| 951 |
inline void enterFakeExitFrame(Register cxreg, Register scratch, |
| 952 |
ExitFrameType type); |
| 953 |
|
| 954 |
// Push an exit frame token for a native call. |
| 955 |
inline void enterFakeExitFrameForNative(Register cxreg, Register scratch, |
| 956 |
bool isConstructing); |
| 957 |
|
| 958 |
// Pop ExitFrame footer in addition to the extra frame. |
| 959 |
inline void leaveExitFrame(size_t extraFrame = 0); |
| 960 |
|
| 961 |
private: |
| 962 |
// Save the top of the stack into JitActivation::packedExitFP of the |
| 963 |
// current thread, which should be the location of the latest exit frame. |
| 964 |
void linkExitFrame(Register cxreg, Register scratch); |
| 965 |
|
| 966 |
public: |
| 967 |
// =============================================================== |
| 968 |
// Move instructions |
| 969 |
|
| 970 |
inline void move64(Imm64 imm, Register64 dest) PER_ARCH; |
| 971 |
inline void move64(Register64 src, Register64 dest) PER_ARCH; |
| 972 |
|
| 973 |
inline void moveFloat16ToGPR(FloatRegister src, |
| 974 |
Register dest) PER_SHARED_ARCH; |
| 975 |
// Clears the high words of `src`. |
| 976 |
inline void moveGPRToFloat16(Register src, |
| 977 |
FloatRegister dest) PER_SHARED_ARCH; |
| 978 |
|
| 979 |
inline void moveFloat32ToGPR(FloatRegister src, |
| 980 |
Register dest) PER_SHARED_ARCH; |
| 981 |
inline void moveGPRToFloat32(Register src, |
| 982 |
FloatRegister dest) PER_SHARED_ARCH; |
| 983 |
|
| 984 |
inline void moveDoubleToGPR64(FloatRegister src, Register64 dest) PER_ARCH; |
| 985 |
inline void moveGPR64ToDouble(Register64 src, FloatRegister dest) PER_ARCH; |
| 986 |
|
| 987 |
// Move the low 32-bits of a double. |
| 988 |
inline void moveLowDoubleToGPR(FloatRegister src, |
| 989 |
Register dest) PER_SHARED_ARCH; |
| 990 |
|
| 991 |
inline void move8ZeroExtend(Register src, Register dest) PER_SHARED_ARCH; |
| 992 |
|
| 993 |
inline void move8SignExtend(Register src, Register dest) PER_SHARED_ARCH; |
| 994 |
inline void move16SignExtend(Register src, Register dest) PER_SHARED_ARCH; |
| 995 |
|
| 996 |
// move64To32 will clear the high bits of `dest` on 64-bit systems. |
| 997 |
inline void move64To32(Register64 src, Register dest) PER_ARCH; |
| 998 |
|
| 999 |
inline void move32To64ZeroExtend(Register src, Register64 dest) PER_ARCH; |
| 1000 |
|
| 1001 |
inline void move8To64SignExtend(Register src, Register64 dest) PER_ARCH; |
| 1002 |
inline void move16To64SignExtend(Register src, Register64 dest) PER_ARCH; |
| 1003 |
inline void move32To64SignExtend(Register src, Register64 dest) PER_ARCH; |
| 1004 |
|
| 1005 |
inline void move8SignExtendToPtr(Register src, Register dest) PER_ARCH; |
| 1006 |
inline void move16SignExtendToPtr(Register src, Register dest) PER_ARCH; |
| 1007 |
inline void move32SignExtendToPtr(Register src, Register dest) PER_ARCH; |
| 1008 |
|
| 1009 |
inline void move32ZeroExtendToPtr(Register src, Register dest) PER_ARCH; |
| 1010 |
|
| 1011 |
// Copy a constant, typed-register, or a ValueOperand into a ValueOperand |
| 1012 |
// destination. |
| 1013 |
inline void moveValue(const ConstantOrRegister& src, |
| 1014 |
const ValueOperand& dest); |
| 1015 |
void moveValue(const TypedOrValueRegister& src, const ValueOperand& dest); |
| 1016 |
void moveValue(const ValueOperand& src, const ValueOperand& dest) PER_ARCH; |
| 1017 |
void moveValue(const Value& src, const ValueOperand& dest) PER_ARCH; |
| 1018 |
|
| 1019 |
void movePropertyKey(PropertyKey key, Register dest); |
| 1020 |
|
| 1021 |
// =============================================================== |
| 1022 |
// Load instructions |
| 1023 |
|
| 1024 |
inline void load32SignExtendToPtr(const Address& src, Register dest) PER_ARCH; |
| 1025 |
|
| 1026 |
inline void loadAbiReturnAddress(Register dest) PER_SHARED_ARCH; |
| 1027 |
|
| 1028 |
// =============================================================== |
| 1029 |
// Copy instructions |
| 1030 |
|
| 1031 |
inline void copy64(const Address& src, const Address& dest, Register scratch); |
| 1032 |
|
| 1033 |
public: |
| 1034 |
// =============================================================== |
| 1035 |
// Logical instructions |
| 1036 |
|
| 1037 |
inline void not32(Register reg) PER_SHARED_ARCH; |
| 1038 |
inline void notPtr(Register reg) PER_ARCH; |
| 1039 |
|
| 1040 |
inline void and32(Register src, Register dest) PER_SHARED_ARCH; |
| 1041 |
inline void and32(Imm32 imm, Register dest) PER_SHARED_ARCH; |
| 1042 |
inline void and32(Imm32 imm, Register src, Register dest) PER_SHARED_ARCH; |
| 1043 |
inline void and32(Imm32 imm, const Address& dest) PER_SHARED_ARCH; |
| 1044 |
inline void and32(const Address& src, Register dest) PER_SHARED_ARCH; |
| 1045 |
|
| 1046 |
inline void andPtr(Register src, Register dest) PER_ARCH; |
| 1047 |
inline void andPtr(Imm32 imm, Register dest) PER_ARCH; |
| 1048 |
inline void andPtr(Imm32 imm, Register src, Register dest) PER_ARCH; |
| 1049 |
|
| 1050 |
inline void and64(Imm64 imm, Register64 dest) PER_ARCH; |
| 1051 |
inline void or64(Imm64 imm, Register64 dest) PER_ARCH; |
| 1052 |
inline void xor64(Imm64 imm, Register64 dest) PER_ARCH; |
| 1053 |
|
| 1054 |
inline void or32(Register src, Register dest) PER_SHARED_ARCH; |
| 1055 |
inline void or32(Imm32 imm, Register dest) PER_SHARED_ARCH; |
| 1056 |
inline void or32(Imm32 imm, Register src, Register dest) PER_SHARED_ARCH; |
| 1057 |
inline void or32(Imm32 imm, const Address& dest) PER_SHARED_ARCH; |
| 1058 |
|
| 1059 |
inline void orPtr(Register src, Register dest) PER_ARCH; |
| 1060 |
inline void orPtr(Imm32 imm, Register dest) PER_ARCH; |
| 1061 |
inline void orPtr(Imm32 imm, Register src, Register dest) PER_ARCH; |
| 1062 |
|
| 1063 |
inline void and64(Register64 src, Register64 dest) PER_ARCH; |
| 1064 |
inline void or64(Register64 src, Register64 dest) PER_ARCH; |
| 1065 |
inline void xor64(Register64 src, Register64 dest) PER_ARCH; |
| 1066 |
|
| 1067 |
inline void xor32(Register src, Register dest) PER_SHARED_ARCH; |
| 1068 |
inline void xor32(Imm32 imm, Register dest) PER_SHARED_ARCH; |
| 1069 |
inline void xor32(Imm32 imm, Register src, Register dest) PER_SHARED_ARCH; |
| 1070 |
inline void xor32(Imm32 imm, const Address& dest) PER_SHARED_ARCH; |
| 1071 |
inline void xor32(const Address& src, Register dest) PER_SHARED_ARCH; |
| 1072 |
|
| 1073 |
inline void xorPtr(Register src, Register dest) PER_ARCH; |
| 1074 |
inline void xorPtr(Imm32 imm, Register dest) PER_ARCH; |
| 1075 |
inline void xorPtr(Imm32 imm, Register src, Register dest) PER_ARCH; |
| 1076 |
|
| 1077 |
inline void and64(const Operand& src, Register64 dest) |
| 1078 |
DEFINED_ON(x64, mips64, loong64, riscv64); |
| 1079 |
inline void or64(const Operand& src, Register64 dest) |
| 1080 |
DEFINED_ON(x64, mips64, loong64, riscv64); |
| 1081 |
inline void xor64(const Operand& src, Register64 dest) |
| 1082 |
DEFINED_ON(x64, mips64, loong64, riscv64); |
| 1083 |
|
| 1084 |
// =============================================================== |
| 1085 |
// Swap instructions |
| 1086 |
|
| 1087 |
// Swap the two lower bytes and sign extend the result to 32-bit. |
| 1088 |
inline void byteSwap16SignExtend(Register reg) PER_SHARED_ARCH; |
| 1089 |
|
| 1090 |
// Swap the two lower bytes and zero extend the result to 32-bit. |
| 1091 |
inline void byteSwap16ZeroExtend(Register reg) PER_SHARED_ARCH; |
| 1092 |
|
| 1093 |
// Swap all four bytes in a 32-bit integer. |
| 1094 |
inline void byteSwap32(Register reg) PER_SHARED_ARCH; |
| 1095 |
|
| 1096 |
// Swap all eight bytes in a 64-bit integer. |
| 1097 |
inline void byteSwap64(Register64 reg) PER_ARCH; |
| 1098 |
|
| 1099 |
// =============================================================== |
| 1100 |
// Arithmetic functions |
| 1101 |
|
| 1102 |
// Condition flags aren't guaranteed to be set by these functions, for example |
| 1103 |
// x86 will always set condition flags, but ARM64 won't do it unless |
| 1104 |
// explicitly requested. Instead use branch(Add|Sub|Mul|Neg) to test for |
| 1105 |
// condition flags after performing arithmetic operations. |
| 1106 |
|
| 1107 |
inline void add32(Register src, Register dest) PER_SHARED_ARCH; |
| 1108 |
inline void add32(Imm32 imm, Register dest) PER_SHARED_ARCH; |
| 1109 |
inline void add32(Imm32 imm, Register src, Register dest) PER_SHARED_ARCH; |
| 1110 |
inline void add32(Imm32 imm, const Address& dest) PER_SHARED_ARCH; |
| 1111 |
inline void add32(Imm32 imm, const AbsoluteAddress& dest) |
| 1112 |
DEFINED_ON(x86_shared); |
| 1113 |
|
| 1114 |
inline void addPtr(Register src, Register dest) PER_ARCH; |
| 1115 |
inline void addPtr(Register src1, Register src2, Register dest) |
| 1116 |
DEFINED_ON(arm64); |
| 1117 |
inline void addPtr(Imm32 imm, Register dest) PER_ARCH; |
| 1118 |
inline void addPtr(Imm32 imm, Register src, Register dest) DEFINED_ON(arm64); |
| 1119 |
inline void addPtr(ImmWord imm, Register dest) PER_ARCH; |
| 1120 |
inline void addPtr(ImmPtr imm, Register dest); |
| 1121 |
inline void addPtr(Imm32 imm, const Address& dest) PER_ARCH; |
| 1122 |
inline void addPtr(Imm32 imm, const AbsoluteAddress& dest) |
| 1123 |
DEFINED_ON(x86, x64); |
| 1124 |
inline void addPtr(const Address& src, Register dest) PER_ARCH; |
| 1125 |
|
| 1126 |
inline void add64(Register64 src, Register64 dest) PER_ARCH; |
| 1127 |
inline void add64(Imm32 imm, Register64 dest) PER_ARCH; |
| 1128 |
inline void add64(Imm64 imm, Register64 dest) PER_ARCH; |
| 1129 |
inline void add64(const Operand& src, Register64 dest) |
| 1130 |
DEFINED_ON(x64, mips64, loong64, riscv64); |
| 1131 |
|
| 1132 |
inline void addFloat32(FloatRegister src, FloatRegister dest) PER_SHARED_ARCH; |
| 1133 |
|
| 1134 |
// Compute dest=SP-imm where dest is a pointer registers and not SP. The |
| 1135 |
// offset returned from sub32FromStackPtrWithPatch() must be passed to |
| 1136 |
// patchSub32FromStackPtr(). |
| 1137 |
inline CodeOffset sub32FromStackPtrWithPatch(Register dest) PER_ARCH; |
| 1138 |
inline void patchSub32FromStackPtr(CodeOffset offset, Imm32 imm) PER_ARCH; |
| 1139 |
|
| 1140 |
inline void addDouble(FloatRegister src, FloatRegister dest) PER_SHARED_ARCH; |
| 1141 |
inline void addConstantDouble(double d, FloatRegister dest) DEFINED_ON(x86); |
| 1142 |
|
| 1143 |
inline void sub32(const Address& src, Register dest) PER_SHARED_ARCH; |
| 1144 |
inline void sub32(Register src, Register dest) PER_SHARED_ARCH; |
| 1145 |
inline void sub32(Imm32 imm, Register dest) PER_SHARED_ARCH; |
| 1146 |
|
| 1147 |
inline void subPtr(Register src, Register dest) PER_ARCH; |
| 1148 |
inline void subPtr(Register src, const Address& dest) PER_ARCH; |
| 1149 |
inline void subPtr(Imm32 imm, Register dest) PER_ARCH; |
| 1150 |
inline void subPtr(ImmWord imm, Register dest) DEFINED_ON(x64); |
| 1151 |
inline void subPtr(const Address& addr, Register dest) PER_ARCH; |
| 1152 |
|
| 1153 |
inline void sub64(Register64 src, Register64 dest) PER_ARCH; |
| 1154 |
inline void sub64(Imm64 imm, Register64 dest) PER_ARCH; |
| 1155 |
inline void sub64(const Operand& src, Register64 dest) |
| 1156 |
DEFINED_ON(x64, mips64, loong64, riscv64); |
| 1157 |
|
| 1158 |
inline void subFloat32(FloatRegister src, FloatRegister dest) PER_SHARED_ARCH; |
| 1159 |
|
| 1160 |
inline void subDouble(FloatRegister src, FloatRegister dest) PER_SHARED_ARCH; |
| 1161 |
|
| 1162 |
inline void mul32(Register rhs, Register srcDest) PER_SHARED_ARCH; |
| 1163 |
inline void mul32(Imm32 imm, Register srcDest) PER_SHARED_ARCH; |
| 1164 |
|
| 1165 |
inline void mul32(Register src1, Register src2, Register dest, Label* onOver) |
| 1166 |
DEFINED_ON(arm64); |
| 1167 |
|
| 1168 |
// Return the high word of the unsigned multiplication into |dest|. |
| 1169 |
inline void mulHighUnsigned32(Imm32 imm, Register src, |
| 1170 |
Register dest) PER_ARCH; |
| 1171 |
|
| 1172 |
inline void mulPtr(Register rhs, Register srcDest) PER_ARCH; |
| 1173 |
|
| 1174 |
inline void mul64(const Operand& src, const Register64& dest) DEFINED_ON(x64); |
| 1175 |
inline void mul64(const Operand& src, const Register64& dest, |
| 1176 |
const Register temp) |
| 1177 |
DEFINED_ON(x64, mips64, loong64, riscv64); |
| 1178 |
inline void mul64(Imm64 imm, const Register64& dest) PER_ARCH; |
| 1179 |
inline void mul64(Imm64 imm, const Register64& dest, const Register temp) |
| 1180 |
DEFINED_ON(x86, x64, arm, mips64, loong64, riscv64); |
| 1181 |
inline void mul64(const Register64& src, const Register64& dest, |
| 1182 |
const Register temp) PER_ARCH; |
| 1183 |
inline void mul64(const Register64& src1, const Register64& src2, |
| 1184 |
const Register64& dest) DEFINED_ON(arm64); |
| 1185 |
inline void mul64(Imm64 src1, const Register64& src2, const Register64& dest) |
| 1186 |
DEFINED_ON(arm64); |
| 1187 |
|
| 1188 |
inline void mulBy3(Register src, Register dest) PER_ARCH; |
| 1189 |
|
| 1190 |
inline void mulFloat32(FloatRegister src, FloatRegister dest) PER_SHARED_ARCH; |
| 1191 |
inline void mulDouble(FloatRegister src, FloatRegister dest) PER_SHARED_ARCH; |
| 1192 |
|
| 1193 |
inline void mulDoublePtr(ImmPtr imm, Register temp, |
| 1194 |
FloatRegister dest) PER_ARCH; |
| 1195 |
|
| 1196 |
// Perform an integer division, returning the integer part rounded toward |
| 1197 |
// zero. rhs must not be zero, and the division must not overflow. |
| 1198 |
// |
| 1199 |
// On ARM, the chip must have hardware division instructions. |
| 1200 |
inline void quotient32(Register rhs, Register srcDest, bool isUnsigned) |
| 1201 |
DEFINED_ON(mips64, arm, arm64, loong64, riscv64, wasm32); |
| 1202 |
|
| 1203 |
inline void quotient64(Register rhs, Register srcDest, bool isUnsigned) |
| 1204 |
DEFINED_ON(arm64, loong64, mips64, riscv64); |
| 1205 |
|
| 1206 |
// As above, but srcDest must be eax and tempEdx must be edx. |
| 1207 |
inline void quotient32(Register rhs, Register srcDest, Register tempEdx, |
| 1208 |
bool isUnsigned) DEFINED_ON(x86_shared); |
| 1209 |
|
| 1210 |
// Perform an integer division, returning the remainder part. |
| 1211 |
// rhs must not be zero, and the division must not overflow. |
| 1212 |
// |
| 1213 |
// On ARM, the chip must have hardware division instructions. |
| 1214 |
inline void remainder32(Register rhs, Register srcDest, bool isUnsigned) |
| 1215 |
DEFINED_ON(mips64, arm, arm64, loong64, riscv64, wasm32); |
| 1216 |
|
| 1217 |
inline void remainder64(Register rhs, Register srcDest, bool isUnsigned) |
| 1218 |
DEFINED_ON(arm64, loong64, mips64, riscv64); |
| 1219 |
|
| 1220 |
// As above, but srcDest must be eax and tempEdx must be edx. |
| 1221 |
inline void remainder32(Register rhs, Register srcDest, Register tempEdx, |
| 1222 |
bool isUnsigned) DEFINED_ON(x86_shared); |
| 1223 |
|
| 1224 |
// Perform an integer division, returning the integer part rounded toward |
| 1225 |
// zero. rhs must not be zero, and the division must not overflow. |
| 1226 |
// |
| 1227 |
// This variant preserves registers, and doesn't require hardware division |
| 1228 |
// instructions on ARM (will call out to a runtime routine). |
| 1229 |
// |
| 1230 |
// rhs is preserved, srdDest is clobbered. |
| 1231 |
void flexibleRemainder32(Register rhs, Register srcDest, bool isUnsigned, |
| 1232 |
const LiveRegisterSet& volatileLiveRegs) |
| 1233 |
PER_SHARED_ARCH; |
| 1234 |
void flexibleRemainderPtr(Register rhs, Register srcDest, bool isUnsigned, |
| 1235 |
const LiveRegisterSet& volatileLiveRegs) PER_ARCH; |
| 1236 |
|
| 1237 |
// Perform an integer division, returning the integer part rounded toward |
| 1238 |
// zero. rhs must not be zero, and the division must not overflow. |
| 1239 |
// |
| 1240 |
// This variant preserves registers, and doesn't require hardware division |
| 1241 |
// instructions on ARM (will call out to a runtime routine). |
| 1242 |
// |
| 1243 |
// rhs is preserved, srdDest is clobbered. |
| 1244 |
void flexibleQuotient32(Register rhs, Register srcDest, bool isUnsigned, |
| 1245 |
const LiveRegisterSet& volatileLiveRegs) |
| 1246 |
PER_SHARED_ARCH; |
| 1247 |
void flexibleQuotientPtr(Register rhs, Register srcDest, bool isUnsigned, |
| 1248 |
const LiveRegisterSet& volatileLiveRegs) PER_ARCH; |
| 1249 |
|
| 1250 |
// Perform an integer division, returning the integer part rounded toward |
| 1251 |
// zero. rhs must not be zero, and the division must not overflow. The |
| 1252 |
// remainder is stored into the third argument register here. |
| 1253 |
// |
| 1254 |
// This variant preserves registers, and doesn't require hardware division |
| 1255 |
// instructions on ARM (will call out to a runtime routine). |
| 1256 |
// |
| 1257 |
// rhs is preserved, srdDest and remOutput are clobbered. |
| 1258 |
void flexibleDivMod32( |
| 1259 |
Register rhs, Register srcDest, Register remOutput, bool isUnsigned, |
| 1260 |
const LiveRegisterSet& volatileLiveRegs) PER_SHARED_ARCH; |
| 1261 |
|
| 1262 |
inline void divFloat32(FloatRegister src, FloatRegister dest) PER_SHARED_ARCH; |
| 1263 |
inline void divDouble(FloatRegister src, FloatRegister dest) PER_SHARED_ARCH; |
| 1264 |
|
| 1265 |
inline void inc64(AbsoluteAddress dest) PER_ARCH; |
| 1266 |
|
| 1267 |
inline void neg32(Register reg) PER_SHARED_ARCH; |
| 1268 |
inline void neg64(Register64 reg) PER_ARCH; |
| 1269 |
inline void negPtr(Register reg) PER_ARCH; |
| 1270 |
|
| 1271 |
inline void negateFloat(FloatRegister reg) PER_SHARED_ARCH; |
| 1272 |
|
| 1273 |
inline void negateDouble(FloatRegister reg) PER_SHARED_ARCH; |
| 1274 |
|
| 1275 |
inline void abs32(Register src, Register dest) PER_SHARED_ARCH; |
| 1276 |
inline void absFloat32(FloatRegister src, FloatRegister dest) PER_SHARED_ARCH; |
| 1277 |
inline void absDouble(FloatRegister src, FloatRegister dest) PER_SHARED_ARCH; |
| 1278 |
|
| 1279 |
inline void sqrtFloat32(FloatRegister src, |
| 1280 |
FloatRegister dest) PER_SHARED_ARCH; |
| 1281 |
inline void sqrtDouble(FloatRegister src, FloatRegister dest) PER_SHARED_ARCH; |
| 1282 |
|
| 1283 |
void floorFloat32ToInt32(FloatRegister src, Register dest, |
| 1284 |
Label* fail) PER_SHARED_ARCH; |
| 1285 |
void floorDoubleToInt32(FloatRegister src, Register dest, |
| 1286 |
Label* fail) PER_SHARED_ARCH; |
| 1287 |
|
| 1288 |
void ceilFloat32ToInt32(FloatRegister src, Register dest, |
| 1289 |
Label* fail) PER_SHARED_ARCH; |
| 1290 |
void ceilDoubleToInt32(FloatRegister src, Register dest, |
| 1291 |
Label* fail) PER_SHARED_ARCH; |
| 1292 |
|
| 1293 |
void roundFloat32ToInt32(FloatRegister src, Register dest, FloatRegister temp, |
| 1294 |
Label* fail) PER_SHARED_ARCH; |
| 1295 |
void roundDoubleToInt32(FloatRegister src, Register dest, FloatRegister temp, |
| 1296 |
Label* fail) PER_SHARED_ARCH; |
| 1297 |
|
| 1298 |
void truncFloat32ToInt32(FloatRegister src, Register dest, |
| 1299 |
Label* fail) PER_SHARED_ARCH; |
| 1300 |
void truncDoubleToInt32(FloatRegister src, Register dest, |
| 1301 |
Label* fail) PER_SHARED_ARCH; |
| 1302 |
|
| 1303 |
void nearbyIntDouble(RoundingMode mode, FloatRegister src, |
| 1304 |
FloatRegister dest) PER_SHARED_ARCH; |
| 1305 |
void nearbyIntFloat32(RoundingMode mode, FloatRegister src, |
| 1306 |
FloatRegister dest) PER_SHARED_ARCH; |
| 1307 |
|
| 1308 |
void signInt32(Register input, Register output); |
| 1309 |
void signDouble(FloatRegister input, FloatRegister output); |
| 1310 |
void signDoubleToInt32(FloatRegister input, Register output, |
| 1311 |
FloatRegister temp, Label* fail); |
| 1312 |
|
| 1313 |
void copySignDouble(FloatRegister lhs, FloatRegister rhs, |
| 1314 |
FloatRegister output) PER_SHARED_ARCH; |
| 1315 |
void copySignFloat32(FloatRegister lhs, FloatRegister rhs, |
| 1316 |
FloatRegister output) DEFINED_ON(x86_shared, arm64); |
| 1317 |
|
| 1318 |
// Returns a random double in range [0, 1) in |dest|. The |rng| register must |
| 1319 |
// hold a pointer to a mozilla::non_crypto::XorShift128PlusRNG. |
| 1320 |
void randomDouble(Register rng, FloatRegister dest, Register64 temp0, |
| 1321 |
Register64 temp1); |
| 1322 |
|
| 1323 |
// srcDest = {min,max}{Float32,Double}(srcDest, other) |
| 1324 |
// For min and max, handle NaN specially if handleNaN is true. |
| 1325 |
|
| 1326 |
inline void minFloat32(FloatRegister other, FloatRegister srcDest, |
| 1327 |
bool handleNaN) PER_SHARED_ARCH; |
| 1328 |
inline void minDouble(FloatRegister other, FloatRegister srcDest, |
| 1329 |
bool handleNaN) PER_SHARED_ARCH; |
| 1330 |
|
| 1331 |
inline void maxFloat32(FloatRegister other, FloatRegister srcDest, |
| 1332 |
bool handleNaN) PER_SHARED_ARCH; |
| 1333 |
inline void maxDouble(FloatRegister other, FloatRegister srcDest, |
| 1334 |
bool handleNaN) PER_SHARED_ARCH; |
| 1335 |
|
| 1336 |
void minMaxArrayInt32(Register array, Register result, Register temp1, |
| 1337 |
Register temp2, Register temp3, bool isMax, |
| 1338 |
Label* fail); |
| 1339 |
void minMaxArrayNumber(Register array, FloatRegister result, |
| 1340 |
FloatRegister floatTemp, Register temp1, |
| 1341 |
Register temp2, bool isMax, Label* fail); |
| 1342 |
|
| 1343 |
// Compute |pow(base, power)| and store the result in |dest|. If the result |
| 1344 |
// exceeds the int32 range, jumps to |onOver|. |
| 1345 |
// |base| and |power| are preserved, the other input registers are clobbered. |
| 1346 |
void pow32(Register base, Register power, Register dest, Register temp1, |
| 1347 |
Register temp2, Label* onOver); |
| 1348 |
void powPtr(Register base, Register power, Register dest, Register temp1, |
| 1349 |
Register temp2, Label* onOver); |
| 1350 |
|
| 1351 |
void sameValueDouble(FloatRegister left, FloatRegister right, |
| 1352 |
FloatRegister temp, Register dest); |
| 1353 |
|
| 1354 |
void loadRegExpLastIndex(Register regexp, Register string, Register lastIndex, |
| 1355 |
Label* notFoundZeroLastIndex); |
| 1356 |
|
| 1357 |
void loadAndClearRegExpSearcherLastLimit(Register result, Register scratch); |
| 1358 |
|
| 1359 |
void loadParsedRegExpShared(Register regexp, Register result, |
| 1360 |
Label* unparsed); |
| 1361 |
|
| 1362 |
// =============================================================== |
| 1363 |
// Shift functions |
| 1364 |
|
| 1365 |
// For shift-by-register there may be platform-specific variations, for |
| 1366 |
// example, x86 will perform the shift mod 32 but ARM will perform the shift |
| 1367 |
// mod 256. |
| 1368 |
// |
| 1369 |
// For shift-by-immediate the platform assembler may restrict the immediate, |
| 1370 |
// for example, the ARM assembler requires the count for 32-bit shifts to be |
| 1371 |
// in the range [0,31]. |
| 1372 |
|
| 1373 |
inline void lshift32(Imm32 shift, Register srcDest) PER_SHARED_ARCH; |
| 1374 |
inline void lshift32(Imm32 shift, Register src, |
| 1375 |
Register dest) PER_SHARED_ARCH; |
| 1376 |
inline void rshift32(Imm32 shift, Register srcDest) PER_SHARED_ARCH; |
| 1377 |
inline void rshift32(Imm32 shift, Register src, |
| 1378 |
Register dest) PER_SHARED_ARCH; |
| 1379 |
inline void rshift32Arithmetic(Imm32 shift, Register srcDest) PER_SHARED_ARCH; |
| 1380 |
inline void rshift32Arithmetic(Imm32 shift, Register src, |
| 1381 |
Register dest) PER_SHARED_ARCH; |
| 1382 |
|
| 1383 |
inline void lshiftPtr(Imm32 imm, Register dest) PER_ARCH; |
| 1384 |
inline void lshiftPtr(Imm32 imm, Register src, Register dest) PER_ARCH; |
| 1385 |
inline void rshiftPtr(Imm32 imm, Register dest) PER_ARCH; |
| 1386 |
inline void rshiftPtr(Imm32 imm, Register src, Register dest) PER_ARCH; |
| 1387 |
inline void rshiftPtrArithmetic(Imm32 imm, Register dest) PER_ARCH; |
| 1388 |
inline void rshiftPtrArithmetic(Imm32 imm, Register src, |
| 1389 |
Register dest) PER_ARCH; |
| 1390 |
|
| 1391 |
inline void lshift64(Imm32 imm, Register64 dest) PER_ARCH; |
| 1392 |
inline void rshift64(Imm32 imm, Register64 dest) PER_ARCH; |
| 1393 |
inline void rshift64Arithmetic(Imm32 imm, Register64 dest) PER_ARCH; |
| 1394 |
|
| 1395 |
// On x86_shared these have the constraint that shift must be in CL. |
| 1396 |
inline void lshift32(Register shift, Register srcDest) PER_SHARED_ARCH; |
| 1397 |
inline void rshift32(Register shift, Register srcDest) PER_SHARED_ARCH; |
| 1398 |
inline void rshift32Arithmetic(Register shift, |
| 1399 |
Register srcDest) PER_SHARED_ARCH; |
| 1400 |
inline void lshiftPtr(Register shift, Register srcDest) PER_ARCH; |
| 1401 |
inline void rshiftPtr(Register shift, Register srcDest) PER_ARCH; |
| 1402 |
inline void rshiftPtrArithmetic(Register shift, Register srcDest) PER_ARCH; |
| 1403 |
|
| 1404 |
// These variants do not have the above constraint, but may emit some extra |
| 1405 |
// instructions on x86_shared. They also handle shift >= 32 consistently by |
| 1406 |
// masking with 0x1F (either explicitly or relying on the hardware to do |
| 1407 |
// that). |
| 1408 |
inline void flexibleLshift32(Register shift, |
| 1409 |
Register srcDest) PER_SHARED_ARCH; |
| 1410 |
inline void flexibleRshift32(Register shift, |
| 1411 |
Register srcDest) PER_SHARED_ARCH; |
| 1412 |
inline void flexibleRshift32Arithmetic(Register shift, |
| 1413 |
Register srcDest) PER_SHARED_ARCH; |
| 1414 |
inline void flexibleLshiftPtr(Register shift, Register srcDest) PER_ARCH; |
| 1415 |
inline void flexibleRshiftPtr(Register shift, Register srcDest) PER_ARCH; |
| 1416 |
inline void flexibleRshiftPtrArithmetic(Register shift, |
| 1417 |
Register srcDest) PER_ARCH; |
| 1418 |
|
| 1419 |
inline void lshift64(Register shift, Register64 srcDest) PER_ARCH; |
| 1420 |
inline void rshift64(Register shift, Register64 srcDest) PER_ARCH; |
| 1421 |
inline void rshift64Arithmetic(Register shift, Register64 srcDest) PER_ARCH; |
| 1422 |
|
| 1423 |
// =============================================================== |
| 1424 |
// Rotation functions |
| 1425 |
// Note: - on x86 and x64 the count register must be in CL. |
| 1426 |
// - on x64 the temp register should be InvalidReg. |
| 1427 |
|
| 1428 |
inline void rotateLeft(Imm32 count, Register input, |
| 1429 |
Register dest) PER_SHARED_ARCH; |
| 1430 |
inline void rotateLeft(Register count, Register input, |
| 1431 |
Register dest) PER_SHARED_ARCH; |
| 1432 |
inline void rotateLeft64(Imm32 count, Register64 input, Register64 dest) |
| 1433 |
DEFINED_ON(x64); |
| 1434 |
inline void rotateLeft64(Register count, Register64 input, Register64 dest) |
| 1435 |
DEFINED_ON(x64); |
| 1436 |
inline void rotateLeft64(Imm32 count, Register64 input, Register64 dest, |
| 1437 |
Register temp) PER_ARCH; |
| 1438 |
inline void rotateLeft64(Register count, Register64 input, Register64 dest, |
| 1439 |
Register temp) PER_ARCH; |
| 1440 |
|
| 1441 |
inline void rotateRight(Imm32 count, Register input, |
| 1442 |
Register dest) PER_SHARED_ARCH; |
| 1443 |
inline void rotateRight(Register count, Register input, |
| 1444 |
Register dest) PER_SHARED_ARCH; |
| 1445 |
inline void rotateRight64(Imm32 count, Register64 input, Register64 dest) |
| 1446 |
DEFINED_ON(x64); |
| 1447 |
inline void rotateRight64(Register count, Register64 input, Register64 dest) |
| 1448 |
DEFINED_ON(x64); |
| 1449 |
inline void rotateRight64(Imm32 count, Register64 input, Register64 dest, |
| 1450 |
Register temp) PER_ARCH; |
| 1451 |
inline void rotateRight64(Register count, Register64 input, Register64 dest, |
| 1452 |
Register temp) PER_ARCH; |
| 1453 |
|
| 1454 |
// =============================================================== |
| 1455 |
// Bit counting functions |
| 1456 |
|
| 1457 |
// knownNotZero may be true only if the src is known not to be zero. |
| 1458 |
inline void clz32(Register src, Register dest, |
| 1459 |
bool knownNotZero) PER_SHARED_ARCH; |
| 1460 |
inline void ctz32(Register src, Register dest, |
| 1461 |
bool knownNotZero) PER_SHARED_ARCH; |
| 1462 |
|
| 1463 |
inline void clz64(Register64 src, Register64 dest) PER_ARCH; |
| 1464 |
inline void ctz64(Register64 src, Register64 dest) PER_ARCH; |
| 1465 |
|
| 1466 |
// On x86_shared, temp may be Invalid only if the chip has the POPCNT |
| 1467 |
// instruction. On ARM, temp may never be Invalid. |
| 1468 |
inline void popcnt32(Register src, Register dest, |
| 1469 |
Register temp) PER_SHARED_ARCH; |
| 1470 |
|
| 1471 |
// temp may be invalid only if the chip has the POPCNT instruction. |
| 1472 |
inline void popcnt64(Register64 src, Register64 dest, Register temp) PER_ARCH; |
| 1473 |
|
| 1474 |
// =============================================================== |
| 1475 |
// Condition functions |
| 1476 |
|
| 1477 |
inline void cmp8Set(Condition cond, Address lhs, Imm32 rhs, |
| 1478 |
Register dest) PER_SHARED_ARCH; |
| 1479 |
|
| 1480 |
inline void cmp16Set(Condition cond, Address lhs, Imm32 rhs, |
| 1481 |
Register dest) PER_SHARED_ARCH; |
| 1482 |
|
| 1483 |
template <typename T1, typename T2> |
| 1484 |
inline void cmp32Set(Condition cond, T1 lhs, T2 rhs, |
| 1485 |
Register dest) PER_SHARED_ARCH; |
| 1486 |
|
| 1487 |
inline void cmp64Set(Condition cond, Register64 lhs, Register64 rhs, |
| 1488 |
Register dest) PER_ARCH; |
| 1489 |
|
| 1490 |
inline void cmp64Set(Condition cond, Register64 lhs, Imm64 rhs, |
| 1491 |
Register dest) PER_ARCH; |
| 1492 |
|
| 1493 |
inline void cmp64Set(Condition cond, Address lhs, Register64 rhs, |
| 1494 |
Register dest) PER_ARCH; |
| 1495 |
|
| 1496 |
inline void cmp64Set(Condition cond, Address lhs, Imm64 rhs, |
| 1497 |
Register dest) PER_ARCH; |
| 1498 |
|
| 1499 |
template <typename T1, typename T2> |
| 1500 |
inline void cmpPtrSet(Condition cond, T1 lhs, T2 rhs, Register dest) PER_ARCH; |
| 1501 |
|
| 1502 |
// =============================================================== |
| 1503 |
// Branch functions |
| 1504 |
|
| 1505 |
inline void branch8(Condition cond, const Address& lhs, Imm32 rhs, |
| 1506 |
Label* label) PER_SHARED_ARCH; |
| 1507 |
|
| 1508 |
// Compares the byte in |lhs| against |rhs| using a 8-bit comparison on |
| 1509 |
// x86/x64 or a 32-bit comparison (all other platforms). The caller should |
| 1510 |
// ensure |rhs| is a zero- resp. sign-extended byte value for cross-platform |
| 1511 |
// compatible code. |
| 1512 |
inline void branch8(Condition cond, const BaseIndex& lhs, Register rhs, |
| 1513 |
Label* label) PER_SHARED_ARCH; |
| 1514 |
|
| 1515 |
inline void branch16(Condition cond, const Address& lhs, Imm32 rhs, |
| 1516 |
Label* label) PER_SHARED_ARCH; |
| 1517 |
|
| 1518 |
// On some platforms, it is possible to do a 32-bit comparison against |
| 1519 |
// the low 32 bits of a 64-bit register, ignoring the high bits. On |
| 1520 |
// other architectures (eg RISC-V), this may not be possible. Passing |
| 1521 |
// LhsHighBitsAreClean::No implies that the architecture-specific code |
| 1522 |
// must zero/sign-extend the low bits of the Lhs if it can't ignore |
| 1523 |
// the high bits. |
| 1524 |
enum class LhsHighBitsAreClean { Yes, No }; |
| 1525 |
|
| 1526 |
inline void branch32(Condition cond, Register lhs, Register rhs, Label* label, |
| 1527 |
LhsHighBitsAreClean clean = LhsHighBitsAreClean::Yes) |
| 1528 |
PER_SHARED_ARCH; |
| 1529 |
inline void branch32(Condition cond, Register lhs, Imm32 rhs, Label* label, |
| 1530 |
LhsHighBitsAreClean clean = LhsHighBitsAreClean::Yes) |
| 1531 |
PER_SHARED_ARCH; |
| 1532 |
|
| 1533 |
inline void branch32(Condition cond, Register lhs, const Address& rhs, |
| 1534 |
Label* label) DEFINED_ON(arm64); |
| 1535 |
|
| 1536 |
inline void branch32(Condition cond, const Address& lhs, Register rhs, |
| 1537 |
Label* label) PER_SHARED_ARCH; |
| 1538 |
inline void branch32(Condition cond, const Address& lhs, Imm32 rhs, |
| 1539 |
Label* label) PER_SHARED_ARCH; |
| 1540 |
|
| 1541 |
inline void branch32(Condition cond, const AbsoluteAddress& lhs, Register rhs, |
| 1542 |
Label* label) PER_ARCH; |
| 1543 |
inline void branch32(Condition cond, const AbsoluteAddress& lhs, Imm32 rhs, |
| 1544 |
Label* label) PER_ARCH; |
| 1545 |
|
| 1546 |
inline void branch32(Condition cond, const BaseIndex& lhs, Register rhs, |
| 1547 |
Label* label) DEFINED_ON(arm, x86_shared); |
| 1548 |
inline void branch32(Condition cond, const BaseIndex& lhs, Imm32 rhs, |
| 1549 |
Label* label) PER_SHARED_ARCH; |
| 1550 |
|
| 1551 |
inline void branch32(Condition cond, const Operand& lhs, Register rhs, |
| 1552 |
Label* label) DEFINED_ON(x86_shared); |
| 1553 |
inline void branch32(Condition cond, const Operand& lhs, Imm32 rhs, |
| 1554 |
Label* label) DEFINED_ON(x86_shared); |
| 1555 |
|
| 1556 |
inline void branch32(Condition cond, wasm::SymbolicAddress lhs, Imm32 rhs, |
| 1557 |
Label* label) PER_ARCH; |
| 1558 |
|
| 1559 |
// The supported condition are Equal, NotEqual, LessThan(orEqual), |
| 1560 |
// GreaterThan(orEqual), Below(orEqual) and Above(orEqual). When a fail label |
| 1561 |
// is not defined it will fall through to next instruction, else jump to the |
| 1562 |
// fail label. |
| 1563 |
inline void branch64(Condition cond, Register64 lhs, Imm64 val, |
| 1564 |
Label* success, Label* fail = nullptr) PER_ARCH; |
| 1565 |
inline void branch64(Condition cond, Register64 lhs, Register64 rhs, |
| 1566 |
Label* success, Label* fail = nullptr) PER_ARCH; |
| 1567 |
inline void branch64(Condition cond, const Address& lhs, Imm64 val, |
| 1568 |
Label* success, Label* fail = nullptr) PER_ARCH; |
| 1569 |
inline void branch64(Condition cond, const Address& lhs, Register64 rhs, |
| 1570 |
Label* success, Label* fail = nullptr) PER_ARCH; |
| 1571 |
|
| 1572 |
// Compare the value at |lhs| with the value at |rhs|. The scratch |
| 1573 |
// register *must not* be the base of |lhs| or |rhs|. |
| 1574 |
// Only the NotEqual and Equal conditions are allowed. |
| 1575 |
inline void branch64(Condition cond, const Address& lhs, const Address& rhs, |
| 1576 |
Register scratch, Label* label) PER_ARCH; |
| 1577 |
|
| 1578 |
inline void branchPtr(Condition cond, Register lhs, Register rhs, |
| 1579 |
Label* label) PER_SHARED_ARCH; |
| 1580 |
inline void branchPtr(Condition cond, Register lhs, Imm32 rhs, |
| 1581 |
Label* label) PER_SHARED_ARCH; |
| 1582 |
inline void branchPtr(Condition cond, Register lhs, ImmPtr rhs, |
| 1583 |
Label* label) PER_SHARED_ARCH; |
| 1584 |
inline void branchPtr(Condition cond, Register lhs, ImmGCPtr rhs, |
| 1585 |
Label* label) PER_SHARED_ARCH; |
| 1586 |
inline void branchPtr(Condition cond, Register lhs, ImmWord rhs, |
| 1587 |
Label* label) PER_SHARED_ARCH; |
| 1588 |
|
| 1589 |
inline void branchPtr(Condition cond, const Address& lhs, Register rhs, |
| 1590 |
Label* label) PER_SHARED_ARCH; |
| 1591 |
inline void branchPtr(Condition cond, const Address& lhs, ImmPtr rhs, |
| 1592 |
Label* label) PER_SHARED_ARCH; |
| 1593 |
inline void branchPtr(Condition cond, const Address& lhs, ImmGCPtr rhs, |
| 1594 |
Label* label) PER_SHARED_ARCH; |
| 1595 |
inline void branchPtr(Condition cond, const Address& lhs, ImmWord rhs, |
| 1596 |
Label* label) PER_SHARED_ARCH; |
| 1597 |
|
| 1598 |
inline void branchPtr(Condition cond, const BaseIndex& lhs, ImmWord rhs, |
| 1599 |
Label* label) PER_SHARED_ARCH; |
| 1600 |
inline void branchPtr(Condition cond, const BaseIndex& lhs, Register rhs, |
| 1601 |
Label* label) PER_SHARED_ARCH; |
| 1602 |
|
| 1603 |
inline void branchPtr(Condition cond, const AbsoluteAddress& lhs, |
| 1604 |
Register rhs, Label* label) PER_ARCH; |
| 1605 |
inline void branchPtr(Condition cond, const AbsoluteAddress& lhs, ImmWord rhs, |
| 1606 |
Label* label) PER_ARCH; |
| 1607 |
|
| 1608 |
inline void branchPtr(Condition cond, wasm::SymbolicAddress lhs, Register rhs, |
| 1609 |
Label* label) PER_ARCH; |
| 1610 |
|
| 1611 |
// Given a pointer to a GC Cell, retrieve the StoreBuffer pointer from its |
| 1612 |
// chunk header, or nullptr if it is in the tenured heap. |
| 1613 |
void loadStoreBuffer(Register ptr, Register buffer) PER_ARCH; |
| 1614 |
|
| 1615 |
void branchPtrInNurseryChunk(Condition cond, Register ptr, Register temp, |
| 1616 |
Label* label) PER_ARCH; |
| 1617 |
void branchPtrInNurseryChunk(Condition cond, const Address& address, |
| 1618 |
Register temp, Label* label) DEFINED_ON(x86); |
| 1619 |
void branchValueIsNurseryCell(Condition cond, const Address& address, |
| 1620 |
Register temp, Label* label) PER_ARCH; |
| 1621 |
void branchValueIsNurseryCell(Condition cond, ValueOperand value, |
| 1622 |
Register temp, Label* label) PER_ARCH; |
| 1623 |
|
| 1624 |
// This function compares a Value (lhs) which is having a private pointer |
| 1625 |
// boxed inside a js::Value, with a raw pointer (rhs). |
| 1626 |
inline void branchPrivatePtr(Condition cond, const Address& lhs, Register rhs, |
| 1627 |
Label* label) PER_ARCH; |
| 1628 |
|
| 1629 |
inline void branchFloat(DoubleCondition cond, FloatRegister lhs, |
| 1630 |
FloatRegister rhs, Label* label) PER_SHARED_ARCH; |
| 1631 |
|
| 1632 |
// Truncate a double/float32 to int32 and when it doesn't fit an int32 it will |
| 1633 |
// jump to the failure label. This particular variant is allowed to return the |
| 1634 |
// value module 2**32, which isn't implemented on all architectures. |
| 1635 |
inline void branchTruncateFloat32MaybeModUint32(FloatRegister src, |
| 1636 |
Register dest, |
| 1637 |
Label* fail) PER_ARCH; |
| 1638 |
inline void branchTruncateDoubleMaybeModUint32(FloatRegister src, |
| 1639 |
Register dest, |
| 1640 |
Label* fail) PER_ARCH; |
| 1641 |
|
| 1642 |
// Truncate a double/float32 to intptr and when it doesn't fit jump to the |
| 1643 |
// failure label. |
| 1644 |
inline void branchTruncateFloat32ToPtr(FloatRegister src, Register dest, |
| 1645 |
Label* fail) DEFINED_ON(x86, x64); |
| 1646 |
inline void branchTruncateDoubleToPtr(FloatRegister src, Register dest, |
| 1647 |
Label* fail) DEFINED_ON(x86, x64); |
| 1648 |
|
| 1649 |
// Truncate a double/float32 to int32 and when it doesn't fit jump to the |
| 1650 |
// failure label. |
| 1651 |
inline void branchTruncateFloat32ToInt32(FloatRegister src, Register dest, |
| 1652 |
Label* fail) PER_ARCH; |
| 1653 |
inline void branchTruncateDoubleToInt32(FloatRegister src, Register dest, |
| 1654 |
Label* fail) PER_ARCH; |
| 1655 |
|
| 1656 |
inline void branchDouble(DoubleCondition cond, FloatRegister lhs, |
| 1657 |
FloatRegister rhs, Label* label) PER_SHARED_ARCH; |
| 1658 |
|
| 1659 |
inline void branchDoubleNotInInt64Range(Address src, Register temp, |
| 1660 |
Label* fail); |
| 1661 |
inline void branchDoubleNotInUInt64Range(Address src, Register temp, |
| 1662 |
Label* fail); |
| 1663 |
inline void branchFloat32NotInInt64Range(Address src, Register temp, |
| 1664 |
Label* fail); |
| 1665 |
inline void branchFloat32NotInUInt64Range(Address src, Register temp, |
| 1666 |
Label* fail); |
| 1667 |
|
| 1668 |
// Branch if the (un)signed int64 is outside the range of a signed intptr. |
| 1669 |
inline void branchInt64NotInPtrRange(Register64 src, Label* label) PER_ARCH; |
| 1670 |
inline void branchUInt64NotInPtrRange(Register64 src, Label* label) PER_ARCH; |
| 1671 |
|
| 1672 |
template <typename T> |
| 1673 |
inline void branchAdd32(Condition cond, T src, Register dest, |
| 1674 |
Label* label) PER_SHARED_ARCH; |
| 1675 |
template <typename T> |
| 1676 |
inline void branchSub32(Condition cond, T src, Register dest, |
| 1677 |
Label* label) PER_SHARED_ARCH; |
| 1678 |
template <typename T> |
| 1679 |
inline void branchMul32(Condition cond, T src, Register dest, |
| 1680 |
Label* label) PER_SHARED_ARCH; |
| 1681 |
template <typename T> |
| 1682 |
inline void branchRshift32(Condition cond, T src, Register dest, |
| 1683 |
Label* label) PER_SHARED_ARCH; |
| 1684 |
|
| 1685 |
inline void branchNeg32(Condition cond, Register reg, |
| 1686 |
Label* label) PER_SHARED_ARCH; |
| 1687 |
|
| 1688 |
inline void branchAdd64(Condition cond, Imm64 imm, Register64 dest, |
| 1689 |
Label* label) DEFINED_ON(x86, arm, wasm32); |
| 1690 |
|
| 1691 |
template <typename T> |
| 1692 |
inline void branchAddPtr(Condition cond, T src, Register dest, |
| 1693 |
Label* label) PER_SHARED_ARCH; |
| 1694 |
|
| 1695 |
template <typename T> |
| 1696 |
inline void branchSubPtr(Condition cond, T src, Register dest, |
| 1697 |
Label* label) PER_SHARED_ARCH; |
| 1698 |
|
| 1699 |
inline void branchMulPtr(Condition cond, Register src, Register dest, |
| 1700 |
Label* label) PER_SHARED_ARCH; |
| 1701 |
|
| 1702 |
inline void branchNegPtr(Condition cond, Register reg, |
| 1703 |
Label* label) PER_SHARED_ARCH; |
| 1704 |
|
| 1705 |
inline void decBranchPtr(Condition cond, Register lhs, Imm32 rhs, |
| 1706 |
Label* label) PER_SHARED_ARCH; |
| 1707 |
|
| 1708 |
inline void branchTest32(Condition cond, Register lhs, Register rhs, |
| 1709 |
Label* label) PER_SHARED_ARCH; |
| 1710 |
inline void branchTest32(Condition cond, Register lhs, Imm32 rhs, |
| 1711 |
Label* label) PER_SHARED_ARCH; |
| 1712 |
inline void branchTest32(Condition cond, const Address& lhs, Imm32 rhh, |
| 1713 |
Label* label) PER_SHARED_ARCH; |
| 1714 |
inline void branchTest32(Condition cond, const AbsoluteAddress& lhs, |
| 1715 |
Imm32 rhs, Label* label) PER_ARCH; |
| 1716 |
|
| 1717 |
inline void branchTestPtr(Condition cond, Register lhs, Register rhs, |
| 1718 |
Label* label) PER_SHARED_ARCH; |
| 1719 |
inline void branchTestPtr(Condition cond, Register lhs, Imm32 rhs, |
| 1720 |
Label* label) PER_SHARED_ARCH; |
| 1721 |
inline void branchTestPtr(Condition cond, Register lhs, ImmWord rhs, |
| 1722 |
Label* label) PER_ARCH; |
| 1723 |
inline void branchTestPtr(Condition cond, const Address& lhs, Imm32 rhs, |
| 1724 |
Label* label) PER_SHARED_ARCH; |
| 1725 |
|
| 1726 |
// When a fail label is not defined it will fall through to next instruction, |
| 1727 |
// else jump to the fail label. |
| 1728 |
// |
| 1729 |
// On x86 if |lhs == rhs|, |temp| is used to generate a single branch |
| 1730 |
// instruction. Otherwise |temp| is unused and can be |InvalidReg|. |
| 1731 |
inline void branchTest64(Condition cond, Register64 lhs, Register64 rhs, |
| 1732 |
Register temp, Label* success, |
| 1733 |
Label* fail = nullptr) PER_ARCH; |
| 1734 |
inline void branchTest64(Condition cond, Register64 lhs, Register64 rhs, |
| 1735 |
Label* success, Label* fail = nullptr); |
| 1736 |
inline void branchTest64(Condition cond, Register64 lhs, Imm64 rhs, |
| 1737 |
Label* success, Label* fail = nullptr) PER_ARCH; |
| 1738 |
|
| 1739 |
// Branches to |label| if |reg| is false. |reg| should be a C++ bool. |
| 1740 |
inline void branchIfFalseBool(Register reg, Label* label); |
| 1741 |
|
| 1742 |
// Branches to |label| if |reg| is true. |reg| should be a C++ bool. |
| 1743 |
inline void branchIfTrueBool(Register reg, Label* label); |
| 1744 |
|
| 1745 |
inline void branchIfNotNullOrUndefined(ValueOperand val, Label* label); |
| 1746 |
|
| 1747 |
inline void branchIfRope(Register str, Label* label); |
| 1748 |
inline void branchIfNotRope(Register str, Label* label); |
| 1749 |
|
| 1750 |
inline void branchLatin1String(Register string, Label* label); |
| 1751 |
inline void branchTwoByteString(Register string, Label* label); |
| 1752 |
|
| 1753 |
inline void branchIfBigIntIsNegative(Register bigInt, Label* label); |
| 1754 |
inline void branchIfBigIntIsNonNegative(Register bigInt, Label* label); |
| 1755 |
inline void branchIfBigIntIsZero(Register bigInt, Label* label); |
| 1756 |
inline void branchIfBigIntIsNonZero(Register bigInt, Label* label); |
| 1757 |
|
| 1758 |
inline void branchTestFunctionFlags(Register fun, uint32_t flags, |
| 1759 |
Condition cond, Label* label); |
| 1760 |
|
| 1761 |
inline void branchIfNotFunctionIsNonBuiltinCtor(Register fun, |
| 1762 |
Register scratch, |
| 1763 |
Label* label); |
| 1764 |
|
| 1765 |
inline void branchIfFunctionHasNoJitEntry(Register fun, Label* label); |
| 1766 |
inline void branchIfFunctionHasJitEntry(Register fun, Label* label); |
| 1767 |
|
| 1768 |
inline void branchIfScriptHasJitScript(Register script, Label* label); |
| 1769 |
inline void branchIfScriptHasNoJitScript(Register script, Label* label); |
| 1770 |
inline void loadJitScript(Register script, Register dest); |
| 1771 |
|
| 1772 |
// Loads the function's argument count. |
| 1773 |
inline void loadFunctionArgCount(Register func, Register output); |
| 1774 |
|
| 1775 |
// Loads the function length. This handles interpreted, native, and bound |
| 1776 |
// functions. The caller is responsible for checking that INTERPRETED_LAZY and |
| 1777 |
// RESOLVED_LENGTH flags are not set. |
| 1778 |
void loadFunctionLength(Register func, Register funFlagsAndArgCount, |
| 1779 |
Register output, Label* slowPath); |
| 1780 |
|
| 1781 |
// Loads the function name. This handles interpreted, native, and bound |
| 1782 |
// functions. |
| 1783 |
void loadFunctionName(Register func, Register output, ImmGCPtr emptyString, |
| 1784 |
Label* slowPath); |
| 1785 |
|
| 1786 |
void assertFunctionIsExtended(Register func); |
| 1787 |
|
| 1788 |
inline void branchFunctionKind(Condition cond, |
| 1789 |
FunctionFlags::FunctionKind kind, Register fun, |
| 1790 |
Register scratch, Label* label); |
| 1791 |
|
| 1792 |
inline void branchIfObjectEmulatesUndefined(Register objReg, Register scratch, |
| 1793 |
Label* slowCheck, Label* label); |
| 1794 |
|
| 1795 |
// For all methods below: spectreRegToZero is a register that will be zeroed |
| 1796 |
// on speculatively executed code paths (when the branch should be taken but |
| 1797 |
// branch prediction speculates it isn't). Usually this will be the object |
| 1798 |
// register but the caller may pass a different register. |
| 1799 |
|
| 1800 |
inline void branchTestObjClass(Condition cond, Register obj, |
| 1801 |
const JSClass* clasp, Register scratch, |
| 1802 |
Register spectreRegToZero, Label* label); |
| 1803 |
inline void branchTestObjClassNoSpectreMitigations(Condition cond, |
| 1804 |
Register obj, |
| 1805 |
const JSClass* clasp, |
| 1806 |
Register scratch, |
| 1807 |
Label* label); |
| 1808 |
|
| 1809 |
inline void branchTestObjClass(Condition cond, Register obj, |
| 1810 |
const Address& clasp, Register scratch, |
| 1811 |
Register spectreRegToZero, Label* label); |
| 1812 |
inline void branchTestObjClassNoSpectreMitigations(Condition cond, |
| 1813 |
Register obj, |
| 1814 |
const Address& clasp, |
| 1815 |
Register scratch, |
| 1816 |
Label* label); |
| 1817 |
|
| 1818 |
inline void branchTestObjClass(Condition cond, Register obj, Register clasp, |
| 1819 |
Register scratch, Register spectreRegToZero, |
| 1820 |
Label* label); |
| 1821 |
|
| 1822 |
private: |
| 1823 |
inline void branchTestClass(Condition cond, Register clasp, |
| 1824 |
std::pair<const JSClass*, const JSClass*> classes, |
| 1825 |
Label* label); |
| 1826 |
|
| 1827 |
public: |
| 1828 |
inline void branchTestObjClass( |
| 1829 |
Condition cond, Register obj, |
| 1830 |
std::pair<const JSClass*, const JSClass*> classes, Register scratch, |
| 1831 |
Register spectreRegToZero, Label* label); |
| 1832 |
inline void branchTestObjClassNoSpectreMitigations( |
| 1833 |
Condition cond, Register obj, |
| 1834 |
std::pair<const JSClass*, const JSClass*> classes, Register scratch, |
| 1835 |
Label* label); |
| 1836 |
|
| 1837 |
inline void branchTestObjShape(Condition cond, Register obj, |
| 1838 |
const Shape* shape, Register scratch, |
| 1839 |
Register spectreRegToZero, Label* label); |
| 1840 |
inline void branchTestObjShapeNoSpectreMitigations(Condition cond, |
| 1841 |
Register obj, |
| 1842 |
const Shape* shape, |
| 1843 |
Label* label); |
| 1844 |
|
| 1845 |
void branchTestObjShapeList(Condition cond, Register obj, |
| 1846 |
Register shapeElements, Register shapeScratch, |
| 1847 |
Register endScratch, Register spectreScratch, |
| 1848 |
Label* label); |
| 1849 |
|
| 1850 |
inline void branchTestClassIsFunction(Condition cond, Register clasp, |
| 1851 |
Label* label); |
| 1852 |
inline void branchTestObjIsFunction(Condition cond, Register obj, |
| 1853 |
Register scratch, |
| 1854 |
Register spectreRegToZero, Label* label); |
| 1855 |
inline void branchTestObjIsFunctionNoSpectreMitigations(Condition cond, |
| 1856 |
Register obj, |
| 1857 |
Register scratch, |
| 1858 |
Label* label); |
| 1859 |
|
| 1860 |
inline void branchTestObjShape(Condition cond, Register obj, Register shape, |
| 1861 |
Register scratch, Register spectreRegToZero, |
| 1862 |
Label* label); |
| 1863 |
inline void branchTestObjShapeNoSpectreMitigations(Condition cond, |
| 1864 |
Register obj, |
| 1865 |
Register shape, |
| 1866 |
Label* label); |
| 1867 |
|
| 1868 |
// TODO: audit/fix callers to be Spectre safe. |
| 1869 |
inline void branchTestObjShapeUnsafe(Condition cond, Register obj, |
| 1870 |
Register shape, Label* label); |
| 1871 |
|
| 1872 |
void branchTestObjCompartment(Condition cond, Register obj, |
| 1873 |
const Address& compartment, Register scratch, |
| 1874 |
Label* label); |
| 1875 |
void branchTestObjCompartment(Condition cond, Register obj, |
| 1876 |
const JS::Compartment* compartment, |
| 1877 |
Register scratch, Label* label); |
| 1878 |
|
| 1879 |
void branchIfNonNativeObj(Register obj, Register scratch, Label* label); |
| 1880 |
|
| 1881 |
void branchIfObjectNotExtensible(Register obj, Register scratch, |
| 1882 |
Label* label); |
| 1883 |
|
| 1884 |
void branchTestObjectNeedsProxyResultValidation(Condition condition, |
| 1885 |
Register obj, |
| 1886 |
Register scratch, |
| 1887 |
Label* label); |
| 1888 |
|
| 1889 |
inline void branchTestClassIsProxy(bool proxy, Register clasp, Label* label); |
| 1890 |
|
| 1891 |
inline void branchTestObjectIsProxy(bool proxy, Register object, |
| 1892 |
Register scratch, Label* label); |
| 1893 |
|
| 1894 |
inline void branchTestProxyHandlerFamily(Condition cond, Register proxy, |
| 1895 |
Register scratch, |
| 1896 |
const void* handlerp, Label* label); |
| 1897 |
|
| 1898 |
inline void branchTestNeedsIncrementalBarrier(Condition cond, Label* label); |
| 1899 |
inline void branchTestNeedsIncrementalBarrierAnyZone(Condition cond, |
| 1900 |
Label* label, |
| 1901 |
Register scratch); |
| 1902 |
|
| 1903 |
// Perform a type-test on a tag of a Value (32bits boxing), or the tagged |
| 1904 |
// value (64bits boxing). |
| 1905 |
inline void branchTestUndefined(Condition cond, Register tag, |
| 1906 |
Label* label) PER_SHARED_ARCH; |
| 1907 |
inline void branchTestInt32(Condition cond, Register tag, |
| 1908 |
Label* label) PER_SHARED_ARCH; |
| 1909 |
inline void branchTestDouble(Condition cond, Register tag, |
| 1910 |
Label* label) PER_SHARED_ARCH; |
| 1911 |
inline void branchTestNumber(Condition cond, Register tag, |
| 1912 |
Label* label) PER_SHARED_ARCH; |
| 1913 |
inline void branchTestBoolean(Condition cond, Register tag, |
| 1914 |
Label* label) PER_SHARED_ARCH; |
| 1915 |
inline void branchTestString(Condition cond, Register tag, |
| 1916 |
Label* label) PER_SHARED_ARCH; |
| 1917 |
inline void branchTestSymbol(Condition cond, Register tag, |
| 1918 |
Label* label) PER_SHARED_ARCH; |
| 1919 |
inline void branchTestBigInt(Condition cond, Register tag, |
| 1920 |
Label* label) PER_SHARED_ARCH; |
| 1921 |
inline void branchTestNull(Condition cond, Register tag, |
| 1922 |
Label* label) PER_SHARED_ARCH; |
| 1923 |
inline void branchTestObject(Condition cond, Register tag, |
| 1924 |
Label* label) PER_SHARED_ARCH; |
| 1925 |
inline void branchTestPrimitive(Condition cond, Register tag, |
| 1926 |
Label* label) PER_SHARED_ARCH; |
| 1927 |
inline void branchTestMagic(Condition cond, Register tag, |
| 1928 |
Label* label) PER_SHARED_ARCH; |
| 1929 |
void branchTestType(Condition cond, Register tag, JSValueType type, |
| 1930 |
Label* label); |
| 1931 |
|
| 1932 |
// Perform a type-test on a Value, addressed by Address or BaseIndex, or |
| 1933 |
// loaded into ValueOperand. |
| 1934 |
// BaseIndex and ValueOperand variants clobber the ScratchReg on x64. |
| 1935 |
// All Variants clobber the ScratchReg on arm64. |
| 1936 |
inline void branchTestUndefined(Condition cond, const Address& address, |
| 1937 |
Label* label) PER_SHARED_ARCH; |
| 1938 |
inline void branchTestUndefined(Condition cond, const BaseIndex& address, |
| 1939 |
Label* label) PER_SHARED_ARCH; |
| 1940 |
inline void branchTestUndefined(Condition cond, const ValueOperand& value, |
| 1941 |
Label* label) PER_SHARED_ARCH; |
| 1942 |
|
| 1943 |
inline void branchTestInt32(Condition cond, const Address& address, |
| 1944 |
Label* label) PER_SHARED_ARCH; |
| 1945 |
inline void branchTestInt32(Condition cond, const BaseIndex& address, |
| 1946 |
Label* label) PER_SHARED_ARCH; |
| 1947 |
inline void branchTestInt32(Condition cond, const ValueOperand& value, |
| 1948 |
Label* label) PER_SHARED_ARCH; |
| 1949 |
|
| 1950 |
inline void branchTestDouble(Condition cond, const Address& address, |
| 1951 |
Label* label) PER_SHARED_ARCH; |
| 1952 |
inline void branchTestDouble(Condition cond, const BaseIndex& address, |
| 1953 |
Label* label) PER_SHARED_ARCH; |
| 1954 |
inline void branchTestDouble(Condition cond, const ValueOperand& value, |
| 1955 |
Label* label) PER_SHARED_ARCH; |
| 1956 |
|
| 1957 |
inline void branchTestNumber(Condition cond, const ValueOperand& value, |
| 1958 |
Label* label) PER_SHARED_ARCH; |
| 1959 |
|
| 1960 |
inline void branchTestBoolean(Condition cond, const Address& address, |
| 1961 |
Label* label) PER_SHARED_ARCH; |
| 1962 |
inline void branchTestBoolean(Condition cond, const BaseIndex& address, |
| 1963 |
Label* label) PER_SHARED_ARCH; |
| 1964 |
inline void branchTestBoolean(Condition cond, const ValueOperand& value, |
| 1965 |
Label* label) PER_SHARED_ARCH; |
| 1966 |
|
| 1967 |
inline void branchTestString(Condition cond, const Address& address, |
| 1968 |
Label* label) PER_SHARED_ARCH; |
| 1969 |
inline void branchTestString(Condition cond, const BaseIndex& address, |
| 1970 |
Label* label) PER_SHARED_ARCH; |
| 1971 |
inline void branchTestString(Condition cond, const ValueOperand& value, |
| 1972 |
Label* label) PER_SHARED_ARCH; |
| 1973 |
|
| 1974 |
inline void branchTestSymbol(Condition cond, const Address& address, |
| 1975 |
Label* label) PER_SHARED_ARCH; |
| 1976 |
inline void branchTestSymbol(Condition cond, const BaseIndex& address, |
| 1977 |
Label* label) PER_SHARED_ARCH; |
| 1978 |
inline void branchTestSymbol(Condition cond, const ValueOperand& value, |
| 1979 |
Label* label) PER_SHARED_ARCH; |
| 1980 |
|
| 1981 |
inline void branchTestBigInt(Condition cond, const Address& address, |
| 1982 |
Label* label) PER_SHARED_ARCH; |
| 1983 |
inline void branchTestBigInt(Condition cond, const BaseIndex& address, |
| 1984 |
Label* label) PER_SHARED_ARCH; |
| 1985 |
inline void branchTestBigInt(Condition cond, const ValueOperand& value, |
| 1986 |
Label* label) PER_SHARED_ARCH; |
| 1987 |
|
| 1988 |
inline void branchTestNull(Condition cond, const Address& address, |
| 1989 |
Label* label) PER_SHARED_ARCH; |
| 1990 |
inline void branchTestNull(Condition cond, const BaseIndex& address, |
| 1991 |
Label* label) PER_SHARED_ARCH; |
| 1992 |
inline void branchTestNull(Condition cond, const ValueOperand& value, |
| 1993 |
Label* label) PER_SHARED_ARCH; |
| 1994 |
|
| 1995 |
// Clobbers the ScratchReg on x64. |
| 1996 |
inline void branchTestObject(Condition cond, const Address& address, |
| 1997 |
Label* label) PER_SHARED_ARCH; |
| 1998 |
inline void branchTestObject(Condition cond, const BaseIndex& address, |
| 1999 |
Label* label) PER_SHARED_ARCH; |
| 2000 |
inline void branchTestObject(Condition cond, const ValueOperand& value, |
| 2001 |
Label* label) PER_SHARED_ARCH; |
| 2002 |
|
| 2003 |
inline void branchTestGCThing(Condition cond, const Address& address, |
| 2004 |
Label* label) PER_SHARED_ARCH; |
| 2005 |
inline void branchTestGCThing(Condition cond, const BaseIndex& address, |
| 2006 |
Label* label) PER_SHARED_ARCH; |
| 2007 |
inline void branchTestGCThing(Condition cond, const ValueOperand& value, |
| 2008 |
Label* label) PER_SHARED_ARCH; |
| 2009 |
|
| 2010 |
inline void branchTestPrimitive(Condition cond, const ValueOperand& value, |
| 2011 |
Label* label) PER_SHARED_ARCH; |
| 2012 |
|
| 2013 |
inline void branchTestMagic(Condition cond, const Address& address, |
| 2014 |
Label* label) PER_SHARED_ARCH; |
| 2015 |
inline void branchTestMagic(Condition cond, const BaseIndex& address, |
| 2016 |
Label* label) PER_SHARED_ARCH; |
| 2017 |
inline void branchTestMagic(Condition cond, const ValueOperand& value, |
| 2018 |
Label* label) PER_SHARED_ARCH; |
| 2019 |
|
| 2020 |
inline void branchTestMagic(Condition cond, const Address& valaddr, |
| 2021 |
JSWhyMagic why, Label* label) PER_ARCH; |
| 2022 |
|
| 2023 |
inline void branchTestMagicValue(Condition cond, const ValueOperand& val, |
| 2024 |
JSWhyMagic why, Label* label); |
| 2025 |
|
| 2026 |
void branchTestValue(Condition cond, const ValueOperand& lhs, |
| 2027 |
const Value& rhs, Label* label) PER_ARCH; |
| 2028 |
void branchTestNaNValue(Condition cond, const ValueOperand& val, |
| 2029 |
Register temp, Label* label) PER_ARCH; |
| 2030 |
|
| 2031 |
template <typename T> |
| 2032 |
inline void branchTestValue(Condition cond, const T& lhs, |
| 2033 |
const ValueOperand& rhs, Label* label) PER_ARCH; |
| 2034 |
|
| 2035 |
// Checks if given Value is evaluated to true or false in a condition. |
| 2036 |
// The type of the value should match the type of the method. |
| 2037 |
inline void branchTestInt32Truthy(bool truthy, const ValueOperand& value, |
| 2038 |
Label* label) PER_SHARED_ARCH; |
| 2039 |
inline void branchTestDoubleTruthy(bool truthy, FloatRegister reg, |
| 2040 |
Label* label) PER_SHARED_ARCH; |
| 2041 |
inline void branchTestBooleanTruthy(bool truthy, const ValueOperand& value, |
| 2042 |
Label* label) PER_ARCH; |
| 2043 |
inline void branchTestStringTruthy(bool truthy, const ValueOperand& value, |
| 2044 |
Label* label) PER_SHARED_ARCH; |
| 2045 |
inline void branchTestBigIntTruthy(bool truthy, const ValueOperand& value, |
| 2046 |
Label* label) PER_SHARED_ARCH; |
| 2047 |
|
| 2048 |
// Create an unconditional branch to the address given as argument. |
| 2049 |
inline void branchToComputedAddress(const BaseIndex& address) PER_ARCH; |
| 2050 |
|
| 2051 |
// Subtract a constant in the range 1 .. 127 inclusive from the value stored |
| 2052 |
// at `address`, write the result back to `address`, and jump to `label` if |
| 2053 |
// the updated value is negative. The subtract is a 32-bit operation even |
| 2054 |
// though the value to be subtracted must fit in 7 bits. |
| 2055 |
CodeOffset sub32FromMemAndBranchIfNegativeWithPatch( |
| 2056 |
Address address, Label* label) PER_SHARED_ARCH; |
| 2057 |
|
| 2058 |
// Patch in the value to be subtracted. Must be 1 .. 127 inclusive. |
| 2059 |
void patchSub32FromMemAndBranchIfNegative(CodeOffset offset, |
| 2060 |
Imm32 imm) PER_SHARED_ARCH; |
| 2061 |
|
| 2062 |
private: |
| 2063 |
template <typename T, typename S, typename L> |
| 2064 |
inline void branchPtrImpl(Condition cond, const T& lhs, const S& rhs, L label) |
| 2065 |
DEFINED_ON(x86_shared); |
| 2066 |
|
| 2067 |
void branchPtrInNurseryChunkImpl(Condition cond, Register ptr, Label* label) |
| 2068 |
DEFINED_ON(x86); |
| 2069 |
template <typename T> |
| 2070 |
void branchValueIsNurseryCellImpl(Condition cond, const T& value, |
| 2071 |
Register temp, Label* label) |
| 2072 |
DEFINED_ON(arm64, x64, mips64, loong64, riscv64); |
| 2073 |
|
| 2074 |
template <typename T> |
| 2075 |
inline void branchTestUndefinedImpl(Condition cond, const T& t, Label* label) |
| 2076 |
DEFINED_ON(arm, arm64, x86_shared); |
| 2077 |
template <typename T> |
| 2078 |
inline void branchTestInt32Impl(Condition cond, const T& t, Label* label) |
| 2079 |
DEFINED_ON(arm, arm64, x86_shared); |
| 2080 |
template <typename T> |
| 2081 |
inline void branchTestDoubleImpl(Condition cond, const T& t, Label* label) |
| 2082 |
DEFINED_ON(arm, arm64, x86_shared); |
| 2083 |
template <typename T> |
| 2084 |
inline void branchTestNumberImpl(Condition cond, const T& t, Label* label) |
| 2085 |
DEFINED_ON(arm, arm64, x86_shared); |
| 2086 |
template <typename T> |
| 2087 |
inline void branchTestBooleanImpl(Condition cond, const T& t, Label* label) |
| 2088 |
DEFINED_ON(arm, arm64, x86_shared); |
| 2089 |
template <typename T> |
| 2090 |
inline void branchTestStringImpl(Condition cond, const T& t, Label* label) |
| 2091 |
DEFINED_ON(arm, arm64, x86_shared); |
| 2092 |
template <typename T> |
| 2093 |
inline void branchTestSymbolImpl(Condition cond, const T& t, Label* label) |
| 2094 |
DEFINED_ON(arm, arm64, x86_shared); |
| 2095 |
template <typename T> |
| 2096 |
inline void branchTestBigIntImpl(Condition cond, const T& t, Label* label) |
| 2097 |
DEFINED_ON(arm, arm64, x86_shared); |
| 2098 |
template <typename T> |
| 2099 |
inline void branchTestNullImpl(Condition cond, const T& t, Label* label) |
| 2100 |
DEFINED_ON(arm, arm64, x86_shared); |
| 2101 |
template <typename T> |
| 2102 |
inline void branchTestObjectImpl(Condition cond, const T& t, Label* label) |
| 2103 |
DEFINED_ON(arm, arm64, x86_shared); |
| 2104 |
template <typename T> |
| 2105 |
inline void branchTestGCThingImpl(Condition cond, const T& t, |
| 2106 |
Label* label) PER_SHARED_ARCH; |
| 2107 |
template <typename T> |
| 2108 |
inline void branchTestPrimitiveImpl(Condition cond, const T& t, Label* label) |
| 2109 |
DEFINED_ON(arm, arm64, x86_shared); |
| 2110 |
template <typename T, class L> |
| 2111 |
inline void branchTestMagicImpl(Condition cond, const T& t, L label) |
| 2112 |
DEFINED_ON(arm, arm64, x86_shared); |
| 2113 |
|
| 2114 |
public: |
| 2115 |
template <typename T> |
| 2116 |
inline void testNumberSet(Condition cond, const T& src, |
| 2117 |
Register dest) PER_SHARED_ARCH; |
| 2118 |
template <typename T> |
| 2119 |
inline void testBooleanSet(Condition cond, const T& src, |
| 2120 |
Register dest) PER_SHARED_ARCH; |
| 2121 |
template <typename T> |
| 2122 |
inline void testStringSet(Condition cond, const T& src, |
| 2123 |
Register dest) PER_SHARED_ARCH; |
| 2124 |
template <typename T> |
| 2125 |
inline void testSymbolSet(Condition cond, const T& src, |
| 2126 |
Register dest) PER_SHARED_ARCH; |
| 2127 |
template <typename T> |
| 2128 |
inline void testBigIntSet(Condition cond, const T& src, |
| 2129 |
Register dest) PER_SHARED_ARCH; |
| 2130 |
|
| 2131 |
public: |
| 2132 |
// The fallibleUnbox* methods below combine a Value type check with an unbox. |
| 2133 |
// Especially on 64-bit platforms this can be implemented more efficiently |
| 2134 |
// than a separate branch + unbox. |
| 2135 |
// |
| 2136 |
// |src| and |dest| can be the same register, but |dest| may hold garbage on |
| 2137 |
// failure. |
| 2138 |
inline void fallibleUnboxPtr(const ValueOperand& src, Register dest, |
| 2139 |
JSValueType type, Label* fail) PER_ARCH; |
| 2140 |
inline void fallibleUnboxPtr(const Address& src, Register dest, |
| 2141 |
JSValueType type, Label* fail) PER_ARCH; |
| 2142 |
inline void fallibleUnboxPtr(const BaseIndex& src, Register dest, |
| 2143 |
JSValueType type, Label* fail) PER_ARCH; |
| 2144 |
template <typename T> |
| 2145 |
inline void fallibleUnboxInt32(const T& src, Register dest, Label* fail); |
| 2146 |
template <typename T> |
| 2147 |
inline void fallibleUnboxBoolean(const T& src, Register dest, Label* fail); |
| 2148 |
template <typename T> |
| 2149 |
inline void fallibleUnboxObject(const T& src, Register dest, Label* fail); |
| 2150 |
template <typename T> |
| 2151 |
inline void fallibleUnboxString(const T& src, Register dest, Label* fail); |
| 2152 |
template <typename T> |
| 2153 |
inline void fallibleUnboxSymbol(const T& src, Register dest, Label* fail); |
| 2154 |
template <typename T> |
| 2155 |
inline void fallibleUnboxBigInt(const T& src, Register dest, Label* fail); |
| 2156 |
|
| 2157 |
inline void cmp32Move32(Condition cond, Register lhs, Imm32 rhs, Register src, |
| 2158 |
Register dest) PER_SHARED_ARCH; |
| 2159 |
|
| 2160 |
inline void cmp32Move32(Condition cond, Register lhs, Register rhs, |
| 2161 |
Register src, Register dest) PER_SHARED_ARCH; |
| 2162 |
|
| 2163 |
inline void cmp32Move32(Condition cond, Register lhs, const Address& rhs, |
| 2164 |
Register src, Register dest) PER_SHARED_ARCH; |
| 2165 |
|
| 2166 |
inline void cmpPtrMovePtr(Condition cond, Register lhs, Imm32 rhs, |
| 2167 |
Register src, Register dest) PER_ARCH; |
| 2168 |
|
| 2169 |
inline void cmpPtrMovePtr(Condition cond, Register lhs, Register rhs, |
| 2170 |
Register src, Register dest) PER_ARCH; |
| 2171 |
|
| 2172 |
inline void cmpPtrMovePtr(Condition cond, Register lhs, const Address& rhs, |
| 2173 |
Register src, Register dest) PER_ARCH; |
| 2174 |
|
| 2175 |
inline void cmp32Load32(Condition cond, Register lhs, const Address& rhs, |
| 2176 |
const Address& src, Register dest) PER_SHARED_ARCH; |
| 2177 |
|
| 2178 |
inline void cmp32Load32(Condition cond, Register lhs, Register rhs, |
| 2179 |
const Address& src, Register dest) PER_SHARED_ARCH; |
| 2180 |
|
| 2181 |
inline void cmp32Load32(Condition cond, Register lhs, Imm32 rhs, |
| 2182 |
const Address& src, Register dest) PER_SHARED_ARCH; |
| 2183 |
|
| 2184 |
inline void cmp32LoadPtr(Condition cond, const Address& lhs, Imm32 rhs, |
| 2185 |
const Address& src, Register dest) PER_ARCH; |
| 2186 |
|
| 2187 |
inline void cmp32MovePtr(Condition cond, Register lhs, Imm32 rhs, |
| 2188 |
Register src, Register dest) PER_ARCH; |
| 2189 |
|
| 2190 |
inline void test32LoadPtr(Condition cond, const Address& addr, Imm32 mask, |
| 2191 |
const Address& src, Register dest) PER_ARCH; |
| 2192 |
|
| 2193 |
inline void test32MovePtr(Condition cond, Register operand, Imm32 mask, |
| 2194 |
Register src, Register dest) PER_ARCH; |
| 2195 |
|
| 2196 |
inline void test32MovePtr(Condition cond, const Address& addr, Imm32 mask, |
| 2197 |
Register src, Register dest) PER_ARCH; |
| 2198 |
|
| 2199 |
// Conditional move for Spectre mitigations. |
| 2200 |
inline void spectreMovePtr(Condition cond, Register src, |
| 2201 |
Register dest) PER_ARCH; |
| 2202 |
|
| 2203 |
// Zeroes dest if the condition is true. |
| 2204 |
inline void spectreZeroRegister(Condition cond, Register scratch, |
| 2205 |
Register dest) PER_SHARED_ARCH; |
| 2206 |
|
| 2207 |
// Performs a bounds check and zeroes the index register if out-of-bounds |
| 2208 |
// (to mitigate Spectre). |
| 2209 |
private: |
| 2210 |
inline void spectreBoundsCheck32(Register index, const Operand& length, |
| 2211 |
Register maybeScratch, Label* failure) |
| 2212 |
DEFINED_ON(x86); |
| 2213 |
|
| 2214 |
public: |
| 2215 |
inline void spectreBoundsCheck32(Register index, Register length, |
| 2216 |
Register maybeScratch, |
| 2217 |
Label* failure) PER_ARCH; |
| 2218 |
inline void spectreBoundsCheck32(Register index, const Address& length, |
| 2219 |
Register maybeScratch, |
| 2220 |
Label* failure) PER_ARCH; |
| 2221 |
|
| 2222 |
inline void spectreBoundsCheckPtr(Register index, Register length, |
| 2223 |
Register maybeScratch, |
| 2224 |
Label* failure) PER_ARCH; |
| 2225 |
inline void spectreBoundsCheckPtr(Register index, const Address& length, |
| 2226 |
Register maybeScratch, |
| 2227 |
Label* failure) PER_ARCH; |
| 2228 |
|
| 2229 |
// ======================================================================== |
| 2230 |
// Canonicalization primitives. |
| 2231 |
inline void canonicalizeDouble(FloatRegister reg); |
| 2232 |
|
| 2233 |
inline void canonicalizeFloat(FloatRegister reg); |
| 2234 |
|
| 2235 |
public: |
| 2236 |
// ======================================================================== |
| 2237 |
// Memory access primitives. |
| 2238 |
inline FaultingCodeOffset storeDouble(FloatRegister src, |
| 2239 |
const Address& dest) PER_SHARED_ARCH; |
| 2240 |
inline FaultingCodeOffset storeDouble(FloatRegister src, |
| 2241 |
const BaseIndex& dest) PER_SHARED_ARCH; |
| 2242 |
inline FaultingCodeOffset storeDouble(FloatRegister src, const Operand& dest) |
| 2243 |
DEFINED_ON(x86_shared); |
| 2244 |
|
| 2245 |
template <class T> |
| 2246 |
inline void boxDouble(FloatRegister src, const T& dest); |
| 2247 |
|
| 2248 |
using MacroAssemblerSpecific::boxDouble; |
| 2249 |
|
| 2250 |
inline FaultingCodeOffset storeFloat32(FloatRegister src, |
| 2251 |
const Address& dest) PER_SHARED_ARCH; |
| 2252 |
inline FaultingCodeOffset storeFloat32(FloatRegister src, |
| 2253 |
const BaseIndex& dest) PER_SHARED_ARCH; |
| 2254 |
inline FaultingCodeOffset storeFloat32(FloatRegister src, const Operand& dest) |
| 2255 |
DEFINED_ON(x86_shared); |
| 2256 |
|
| 2257 |
inline FaultingCodeOffset storeFloat16(FloatRegister src, const Address& dest, |
| 2258 |
Register scratch) PER_SHARED_ARCH; |
| 2259 |
inline FaultingCodeOffset storeFloat16(FloatRegister src, |
| 2260 |
const BaseIndex& dest, |
| 2261 |
Register scratch) PER_SHARED_ARCH; |
| 2262 |
|
| 2263 |
template <typename T> |
| 2264 |
void storeUnboxedValue(const ConstantOrRegister& value, MIRType valueType, |
| 2265 |
const T& dest) PER_ARCH; |
| 2266 |
|
| 2267 |
inline void memoryBarrier(MemoryBarrier barrier) PER_SHARED_ARCH; |
| 2268 |
|
| 2269 |
public: |
| 2270 |
// ======================================================================== |
| 2271 |
// Wasm SIMD |
| 2272 |
// |
| 2273 |
// Naming is "operationSimd128" when operate on the whole vector, otherwise |
| 2274 |
// it's "operation<Type><Size>x<Lanes>". |
| 2275 |
// |
| 2276 |
// For microarchitectural reasons we can in principle get a performance win by |
| 2277 |
// using int or float specific instructions in the operationSimd128 case when |
| 2278 |
// we know that subsequent operations on the result are int or float oriented. |
| 2279 |
// In practice, we don't care about that yet. |
| 2280 |
// |
| 2281 |
// The order of operations here follows those in the SIMD overview document, |
| 2282 |
// https://github.com/WebAssembly/simd/blob/master/proposals/simd/SIMD.md. |
| 2283 |
// |
| 2284 |
// Since we must target Intel SSE indefinitely and SSE is one-address or |
| 2285 |
// two-address, the x86 porting interfaces are nearly all one-address or |
| 2286 |
// two-address. Likewise there are two-address ARM64 interfaces to support |
| 2287 |
// the baseline compiler. But there are also three-address ARM64 interfaces |
| 2288 |
// as the ARM64 Ion back-end can use those. In the future, they may support |
| 2289 |
// AVX2 or similar for x86. |
| 2290 |
// |
| 2291 |
// Conventions for argument order and naming and semantics: |
| 2292 |
// - Condition codes come first. |
| 2293 |
// - Other immediates (masks, shift counts) come next. |
| 2294 |
// - Operands come next: |
| 2295 |
// - For a binary two-address operator where the left-hand-side has the |
| 2296 |
// same type as the result, one register parameter is normally named |
| 2297 |
// `lhsDest` and is both the left-hand side and destination; the other |
| 2298 |
// parameter is named `rhs` and is the right-hand side. `rhs` comes |
| 2299 |
// first, `lhsDest` second. `rhs` and `lhsDest` may be the same register |
| 2300 |
// (if rhs is a register). |
| 2301 |
// - For a binary three-address operator the order is `lhs`, `rhs`, `dest`, |
| 2302 |
// and generally these registers may be the same. |
| 2303 |
// - For a unary operator, the input is named `src` and the output is named |
| 2304 |
// `dest`. `src` comes first, `dest` second. `src` and `dest` may be |
| 2305 |
// the same register (if `src` is a register). |
| 2306 |
// - Temp registers follow operands and are named `temp` if there's only one, |
| 2307 |
// otherwise `temp1`, `temp2`, etc regardless of type. GPR temps precede |
| 2308 |
// FPU temps. If there are several temps then they must be distinct |
| 2309 |
// registers, and they must be distinct from the operand registers unless |
| 2310 |
// noted. |
| 2311 |
|
| 2312 |
// Moves |
| 2313 |
|
| 2314 |
inline void moveSimd128(FloatRegister src, FloatRegister dest) |
| 2315 |
DEFINED_ON(x86_shared, arm64); |
| 2316 |
|
| 2317 |
// Constants |
| 2318 |
|
| 2319 |
inline void loadConstantSimd128(const SimdConstant& v, FloatRegister dest) |
| 2320 |
DEFINED_ON(x86_shared, arm64); |
| 2321 |
|
| 2322 |
// Splat |
| 2323 |
|
| 2324 |
inline void splatX16(Register src, FloatRegister dest) |
| 2325 |
DEFINED_ON(x86_shared, arm64); |
| 2326 |
|
| 2327 |
inline void splatX16(uint32_t srcLane, FloatRegister src, FloatRegister dest) |
| 2328 |
DEFINED_ON(arm64); |
| 2329 |
|
| 2330 |
inline void splatX8(Register src, FloatRegister dest) |
| 2331 |
DEFINED_ON(x86_shared, arm64); |
| 2332 |
|
| 2333 |
inline void splatX8(uint32_t srcLane, FloatRegister src, FloatRegister dest) |
| 2334 |
DEFINED_ON(arm64); |
| 2335 |
|
| 2336 |
inline void splatX4(Register src, FloatRegister dest) |
| 2337 |
DEFINED_ON(x86_shared, arm64); |
| 2338 |
|
| 2339 |
inline void splatX4(FloatRegister src, FloatRegister dest) |
| 2340 |
DEFINED_ON(x86_shared, arm64); |
| 2341 |
|
| 2342 |
inline void splatX2(Register64 src, FloatRegister dest) |
| 2343 |
DEFINED_ON(x86, x64, arm64); |
| 2344 |
|
| 2345 |
inline void splatX2(FloatRegister src, FloatRegister dest) |
| 2346 |
DEFINED_ON(x86_shared, arm64); |
| 2347 |
|
| 2348 |
// Extract lane as scalar. Float extraction does not canonicalize the value. |
| 2349 |
|
| 2350 |
inline void extractLaneInt8x16(uint32_t lane, FloatRegister src, |
| 2351 |
Register dest) DEFINED_ON(x86_shared, arm64); |
| 2352 |
|
| 2353 |
inline void unsignedExtractLaneInt8x16(uint32_t lane, FloatRegister src, |
| 2354 |
Register dest) |
| 2355 |
DEFINED_ON(x86_shared, arm64); |
| 2356 |
|
| 2357 |
inline void extractLaneInt16x8(uint32_t lane, FloatRegister src, |
| 2358 |
Register dest) DEFINED_ON(x86_shared, arm64); |
| 2359 |
|
| 2360 |
inline void unsignedExtractLaneInt16x8(uint32_t lane, FloatRegister src, |
| 2361 |
Register dest) |
| 2362 |
DEFINED_ON(x86_shared, arm64); |
| 2363 |
|
| 2364 |
inline void extractLaneInt32x4(uint32_t lane, FloatRegister src, |
| 2365 |
Register dest) DEFINED_ON(x86_shared, arm64); |
| 2366 |
|
| 2367 |
inline void extractLaneInt64x2(uint32_t lane, FloatRegister src, |
| 2368 |
Register64 dest) DEFINED_ON(x86, x64, arm64); |
| 2369 |
|
| 2370 |
inline void extractLaneFloat32x4(uint32_t lane, FloatRegister src, |
| 2371 |
FloatRegister dest) |
| 2372 |
DEFINED_ON(x86_shared, arm64); |
| 2373 |
|
| 2374 |
inline void extractLaneFloat64x2(uint32_t lane, FloatRegister src, |
| 2375 |
FloatRegister dest) |
| 2376 |
DEFINED_ON(x86_shared, arm64); |
| 2377 |
|
| 2378 |
// Replace lane value |
| 2379 |
|
| 2380 |
inline void replaceLaneInt8x16(unsigned lane, FloatRegister lhs, Register rhs, |
| 2381 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 2382 |
|
| 2383 |
inline void replaceLaneInt8x16(unsigned lane, Register rhs, |
| 2384 |
FloatRegister lhsDest) |
| 2385 |
DEFINED_ON(x86_shared, arm64); |
| 2386 |
|
| 2387 |
inline void replaceLaneInt16x8(unsigned lane, FloatRegister lhs, Register rhs, |
| 2388 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 2389 |
|
| 2390 |
inline void replaceLaneInt16x8(unsigned lane, Register rhs, |
| 2391 |
FloatRegister lhsDest) |
| 2392 |
DEFINED_ON(x86_shared, arm64); |
| 2393 |
|
| 2394 |
inline void replaceLaneInt32x4(unsigned lane, FloatRegister lhs, Register rhs, |
| 2395 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 2396 |
|
| 2397 |
inline void replaceLaneInt32x4(unsigned lane, Register rhs, |
| 2398 |
FloatRegister lhsDest) |
| 2399 |
DEFINED_ON(x86_shared, arm64); |
| 2400 |
|
| 2401 |
inline void replaceLaneInt64x2(unsigned lane, FloatRegister lhs, |
| 2402 |
Register64 rhs, FloatRegister dest) |
| 2403 |
DEFINED_ON(x86, x64); |
| 2404 |
|
| 2405 |
inline void replaceLaneInt64x2(unsigned lane, Register64 rhs, |
| 2406 |
FloatRegister lhsDest) |
| 2407 |
DEFINED_ON(x86, x64, arm64); |
| 2408 |
|
| 2409 |
inline void replaceLaneFloat32x4(unsigned lane, FloatRegister lhs, |
| 2410 |
FloatRegister rhs, FloatRegister dest) |
| 2411 |
DEFINED_ON(x86_shared); |
| 2412 |
|
| 2413 |
inline void replaceLaneFloat32x4(unsigned lane, FloatRegister rhs, |
| 2414 |
FloatRegister lhsDest) |
| 2415 |
DEFINED_ON(x86_shared, arm64); |
| 2416 |
|
| 2417 |
inline void replaceLaneFloat64x2(unsigned lane, FloatRegister lhs, |
| 2418 |
FloatRegister rhs, FloatRegister dest) |
| 2419 |
DEFINED_ON(x86_shared); |
| 2420 |
|
| 2421 |
inline void replaceLaneFloat64x2(unsigned lane, FloatRegister rhs, |
| 2422 |
FloatRegister lhsDest) |
| 2423 |
DEFINED_ON(x86_shared, arm64); |
| 2424 |
|
| 2425 |
// Shuffle - blend and permute with immediate indices, and its many |
| 2426 |
// specializations. Lane values other than those mentioned are illegal. |
| 2427 |
|
| 2428 |
// lane values 0..31 |
| 2429 |
inline void shuffleInt8x16(const uint8_t lanes[16], FloatRegister rhs, |
| 2430 |
FloatRegister lhsDest) |
| 2431 |
DEFINED_ON(x86_shared, arm64); |
| 2432 |
|
| 2433 |
inline void shuffleInt8x16(const uint8_t lanes[16], FloatRegister lhs, |
| 2434 |
FloatRegister rhs, FloatRegister dest) |
| 2435 |
DEFINED_ON(x86_shared, arm64); |
| 2436 |
|
| 2437 |
// Lane values must be 0 (select from lhs) or FF (select from rhs). |
| 2438 |
// The behavior is undefined for lane values that are neither 0 nor FF. |
| 2439 |
// on x86_shared: it is required that lhs == dest. |
| 2440 |
inline void blendInt8x16(const uint8_t lanes[16], FloatRegister lhs, |
| 2441 |
FloatRegister rhs, FloatRegister dest, |
| 2442 |
FloatRegister temp) DEFINED_ON(x86_shared); |
| 2443 |
|
| 2444 |
// Lane values must be 0 (select from lhs) or FF (select from rhs). |
| 2445 |
// The behavior is undefined for lane values that are neither 0 nor FF. |
| 2446 |
inline void blendInt8x16(const uint8_t lanes[16], FloatRegister lhs, |
| 2447 |
FloatRegister rhs, FloatRegister dest) |
| 2448 |
DEFINED_ON(arm64); |
| 2449 |
|
| 2450 |
// Lane values must be 0 (select from lhs) or FFFF (select from rhs). |
| 2451 |
// The behavior is undefined for lane values that are neither 0 nor FFFF. |
| 2452 |
// on x86_shared: it is required that lhs == dest. |
| 2453 |
inline void blendInt16x8(const uint16_t lanes[8], FloatRegister lhs, |
| 2454 |
FloatRegister rhs, FloatRegister dest) |
| 2455 |
DEFINED_ON(x86_shared, arm64); |
| 2456 |
|
| 2457 |
// Mask lane values must be ~0 or 0. The former selects from lhs and the |
| 2458 |
// latter from rhs. |
| 2459 |
// The implementation works effectively for I8x16, I16x8, I32x4, and I64x2. |
| 2460 |
inline void laneSelectSimd128(FloatRegister mask, FloatRegister lhs, |
| 2461 |
FloatRegister rhs, FloatRegister dest) |
| 2462 |
DEFINED_ON(x86_shared, arm64); |
| 2463 |
|
| 2464 |
inline void interleaveHighInt8x16(FloatRegister lhs, FloatRegister rhs, |
| 2465 |
FloatRegister dest) |
| 2466 |
DEFINED_ON(x86_shared, arm64); |
| 2467 |
|
| 2468 |
inline void interleaveHighInt16x8(FloatRegister lhs, FloatRegister rhs, |
| 2469 |
FloatRegister dest) |
| 2470 |
DEFINED_ON(x86_shared, arm64); |
| 2471 |
|
| 2472 |
inline void interleaveHighInt32x4(FloatRegister lhs, FloatRegister rhs, |
| 2473 |
FloatRegister dest) |
| 2474 |
DEFINED_ON(x86_shared, arm64); |
| 2475 |
|
| 2476 |
inline void interleaveHighInt64x2(FloatRegister lhs, FloatRegister rhs, |
| 2477 |
FloatRegister dest) |
| 2478 |
DEFINED_ON(x86_shared, arm64); |
| 2479 |
|
| 2480 |
inline void interleaveLowInt8x16(FloatRegister lhs, FloatRegister rhs, |
| 2481 |
FloatRegister dest) |
| 2482 |
DEFINED_ON(x86_shared, arm64); |
| 2483 |
|
| 2484 |
inline void interleaveLowInt16x8(FloatRegister lhs, FloatRegister rhs, |
| 2485 |
FloatRegister dest) |
| 2486 |
DEFINED_ON(x86_shared, arm64); |
| 2487 |
|
| 2488 |
inline void interleaveLowInt32x4(FloatRegister lhs, FloatRegister rhs, |
| 2489 |
FloatRegister dest) |
| 2490 |
DEFINED_ON(x86_shared, arm64); |
| 2491 |
|
| 2492 |
inline void interleaveLowInt64x2(FloatRegister lhs, FloatRegister rhs, |
| 2493 |
FloatRegister dest) |
| 2494 |
DEFINED_ON(x86_shared, arm64); |
| 2495 |
|
| 2496 |
// Permute - permute with immediate indices. |
| 2497 |
|
| 2498 |
// lane values 0..15 |
| 2499 |
inline void permuteInt8x16(const uint8_t lanes[16], FloatRegister src, |
| 2500 |
FloatRegister dest) DEFINED_ON(x86_shared, arm64); |
| 2501 |
|
| 2502 |
// lane values 0..7 |
| 2503 |
inline void permuteInt16x8(const uint16_t lanes[8], FloatRegister src, |
| 2504 |
FloatRegister dest) DEFINED_ON(arm64); |
| 2505 |
|
| 2506 |
// lane values 0..3 [sic]. |
| 2507 |
inline void permuteHighInt16x8(const uint16_t lanes[4], FloatRegister src, |
| 2508 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 2509 |
|
| 2510 |
// lane values 0..3. |
| 2511 |
inline void permuteLowInt16x8(const uint16_t lanes[4], FloatRegister src, |
| 2512 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 2513 |
|
| 2514 |
// lane values 0..3 |
| 2515 |
inline void permuteInt32x4(const uint32_t lanes[4], FloatRegister src, |
| 2516 |
FloatRegister dest) DEFINED_ON(x86_shared, arm64); |
| 2517 |
|
| 2518 |
// Funnel shift by immediate count: |
| 2519 |
// low_16_bytes_of((lhs ++ rhs) >> shift*8), shift must be < 16 |
| 2520 |
inline void concatAndRightShiftSimd128(FloatRegister lhs, FloatRegister rhs, |
| 2521 |
FloatRegister dest, uint32_t shift) |
| 2522 |
DEFINED_ON(x86_shared, arm64); |
| 2523 |
|
| 2524 |
// Rotate right by immediate count: |
| 2525 |
// low_16_bytes_of((src ++ src) >> shift*8), shift must be < 16 |
| 2526 |
inline void rotateRightSimd128(FloatRegister src, FloatRegister dest, |
| 2527 |
uint32_t shift) DEFINED_ON(arm64); |
| 2528 |
|
| 2529 |
// Shift bytes with immediate count, shifting in zeroes. Shift count 0..15. |
| 2530 |
|
| 2531 |
inline void leftShiftSimd128(Imm32 count, FloatRegister src, |
| 2532 |
FloatRegister dest) |
| 2533 |
DEFINED_ON(x86_shared, arm64); |
| 2534 |
|
| 2535 |
inline void rightShiftSimd128(Imm32 count, FloatRegister src, |
| 2536 |
FloatRegister dest) |
| 2537 |
DEFINED_ON(x86_shared, arm64); |
| 2538 |
|
| 2539 |
// Zero extend int values. |
| 2540 |
|
| 2541 |
inline void zeroExtend8x16To16x8(FloatRegister src, FloatRegister dest) |
| 2542 |
DEFINED_ON(x86_shared, arm64); |
| 2543 |
inline void zeroExtend8x16To32x4(FloatRegister src, FloatRegister dest) |
| 2544 |
DEFINED_ON(x86_shared, arm64); |
| 2545 |
inline void zeroExtend8x16To64x2(FloatRegister src, FloatRegister dest) |
| 2546 |
DEFINED_ON(x86_shared, arm64); |
| 2547 |
inline void zeroExtend16x8To32x4(FloatRegister src, FloatRegister dest) |
| 2548 |
DEFINED_ON(x86_shared, arm64); |
| 2549 |
inline void zeroExtend16x8To64x2(FloatRegister src, FloatRegister dest) |
| 2550 |
DEFINED_ON(x86_shared, arm64); |
| 2551 |
inline void zeroExtend32x4To64x2(FloatRegister src, FloatRegister dest) |
| 2552 |
DEFINED_ON(x86_shared, arm64); |
| 2553 |
|
| 2554 |
// Reverse bytes in lanes. |
| 2555 |
|
| 2556 |
inline void reverseInt16x8(FloatRegister src, FloatRegister dest) |
| 2557 |
DEFINED_ON(x86_shared, arm64); |
| 2558 |
|
| 2559 |
inline void reverseInt32x4(FloatRegister src, FloatRegister dest) |
| 2560 |
DEFINED_ON(x86_shared, arm64); |
| 2561 |
|
| 2562 |
inline void reverseInt64x2(FloatRegister src, FloatRegister dest) |
| 2563 |
DEFINED_ON(x86_shared, arm64); |
| 2564 |
|
| 2565 |
// Swizzle - permute with variable indices. `rhs` holds the lanes parameter. |
| 2566 |
|
| 2567 |
inline void swizzleInt8x16(FloatRegister lhs, FloatRegister rhs, |
| 2568 |
FloatRegister dest) DEFINED_ON(x86_shared, arm64); |
| 2569 |
|
| 2570 |
inline void swizzleInt8x16Relaxed(FloatRegister lhs, FloatRegister rhs, |
| 2571 |
FloatRegister dest) |
| 2572 |
DEFINED_ON(x86_shared, arm64); |
| 2573 |
|
| 2574 |
// Integer Add |
| 2575 |
|
| 2576 |
inline void addInt8x16(FloatRegister lhs, FloatRegister rhs, |
| 2577 |
FloatRegister dest) DEFINED_ON(x86_shared, arm64); |
| 2578 |
|
| 2579 |
inline void addInt8x16(FloatRegister lhs, const SimdConstant& rhs, |
| 2580 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 2581 |
|
| 2582 |
inline void addInt16x8(FloatRegister lhs, FloatRegister rhs, |
| 2583 |
FloatRegister dest) DEFINED_ON(x86_shared, arm64); |
| 2584 |
|
| 2585 |
inline void addInt16x8(FloatRegister lhs, const SimdConstant& rhs, |
| 2586 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 2587 |
|
| 2588 |
inline void addInt32x4(FloatRegister lhs, FloatRegister rhs, |
| 2589 |
FloatRegister dest) DEFINED_ON(x86_shared, arm64); |
| 2590 |
|
| 2591 |
inline void addInt32x4(FloatRegister lhs, const SimdConstant& rhs, |
| 2592 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 2593 |
|
| 2594 |
inline void addInt64x2(FloatRegister lhs, FloatRegister rhs, |
| 2595 |
FloatRegister dest) DEFINED_ON(x86_shared, arm64); |
| 2596 |
|
| 2597 |
inline void addInt64x2(FloatRegister lhs, const SimdConstant& rhs, |
| 2598 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 2599 |
|
| 2600 |
// Integer Subtract |
| 2601 |
|
| 2602 |
inline void subInt8x16(FloatRegister lhs, FloatRegister rhs, |
| 2603 |
FloatRegister dest) DEFINED_ON(x86_shared, arm64); |
| 2604 |
|
| 2605 |
inline void subInt8x16(FloatRegister lhs, const SimdConstant& rhs, |
| 2606 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 2607 |
|
| 2608 |
inline void subInt16x8(FloatRegister lhs, FloatRegister rhs, |
| 2609 |
FloatRegister dest) DEFINED_ON(x86_shared, arm64); |
| 2610 |
|
| 2611 |
inline void subInt16x8(FloatRegister lhs, const SimdConstant& rhs, |
| 2612 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 2613 |
|
| 2614 |
inline void subInt32x4(FloatRegister lhs, const SimdConstant& rhs, |
| 2615 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 2616 |
|
| 2617 |
inline void subInt32x4(FloatRegister lhs, FloatRegister rhs, |
| 2618 |
FloatRegister dest) DEFINED_ON(x86_shared, arm64); |
| 2619 |
|
| 2620 |
inline void subInt64x2(FloatRegister lhs, const SimdConstant& rhs, |
| 2621 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 2622 |
|
| 2623 |
inline void subInt64x2(FloatRegister lhs, FloatRegister rhs, |
| 2624 |
FloatRegister dest) DEFINED_ON(x86_shared, arm64); |
| 2625 |
|
| 2626 |
// Integer Multiply |
| 2627 |
|
| 2628 |
inline void mulInt16x8(FloatRegister lhs, FloatRegister rhs, |
| 2629 |
FloatRegister dest) DEFINED_ON(x86_shared, arm64); |
| 2630 |
|
| 2631 |
inline void mulInt16x8(FloatRegister lhs, const SimdConstant& rhs, |
| 2632 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 2633 |
|
| 2634 |
inline void mulInt32x4(FloatRegister lhs, FloatRegister rhs, |
| 2635 |
FloatRegister dest) DEFINED_ON(x86_shared, arm64); |
| 2636 |
|
| 2637 |
inline void mulInt32x4(FloatRegister lhs, const SimdConstant& rhs, |
| 2638 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 2639 |
|
| 2640 |
// On x86_shared, it is required lhs == dest |
| 2641 |
inline void mulInt64x2(FloatRegister lhs, FloatRegister rhs, |
| 2642 |
FloatRegister dest, FloatRegister temp) |
| 2643 |
DEFINED_ON(x86_shared); |
| 2644 |
|
| 2645 |
inline void mulInt64x2(FloatRegister lhs, const SimdConstant& rhs, |
| 2646 |
FloatRegister dest, FloatRegister temp) |
| 2647 |
DEFINED_ON(x86_shared); |
| 2648 |
|
| 2649 |
inline void mulInt64x2(FloatRegister lhs, FloatRegister rhs, |
| 2650 |
FloatRegister dest, FloatRegister temp1, |
| 2651 |
FloatRegister temp2) DEFINED_ON(arm64); |
| 2652 |
|
| 2653 |
// Note for the extMul opcodes, the NxM designation is for the input lanes; |
| 2654 |
// the output lanes are twice as wide. |
| 2655 |
inline void extMulLowInt8x16(FloatRegister lhs, FloatRegister rhs, |
| 2656 |
FloatRegister dest) |
| 2657 |
DEFINED_ON(x86_shared, arm64); |
| 2658 |
|
| 2659 |
inline void extMulHighInt8x16(FloatRegister lhs, FloatRegister rhs, |
| 2660 |
FloatRegister dest) |
| 2661 |
DEFINED_ON(x86_shared, arm64); |
| 2662 |
|
| 2663 |
inline void unsignedExtMulLowInt8x16(FloatRegister lhs, FloatRegister rhs, |
| 2664 |
FloatRegister dest) |
| 2665 |
DEFINED_ON(x86_shared, arm64); |
| 2666 |
|
| 2667 |
inline void unsignedExtMulHighInt8x16(FloatRegister lhs, FloatRegister rhs, |
| 2668 |
FloatRegister dest) |
| 2669 |
DEFINED_ON(x86_shared, arm64); |
| 2670 |
|
| 2671 |
inline void extMulLowInt16x8(FloatRegister lhs, FloatRegister rhs, |
| 2672 |
FloatRegister dest) |
| 2673 |
DEFINED_ON(x86_shared, arm64); |
| 2674 |
|
| 2675 |
inline void extMulHighInt16x8(FloatRegister lhs, FloatRegister rhs, |
| 2676 |
FloatRegister dest) |
| 2677 |
DEFINED_ON(x86_shared, arm64); |
| 2678 |
|
| 2679 |
inline void unsignedExtMulLowInt16x8(FloatRegister lhs, FloatRegister rhs, |
| 2680 |
FloatRegister dest) |
| 2681 |
DEFINED_ON(x86_shared, arm64); |
| 2682 |
|
| 2683 |
inline void unsignedExtMulHighInt16x8(FloatRegister lhs, FloatRegister rhs, |
| 2684 |
FloatRegister dest) |
| 2685 |
DEFINED_ON(x86_shared, arm64); |
| 2686 |
|
| 2687 |
inline void extMulLowInt32x4(FloatRegister lhs, FloatRegister rhs, |
| 2688 |
FloatRegister dest) |
| 2689 |
DEFINED_ON(x86_shared, arm64); |
| 2690 |
|
| 2691 |
inline void extMulHighInt32x4(FloatRegister lhs, FloatRegister rhs, |
| 2692 |
FloatRegister dest) |
| 2693 |
DEFINED_ON(x86_shared, arm64); |
| 2694 |
|
| 2695 |
inline void unsignedExtMulLowInt32x4(FloatRegister lhs, FloatRegister rhs, |
| 2696 |
FloatRegister dest) |
| 2697 |
DEFINED_ON(x86_shared, arm64); |
| 2698 |
|
| 2699 |
inline void unsignedExtMulHighInt32x4(FloatRegister lhs, FloatRegister rhs, |
| 2700 |
FloatRegister dest) |
| 2701 |
DEFINED_ON(x86_shared, arm64); |
| 2702 |
|
| 2703 |
inline void q15MulrSatInt16x8(FloatRegister lhs, FloatRegister rhs, |
| 2704 |
FloatRegister dest) |
| 2705 |
DEFINED_ON(x86_shared, arm64); |
| 2706 |
|
| 2707 |
// Integer Negate |
| 2708 |
|
| 2709 |
inline void negInt8x16(FloatRegister src, FloatRegister dest) |
| 2710 |
DEFINED_ON(x86_shared, arm64); |
| 2711 |
|
| 2712 |
inline void negInt16x8(FloatRegister src, FloatRegister dest) |
| 2713 |
DEFINED_ON(x86_shared, arm64); |
| 2714 |
|
| 2715 |
inline void negInt32x4(FloatRegister src, FloatRegister dest) |
| 2716 |
DEFINED_ON(x86_shared, arm64); |
| 2717 |
|
| 2718 |
inline void negInt64x2(FloatRegister src, FloatRegister dest) |
| 2719 |
DEFINED_ON(x86_shared, arm64); |
| 2720 |
|
| 2721 |
// Saturating integer add |
| 2722 |
|
| 2723 |
inline void addSatInt8x16(FloatRegister lhs, FloatRegister rhs, |
| 2724 |
FloatRegister dest) DEFINED_ON(x86_shared, arm64); |
| 2725 |
|
| 2726 |
inline void addSatInt8x16(FloatRegister lhs, const SimdConstant& rhs, |
| 2727 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 2728 |
|
| 2729 |
inline void unsignedAddSatInt8x16(FloatRegister lhs, FloatRegister rhs, |
| 2730 |
FloatRegister dest) |
| 2731 |
DEFINED_ON(x86_shared, arm64); |
| 2732 |
|
| 2733 |
inline void unsignedAddSatInt8x16(FloatRegister lhs, const SimdConstant& rhs, |
| 2734 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 2735 |
|
| 2736 |
inline void addSatInt16x8(FloatRegister lhs, FloatRegister rhs, |
| 2737 |
FloatRegister dest) DEFINED_ON(x86_shared, arm64); |
| 2738 |
|
| 2739 |
inline void addSatInt16x8(FloatRegister lhs, const SimdConstant& rhs, |
| 2740 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 2741 |
|
| 2742 |
inline void unsignedAddSatInt16x8(FloatRegister lhs, FloatRegister rhs, |
| 2743 |
FloatRegister dest) |
| 2744 |
DEFINED_ON(x86_shared, arm64); |
| 2745 |
|
| 2746 |
inline void unsignedAddSatInt16x8(FloatRegister lhs, const SimdConstant& rhs, |
| 2747 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 2748 |
|
| 2749 |
// Saturating integer subtract |
| 2750 |
|
| 2751 |
inline void subSatInt8x16(FloatRegister lhs, FloatRegister rhs, |
| 2752 |
FloatRegister dest) DEFINED_ON(x86_shared, arm64); |
| 2753 |
|
| 2754 |
inline void subSatInt8x16(FloatRegister lhs, const SimdConstant& rhs, |
| 2755 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 2756 |
|
| 2757 |
inline void unsignedSubSatInt8x16(FloatRegister lhs, FloatRegister rhs, |
| 2758 |
FloatRegister dest) |
| 2759 |
DEFINED_ON(x86_shared, arm64); |
| 2760 |
|
| 2761 |
inline void unsignedSubSatInt8x16(FloatRegister lhs, const SimdConstant& rhs, |
| 2762 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 2763 |
|
| 2764 |
inline void subSatInt16x8(FloatRegister lhs, FloatRegister rhs, |
| 2765 |
FloatRegister dest) DEFINED_ON(x86_shared, arm64); |
| 2766 |
|
| 2767 |
inline void subSatInt16x8(FloatRegister lhs, const SimdConstant& rhs, |
| 2768 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 2769 |
|
| 2770 |
inline void unsignedSubSatInt16x8(FloatRegister lhs, FloatRegister rhs, |
| 2771 |
FloatRegister dest) |
| 2772 |
DEFINED_ON(x86_shared, arm64); |
| 2773 |
|
| 2774 |
inline void unsignedSubSatInt16x8(FloatRegister lhs, const SimdConstant& rhs, |
| 2775 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 2776 |
|
| 2777 |
// Lane-wise integer minimum |
| 2778 |
|
| 2779 |
inline void minInt8x16(FloatRegister lhs, FloatRegister rhs, |
| 2780 |
FloatRegister dest) DEFINED_ON(x86_shared, arm64); |
| 2781 |
|
| 2782 |
inline void minInt8x16(FloatRegister lhs, const SimdConstant& rhs, |
| 2783 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 2784 |
|
| 2785 |
inline void unsignedMinInt8x16(FloatRegister lhs, FloatRegister rhs, |
| 2786 |
FloatRegister dest) |
| 2787 |
DEFINED_ON(x86_shared, arm64); |
| 2788 |
|
| 2789 |
inline void unsignedMinInt8x16(FloatRegister lhs, const SimdConstant& rhs, |
| 2790 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 2791 |
|
| 2792 |
inline void minInt16x8(FloatRegister lhs, FloatRegister rhs, |
| 2793 |
FloatRegister dest) DEFINED_ON(x86_shared, arm64); |
| 2794 |
|
| 2795 |
inline void minInt16x8(FloatRegister lhs, const SimdConstant& rhs, |
| 2796 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 2797 |
|
| 2798 |
inline void unsignedMinInt16x8(FloatRegister lhs, FloatRegister rhs, |
| 2799 |
FloatRegister dest) |
| 2800 |
DEFINED_ON(x86_shared, arm64); |
| 2801 |
|
| 2802 |
inline void unsignedMinInt16x8(FloatRegister lhs, const SimdConstant& rhs, |
| 2803 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 2804 |
|
| 2805 |
inline void minInt32x4(FloatRegister lhs, FloatRegister rhs, |
| 2806 |
FloatRegister dest) DEFINED_ON(x86_shared, arm64); |
| 2807 |
|
| 2808 |
inline void minInt32x4(FloatRegister lhs, const SimdConstant& rhs, |
| 2809 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 2810 |
|
| 2811 |
inline void unsignedMinInt32x4(FloatRegister lhs, FloatRegister rhs, |
| 2812 |
FloatRegister dest) |
| 2813 |
DEFINED_ON(x86_shared, arm64); |
| 2814 |
|
| 2815 |
inline void unsignedMinInt32x4(FloatRegister lhs, const SimdConstant& rhs, |
| 2816 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 2817 |
|
| 2818 |
// Lane-wise integer maximum |
| 2819 |
|
| 2820 |
inline void maxInt8x16(FloatRegister lhs, FloatRegister rhs, |
| 2821 |
FloatRegister dest) DEFINED_ON(x86_shared, arm64); |
| 2822 |
|
| 2823 |
inline void maxInt8x16(FloatRegister lhs, const SimdConstant& rhs, |
| 2824 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 2825 |
|
| 2826 |
inline void unsignedMaxInt8x16(FloatRegister lhs, FloatRegister rhs, |
| 2827 |
FloatRegister dest) |
| 2828 |
DEFINED_ON(x86_shared, arm64); |
| 2829 |
|
| 2830 |
inline void unsignedMaxInt8x16(FloatRegister lhs, const SimdConstant& rhs, |
| 2831 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 2832 |
|
| 2833 |
inline void maxInt16x8(FloatRegister lhs, FloatRegister rhs, |
| 2834 |
FloatRegister dest) DEFINED_ON(x86_shared, arm64); |
| 2835 |
|
| 2836 |
inline void maxInt16x8(FloatRegister lhs, const SimdConstant& rhs, |
| 2837 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 2838 |
|
| 2839 |
inline void unsignedMaxInt16x8(FloatRegister lhs, FloatRegister rhs, |
| 2840 |
FloatRegister dest) |
| 2841 |
DEFINED_ON(x86_shared, arm64); |
| 2842 |
|
| 2843 |
inline void unsignedMaxInt16x8(FloatRegister lhs, const SimdConstant& rhs, |
| 2844 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 2845 |
|
| 2846 |
inline void maxInt32x4(FloatRegister lhs, FloatRegister rhs, |
| 2847 |
FloatRegister dest) DEFINED_ON(x86_shared, arm64); |
| 2848 |
|
| 2849 |
inline void maxInt32x4(FloatRegister lhs, const SimdConstant& rhs, |
| 2850 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 2851 |
|
| 2852 |
inline void unsignedMaxInt32x4(FloatRegister lhs, FloatRegister rhs, |
| 2853 |
FloatRegister dest) |
| 2854 |
DEFINED_ON(x86_shared, arm64); |
| 2855 |
|
| 2856 |
inline void unsignedMaxInt32x4(FloatRegister lhs, const SimdConstant& rhs, |
| 2857 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 2858 |
|
| 2859 |
// Lane-wise integer rounding average |
| 2860 |
|
| 2861 |
inline void unsignedAverageInt8x16(FloatRegister lhs, FloatRegister rhs, |
| 2862 |
FloatRegister dest) |
| 2863 |
DEFINED_ON(x86_shared, arm64); |
| 2864 |
|
| 2865 |
inline void unsignedAverageInt16x8(FloatRegister lhs, FloatRegister rhs, |
| 2866 |
FloatRegister dest) |
| 2867 |
DEFINED_ON(x86_shared, arm64); |
| 2868 |
|
| 2869 |
// Lane-wise integer absolute value |
| 2870 |
|
| 2871 |
inline void absInt8x16(FloatRegister src, FloatRegister dest) |
| 2872 |
DEFINED_ON(x86_shared, arm64); |
| 2873 |
|
| 2874 |
inline void absInt16x8(FloatRegister src, FloatRegister dest) |
| 2875 |
DEFINED_ON(x86_shared, arm64); |
| 2876 |
|
| 2877 |
inline void absInt32x4(FloatRegister src, FloatRegister dest) |
| 2878 |
DEFINED_ON(x86_shared, arm64); |
| 2879 |
|
| 2880 |
inline void absInt64x2(FloatRegister src, FloatRegister dest) |
| 2881 |
DEFINED_ON(x86_shared, arm64); |
| 2882 |
|
| 2883 |
// Left shift by scalar. Immediates and variable shifts must have been |
| 2884 |
// masked; shifts of zero will work but may or may not generate code. |
| 2885 |
|
| 2886 |
inline void leftShiftInt8x16(Register rhs, FloatRegister lhsDest, |
| 2887 |
FloatRegister temp) DEFINED_ON(x86_shared); |
| 2888 |
|
| 2889 |
inline void leftShiftInt8x16(FloatRegister lhs, Register rhs, |
| 2890 |
FloatRegister dest) DEFINED_ON(arm64); |
| 2891 |
|
| 2892 |
inline void leftShiftInt8x16(Imm32 count, FloatRegister src, |
| 2893 |
FloatRegister dest) |
| 2894 |
DEFINED_ON(x86_shared, arm64); |
| 2895 |
|
| 2896 |
inline void leftShiftInt16x8(Register rhs, FloatRegister lhsDest) |
| 2897 |
DEFINED_ON(x86_shared); |
| 2898 |
|
| 2899 |
inline void leftShiftInt16x8(FloatRegister lhs, Register rhs, |
| 2900 |
FloatRegister dest) DEFINED_ON(arm64); |
| 2901 |
|
| 2902 |
inline void leftShiftInt16x8(Imm32 count, FloatRegister src, |
| 2903 |
FloatRegister dest) |
| 2904 |
DEFINED_ON(x86_shared, arm64); |
| 2905 |
|
| 2906 |
inline void leftShiftInt32x4(Register rhs, FloatRegister lhsDest) |
| 2907 |
DEFINED_ON(x86_shared); |
| 2908 |
|
| 2909 |
inline void leftShiftInt32x4(FloatRegister lhs, Register rhs, |
| 2910 |
FloatRegister dest) DEFINED_ON(arm64); |
| 2911 |
|
| 2912 |
inline void leftShiftInt32x4(Imm32 count, FloatRegister src, |
| 2913 |
FloatRegister dest) |
| 2914 |
DEFINED_ON(x86_shared, arm64); |
| 2915 |
|
| 2916 |
inline void leftShiftInt64x2(Register rhs, FloatRegister lhsDest) |
| 2917 |
DEFINED_ON(x86_shared); |
| 2918 |
|
| 2919 |
inline void leftShiftInt64x2(FloatRegister lhs, Register rhs, |
| 2920 |
FloatRegister dest) DEFINED_ON(arm64); |
| 2921 |
|
| 2922 |
inline void leftShiftInt64x2(Imm32 count, FloatRegister src, |
| 2923 |
FloatRegister dest) |
| 2924 |
DEFINED_ON(x86_shared, arm64); |
| 2925 |
|
| 2926 |
// Right shift by scalar. Immediates and variable shifts must have been |
| 2927 |
// masked; shifts of zero will work but may or may not generate code. |
| 2928 |
|
| 2929 |
inline void rightShiftInt8x16(Register rhs, FloatRegister lhsDest, |
| 2930 |
FloatRegister temp) DEFINED_ON(x86_shared); |
| 2931 |
|
| 2932 |
inline void rightShiftInt8x16(FloatRegister lhs, Register rhs, |
| 2933 |
FloatRegister dest) DEFINED_ON(arm64); |
| 2934 |
|
| 2935 |
inline void rightShiftInt8x16(Imm32 count, FloatRegister src, |
| 2936 |
FloatRegister dest) |
| 2937 |
DEFINED_ON(x86_shared, arm64); |
| 2938 |
|
| 2939 |
inline void unsignedRightShiftInt8x16(Register rhs, FloatRegister lhsDest, |
| 2940 |
FloatRegister temp) |
| 2941 |
DEFINED_ON(x86_shared); |
| 2942 |
|
| 2943 |
inline void unsignedRightShiftInt8x16(FloatRegister lhs, Register rhs, |
| 2944 |
FloatRegister dest) DEFINED_ON(arm64); |
| 2945 |
|
| 2946 |
inline void unsignedRightShiftInt8x16(Imm32 count, FloatRegister src, |
| 2947 |
FloatRegister dest) |
| 2948 |
DEFINED_ON(x86_shared, arm64); |
| 2949 |
|
| 2950 |
inline void rightShiftInt16x8(Register rhs, FloatRegister lhsDest) |
| 2951 |
DEFINED_ON(x86_shared); |
| 2952 |
|
| 2953 |
inline void rightShiftInt16x8(FloatRegister lhs, Register rhs, |
| 2954 |
FloatRegister dest) DEFINED_ON(arm64); |
| 2955 |
|
| 2956 |
inline void rightShiftInt16x8(Imm32 count, FloatRegister src, |
| 2957 |
FloatRegister dest) |
| 2958 |
DEFINED_ON(x86_shared, arm64); |
| 2959 |
|
| 2960 |
inline void unsignedRightShiftInt16x8(Register rhs, FloatRegister lhsDest) |
| 2961 |
DEFINED_ON(x86_shared); |
| 2962 |
|
| 2963 |
inline void unsignedRightShiftInt16x8(FloatRegister lhs, Register rhs, |
| 2964 |
FloatRegister dest) DEFINED_ON(arm64); |
| 2965 |
|
| 2966 |
inline void unsignedRightShiftInt16x8(Imm32 count, FloatRegister src, |
| 2967 |
FloatRegister dest) |
| 2968 |
DEFINED_ON(x86_shared, arm64); |
| 2969 |
|
| 2970 |
inline void rightShiftInt32x4(Register rhs, FloatRegister lhsDest) |
| 2971 |
DEFINED_ON(x86_shared); |
| 2972 |
|
| 2973 |
inline void rightShiftInt32x4(FloatRegister lhs, Register rhs, |
| 2974 |
FloatRegister dest) DEFINED_ON(arm64); |
| 2975 |
|
| 2976 |
inline void rightShiftInt32x4(Imm32 count, FloatRegister src, |
| 2977 |
FloatRegister dest) |
| 2978 |
DEFINED_ON(x86_shared, arm64); |
| 2979 |
|
| 2980 |
inline void unsignedRightShiftInt32x4(Register rhs, FloatRegister lhsDest) |
| 2981 |
DEFINED_ON(x86_shared); |
| 2982 |
|
| 2983 |
inline void unsignedRightShiftInt32x4(FloatRegister lhs, Register rhs, |
| 2984 |
FloatRegister dest) DEFINED_ON(arm64); |
| 2985 |
|
| 2986 |
inline void unsignedRightShiftInt32x4(Imm32 count, FloatRegister src, |
| 2987 |
FloatRegister dest) |
| 2988 |
DEFINED_ON(x86_shared, arm64); |
| 2989 |
|
| 2990 |
inline void rightShiftInt64x2(Register rhs, FloatRegister lhsDest, |
| 2991 |
FloatRegister temp) DEFINED_ON(x86_shared); |
| 2992 |
|
| 2993 |
inline void rightShiftInt64x2(Imm32 count, FloatRegister src, |
| 2994 |
FloatRegister dest) |
| 2995 |
DEFINED_ON(x86_shared, arm64); |
| 2996 |
|
| 2997 |
inline void rightShiftInt64x2(FloatRegister lhs, Register rhs, |
| 2998 |
FloatRegister dest) DEFINED_ON(arm64); |
| 2999 |
|
| 3000 |
inline void unsignedRightShiftInt64x2(Register rhs, FloatRegister lhsDest) |
| 3001 |
DEFINED_ON(x86_shared); |
| 3002 |
|
| 3003 |
inline void unsignedRightShiftInt64x2(FloatRegister lhs, Register rhs, |
| 3004 |
FloatRegister dest) DEFINED_ON(arm64); |
| 3005 |
|
| 3006 |
inline void unsignedRightShiftInt64x2(Imm32 count, FloatRegister src, |
| 3007 |
FloatRegister dest) |
| 3008 |
DEFINED_ON(x86_shared, arm64); |
| 3009 |
|
| 3010 |
// Sign replication operation |
| 3011 |
|
| 3012 |
inline void signReplicationInt8x16(FloatRegister src, FloatRegister dest) |
| 3013 |
DEFINED_ON(x86_shared); |
| 3014 |
|
| 3015 |
inline void signReplicationInt16x8(FloatRegister src, FloatRegister dest) |
| 3016 |
DEFINED_ON(x86_shared); |
| 3017 |
|
| 3018 |
inline void signReplicationInt32x4(FloatRegister src, FloatRegister dest) |
| 3019 |
DEFINED_ON(x86_shared); |
| 3020 |
|
| 3021 |
inline void signReplicationInt64x2(FloatRegister src, FloatRegister dest) |
| 3022 |
DEFINED_ON(x86_shared); |
| 3023 |
|
| 3024 |
// Bitwise and, or, xor, not |
| 3025 |
|
| 3026 |
inline void bitwiseAndSimd128(FloatRegister rhs, FloatRegister lhsDest) |
| 3027 |
DEFINED_ON(x86_shared, arm64); |
| 3028 |
|
| 3029 |
inline void bitwiseAndSimd128(FloatRegister lhs, FloatRegister rhs, |
| 3030 |
FloatRegister dest) |
| 3031 |
DEFINED_ON(x86_shared, arm64); |
| 3032 |
|
| 3033 |
inline void bitwiseAndSimd128(FloatRegister lhs, const SimdConstant& rhs, |
| 3034 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 3035 |
|
| 3036 |
inline void bitwiseOrSimd128(FloatRegister rhs, FloatRegister lhsDest) |
| 3037 |
DEFINED_ON(x86_shared, arm64); |
| 3038 |
|
| 3039 |
inline void bitwiseOrSimd128(FloatRegister lhs, FloatRegister rhs, |
| 3040 |
FloatRegister dest) |
| 3041 |
DEFINED_ON(x86_shared, arm64); |
| 3042 |
|
| 3043 |
inline void bitwiseOrSimd128(FloatRegister lhs, const SimdConstant& rhs, |
| 3044 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 3045 |
|
| 3046 |
inline void bitwiseXorSimd128(FloatRegister rhs, FloatRegister lhsDest) |
| 3047 |
DEFINED_ON(x86_shared, arm64); |
| 3048 |
|
| 3049 |
inline void bitwiseXorSimd128(FloatRegister lhs, FloatRegister rhs, |
| 3050 |
FloatRegister dest) |
| 3051 |
DEFINED_ON(x86_shared, arm64); |
| 3052 |
|
| 3053 |
inline void bitwiseXorSimd128(FloatRegister lhs, const SimdConstant& rhs, |
| 3054 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 3055 |
|
| 3056 |
inline void bitwiseNotSimd128(FloatRegister src, FloatRegister dest) |
| 3057 |
DEFINED_ON(x86_shared, arm64); |
| 3058 |
|
| 3059 |
// Bitwise AND with compliment: dest = lhs & ~rhs, note only arm64 can do it. |
| 3060 |
inline void bitwiseAndNotSimd128(FloatRegister lhs, FloatRegister rhs, |
| 3061 |
FloatRegister lhsDest) DEFINED_ON(arm64); |
| 3062 |
|
| 3063 |
// Bitwise AND with complement: dest = ~lhs & rhs, note this is not what Wasm |
| 3064 |
// wants but what the x86 hardware offers. Hence the name. |
| 3065 |
|
| 3066 |
inline void bitwiseNotAndSimd128(FloatRegister rhs, FloatRegister lhsDest) |
| 3067 |
DEFINED_ON(x86_shared, arm64); |
| 3068 |
|
| 3069 |
inline void bitwiseNotAndSimd128(FloatRegister lhs, FloatRegister rhs, |
| 3070 |
FloatRegister lhsDest) |
| 3071 |
DEFINED_ON(x86_shared); |
| 3072 |
|
| 3073 |
// Bitwise select |
| 3074 |
|
| 3075 |
inline void bitwiseSelectSimd128(FloatRegister mask, FloatRegister onTrue, |
| 3076 |
FloatRegister onFalse, FloatRegister dest, |
| 3077 |
FloatRegister temp) DEFINED_ON(x86_shared); |
| 3078 |
|
| 3079 |
inline void bitwiseSelectSimd128(FloatRegister onTrue, FloatRegister onFalse, |
| 3080 |
FloatRegister maskDest) DEFINED_ON(arm64); |
| 3081 |
|
| 3082 |
// Population count |
| 3083 |
|
| 3084 |
inline void popcntInt8x16(FloatRegister src, FloatRegister dest, |
| 3085 |
FloatRegister temp) DEFINED_ON(x86_shared); |
| 3086 |
|
| 3087 |
inline void popcntInt8x16(FloatRegister src, FloatRegister dest) |
| 3088 |
DEFINED_ON(arm64); |
| 3089 |
|
| 3090 |
// Any lane true, ie, any bit set |
| 3091 |
|
| 3092 |
inline void anyTrueSimd128(FloatRegister src, Register dest) |
| 3093 |
DEFINED_ON(x86_shared, arm64); |
| 3094 |
|
| 3095 |
// All lanes true |
| 3096 |
|
| 3097 |
inline void allTrueInt8x16(FloatRegister src, Register dest) |
| 3098 |
DEFINED_ON(x86_shared, arm64); |
| 3099 |
|
| 3100 |
inline void allTrueInt16x8(FloatRegister src, Register dest) |
| 3101 |
DEFINED_ON(x86_shared, arm64); |
| 3102 |
|
| 3103 |
inline void allTrueInt32x4(FloatRegister src, Register dest) |
| 3104 |
DEFINED_ON(x86_shared, arm64); |
| 3105 |
|
| 3106 |
inline void allTrueInt64x2(FloatRegister src, Register dest) |
| 3107 |
DEFINED_ON(x86_shared, arm64); |
| 3108 |
|
| 3109 |
// Bitmask, ie extract and compress high bits of all lanes |
| 3110 |
|
| 3111 |
inline void bitmaskInt8x16(FloatRegister src, Register dest) |
| 3112 |
DEFINED_ON(x86_shared); |
| 3113 |
|
| 3114 |
inline void bitmaskInt8x16(FloatRegister src, Register dest, |
| 3115 |
FloatRegister temp) DEFINED_ON(arm64); |
| 3116 |
|
| 3117 |
inline void bitmaskInt16x8(FloatRegister src, Register dest) |
| 3118 |
DEFINED_ON(x86_shared); |
| 3119 |
|
| 3120 |
inline void bitmaskInt16x8(FloatRegister src, Register dest, |
| 3121 |
FloatRegister temp) DEFINED_ON(arm64); |
| 3122 |
|
| 3123 |
inline void bitmaskInt32x4(FloatRegister src, Register dest) |
| 3124 |
DEFINED_ON(x86_shared); |
| 3125 |
|
| 3126 |
inline void bitmaskInt32x4(FloatRegister src, Register dest, |
| 3127 |
FloatRegister temp) DEFINED_ON(arm64); |
| 3128 |
|
| 3129 |
inline void bitmaskInt64x2(FloatRegister src, Register dest) |
| 3130 |
DEFINED_ON(x86_shared); |
| 3131 |
|
| 3132 |
inline void bitmaskInt64x2(FloatRegister src, Register dest, |
| 3133 |
FloatRegister temp) DEFINED_ON(arm64); |
| 3134 |
|
| 3135 |
// Comparisons (integer and floating-point) |
| 3136 |
|
| 3137 |
inline void compareInt8x16(Assembler::Condition cond, FloatRegister rhs, |
| 3138 |
FloatRegister lhsDest) |
| 3139 |
DEFINED_ON(x86_shared, arm64); |
| 3140 |
|
| 3141 |
// On x86_shared, limited to !=, ==, <=, > |
| 3142 |
inline void compareInt8x16(Assembler::Condition cond, FloatRegister lhs, |
| 3143 |
const SimdConstant& rhs, FloatRegister dest) |
| 3144 |
DEFINED_ON(x86_shared); |
| 3145 |
|
| 3146 |
// On arm64, use any integer comparison condition. |
| 3147 |
inline void compareInt8x16(Assembler::Condition cond, FloatRegister lhs, |
| 3148 |
FloatRegister rhs, FloatRegister dest) |
| 3149 |
DEFINED_ON(x86_shared, arm64); |
| 3150 |
|
| 3151 |
inline void compareInt16x8(Assembler::Condition cond, FloatRegister rhs, |
| 3152 |
FloatRegister lhsDest) |
| 3153 |
DEFINED_ON(x86_shared, arm64); |
| 3154 |
|
| 3155 |
inline void compareInt16x8(Assembler::Condition cond, FloatRegister lhs, |
| 3156 |
FloatRegister rhs, FloatRegister dest) |
| 3157 |
DEFINED_ON(x86_shared, arm64); |
| 3158 |
|
| 3159 |
// On x86_shared, limited to !=, ==, <=, > |
| 3160 |
inline void compareInt16x8(Assembler::Condition cond, FloatRegister lhs, |
| 3161 |
const SimdConstant& rhs, FloatRegister dest) |
| 3162 |
DEFINED_ON(x86_shared); |
| 3163 |
|
| 3164 |
// On x86_shared, limited to !=, ==, <=, > |
| 3165 |
inline void compareInt32x4(Assembler::Condition cond, FloatRegister rhs, |
| 3166 |
FloatRegister lhsDest) |
| 3167 |
DEFINED_ON(x86_shared, arm64); |
| 3168 |
|
| 3169 |
inline void compareInt32x4(Assembler::Condition cond, FloatRegister lhs, |
| 3170 |
const SimdConstant& rhs, FloatRegister dest) |
| 3171 |
DEFINED_ON(x86_shared); |
| 3172 |
|
| 3173 |
// On arm64, use any integer comparison condition. |
| 3174 |
inline void compareInt32x4(Assembler::Condition cond, FloatRegister lhs, |
| 3175 |
FloatRegister rhs, FloatRegister dest) |
| 3176 |
DEFINED_ON(x86_shared, arm64); |
| 3177 |
|
| 3178 |
inline void compareForEqualityInt64x2(Assembler::Condition cond, |
| 3179 |
FloatRegister lhs, FloatRegister rhs, |
| 3180 |
FloatRegister dest) |
| 3181 |
DEFINED_ON(x86_shared); |
| 3182 |
|
| 3183 |
inline void compareForOrderingInt64x2(Assembler::Condition cond, |
| 3184 |
FloatRegister lhs, FloatRegister rhs, |
| 3185 |
FloatRegister dest, FloatRegister temp1, |
| 3186 |
FloatRegister temp2) |
| 3187 |
DEFINED_ON(x86_shared); |
| 3188 |
|
| 3189 |
inline void compareInt64x2(Assembler::Condition cond, FloatRegister rhs, |
| 3190 |
FloatRegister lhsDest) DEFINED_ON(arm64); |
| 3191 |
|
| 3192 |
inline void compareInt64x2(Assembler::Condition cond, FloatRegister lhs, |
| 3193 |
FloatRegister rhs, FloatRegister dest) |
| 3194 |
DEFINED_ON(arm64); |
| 3195 |
|
| 3196 |
inline void compareFloat32x4(Assembler::Condition cond, FloatRegister rhs, |
| 3197 |
FloatRegister lhsDest) |
| 3198 |
DEFINED_ON(x86_shared, arm64); |
| 3199 |
|
| 3200 |
// On x86_shared, limited to ==, !=, <, <= |
| 3201 |
inline void compareFloat32x4(Assembler::Condition cond, FloatRegister lhs, |
| 3202 |
const SimdConstant& rhs, FloatRegister dest) |
| 3203 |
DEFINED_ON(x86_shared); |
| 3204 |
|
| 3205 |
// On x86_shared, limited to ==, !=, <, <= |
| 3206 |
// On arm64, use any float-point comparison condition. |
| 3207 |
inline void compareFloat32x4(Assembler::Condition cond, FloatRegister lhs, |
| 3208 |
FloatRegister rhs, FloatRegister dest) |
| 3209 |
DEFINED_ON(x86_shared, arm64); |
| 3210 |
|
| 3211 |
inline void compareFloat64x2(Assembler::Condition cond, FloatRegister rhs, |
| 3212 |
FloatRegister lhsDest) |
| 3213 |
DEFINED_ON(x86_shared, arm64); |
| 3214 |
|
| 3215 |
// On x86_shared, limited to ==, !=, <, <= |
| 3216 |
inline void compareFloat64x2(Assembler::Condition cond, FloatRegister lhs, |
| 3217 |
const SimdConstant& rhs, FloatRegister dest) |
| 3218 |
DEFINED_ON(x86_shared); |
| 3219 |
|
| 3220 |
// On x86_shared, limited to ==, !=, <, <= |
| 3221 |
// On arm64, use any float-point comparison condition. |
| 3222 |
inline void compareFloat64x2(Assembler::Condition cond, FloatRegister lhs, |
| 3223 |
FloatRegister rhs, FloatRegister dest) |
| 3224 |
DEFINED_ON(x86_shared, arm64); |
| 3225 |
|
| 3226 |
// Load |
| 3227 |
|
| 3228 |
inline void loadUnalignedSimd128(const Operand& src, FloatRegister dest) |
| 3229 |
DEFINED_ON(x86_shared); |
| 3230 |
|
| 3231 |
inline FaultingCodeOffset loadUnalignedSimd128(const Address& src, |
| 3232 |
FloatRegister dest) |
| 3233 |
DEFINED_ON(x86_shared, arm64); |
| 3234 |
|
| 3235 |
inline FaultingCodeOffset loadUnalignedSimd128(const BaseIndex& src, |
| 3236 |
FloatRegister dest) |
| 3237 |
DEFINED_ON(x86_shared, arm64); |
| 3238 |
|
| 3239 |
// Store |
| 3240 |
|
| 3241 |
inline FaultingCodeOffset storeUnalignedSimd128(FloatRegister src, |
| 3242 |
const Address& dest) |
| 3243 |
DEFINED_ON(x86_shared, arm64); |
| 3244 |
|
| 3245 |
inline FaultingCodeOffset storeUnalignedSimd128(FloatRegister src, |
| 3246 |
const BaseIndex& dest) |
| 3247 |
DEFINED_ON(x86_shared, arm64); |
| 3248 |
|
| 3249 |
// Floating point negation |
| 3250 |
|
| 3251 |
inline void negFloat32x4(FloatRegister src, FloatRegister dest) |
| 3252 |
DEFINED_ON(x86_shared, arm64); |
| 3253 |
|
| 3254 |
inline void negFloat64x2(FloatRegister src, FloatRegister dest) |
| 3255 |
DEFINED_ON(x86_shared, arm64); |
| 3256 |
|
| 3257 |
// Floating point absolute value |
| 3258 |
|
| 3259 |
inline void absFloat32x4(FloatRegister src, FloatRegister dest) |
| 3260 |
DEFINED_ON(x86_shared, arm64); |
| 3261 |
|
| 3262 |
inline void absFloat64x2(FloatRegister src, FloatRegister dest) |
| 3263 |
DEFINED_ON(x86_shared, arm64); |
| 3264 |
|
| 3265 |
// NaN-propagating minimum |
| 3266 |
|
| 3267 |
inline void minFloat32x4(FloatRegister lhs, FloatRegister rhs, |
| 3268 |
FloatRegister dest, FloatRegister temp1, |
| 3269 |
FloatRegister temp2) DEFINED_ON(x86_shared); |
| 3270 |
|
| 3271 |
inline void minFloat32x4(FloatRegister rhs, FloatRegister lhsDest) |
| 3272 |
DEFINED_ON(arm64); |
| 3273 |
|
| 3274 |
inline void minFloat32x4(FloatRegister lhs, FloatRegister rhs, |
| 3275 |
FloatRegister dest) DEFINED_ON(arm64); |
| 3276 |
|
| 3277 |
inline void minFloat64x2(FloatRegister lhs, FloatRegister rhs, |
| 3278 |
FloatRegister dest, FloatRegister temp1, |
| 3279 |
FloatRegister temp2) DEFINED_ON(x86_shared); |
| 3280 |
|
| 3281 |
inline void minFloat64x2(FloatRegister rhs, FloatRegister lhsDest) |
| 3282 |
DEFINED_ON(arm64); |
| 3283 |
|
| 3284 |
inline void minFloat64x2(FloatRegister lhs, FloatRegister rhs, |
| 3285 |
FloatRegister dest) DEFINED_ON(arm64); |
| 3286 |
|
| 3287 |
// NaN-propagating maximum |
| 3288 |
|
| 3289 |
inline void maxFloat32x4(FloatRegister lhs, FloatRegister rhs, |
| 3290 |
FloatRegister dest, FloatRegister temp1, |
| 3291 |
FloatRegister temp2) DEFINED_ON(x86_shared); |
| 3292 |
|
| 3293 |
inline void maxFloat32x4(FloatRegister rhs, FloatRegister lhsDest) |
| 3294 |
DEFINED_ON(arm64); |
| 3295 |
|
| 3296 |
inline void maxFloat32x4(FloatRegister lhs, FloatRegister rhs, |
| 3297 |
FloatRegister dest) DEFINED_ON(arm64); |
| 3298 |
|
| 3299 |
inline void maxFloat64x2(FloatRegister lhs, FloatRegister rhs, |
| 3300 |
FloatRegister dest, FloatRegister temp1, |
| 3301 |
FloatRegister temp2) DEFINED_ON(x86_shared); |
| 3302 |
|
| 3303 |
inline void maxFloat64x2(FloatRegister rhs, FloatRegister lhsDest) |
| 3304 |
DEFINED_ON(arm64); |
| 3305 |
|
| 3306 |
inline void maxFloat64x2(FloatRegister lhs, FloatRegister rhs, |
| 3307 |
FloatRegister dest) DEFINED_ON(arm64); |
| 3308 |
|
| 3309 |
// Floating add |
| 3310 |
|
| 3311 |
inline void addFloat32x4(FloatRegister lhs, FloatRegister rhs, |
| 3312 |
FloatRegister dest) DEFINED_ON(x86_shared, arm64); |
| 3313 |
|
| 3314 |
inline void addFloat32x4(FloatRegister lhs, const SimdConstant& rhs, |
| 3315 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 3316 |
|
| 3317 |
inline void addFloat64x2(FloatRegister lhs, FloatRegister rhs, |
| 3318 |
FloatRegister dest) DEFINED_ON(x86_shared, arm64); |
| 3319 |
|
| 3320 |
inline void addFloat64x2(FloatRegister lhs, const SimdConstant& rhs, |
| 3321 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 3322 |
|
| 3323 |
// Floating subtract |
| 3324 |
|
| 3325 |
inline void subFloat32x4(FloatRegister lhs, FloatRegister rhs, |
| 3326 |
FloatRegister dest) DEFINED_ON(x86_shared, arm64); |
| 3327 |
|
| 3328 |
inline void subFloat32x4(FloatRegister lhs, const SimdConstant& rhs, |
| 3329 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 3330 |
|
| 3331 |
inline void subFloat64x2(FloatRegister lhs, FloatRegister rhs, |
| 3332 |
FloatRegister dest) DEFINED_ON(x86_shared, arm64); |
| 3333 |
|
| 3334 |
inline void subFloat64x2(FloatRegister lhs, const SimdConstant& rhs, |
| 3335 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 3336 |
|
| 3337 |
// Floating division |
| 3338 |
|
| 3339 |
inline void divFloat32x4(FloatRegister lhs, FloatRegister rhs, |
| 3340 |
FloatRegister dest) DEFINED_ON(x86_shared, arm64); |
| 3341 |
|
| 3342 |
inline void divFloat32x4(FloatRegister lhs, const SimdConstant& rhs, |
| 3343 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 3344 |
|
| 3345 |
inline void divFloat64x2(FloatRegister lhs, FloatRegister rhs, |
| 3346 |
FloatRegister dest) DEFINED_ON(x86_shared, arm64); |
| 3347 |
|
| 3348 |
inline void divFloat64x2(FloatRegister lhs, const SimdConstant& rhs, |
| 3349 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 3350 |
|
| 3351 |
// Floating Multiply |
| 3352 |
|
| 3353 |
inline void mulFloat32x4(FloatRegister lhs, FloatRegister rhs, |
| 3354 |
FloatRegister dest) DEFINED_ON(x86_shared, arm64); |
| 3355 |
|
| 3356 |
inline void mulFloat32x4(FloatRegister lhs, const SimdConstant& rhs, |
| 3357 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 3358 |
|
| 3359 |
inline void mulFloat64x2(FloatRegister lhs, FloatRegister rhs, |
| 3360 |
FloatRegister dest) DEFINED_ON(x86_shared, arm64); |
| 3361 |
|
| 3362 |
inline void mulFloat64x2(FloatRegister lhs, const SimdConstant& rhs, |
| 3363 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 3364 |
|
| 3365 |
// Pairwise add |
| 3366 |
|
| 3367 |
inline void extAddPairwiseInt8x16(FloatRegister src, FloatRegister dest) |
| 3368 |
DEFINED_ON(x86_shared, arm64); |
| 3369 |
|
| 3370 |
inline void unsignedExtAddPairwiseInt8x16(FloatRegister src, |
| 3371 |
FloatRegister dest) |
| 3372 |
DEFINED_ON(x86_shared, arm64); |
| 3373 |
|
| 3374 |
inline void extAddPairwiseInt16x8(FloatRegister src, FloatRegister dest) |
| 3375 |
DEFINED_ON(x86_shared, arm64); |
| 3376 |
|
| 3377 |
inline void unsignedExtAddPairwiseInt16x8(FloatRegister src, |
| 3378 |
FloatRegister dest) |
| 3379 |
DEFINED_ON(x86_shared, arm64); |
| 3380 |
|
| 3381 |
// Floating square root |
| 3382 |
|
| 3383 |
inline void sqrtFloat32x4(FloatRegister src, FloatRegister dest) |
| 3384 |
DEFINED_ON(x86_shared, arm64); |
| 3385 |
|
| 3386 |
inline void sqrtFloat64x2(FloatRegister src, FloatRegister dest) |
| 3387 |
DEFINED_ON(x86_shared, arm64); |
| 3388 |
|
| 3389 |
// Integer to floating point with rounding |
| 3390 |
|
| 3391 |
inline void convertInt32x4ToFloat32x4(FloatRegister src, FloatRegister dest) |
| 3392 |
DEFINED_ON(x86_shared, arm64); |
| 3393 |
|
| 3394 |
inline void unsignedConvertInt32x4ToFloat32x4(FloatRegister src, |
| 3395 |
FloatRegister dest) |
| 3396 |
DEFINED_ON(x86_shared, arm64); |
| 3397 |
|
| 3398 |
inline void convertInt32x4ToFloat64x2(FloatRegister src, FloatRegister dest) |
| 3399 |
DEFINED_ON(x86_shared, arm64); |
| 3400 |
|
| 3401 |
inline void unsignedConvertInt32x4ToFloat64x2(FloatRegister src, |
| 3402 |
FloatRegister dest) |
| 3403 |
DEFINED_ON(x86_shared, arm64); |
| 3404 |
|
| 3405 |
// Floating point to integer with saturation |
| 3406 |
|
| 3407 |
inline void truncSatFloat32x4ToInt32x4(FloatRegister src, FloatRegister dest) |
| 3408 |
DEFINED_ON(x86_shared, arm64); |
| 3409 |
|
| 3410 |
inline void unsignedTruncSatFloat32x4ToInt32x4(FloatRegister src, |
| 3411 |
FloatRegister dest, |
| 3412 |
FloatRegister temp) |
| 3413 |
DEFINED_ON(x86_shared); |
| 3414 |
|
| 3415 |
inline void unsignedTruncSatFloat32x4ToInt32x4(FloatRegister src, |
| 3416 |
FloatRegister dest) |
| 3417 |
DEFINED_ON(arm64); |
| 3418 |
|
| 3419 |
inline void truncSatFloat64x2ToInt32x4(FloatRegister src, FloatRegister dest, |
| 3420 |
FloatRegister temp) |
| 3421 |
DEFINED_ON(x86_shared, arm64); |
| 3422 |
|
| 3423 |
inline void unsignedTruncSatFloat64x2ToInt32x4(FloatRegister src, |
| 3424 |
FloatRegister dest, |
| 3425 |
FloatRegister temp) |
| 3426 |
DEFINED_ON(x86_shared, arm64); |
| 3427 |
|
| 3428 |
inline void truncFloat32x4ToInt32x4Relaxed(FloatRegister src, |
| 3429 |
FloatRegister dest) |
| 3430 |
DEFINED_ON(x86_shared, arm64); |
| 3431 |
|
| 3432 |
inline void unsignedTruncFloat32x4ToInt32x4Relaxed(FloatRegister src, |
| 3433 |
FloatRegister dest) |
| 3434 |
DEFINED_ON(x86_shared, arm64); |
| 3435 |
|
| 3436 |
inline void truncFloat64x2ToInt32x4Relaxed(FloatRegister src, |
| 3437 |
FloatRegister dest) |
| 3438 |
DEFINED_ON(x86_shared, arm64); |
| 3439 |
|
| 3440 |
inline void unsignedTruncFloat64x2ToInt32x4Relaxed(FloatRegister src, |
| 3441 |
FloatRegister dest) |
| 3442 |
DEFINED_ON(x86_shared, arm64); |
| 3443 |
|
| 3444 |
// Floating point narrowing |
| 3445 |
|
| 3446 |
inline void convertFloat64x2ToFloat32x4(FloatRegister src, FloatRegister dest) |
| 3447 |
DEFINED_ON(x86_shared, arm64); |
| 3448 |
|
| 3449 |
// Floating point widening |
| 3450 |
|
| 3451 |
inline void convertFloat32x4ToFloat64x2(FloatRegister src, FloatRegister dest) |
| 3452 |
DEFINED_ON(x86_shared, arm64); |
| 3453 |
|
| 3454 |
// Integer to integer narrowing |
| 3455 |
|
| 3456 |
inline void narrowInt16x8(FloatRegister lhs, const SimdConstant& rhs, |
| 3457 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 3458 |
|
| 3459 |
inline void narrowInt16x8(FloatRegister lhs, FloatRegister rhs, |
| 3460 |
FloatRegister dest) DEFINED_ON(x86_shared, arm64); |
| 3461 |
|
| 3462 |
inline void unsignedNarrowInt16x8(FloatRegister lhs, const SimdConstant& rhs, |
| 3463 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 3464 |
|
| 3465 |
inline void unsignedNarrowInt16x8(FloatRegister lhs, FloatRegister rhs, |
| 3466 |
FloatRegister dest) |
| 3467 |
DEFINED_ON(x86_shared, arm64); |
| 3468 |
|
| 3469 |
inline void narrowInt32x4(FloatRegister lhs, const SimdConstant& rhs, |
| 3470 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 3471 |
|
| 3472 |
inline void narrowInt32x4(FloatRegister lhs, FloatRegister rhs, |
| 3473 |
FloatRegister dest) DEFINED_ON(x86_shared, arm64); |
| 3474 |
|
| 3475 |
inline void unsignedNarrowInt32x4(FloatRegister lhs, const SimdConstant& rhs, |
| 3476 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 3477 |
|
| 3478 |
inline void unsignedNarrowInt32x4(FloatRegister lhs, FloatRegister rhs, |
| 3479 |
FloatRegister dest) |
| 3480 |
DEFINED_ON(x86_shared, arm64); |
| 3481 |
|
| 3482 |
// Integer to integer widening |
| 3483 |
|
| 3484 |
inline void widenLowInt8x16(FloatRegister src, FloatRegister dest) |
| 3485 |
DEFINED_ON(x86_shared, arm64); |
| 3486 |
|
| 3487 |
inline void widenHighInt8x16(FloatRegister src, FloatRegister dest) |
| 3488 |
DEFINED_ON(x86_shared, arm64); |
| 3489 |
|
| 3490 |
inline void unsignedWidenLowInt8x16(FloatRegister src, FloatRegister dest) |
| 3491 |
DEFINED_ON(x86_shared, arm64); |
| 3492 |
|
| 3493 |
inline void unsignedWidenHighInt8x16(FloatRegister src, FloatRegister dest) |
| 3494 |
DEFINED_ON(x86_shared, arm64); |
| 3495 |
|
| 3496 |
inline void widenLowInt16x8(FloatRegister src, FloatRegister dest) |
| 3497 |
DEFINED_ON(x86_shared, arm64); |
| 3498 |
|
| 3499 |
inline void widenHighInt16x8(FloatRegister src, FloatRegister dest) |
| 3500 |
DEFINED_ON(x86_shared, arm64); |
| 3501 |
|
| 3502 |
inline void unsignedWidenLowInt16x8(FloatRegister src, FloatRegister dest) |
| 3503 |
DEFINED_ON(x86_shared, arm64); |
| 3504 |
|
| 3505 |
inline void unsignedWidenHighInt16x8(FloatRegister src, FloatRegister dest) |
| 3506 |
DEFINED_ON(x86_shared, arm64); |
| 3507 |
|
| 3508 |
inline void widenLowInt32x4(FloatRegister src, FloatRegister dest) |
| 3509 |
DEFINED_ON(x86_shared, arm64); |
| 3510 |
|
| 3511 |
inline void unsignedWidenLowInt32x4(FloatRegister src, FloatRegister dest) |
| 3512 |
DEFINED_ON(x86_shared, arm64); |
| 3513 |
|
| 3514 |
inline void widenHighInt32x4(FloatRegister src, FloatRegister dest) |
| 3515 |
DEFINED_ON(x86_shared, arm64); |
| 3516 |
|
| 3517 |
inline void unsignedWidenHighInt32x4(FloatRegister src, FloatRegister dest) |
| 3518 |
DEFINED_ON(x86_shared, arm64); |
| 3519 |
|
| 3520 |
// Compare-based minimum/maximum |
| 3521 |
// |
| 3522 |
// On x86, the signature is (rhsDest, lhs); on arm64 it is (rhs, lhsDest). |
| 3523 |
// |
| 3524 |
// The masm preprocessor can't deal with multiple declarations with identical |
| 3525 |
// signatures even if they are on different platforms, hence the weird |
| 3526 |
// argument names. |
| 3527 |
|
| 3528 |
inline void pseudoMinFloat32x4(FloatRegister rhsOrRhsDest, |
| 3529 |
FloatRegister lhsOrLhsDest) |
| 3530 |
DEFINED_ON(x86_shared, arm64); |
| 3531 |
|
| 3532 |
inline void pseudoMinFloat32x4(FloatRegister lhs, FloatRegister rhs, |
| 3533 |
FloatRegister dest) |
| 3534 |
DEFINED_ON(x86_shared, arm64); |
| 3535 |
|
| 3536 |
inline void pseudoMinFloat64x2(FloatRegister rhsOrRhsDest, |
| 3537 |
FloatRegister lhsOrLhsDest) |
| 3538 |
DEFINED_ON(x86_shared, arm64); |
| 3539 |
|
| 3540 |
inline void pseudoMinFloat64x2(FloatRegister lhs, FloatRegister rhs, |
| 3541 |
FloatRegister dest) |
| 3542 |
DEFINED_ON(x86_shared, arm64); |
| 3543 |
|
| 3544 |
inline void pseudoMaxFloat32x4(FloatRegister rhsOrRhsDest, |
| 3545 |
FloatRegister lhsOrLhsDest) |
| 3546 |
DEFINED_ON(x86_shared, arm64); |
| 3547 |
|
| 3548 |
inline void pseudoMaxFloat32x4(FloatRegister lhs, FloatRegister rhs, |
| 3549 |
FloatRegister dest) |
| 3550 |
DEFINED_ON(x86_shared, arm64); |
| 3551 |
|
| 3552 |
inline void pseudoMaxFloat64x2(FloatRegister rhsOrRhsDest, |
| 3553 |
FloatRegister lhsOrLhsDest) |
| 3554 |
DEFINED_ON(x86_shared, arm64); |
| 3555 |
|
| 3556 |
inline void pseudoMaxFloat64x2(FloatRegister lhs, FloatRegister rhs, |
| 3557 |
FloatRegister dest) |
| 3558 |
DEFINED_ON(x86_shared, arm64); |
| 3559 |
|
| 3560 |
// Widening/pairwise integer dot product |
| 3561 |
|
| 3562 |
inline void widenDotInt16x8(FloatRegister lhs, FloatRegister rhs, |
| 3563 |
FloatRegister dest) DEFINED_ON(x86_shared, arm64); |
| 3564 |
|
| 3565 |
inline void widenDotInt16x8(FloatRegister lhs, const SimdConstant& rhs, |
| 3566 |
FloatRegister dest) DEFINED_ON(x86_shared); |
| 3567 |
|
| 3568 |
inline void dotInt8x16Int7x16(FloatRegister lhs, FloatRegister rhs, |
| 3569 |
FloatRegister dest) |
| 3570 |
DEFINED_ON(x86_shared, arm64); |
| 3571 |
|
| 3572 |
inline void dotInt8x16Int7x16ThenAdd(FloatRegister lhs, FloatRegister rhs, |
| 3573 |
FloatRegister dest) |
| 3574 |
DEFINED_ON(x86_shared); |
| 3575 |
|
| 3576 |
inline void dotInt8x16Int7x16ThenAdd(FloatRegister lhs, FloatRegister rhs, |
| 3577 |
FloatRegister dest, FloatRegister temp) |
| 3578 |
DEFINED_ON(arm64); |
| 3579 |
|
| 3580 |
// Floating point rounding |
| 3581 |
|
| 3582 |
inline void ceilFloat32x4(FloatRegister src, FloatRegister dest) |
| 3583 |
DEFINED_ON(x86_shared, arm64); |
| 3584 |
|
| 3585 |
inline void ceilFloat64x2(FloatRegister src, FloatRegister dest) |
| 3586 |
DEFINED_ON(x86_shared, arm64); |
| 3587 |
|
| 3588 |
inline void floorFloat32x4(FloatRegister src, FloatRegister dest) |
| 3589 |
DEFINED_ON(x86_shared, arm64); |
| 3590 |
|
| 3591 |
inline void floorFloat64x2(FloatRegister src, FloatRegister dest) |
| 3592 |
DEFINED_ON(x86_shared, arm64); |
| 3593 |
|
| 3594 |
inline void truncFloat32x4(FloatRegister src, FloatRegister dest) |
| 3595 |
DEFINED_ON(x86_shared, arm64); |
| 3596 |
|
| 3597 |
inline void truncFloat64x2(FloatRegister src, FloatRegister dest) |
| 3598 |
DEFINED_ON(x86_shared, arm64); |
| 3599 |
|
| 3600 |
inline void nearestFloat32x4(FloatRegister src, FloatRegister dest) |
| 3601 |
DEFINED_ON(x86_shared, arm64); |
| 3602 |
|
| 3603 |
inline void nearestFloat64x2(FloatRegister src, FloatRegister dest) |
| 3604 |
DEFINED_ON(x86_shared, arm64); |
| 3605 |
|
| 3606 |
// Floating multiply-accumulate: srcDest [+-]= src1 * src2 |
| 3607 |
|
| 3608 |
inline void fmaFloat32x4(FloatRegister src1, FloatRegister src2, |
| 3609 |
FloatRegister srcDest) DEFINED_ON(x86_shared, arm64); |
| 3610 |
|
| 3611 |
inline void fnmaFloat32x4(FloatRegister src1, FloatRegister src2, |
| 3612 |
FloatRegister srcDest) |
| 3613 |
DEFINED_ON(x86_shared, arm64); |
| 3614 |
|
| 3615 |
inline void fmaFloat64x2(FloatRegister src1, FloatRegister src2, |
| 3616 |
FloatRegister srcDest) DEFINED_ON(x86_shared, arm64); |
| 3617 |
|
| 3618 |
inline void fnmaFloat64x2(FloatRegister src1, FloatRegister src2, |
| 3619 |
FloatRegister srcDest) |
| 3620 |
DEFINED_ON(x86_shared, arm64); |
| 3621 |
|
| 3622 |
inline void minFloat32x4Relaxed(FloatRegister src, FloatRegister srcDest) |
| 3623 |
DEFINED_ON(x86_shared, arm64); |
| 3624 |
|
| 3625 |
inline void minFloat32x4Relaxed(FloatRegister lhs, FloatRegister rhs, |
| 3626 |
FloatRegister dest) |
| 3627 |
DEFINED_ON(x86_shared, arm64); |
| 3628 |
|
| 3629 |
inline void maxFloat32x4Relaxed(FloatRegister src, FloatRegister srcDest) |
| 3630 |
DEFINED_ON(x86_shared, arm64); |
| 3631 |
|
| 3632 |
inline void maxFloat32x4Relaxed(FloatRegister lhs, FloatRegister rhs, |
| 3633 |
FloatRegister dest) |
| 3634 |
DEFINED_ON(x86_shared, arm64); |
| 3635 |
|
| 3636 |
inline void minFloat64x2Relaxed(FloatRegister src, FloatRegister srcDest) |
| 3637 |
DEFINED_ON(x86_shared, arm64); |
| 3638 |
|
| 3639 |
inline void minFloat64x2Relaxed(FloatRegister lhs, FloatRegister rhs, |
| 3640 |
FloatRegister dest) |
| 3641 |
DEFINED_ON(x86_shared, arm64); |
| 3642 |
|
| 3643 |
inline void maxFloat64x2Relaxed(FloatRegister src, FloatRegister srcDest) |
| 3644 |
DEFINED_ON(x86_shared, arm64); |
| 3645 |
|
| 3646 |
inline void maxFloat64x2Relaxed(FloatRegister lhs, FloatRegister rhs, |
| 3647 |
FloatRegister dest) |
| 3648 |
DEFINED_ON(x86_shared, arm64); |
| 3649 |
|
| 3650 |
inline void q15MulrInt16x8Relaxed(FloatRegister lhs, FloatRegister rhs, |
| 3651 |
FloatRegister dest) |
| 3652 |
DEFINED_ON(x86_shared, arm64); |
| 3653 |
|
| 3654 |
public: |
| 3655 |
// ======================================================================== |
| 3656 |
// Truncate floating point. |
| 3657 |
|
| 3658 |
// Undefined behaviour when truncation is outside Int64 range. |
| 3659 |
// Needs a temp register if SSE3 is not present. |
| 3660 |
inline void truncateFloat32ToInt64(Address src, Address dest, Register temp) |
| 3661 |
DEFINED_ON(x86_shared); |
| 3662 |
inline void truncateFloat32ToUInt64(Address src, Address dest, Register temp, |
| 3663 |
FloatRegister floatTemp) |
| 3664 |
DEFINED_ON(x86, x64); |
| 3665 |
inline void truncateDoubleToInt64(Address src, Address dest, Register temp) |
| 3666 |
DEFINED_ON(x86_shared); |
| 3667 |
inline void truncateDoubleToUInt64(Address src, Address dest, Register temp, |
| 3668 |
FloatRegister floatTemp) |
| 3669 |
DEFINED_ON(x86, x64); |
| 3670 |
|
| 3671 |
public: |
| 3672 |
// ======================================================================== |
| 3673 |
// Convert floating point. |
| 3674 |
|
| 3675 |
// temp required on x86 and x64; must be undefined on mips64 and loong64. |
| 3676 |
void convertUInt64ToFloat32(Register64 src, FloatRegister dest, Register temp) |
| 3677 |
DEFINED_ON(arm64, mips64, loong64, riscv64, wasm32, x64, x86); |
| 3678 |
|
| 3679 |
void convertInt64ToFloat32(Register64 src, FloatRegister dest) |
| 3680 |
DEFINED_ON(arm64, mips64, loong64, riscv64, wasm32, x64, x86); |
| 3681 |
|
| 3682 |
bool convertUInt64ToDoubleNeedsTemp() PER_ARCH; |
| 3683 |
|
| 3684 |
// temp required when convertUInt64ToDoubleNeedsTemp() returns true. |
| 3685 |
void convertUInt64ToDouble(Register64 src, FloatRegister dest, |
| 3686 |
Register temp) PER_ARCH; |
| 3687 |
|
| 3688 |
void convertInt64ToDouble(Register64 src, FloatRegister dest) PER_ARCH; |
| 3689 |
|
| 3690 |
void convertIntPtrToDouble(Register src, FloatRegister dest) PER_ARCH; |
| 3691 |
|
| 3692 |
public: |
| 3693 |
// ======================================================================== |
| 3694 |
// wasm support |
| 3695 |
|
| 3696 |
FaultingCodeOffset wasmTrapInstruction() PER_SHARED_ARCH; |
| 3697 |
|
| 3698 |
void wasmTrap(wasm::Trap trap, const wasm::TrapSiteDesc& trapSiteDesc); |
| 3699 |
|
| 3700 |
// Load all pinned regs via InstanceReg. If the trapOffset is something, |
| 3701 |
// give the first load a trap descriptor with type IndirectCallToNull, so that |
| 3702 |
// a null instance will cause a trap. |
| 3703 |
void loadWasmPinnedRegsFromInstance( |
| 3704 |
const wasm::MaybeTrapSiteDesc& trapSiteDesc); |
| 3705 |
|
| 3706 |
// Returns a pair: the offset of the undefined (trapping) instruction, and |
| 3707 |
// the number of extra bytes of stack allocated prior to the trap |
| 3708 |
// instruction proper. |
| 3709 |
std::pair<CodeOffset, uint32_t> wasmReserveStackChecked( |
| 3710 |
uint32_t amount, const wasm::TrapSiteDesc& trapSiteDesc); |
| 3711 |
|
| 3712 |
// Emit a bounds check against the wasm heap limit, jumping to 'ok' if 'cond' |
| 3713 |
// holds; this can be the label either of the access or of the trap. The |
| 3714 |
// label should name a code position greater than the position of the bounds |
| 3715 |
// check. |
| 3716 |
// |
| 3717 |
// If JitOptions.spectreMaskIndex is true, a no-op speculation barrier is |
| 3718 |
// emitted in the code stream after the check to prevent an OOB access from |
| 3719 |
// being executed speculatively. (On current tier-1 platforms the barrier is |
| 3720 |
// a conditional saturation of 'index' to 'boundsCheckLimit', using the same |
| 3721 |
// condition as the check.) If the condition is such that the bounds check |
| 3722 |
// branches out of line to the trap, the barrier will actually be executed |
| 3723 |
// when the bounds check passes. |
| 3724 |
// |
| 3725 |
// On 32-bit systems for both wasm and asm.js, and on 64-bit systems for |
| 3726 |
// asm.js, heap lengths are limited to 2GB. On 64-bit systems for wasm, |
| 3727 |
// 32-bit heap lengths are limited to 4GB, and 64-bit heap lengths will be |
| 3728 |
// limited to something much larger. |
| 3729 |
|
| 3730 |
void wasmBoundsCheck32(Condition cond, Register index, |
| 3731 |
Register boundsCheckLimit, Label* ok) PER_SHARED_ARCH; |
| 3732 |
|
| 3733 |
void wasmBoundsCheck32(Condition cond, Register index, |
| 3734 |
Address boundsCheckLimit, Label* ok) PER_SHARED_ARCH; |
| 3735 |
|
| 3736 |
void wasmBoundsCheck64(Condition cond, Register64 index, |
| 3737 |
Register64 boundsCheckLimit, Label* ok) PER_ARCH; |
| 3738 |
|
| 3739 |
void wasmBoundsCheck64(Condition cond, Register64 index, |
| 3740 |
Address boundsCheckLimit, Label* ok) PER_ARCH; |
| 3741 |
|
| 3742 |
// Each wasm load/store instruction appends its own wasm::Trap::OutOfBounds. |
| 3743 |
void wasmLoad(const wasm::MemoryAccessDesc& access, Operand srcAddr, |
| 3744 |
AnyRegister out) DEFINED_ON(x86, x64); |
| 3745 |
void wasmLoadI64(const wasm::MemoryAccessDesc& access, Operand srcAddr, |
| 3746 |
Register64 out) DEFINED_ON(x86, x64); |
| 3747 |
void wasmStore(const wasm::MemoryAccessDesc& access, AnyRegister value, |
| 3748 |
Operand dstAddr) DEFINED_ON(x86, x64); |
| 3749 |
void wasmStoreI64(const wasm::MemoryAccessDesc& access, Register64 value, |
| 3750 |
Operand dstAddr) DEFINED_ON(x86); |
| 3751 |
|
| 3752 |
// For all the ARM/MIPS/LOONG64 wasmLoad and wasmStore functions below, `ptr` |
| 3753 |
// MUST equal `ptrScratch`, and that register will be updated based on |
| 3754 |
// conditions listed below (where it is only mentioned as `ptr`). |
| 3755 |
|
| 3756 |
// `ptr` will be updated if access.offset32() != 0 or access.type() == |
| 3757 |
// Scalar::Int64. |
| 3758 |
void wasmLoad(const wasm::MemoryAccessDesc& access, Register memoryBase, |
| 3759 |
Register ptr, Register ptrScratch, AnyRegister output) |
| 3760 |
DEFINED_ON(arm, loong64, riscv64, mips64); |
| 3761 |
void wasmLoadI64(const wasm::MemoryAccessDesc& access, Register memoryBase, |
| 3762 |
Register ptr, Register ptrScratch, Register64 output) |
| 3763 |
DEFINED_ON(arm, mips64, loong64, riscv64); |
| 3764 |
void wasmStore(const wasm::MemoryAccessDesc& access, AnyRegister value, |
| 3765 |
Register memoryBase, Register ptr, Register ptrScratch) |
| 3766 |
DEFINED_ON(arm, loong64, riscv64, mips64); |
| 3767 |
void wasmStoreI64(const wasm::MemoryAccessDesc& access, Register64 value, |
| 3768 |
Register memoryBase, Register ptr, Register ptrScratch) |
| 3769 |
DEFINED_ON(arm, mips64, loong64, riscv64); |
| 3770 |
|
| 3771 |
// These accept general memoryBase + ptr + offset (in `access`); the offset is |
| 3772 |
// always smaller than the guard region. They will insert an additional add |
| 3773 |
// if the offset is nonzero, and of course that add may require a temporary |
| 3774 |
// register for the offset if the offset is large, and instructions to set it |
| 3775 |
// up. |
| 3776 |
void wasmLoad(const wasm::MemoryAccessDesc& access, Register memoryBase, |
| 3777 |
Register ptr, AnyRegister output) DEFINED_ON(arm64); |
| 3778 |
void wasmLoadI64(const wasm::MemoryAccessDesc& access, Register memoryBase, |
| 3779 |
Register ptr, Register64 output) DEFINED_ON(arm64); |
| 3780 |
void wasmStore(const wasm::MemoryAccessDesc& access, AnyRegister value, |
| 3781 |
Register memoryBase, Register ptr) DEFINED_ON(arm64); |
| 3782 |
void wasmStoreI64(const wasm::MemoryAccessDesc& access, Register64 value, |
| 3783 |
Register memoryBase, Register ptr) DEFINED_ON(arm64); |
| 3784 |
|
| 3785 |
// `ptr` will always be updated. |
| 3786 |
void wasmUnalignedLoad(const wasm::MemoryAccessDesc& access, |
| 3787 |
Register memoryBase, Register ptr, Register ptrScratch, |
| 3788 |
Register output, Register tmp) DEFINED_ON(mips64); |
| 3789 |
|
| 3790 |
// MIPS: `ptr` will always be updated. |
| 3791 |
void wasmUnalignedLoadFP(const wasm::MemoryAccessDesc& access, |
| 3792 |
Register memoryBase, Register ptr, |
| 3793 |
Register ptrScratch, FloatRegister output, |
| 3794 |
Register tmp1) DEFINED_ON(mips64); |
| 3795 |
|
| 3796 |
// `ptr` will always be updated. |
| 3797 |
void wasmUnalignedLoadI64(const wasm::MemoryAccessDesc& access, |
| 3798 |
Register memoryBase, Register ptr, |
| 3799 |
Register ptrScratch, Register64 output, |
| 3800 |
Register tmp) DEFINED_ON(mips64); |
| 3801 |
|
| 3802 |
// MIPS: `ptr` will always be updated. |
| 3803 |
void wasmUnalignedStore(const wasm::MemoryAccessDesc& access, Register value, |
| 3804 |
Register memoryBase, Register ptr, |
| 3805 |
Register ptrScratch, Register tmp) DEFINED_ON(mips64); |
| 3806 |
|
| 3807 |
// `ptr` will always be updated. |
| 3808 |
void wasmUnalignedStoreFP(const wasm::MemoryAccessDesc& access, |
| 3809 |
FloatRegister floatValue, Register memoryBase, |
| 3810 |
Register ptr, Register ptrScratch, Register tmp) |
| 3811 |
DEFINED_ON(mips64); |
| 3812 |
|
| 3813 |
// `ptr` will always be updated. |
| 3814 |
void wasmUnalignedStoreI64(const wasm::MemoryAccessDesc& access, |
| 3815 |
Register64 value, Register memoryBase, |
| 3816 |
Register ptr, Register ptrScratch, Register tmp) |
| 3817 |
DEFINED_ON(mips64); |
| 3818 |
|
| 3819 |
// wasm specific methods, used in both the wasm baseline compiler and ion. |
| 3820 |
|
| 3821 |
// The truncate-to-int32 methods do not bind the rejoin label; clients must |
| 3822 |
// do so if oolWasmTruncateCheckF64ToI32() can jump to it. |
| 3823 |
void wasmTruncateDoubleToUInt32(FloatRegister input, Register output, |
| 3824 |
bool isSaturating, Label* oolEntry) PER_ARCH; |
| 3825 |
void wasmTruncateDoubleToInt32(FloatRegister input, Register output, |
| 3826 |
bool isSaturating, |
| 3827 |
Label* oolEntry) PER_SHARED_ARCH; |
| 3828 |
void oolWasmTruncateCheckF64ToI32(FloatRegister input, Register output, |
| 3829 |
TruncFlags flags, |
| 3830 |
const wasm::TrapSiteDesc& trapSiteDesc, |
| 3831 |
Label* rejoin) PER_SHARED_ARCH; |
| 3832 |
|
| 3833 |
void wasmTruncateFloat32ToUInt32(FloatRegister input, Register output, |
| 3834 |
bool isSaturating, Label* oolEntry) PER_ARCH; |
| 3835 |
void wasmTruncateFloat32ToInt32(FloatRegister input, Register output, |
| 3836 |
bool isSaturating, |
| 3837 |
Label* oolEntry) PER_SHARED_ARCH; |
| 3838 |
void oolWasmTruncateCheckF32ToI32(FloatRegister input, Register output, |
| 3839 |
TruncFlags flags, |
| 3840 |
const wasm::TrapSiteDesc& trapSiteDesc, |
| 3841 |
Label* rejoin) PER_SHARED_ARCH; |
| 3842 |
|
| 3843 |
// The truncate-to-int64 methods will always bind the `oolRejoin` label |
| 3844 |
// after the last emitted instruction. |
| 3845 |
void wasmTruncateDoubleToInt64(FloatRegister input, Register64 output, |
| 3846 |
bool isSaturating, Label* oolEntry, |
| 3847 |
Label* oolRejoin, FloatRegister tempDouble) |
| 3848 |
DEFINED_ON(arm64, x86, x64, mips64, loong64, riscv64, wasm32); |
| 3849 |
void wasmTruncateDoubleToUInt64(FloatRegister input, Register64 output, |
| 3850 |
bool isSaturating, Label* oolEntry, |
| 3851 |
Label* oolRejoin, FloatRegister tempDouble) |
| 3852 |
DEFINED_ON(arm64, x86, x64, mips64, loong64, riscv64, wasm32); |
| 3853 |
void oolWasmTruncateCheckF64ToI64(FloatRegister input, Register64 output, |
| 3854 |
TruncFlags flags, |
| 3855 |
const wasm::TrapSiteDesc& trapSiteDesc, |
| 3856 |
Label* rejoin) PER_SHARED_ARCH; |
| 3857 |
|
| 3858 |
void wasmTruncateFloat32ToInt64(FloatRegister input, Register64 output, |
| 3859 |
bool isSaturating, Label* oolEntry, |
| 3860 |
Label* oolRejoin, FloatRegister tempDouble) |
| 3861 |
DEFINED_ON(arm64, x86, x64, mips64, loong64, riscv64, wasm32); |
| 3862 |
void wasmTruncateFloat32ToUInt64(FloatRegister input, Register64 output, |
| 3863 |
bool isSaturating, Label* oolEntry, |
| 3864 |
Label* oolRejoin, FloatRegister tempDouble) |
| 3865 |
DEFINED_ON(arm64, x86, x64, mips64, loong64, riscv64, wasm32); |
| 3866 |
void oolWasmTruncateCheckF32ToI64(FloatRegister input, Register64 output, |
| 3867 |
TruncFlags flags, |
| 3868 |
const wasm::TrapSiteDesc& trapSiteDesc, |
| 3869 |
Label* rejoin) PER_SHARED_ARCH; |
| 3870 |
|
| 3871 |
// This function takes care of loading the callee's instance and pinned regs |
| 3872 |
// but it is the caller's responsibility to save/restore instance or pinned |
| 3873 |
// regs. |
| 3874 |
CodeOffset wasmCallImport(const wasm::CallSiteDesc& desc, |
| 3875 |
const wasm::CalleeDesc& callee); |
| 3876 |
|
| 3877 |
CodeOffset wasmReturnCallImport(const wasm::CallSiteDesc& desc, |
| 3878 |
const wasm::CalleeDesc& callee, |
| 3879 |
const ReturnCallAdjustmentInfo& retCallInfo); |
| 3880 |
|
| 3881 |
CodeOffset wasmReturnCall(const wasm::CallSiteDesc& desc, |
| 3882 |
uint32_t funcDefIndex, |
| 3883 |
const ReturnCallAdjustmentInfo& retCallInfo); |
| 3884 |
|
| 3885 |
void wasmCollapseFrameSlow(const ReturnCallAdjustmentInfo& retCallInfo, |
| 3886 |
wasm::CallSiteDesc desc); |
| 3887 |
|
| 3888 |
void wasmCollapseFrameFast(const ReturnCallAdjustmentInfo& retCallInfo); |
| 3889 |
|
| 3890 |
void wasmCheckSlowCallsite(Register ra, Label* notSlow, Register temp1, |
| 3891 |
Register temp2) PER_ARCH; |
| 3892 |
|
| 3893 |
// Places slow class marker for tail calls. |
| 3894 |
void wasmMarkCallAsSlow() PER_ARCH; |
| 3895 |
|
| 3896 |
// Combines slow class marker with actual assembler call. |
| 3897 |
CodeOffset wasmMarkedSlowCall(const wasm::CallSiteDesc& desc, |
| 3898 |
const Register reg) PER_SHARED_ARCH; |
| 3899 |
|
| 3900 |
#ifdef ENABLE_WASM_MEMORY64 |
| 3901 |
void wasmClampTable64Address(Register64 address, Register out); |
| 3902 |
#endif |
| 3903 |
|
| 3904 |
// WasmTableCallIndexReg must contain the index of the indirect call. This is |
| 3905 |
// for wasm calls only. |
| 3906 |
// |
| 3907 |
// Indirect calls use a dual-path mechanism where a run-time test determines |
| 3908 |
// whether a context switch is needed (slow path) or not (fast path). This |
| 3909 |
// gives rise to two call instructions, both of which need safe points. As |
| 3910 |
// per normal, the call offsets are the code offsets at the end of the call |
| 3911 |
// instructions (the return points). |
| 3912 |
// |
| 3913 |
// `boundsCheckFailedLabel` is non-null iff a bounds check is required. |
| 3914 |
// `nullCheckFailedLabel` is non-null only on platforms that can't fold the |
| 3915 |
// null check into the rest of the call instructions. |
| 3916 |
void wasmCallIndirect(const wasm::CallSiteDesc& desc, |
| 3917 |
const wasm::CalleeDesc& callee, |
| 3918 |
Label* boundsCheckFailedLabel, |
| 3919 |
Label* nullCheckFailedLabel, |
| 3920 |
mozilla::Maybe<uint32_t> tableSize, |
| 3921 |
CodeOffset* fastCallOffset, CodeOffset* slowCallOffset); |
| 3922 |
|
| 3923 |
// WasmTableCallIndexReg must contain the index of the indirect call. This is |
| 3924 |
// for wasm calls only. |
| 3925 |
// |
| 3926 |
// `boundsCheckFailedLabel` is non-null iff a bounds check is required. |
| 3927 |
// `nullCheckFailedLabel` is non-null only on platforms that can't fold the |
| 3928 |
// null check into the rest of the call instructions. |
| 3929 |
void wasmReturnCallIndirect(const wasm::CallSiteDesc& desc, |
| 3930 |
const wasm::CalleeDesc& callee, |
| 3931 |
Label* boundsCheckFailedLabel, |
| 3932 |
Label* nullCheckFailedLabel, |
| 3933 |
mozilla::Maybe<uint32_t> tableSize, |
| 3934 |
const ReturnCallAdjustmentInfo& retCallInfo); |
| 3935 |
|
| 3936 |
// This function takes care of loading the callee's instance and address from |
| 3937 |
// pinned reg. |
| 3938 |
void wasmCallRef(const wasm::CallSiteDesc& desc, |
| 3939 |
const wasm::CalleeDesc& callee, CodeOffset* fastCallOffset, |
| 3940 |
CodeOffset* slowCallOffset); |
| 3941 |
|
| 3942 |
void wasmReturnCallRef(const wasm::CallSiteDesc& desc, |
| 3943 |
const wasm::CalleeDesc& callee, |
| 3944 |
const ReturnCallAdjustmentInfo& retCallInfo); |
| 3945 |
|
| 3946 |
// WasmTableCallIndexReg must contain the index of the indirect call. |
| 3947 |
// This is for asm.js calls only. |
| 3948 |
CodeOffset asmCallIndirect(const wasm::CallSiteDesc& desc, |
| 3949 |
const wasm::CalleeDesc& callee); |
| 3950 |
|
| 3951 |
// This function takes care of loading the pointer to the current instance |
| 3952 |
// as the implicit first argument. It preserves instance and pinned registers. |
| 3953 |
// (instance & pinned regs are non-volatile registers in the system ABI). |
| 3954 |
CodeOffset wasmCallBuiltinInstanceMethod(const wasm::CallSiteDesc& desc, |
| 3955 |
const ABIArg& instanceArg, |
| 3956 |
wasm::SymbolicAddress builtin, |
| 3957 |
wasm::FailureMode failureMode); |
| 3958 |
|
| 3959 |
// Performs the appropriate check based on the instance call's FailureMode, |
| 3960 |
// and traps if the check fails. The resultRegister should likely be |
| 3961 |
// ReturnReg, but this depends on whatever you do with registers immediately |
| 3962 |
// after the call. |
| 3963 |
void wasmTrapOnFailedInstanceCall(Register resultRegister, |
| 3964 |
wasm::FailureMode failureMode, |
| 3965 |
const wasm::TrapSiteDesc& trapSiteDesc); |
| 3966 |
|
| 3967 |
// Performs a bounds check for ranged wasm operations like memory.fill or |
| 3968 |
// array.fill. This handles the bizarre edge case in the wasm spec where a |
| 3969 |
// write to index N is valid as long as the length is zero - despite the index |
| 3970 |
// itself being out of bounds. |
| 3971 |
// |
| 3972 |
// `length` and `limit` will be unchanged. |
| 3973 |
void wasmBoundsCheckRange32(Register index, Register length, Register limit, |
| 3974 |
Register tmp, |
| 3975 |
const wasm::TrapSiteDesc& trapSiteDesc); |
| 3976 |
|
| 3977 |
// Returns information about which registers are necessary for a |
| 3978 |
// branchWasmRefIsSubtype call. |
| 3979 |
static BranchWasmRefIsSubtypeRegisters regsForBranchWasmRefIsSubtype( |
| 3980 |
wasm::RefType type); |
| 3981 |
|
| 3982 |
// Perform a subtype check that `ref` is a subtype of `type`, branching to |
| 3983 |
// `label` depending on `onSuccess`. |
| 3984 |
// |
| 3985 |
// Will select one of the other branchWasmRefIsSubtype* functions depending on |
| 3986 |
// destType. See each function for the register allocation requirements, as |
| 3987 |
// well as which registers will be preserved. |
| 3988 |
void branchWasmRefIsSubtype(Register ref, wasm::MaybeRefType sourceType, |
| 3989 |
wasm::RefType destType, Label* label, |
| 3990 |
bool onSuccess, Register superSTV, |
| 3991 |
Register scratch1, Register scratch2); |
| 3992 |
|
| 3993 |
// Perform a subtype check that `ref` is a subtype of `type`, branching to |
| 3994 |
// `label` depending on `onSuccess`. `type` must be in the `any` hierarchy. |
| 3995 |
// |
| 3996 |
// `superSTV` is required iff the destination type is a concrete |
| 3997 |
// type. `scratch1` is required iff the destination type is eq or lower and |
| 3998 |
// not none. `scratch2` is required iff the destination type is a concrete |
| 3999 |
// type and its `subTypingDepth` is >= wasm::MinSuperTypeVectorLength. See |
| 4000 |
// regsForBranchWasmRefIsSubtype. |
| 4001 |
// |
| 4002 |
// `ref` and `superSTV` are preserved. Scratch registers are |
| 4003 |
// clobbered. |
| 4004 |
void branchWasmRefIsSubtypeAny(Register ref, wasm::RefType sourceType, |
| 4005 |
wasm::RefType destType, Label* label, |
| 4006 |
bool onSuccess, Register superSTV, |
| 4007 |
Register scratch1, Register scratch2); |
| 4008 |
|
| 4009 |
// Perform a subtype check that `ref` is a subtype of `type`, branching to |
| 4010 |
// `label` depending on `onSuccess`. `type` must be in the `func` hierarchy. |
| 4011 |
// |
| 4012 |
// `superSTV` and `scratch1` are required iff the destination type |
| 4013 |
// is a concrete type (not func and not nofunc). `scratch2` is required iff |
| 4014 |
// the destination type is a concrete type and its `subTypingDepth` is >= |
| 4015 |
// wasm::MinSuperTypeVectorLength. See regsForBranchWasmRefIsSubtype. |
| 4016 |
// |
| 4017 |
// `ref` and `superSTV` are preserved. Scratch registers are |
| 4018 |
// clobbered. |
| 4019 |
void branchWasmRefIsSubtypeFunc(Register ref, wasm::RefType sourceType, |
| 4020 |
wasm::RefType destType, Label* label, |
| 4021 |
bool onSuccess, Register superSTV, |
| 4022 |
Register scratch1, Register scratch2); |
| 4023 |
|
| 4024 |
// Perform a subtype check that `ref` is a subtype of `destType`, branching to |
| 4025 |
// `label` depending on `onSuccess`. `type` must be in the `extern` hierarchy. |
| 4026 |
void branchWasmRefIsSubtypeExtern(Register ref, wasm::RefType sourceType, |
| 4027 |
wasm::RefType destType, Label* label, |
| 4028 |
bool onSuccess); |
| 4029 |
|
| 4030 |
// Perform a subtype check that `ref` is a subtype of `destType`, branching to |
| 4031 |
// `label` depending on `onSuccess`. `type` must be in the `exn` hierarchy. |
| 4032 |
void branchWasmRefIsSubtypeExn(Register ref, wasm::RefType sourceType, |
| 4033 |
wasm::RefType destType, Label* label, |
| 4034 |
bool onSuccess); |
| 4035 |
|
| 4036 |
// Perform a subtype check that `subSTV` is a subtype of `superSTV`, branching |
| 4037 |
// to `label` depending on `onSuccess`. This method is a specialization of the |
| 4038 |
// general `wasm::TypeDef::isSubTypeOf` method for the case where the |
| 4039 |
// `superSTV` is statically known, which is the case for all wasm |
| 4040 |
// instructions. |
| 4041 |
// |
| 4042 |
// `scratch` is required iff the destination type is not final and the |
| 4043 |
// `superDepth` is >= wasm::MinSuperTypeVectorLength. `subSTV` is clobbered by |
| 4044 |
// this method if the destination type is not final. `superSTV` is always |
| 4045 |
// preserved. |
| 4046 |
void branchWasmSTVIsSubtype(Register subSTV, Register superSTV, |
| 4047 |
Register scratch, const wasm::TypeDef* destType, |
| 4048 |
Label* label, bool onSuccess); |
| 4049 |
|
| 4050 |
// Same as branchWasmSTVIsSubtype, but looks up a dynamic position in the |
| 4051 |
// super type vector. |
| 4052 |
// |
| 4053 |
// `scratch` is always required. `subSTV` and `superDepth` are clobbered. |
| 4054 |
// `superSTV` is preserved. |
| 4055 |
void branchWasmSTVIsSubtypeDynamicDepth(Register subSTV, Register superSTV, |
| 4056 |
Register superDepth, Register scratch, |
| 4057 |
Label* label, bool onSuccess); |
| 4058 |
|
| 4059 |
// Extract the tag of wasm anyref `src`. |
| 4060 |
void extractWasmAnyRefTag(Register src, Register dest); |
| 4061 |
|
| 4062 |
// Remove the known tag of wasm anyref `src`. |
| 4063 |
void untagWasmAnyRef(Register src, Register dest, wasm::AnyRefTag tag); |
| 4064 |
|
| 4065 |
// Branch if the wasm anyref `src` is or is not the null value. |
| 4066 |
void branchWasmAnyRefIsNull(bool isNull, Register src, Label* label); |
| 4067 |
// Branch if the wasm anyref `src` is or is not an I31. |
| 4068 |
void branchWasmAnyRefIsI31(bool isI31, Register src, Label* label); |
| 4069 |
// Branch if the wasm anyref `src` is or is not a JSObject*. |
| 4070 |
void branchWasmAnyRefIsObjectOrNull(bool isObject, Register src, |
| 4071 |
Label* label); |
| 4072 |
// Branch if the wasm anyref `src` is or is not a JSString. |
| 4073 |
void branchWasmAnyRefIsJSString(bool isJSString, Register src, Register temp, |
| 4074 |
Label* label); |
| 4075 |
// Branch if the wasm anyref `src` is or is not a GC thing. |
| 4076 |
void branchWasmAnyRefIsGCThing(bool isGCThing, Register src, Label* label); |
| 4077 |
// Branch if the wasm anyref `src` is or is not pointing to a nursery cell. |
| 4078 |
void branchWasmAnyRefIsNurseryCell(bool isNurseryCell, Register src, |
| 4079 |
Register scratch, Label* label); |
| 4080 |
|
| 4081 |
// Create a wasm i31ref by truncating the 32-bit integer. |
| 4082 |
void truncate32ToWasmI31Ref(Register src, Register dest); |
| 4083 |
// Convert a wasm i31ref to a signed 32-bit integer. |
| 4084 |
void convertWasmI31RefTo32Signed(Register src, Register dest); |
| 4085 |
// Convert a wasm i31ref to an unsigned 32-bit integer. |
| 4086 |
void convertWasmI31RefTo32Unsigned(Register src, Register dest); |
| 4087 |
|
| 4088 |
// Branch if the JS value `src` would need to be boxed out of line to be |
| 4089 |
// converted to a wasm anyref. |
| 4090 |
void branchValueConvertsToWasmAnyRefInline(ValueOperand src, |
| 4091 |
Register scratchInt, |
| 4092 |
FloatRegister scratchFloat, |
| 4093 |
Label* label); |
| 4094 |
// Convert a JS value to a wasm anyref. If the value requires boxing, this |
| 4095 |
// will branch to `oolConvert`. |
| 4096 |
void convertValueToWasmAnyRef(ValueOperand src, Register dest, |
| 4097 |
FloatRegister scratchFloat, Label* oolConvert); |
| 4098 |
// Convert a JS object to a wasm anyref. This cannot fail. |
| 4099 |
void convertObjectToWasmAnyRef(Register src, Register dest); |
| 4100 |
// Convert a JS string to a wasm anyref. This cannot fail. |
| 4101 |
void convertStringToWasmAnyRef(Register src, Register dest); |
| 4102 |
|
| 4103 |
// Convert a wasm anyref to a JS value. This cannot fail. |
| 4104 |
// |
| 4105 |
// Due to spectre mitigations, these methods may clobber src. |
| 4106 |
void convertWasmAnyRefToValue(Register instance, Register src, |
| 4107 |
ValueOperand dst, Register scratch); |
| 4108 |
void convertWasmAnyRefToValue(Register instance, Register src, |
| 4109 |
const Address& dst, Register scratch); |
| 4110 |
|
| 4111 |
// Branch if the object `src` is or is not a WasmGcObject. |
| 4112 |
void branchObjectIsWasmGcObject(bool isGcObject, Register src, |
| 4113 |
Register scratch, Label* label); |
| 4114 |
|
| 4115 |
// `typeDefData` will be preserved. `instance` and `result` may be the same |
| 4116 |
// register, in which case `instance` will be clobbered. |
| 4117 |
void wasmNewStructObject(Register instance, Register result, |
| 4118 |
Register allocSite, Register temp1, |
| 4119 |
size_t offsetOfTypeDefData, Label* fail, |
| 4120 |
gc::AllocKind allocKind, bool zeroFields); |
| 4121 |
// Allocates a wasm array with a dynamic number of elements. |
| 4122 |
// |
| 4123 |
// `numElements` and `typeDefData` will be preserved. `instance` and `result` |
| 4124 |
// may be the same register, in which case `instance` will be clobbered. |
| 4125 |
void wasmNewArrayObject(Register instance, Register result, |
| 4126 |
Register numElements, Register allocSite, |
| 4127 |
Register temp, size_t offsetOfTypeDefData, |
| 4128 |
Label* fail, uint32_t elemSize, bool zeroFields); |
| 4129 |
// Allocates a wasm array with a fixed number of elements. |
| 4130 |
// |
| 4131 |
// `typeDefData` will be preserved. `instance` and `result` may be the same |
| 4132 |
// register, in which case `instance` will be clobbered. |
| 4133 |
void wasmNewArrayObjectFixed(Register instance, Register result, |
| 4134 |
Register allocSite, Register temp1, |
| 4135 |
Register temp2, size_t offsetOfTypeDefData, |
| 4136 |
Label* fail, uint32_t numElements, |
| 4137 |
uint32_t storageBytes, bool zeroFields); |
| 4138 |
|
| 4139 |
// This function handles nursery allocations for wasm. For JS, see |
| 4140 |
// MacroAssembler::bumpPointerAllocate. |
| 4141 |
// |
| 4142 |
// `typeDefData` will be preserved. `instance` and `result` may be the same |
| 4143 |
// register, in which case `instance` will be clobbered. |
| 4144 |
// |
| 4145 |
// See also the dynamically-sized version, |
| 4146 |
// MacroAssembler::wasmBumpPointerAllocateDynamic. |
| 4147 |
void wasmBumpPointerAllocate(Register instance, Register result, |
| 4148 |
Register allocSite, Register temp1, Label* fail, |
| 4149 |
uint32_t size); |
| 4150 |
// This function handles nursery allocations for wasm of dynamic size. For |
| 4151 |
// fixed-size allocations, see MacroAssembler::wasmBumpPointerAllocate. |
| 4152 |
// |
| 4153 |
// `typeDefData` and `size` will be preserved. `instance` and `result` may be |
| 4154 |
// the same register, in which case `instance` will be clobbered. |
| 4155 |
void wasmBumpPointerAllocateDynamic(Register instance, Register result, |
| 4156 |
Register allocSite, Register size, |
| 4157 |
Register temp1, Label* fail); |
| 4158 |
|
| 4159 |
// Compute ptr += (indexTemp32 << shift) where shift can be any value < 32. |
| 4160 |
// May destroy indexTemp32. The value of indexTemp32 must be positive, and it |
| 4161 |
// is implementation-defined what happens if bits are lost or the value |
| 4162 |
// becomes negative through the shift. On 64-bit systems, the high 32 bits of |
| 4163 |
// indexTemp32 must be zero, not garbage. |
| 4164 |
void shiftIndex32AndAdd(Register indexTemp32, int shift, |
| 4165 |
Register pointer) PER_SHARED_ARCH; |
| 4166 |
|
| 4167 |
// The System ABI frequently states that the high bits of a 64-bit register |
| 4168 |
// that holds a 32-bit return value are unpredictable, and C++ compilers will |
| 4169 |
// indeed generate code that leaves garbage in the upper bits. |
| 4170 |
// |
| 4171 |
// Adjust the contents of the 64-bit register `r` to conform to our internal |
| 4172 |
// convention, which requires predictable high bits. In practice, this means |
| 4173 |
// that the 32-bit value will be zero-extended or sign-extended to 64 bits as |
| 4174 |
// appropriate for the platform. |
| 4175 |
void widenInt32(Register r) DEFINED_ON(arm64, x64, mips64, loong64, riscv64); |
| 4176 |
|
| 4177 |
// As enterFakeExitFrame(), but using register conventions appropriate for |
| 4178 |
// wasm stubs. |
| 4179 |
void enterFakeExitFrameForWasm(Register cxreg, Register scratch, |
| 4180 |
ExitFrameType type) PER_SHARED_ARCH; |
| 4181 |
|
| 4182 |
public: |
| 4183 |
// ======================================================================== |
| 4184 |
// Barrier functions. |
| 4185 |
|
| 4186 |
void emitPreBarrierFastPath(JSRuntime* rt, MIRType type, Register temp1, |
| 4187 |
Register temp2, Register temp3, Label* noBarrier); |
| 4188 |
|
| 4189 |
public: |
| 4190 |
// ======================================================================== |
| 4191 |
// Clamping functions. |
| 4192 |
|
| 4193 |
inline void clampIntToUint8(Register reg) PER_SHARED_ARCH; |
| 4194 |
|
| 4195 |
public: |
| 4196 |
// ======================================================================== |
| 4197 |
// Primitive atomic operations. |
| 4198 |
// |
| 4199 |
// If the access is from JS and the eventual destination of the result is a |
| 4200 |
// js::Value, it's probably best to use the JS-specific versions of these, |
| 4201 |
// see further below. |
| 4202 |
// |
| 4203 |
// Temp registers must be defined unless otherwise noted in the per-function |
| 4204 |
// constraints. |
| 4205 |
|
| 4206 |
// 8-bit, 16-bit, and 32-bit wide operations. |
| 4207 |
// |
| 4208 |
// The 8-bit and 16-bit operations zero-extend or sign-extend the result to |
| 4209 |
// 32 bits, according to `type`. On 64-bit systems, the upper 32 bits of the |
| 4210 |
// result will be zero on some platforms (eg, on x64) and will be the sign |
| 4211 |
// extension of the lower bits on other platforms (eg, MIPS). |
| 4212 |
|
| 4213 |
// CompareExchange with memory. Return the value that was in memory, |
| 4214 |
// whether we wrote or not. |
| 4215 |
// |
| 4216 |
// x86-shared: `output` must be eax. |
| 4217 |
// MIPS: `valueTemp`, `offsetTemp` and `maskTemp` must be defined for 8-bit |
| 4218 |
// and 16-bit wide operations. |
| 4219 |
|
| 4220 |
void compareExchange(Scalar::Type type, Synchronization sync, |
| 4221 |
const Address& mem, Register expected, |
| 4222 |
Register replacement, Register output) |
| 4223 |
DEFINED_ON(arm, arm64, x86_shared); |
| 4224 |
|
| 4225 |
void compareExchange(Scalar::Type type, Synchronization sync, |
| 4226 |
const BaseIndex& mem, Register expected, |
| 4227 |
Register replacement, Register output) |
| 4228 |
DEFINED_ON(arm, arm64, x86_shared); |
| 4229 |
|
| 4230 |
void compareExchange(Scalar::Type type, Synchronization sync, |
| 4231 |
const Address& mem, Register expected, |
| 4232 |
Register replacement, Register valueTemp, |
| 4233 |
Register offsetTemp, Register maskTemp, Register output) |
| 4234 |
DEFINED_ON(mips64, loong64, riscv64); |
| 4235 |
|
| 4236 |
void compareExchange(Scalar::Type type, Synchronization sync, |
| 4237 |
const BaseIndex& mem, Register expected, |
| 4238 |
Register replacement, Register valueTemp, |
| 4239 |
Register offsetTemp, Register maskTemp, Register output) |
| 4240 |
DEFINED_ON(mips64, loong64, riscv64); |
| 4241 |
|
| 4242 |
// x86: `expected` and `output` must be edx:eax; `replacement` is ecx:ebx. |
| 4243 |
// x64: `output` must be rax. |
| 4244 |
// ARM: Registers must be distinct; `replacement` and `output` must be |
| 4245 |
// (even,odd) pairs. |
| 4246 |
|
| 4247 |
void compareExchange64(Synchronization sync, const Address& mem, |
| 4248 |
Register64 expected, Register64 replacement, |
| 4249 |
Register64 output) |
| 4250 |
DEFINED_ON(arm, arm64, x64, x86, mips64, loong64, riscv64); |
| 4251 |
|
| 4252 |
void compareExchange64(Synchronization sync, const BaseIndex& mem, |
| 4253 |
Register64 expected, Register64 replacement, |
| 4254 |
Register64 output) |
| 4255 |
DEFINED_ON(arm, arm64, x64, x86, mips64, loong64, riscv64); |
| 4256 |
|
| 4257 |
// Exchange with memory. Return the value initially in memory. |
| 4258 |
// MIPS: `valueTemp`, `offsetTemp` and `maskTemp` must be defined for 8-bit |
| 4259 |
// and 16-bit wide operations. |
| 4260 |
|
| 4261 |
void atomicExchange(Scalar::Type type, Synchronization sync, |
| 4262 |
const Address& mem, Register value, Register output) |
| 4263 |
DEFINED_ON(arm, arm64, x86_shared); |
| 4264 |
|
| 4265 |
void atomicExchange(Scalar::Type type, Synchronization sync, |
| 4266 |
const BaseIndex& mem, Register value, Register output) |
| 4267 |
DEFINED_ON(arm, arm64, x86_shared); |
| 4268 |
|
| 4269 |
void atomicExchange(Scalar::Type type, Synchronization sync, |
| 4270 |
const Address& mem, Register value, Register valueTemp, |
| 4271 |
Register offsetTemp, Register maskTemp, Register output) |
| 4272 |
DEFINED_ON(mips64, loong64, riscv64); |
| 4273 |
|
| 4274 |
void atomicExchange(Scalar::Type type, Synchronization sync, |
| 4275 |
const BaseIndex& mem, Register value, Register valueTemp, |
| 4276 |
Register offsetTemp, Register maskTemp, Register output) |
| 4277 |
DEFINED_ON(mips64, loong64, riscv64); |
| 4278 |
|
| 4279 |
// x86: `value` must be ecx:ebx; `output` must be edx:eax. |
| 4280 |
// ARM: `value` and `output` must be distinct and (even,odd) pairs. |
| 4281 |
// ARM64: `value` and `output` must be distinct. |
| 4282 |
|
| 4283 |
void atomicExchange64(Synchronization sync, const Address& mem, |
| 4284 |
Register64 value, Register64 output) |
| 4285 |
DEFINED_ON(arm, arm64, x64, x86, mips64, loong64, riscv64); |
| 4286 |
|
| 4287 |
void atomicExchange64(Synchronization sync, const BaseIndex& mem, |
| 4288 |
Register64 value, Register64 output) |
| 4289 |
DEFINED_ON(arm, arm64, x64, x86, mips64, loong64, riscv64); |
| 4290 |
|
| 4291 |
// Read-modify-write with memory. Return the value in memory before the |
| 4292 |
// operation. |
| 4293 |
// |
| 4294 |
// x86-shared: |
| 4295 |
// For 8-bit operations, `value` and `output` must have a byte subregister. |
| 4296 |
// For Add and Sub, `temp` must be invalid. |
| 4297 |
// For And, Or, and Xor, `output` must be eax and `temp` must have a byte |
| 4298 |
// subregister. |
| 4299 |
// |
| 4300 |
// ARM: Registers `value` and `output` must differ. |
| 4301 |
// MIPS: `valueTemp`, `offsetTemp` and `maskTemp` must be defined for 8-bit |
| 4302 |
// and 16-bit wide operations; `value` and `output` must differ. |
| 4303 |
|
| 4304 |
void atomicFetchOp(Scalar::Type type, Synchronization sync, AtomicOp op, |
| 4305 |
Register value, const Address& mem, Register temp, |
| 4306 |
Register output) DEFINED_ON(arm, arm64, x86_shared); |
| 4307 |
|
| 4308 |
void atomicFetchOp(Scalar::Type type, Synchronization sync, AtomicOp op, |
| 4309 |
Imm32 value, const Address& mem, Register temp, |
| 4310 |
Register output) DEFINED_ON(x86_shared); |
| 4311 |
|
| 4312 |
void atomicFetchOp(Scalar::Type type, Synchronization sync, AtomicOp op, |
| 4313 |
Register value, const BaseIndex& mem, Register temp, |
| 4314 |
Register output) DEFINED_ON(arm, arm64, x86_shared); |
| 4315 |
|
| 4316 |
void atomicFetchOp(Scalar::Type type, Synchronization sync, AtomicOp op, |
| 4317 |
Imm32 value, const BaseIndex& mem, Register temp, |
| 4318 |
Register output) DEFINED_ON(x86_shared); |
| 4319 |
|
| 4320 |
void atomicFetchOp(Scalar::Type type, Synchronization sync, AtomicOp op, |
| 4321 |
Register value, const Address& mem, Register valueTemp, |
| 4322 |
Register offsetTemp, Register maskTemp, Register output) |
| 4323 |
DEFINED_ON(mips64, loong64, riscv64); |
| 4324 |
|
| 4325 |
void atomicFetchOp(Scalar::Type type, Synchronization sync, AtomicOp op, |
| 4326 |
Register value, const BaseIndex& mem, Register valueTemp, |
| 4327 |
Register offsetTemp, Register maskTemp, Register output) |
| 4328 |
DEFINED_ON(mips64, loong64, riscv64); |
| 4329 |
|
| 4330 |
// x86: |
| 4331 |
// `temp` must be ecx:ebx; `output` must be edx:eax. |
| 4332 |
// x64: |
| 4333 |
// For Add and Sub, `temp` is ignored. |
| 4334 |
// For And, Or, and Xor, `output` must be rax. |
| 4335 |
// ARM: |
| 4336 |
// `temp` and `output` must be (even,odd) pairs and distinct from `value`. |
| 4337 |
// ARM64: |
| 4338 |
// Registers `value`, `temp`, and `output` must all differ. |
| 4339 |
|
| 4340 |
void atomicFetchOp64(Synchronization sync, AtomicOp op, Register64 value, |
| 4341 |
const Address& mem, Register64 temp, Register64 output) |
| 4342 |
DEFINED_ON(arm, arm64, x64, mips64, loong64, riscv64); |
| 4343 |
|
| 4344 |
void atomicFetchOp64(Synchronization sync, AtomicOp op, const Address& value, |
| 4345 |
const Address& mem, Register64 temp, Register64 output) |
| 4346 |
DEFINED_ON(x86); |
| 4347 |
|
| 4348 |
void atomicFetchOp64(Synchronization sync, AtomicOp op, Register64 value, |
| 4349 |
const BaseIndex& mem, Register64 temp, Register64 output) |
| 4350 |
DEFINED_ON(arm, arm64, x64, mips64, loong64, riscv64); |
| 4351 |
|
| 4352 |
void atomicFetchOp64(Synchronization sync, AtomicOp op, const Address& value, |
| 4353 |
const BaseIndex& mem, Register64 temp, Register64 output) |
| 4354 |
DEFINED_ON(x86); |
| 4355 |
|
| 4356 |
// x64: |
| 4357 |
// `value` can be any register. |
| 4358 |
// ARM: |
| 4359 |
// `temp` must be an (even,odd) pair and distinct from `value`. |
| 4360 |
// ARM64: |
| 4361 |
// Registers `value` and `temp` must differ. |
| 4362 |
|
| 4363 |
void atomicEffectOp64(Synchronization sync, AtomicOp op, Register64 value, |
| 4364 |
const Address& mem) DEFINED_ON(x64); |
| 4365 |
|
| 4366 |
void atomicEffectOp64(Synchronization sync, AtomicOp op, Register64 value, |
| 4367 |
const Address& mem, Register64 temp) |
| 4368 |
DEFINED_ON(arm, arm64, mips64, loong64, riscv64); |
| 4369 |
|
| 4370 |
void atomicEffectOp64(Synchronization sync, AtomicOp op, Register64 value, |
| 4371 |
const BaseIndex& mem) DEFINED_ON(x64); |
| 4372 |
|
| 4373 |
void atomicEffectOp64(Synchronization sync, AtomicOp op, Register64 value, |
| 4374 |
const BaseIndex& mem, Register64 temp) |
| 4375 |
DEFINED_ON(arm, arm64, mips64, loong64, riscv64); |
| 4376 |
|
| 4377 |
// 64-bit atomic load. On 64-bit systems, use regular load with |
| 4378 |
// Synchronization::Load, not this method. |
| 4379 |
// |
| 4380 |
// x86: `temp` must be ecx:ebx; `output` must be edx:eax. |
| 4381 |
// ARM: `output` must be (even,odd) pair. |
| 4382 |
|
| 4383 |
void atomicLoad64(Synchronization sync, const Address& mem, Register64 temp, |
| 4384 |
Register64 output) DEFINED_ON(x86); |
| 4385 |
|
| 4386 |
void atomicLoad64(Synchronization sync, const BaseIndex& mem, Register64 temp, |
| 4387 |
Register64 output) DEFINED_ON(x86); |
| 4388 |
|
| 4389 |
void atomicLoad64(Synchronization sync, const Address& mem, Register64 output) |
| 4390 |
DEFINED_ON(arm); |
| 4391 |
|
| 4392 |
void atomicLoad64(Synchronization sync, const BaseIndex& mem, |
| 4393 |
Register64 output) DEFINED_ON(arm); |
| 4394 |
|
| 4395 |
// 64-bit atomic store. On 64-bit systems, use regular store with |
| 4396 |
// Synchronization::Store, not this method. |
| 4397 |
// |
| 4398 |
// x86: `value` must be ecx:ebx; `temp` must be edx:eax. |
| 4399 |
// ARM: `value` and `temp` must be (even,odd) pairs. |
| 4400 |
|
| 4401 |
void atomicStore64(Synchronization sync, const Address& mem, Register64 value, |
| 4402 |
Register64 temp) DEFINED_ON(x86, arm); |
| 4403 |
|
| 4404 |
void atomicStore64(Synchronization sync, const BaseIndex& mem, |
| 4405 |
Register64 value, Register64 temp) DEFINED_ON(x86, arm); |
| 4406 |
|
| 4407 |
// ======================================================================== |
| 4408 |
// Wasm atomic operations. |
| 4409 |
// |
| 4410 |
// Constraints, when omitted, are exactly as for the primitive operations |
| 4411 |
// above. |
| 4412 |
|
| 4413 |
void wasmCompareExchange(const wasm::MemoryAccessDesc& access, |
| 4414 |
const Address& mem, Register expected, |
| 4415 |
Register replacement, Register output) |
| 4416 |
DEFINED_ON(arm, arm64, x86_shared); |
| 4417 |
|
| 4418 |
void wasmCompareExchange(const wasm::MemoryAccessDesc& access, |
| 4419 |
const BaseIndex& mem, Register expected, |
| 4420 |
Register replacement, Register output) |
| 4421 |
DEFINED_ON(arm, arm64, x86_shared); |
| 4422 |
|
| 4423 |
void wasmCompareExchange(const wasm::MemoryAccessDesc& access, |
| 4424 |
const Address& mem, Register expected, |
| 4425 |
Register replacement, Register valueTemp, |
| 4426 |
Register offsetTemp, Register maskTemp, |
| 4427 |
Register output) |
| 4428 |
DEFINED_ON(mips64, loong64, riscv64); |
| 4429 |
|
| 4430 |
void wasmCompareExchange(const wasm::MemoryAccessDesc& access, |
| 4431 |
const BaseIndex& mem, Register expected, |
| 4432 |
Register replacement, Register valueTemp, |
| 4433 |
Register offsetTemp, Register maskTemp, |
| 4434 |
Register output) |
| 4435 |
DEFINED_ON(mips64, loong64, riscv64); |
| 4436 |
|
| 4437 |
void wasmAtomicExchange(const wasm::MemoryAccessDesc& access, |
| 4438 |
const Address& mem, Register value, Register output) |
| 4439 |
DEFINED_ON(arm, arm64, x86_shared); |
| 4440 |
|
| 4441 |
void wasmAtomicExchange(const wasm::MemoryAccessDesc& access, |
| 4442 |
const BaseIndex& mem, Register value, Register output) |
| 4443 |
DEFINED_ON(arm, arm64, x86_shared); |
| 4444 |
|
| 4445 |
void wasmAtomicExchange(const wasm::MemoryAccessDesc& access, |
| 4446 |
const Address& mem, Register value, |
| 4447 |
Register valueTemp, Register offsetTemp, |
| 4448 |
Register maskTemp, Register output) |
| 4449 |
DEFINED_ON(mips64, loong64, riscv64); |
| 4450 |
|
| 4451 |
void wasmAtomicExchange(const wasm::MemoryAccessDesc& access, |
| 4452 |
const BaseIndex& mem, Register value, |
| 4453 |
Register valueTemp, Register offsetTemp, |
| 4454 |
Register maskTemp, Register output) |
| 4455 |
DEFINED_ON(mips64, loong64, riscv64); |
| 4456 |
|
| 4457 |
void wasmAtomicFetchOp(const wasm::MemoryAccessDesc& access, AtomicOp op, |
| 4458 |
Register value, const Address& mem, Register temp, |
| 4459 |
Register output) DEFINED_ON(arm, arm64, x86_shared); |
| 4460 |
|
| 4461 |
void wasmAtomicFetchOp(const wasm::MemoryAccessDesc& access, AtomicOp op, |
| 4462 |
Imm32 value, const Address& mem, Register temp, |
| 4463 |
Register output) DEFINED_ON(x86_shared); |
| 4464 |
|
| 4465 |
void wasmAtomicFetchOp(const wasm::MemoryAccessDesc& access, AtomicOp op, |
| 4466 |
Register value, const BaseIndex& mem, Register temp, |
| 4467 |
Register output) DEFINED_ON(arm, arm64, x86_shared); |
| 4468 |
|
| 4469 |
void wasmAtomicFetchOp(const wasm::MemoryAccessDesc& access, AtomicOp op, |
| 4470 |
Imm32 value, const BaseIndex& mem, Register temp, |
| 4471 |
Register output) DEFINED_ON(x86_shared); |
| 4472 |
|
| 4473 |
void wasmAtomicFetchOp(const wasm::MemoryAccessDesc& access, AtomicOp op, |
| 4474 |
Register value, const Address& mem, Register valueTemp, |
| 4475 |
Register offsetTemp, Register maskTemp, |
| 4476 |
Register output) DEFINED_ON(mips64, loong64, riscv64); |
| 4477 |
|
| 4478 |
void wasmAtomicFetchOp(const wasm::MemoryAccessDesc& access, AtomicOp op, |
| 4479 |
Register value, const BaseIndex& mem, |
| 4480 |
Register valueTemp, Register offsetTemp, |
| 4481 |
Register maskTemp, Register output) |
| 4482 |
DEFINED_ON(mips64, loong64, riscv64); |
| 4483 |
|
| 4484 |
// Read-modify-write with memory. Return no value. |
| 4485 |
// |
| 4486 |
// MIPS: `valueTemp`, `offsetTemp` and `maskTemp` must be defined for 8-bit |
| 4487 |
// and 16-bit wide operations. |
| 4488 |
|
| 4489 |
void wasmAtomicEffectOp(const wasm::MemoryAccessDesc& access, AtomicOp op, |
| 4490 |
Register value, const Address& mem, Register temp) |
| 4491 |
DEFINED_ON(arm, arm64, x86_shared); |
| 4492 |
|
| 4493 |
void wasmAtomicEffectOp(const wasm::MemoryAccessDesc& access, AtomicOp op, |
| 4494 |
Imm32 value, const Address& mem, Register temp) |
| 4495 |
DEFINED_ON(x86_shared); |
| 4496 |
|
| 4497 |
void wasmAtomicEffectOp(const wasm::MemoryAccessDesc& access, AtomicOp op, |
| 4498 |
Register value, const BaseIndex& mem, Register temp) |
| 4499 |
DEFINED_ON(arm, arm64, x86_shared); |
| 4500 |
|
| 4501 |
void wasmAtomicEffectOp(const wasm::MemoryAccessDesc& access, AtomicOp op, |
| 4502 |
Imm32 value, const BaseIndex& mem, Register temp) |
| 4503 |
DEFINED_ON(x86_shared); |
| 4504 |
|
| 4505 |
void wasmAtomicEffectOp(const wasm::MemoryAccessDesc& access, AtomicOp op, |
| 4506 |
Register value, const Address& mem, |
| 4507 |
Register valueTemp, Register offsetTemp, |
| 4508 |
Register maskTemp) |
| 4509 |
DEFINED_ON(mips64, loong64, riscv64); |
| 4510 |
|
| 4511 |
void wasmAtomicEffectOp(const wasm::MemoryAccessDesc& access, AtomicOp op, |
| 4512 |
Register value, const BaseIndex& mem, |
| 4513 |
Register valueTemp, Register offsetTemp, |
| 4514 |
Register maskTemp) |
| 4515 |
DEFINED_ON(mips64, loong64, riscv64); |
| 4516 |
|
| 4517 |
// 64-bit wide operations. |
| 4518 |
|
| 4519 |
// 64-bit atomic load. On 64-bit systems, use regular wasm load with |
| 4520 |
// Synchronization::Load, not this method. |
| 4521 |
// |
| 4522 |
// x86: `temp` must be ecx:ebx; `output` must be edx:eax. |
| 4523 |
// ARM: `temp` should be invalid; `output` must be (even,odd) pair. |
| 4524 |
|
| 4525 |
void wasmAtomicLoad64(const wasm::MemoryAccessDesc& access, |
| 4526 |
const Address& mem, Register64 temp, Register64 output) |
| 4527 |
DEFINED_ON(arm, x86, wasm32); |
| 4528 |
|
| 4529 |
void wasmAtomicLoad64(const wasm::MemoryAccessDesc& access, |
| 4530 |
const BaseIndex& mem, Register64 temp, |
| 4531 |
Register64 output) DEFINED_ON(arm, x86, wasm32); |
| 4532 |
|
| 4533 |
// x86: `expected` must be the same as `output`, and must be edx:eax. |
| 4534 |
// x86: `replacement` must be ecx:ebx. |
| 4535 |
// x64: `output` must be rax. |
| 4536 |
// ARM: Registers must be distinct; `replacement` and `output` must be |
| 4537 |
// (even,odd) pairs. |
| 4538 |
// ARM64: The base register in `mem` must not overlap `output`. |
| 4539 |
// MIPS: Registers must be distinct. |
| 4540 |
|
| 4541 |
void wasmCompareExchange64(const wasm::MemoryAccessDesc& access, |
| 4542 |
const Address& mem, Register64 expected, |
| 4543 |
Register64 replacement, |
| 4544 |
Register64 output) PER_ARCH; |
| 4545 |
|
| 4546 |
void wasmCompareExchange64(const wasm::MemoryAccessDesc& access, |
| 4547 |
const BaseIndex& mem, Register64 expected, |
| 4548 |
Register64 replacement, |
| 4549 |
Register64 output) PER_ARCH; |
| 4550 |
|
| 4551 |
// x86: `value` must be ecx:ebx; `output` must be edx:eax. |
| 4552 |
// ARM: Registers must be distinct; `value` and `output` must be (even,odd) |
| 4553 |
// pairs. |
| 4554 |
// MIPS: Registers must be distinct. |
| 4555 |
|
| 4556 |
void wasmAtomicExchange64(const wasm::MemoryAccessDesc& access, |
| 4557 |
const Address& mem, Register64 value, |
| 4558 |
Register64 output) PER_ARCH; |
| 4559 |
|
| 4560 |
void wasmAtomicExchange64(const wasm::MemoryAccessDesc& access, |
| 4561 |
const BaseIndex& mem, Register64 value, |
| 4562 |
Register64 output) PER_ARCH; |
| 4563 |
|
| 4564 |
// x86: `output` must be edx:eax, `temp` must be ecx:ebx. |
| 4565 |
// x64: For And, Or, and Xor `output` must be rax. |
| 4566 |
// ARM: Registers must be distinct; `temp` and `output` must be (even,odd) |
| 4567 |
// pairs. |
| 4568 |
// MIPS: Registers must be distinct. |
| 4569 |
|
| 4570 |
void wasmAtomicFetchOp64(const wasm::MemoryAccessDesc& access, AtomicOp op, |
| 4571 |
Register64 value, const Address& mem, |
| 4572 |
Register64 temp, Register64 output) |
| 4573 |
DEFINED_ON(arm, arm64, mips64, loong64, riscv64, x64); |
| 4574 |
|
| 4575 |
void wasmAtomicFetchOp64(const wasm::MemoryAccessDesc& access, AtomicOp op, |
| 4576 |
Register64 value, const BaseIndex& mem, |
| 4577 |
Register64 temp, Register64 output) |
| 4578 |
DEFINED_ON(arm, arm64, mips64, loong64, riscv64, x64); |
| 4579 |
|
| 4580 |
void wasmAtomicFetchOp64(const wasm::MemoryAccessDesc& access, AtomicOp op, |
| 4581 |
const Address& value, const Address& mem, |
| 4582 |
Register64 temp, Register64 output) DEFINED_ON(x86); |
| 4583 |
|
| 4584 |
void wasmAtomicFetchOp64(const wasm::MemoryAccessDesc& access, AtomicOp op, |
| 4585 |
const Address& value, const BaseIndex& mem, |
| 4586 |
Register64 temp, Register64 output) DEFINED_ON(x86); |
| 4587 |
|
| 4588 |
// Here `value` can be any register. |
| 4589 |
|
| 4590 |
void wasmAtomicEffectOp64(const wasm::MemoryAccessDesc& access, AtomicOp op, |
| 4591 |
Register64 value, const BaseIndex& mem) |
| 4592 |
DEFINED_ON(x64); |
| 4593 |
|
| 4594 |
void wasmAtomicEffectOp64(const wasm::MemoryAccessDesc& access, AtomicOp op, |
| 4595 |
Register64 value, const BaseIndex& mem, |
| 4596 |
Register64 temp) DEFINED_ON(arm64); |
| 4597 |
|
| 4598 |
// ======================================================================== |
| 4599 |
// JS atomic operations. |
| 4600 |
// |
| 4601 |
// Here the arrayType must be a type that is valid for JS. As of 2017 that |
| 4602 |
// is an 8-bit, 16-bit, or 32-bit integer type. |
| 4603 |
// |
| 4604 |
// If arrayType is Scalar::Uint32 then: |
| 4605 |
// |
| 4606 |
// - `output` must be a float register |
| 4607 |
// - if the operation takes one temp register then `temp` must be defined |
| 4608 |
// - if the operation takes two temp registers then `temp2` must be defined. |
| 4609 |
// |
| 4610 |
// Otherwise `output` must be a GPR and `temp`/`temp2` should be InvalidReg. |
| 4611 |
// (`temp1` must always be valid.) |
| 4612 |
// |
| 4613 |
// For additional register constraints, see the primitive 32-bit operations |
| 4614 |
// and/or wasm operations above. |
| 4615 |
|
| 4616 |
void compareExchangeJS(Scalar::Type arrayType, Synchronization sync, |
| 4617 |
const Address& mem, Register expected, |
| 4618 |
Register replacement, Register temp, |
| 4619 |
AnyRegister output) DEFINED_ON(arm, arm64, x86_shared); |
| 4620 |
|
| 4621 |
void compareExchangeJS(Scalar::Type arrayType, Synchronization sync, |
| 4622 |
const BaseIndex& mem, Register expected, |
| 4623 |
Register replacement, Register temp, |
| 4624 |
AnyRegister output) DEFINED_ON(arm, arm64, x86_shared); |
| 4625 |
|
| 4626 |
void compareExchangeJS(Scalar::Type arrayType, Synchronization sync, |
| 4627 |
const Address& mem, Register expected, |
| 4628 |
Register replacement, Register valueTemp, |
| 4629 |
Register offsetTemp, Register maskTemp, Register temp, |
| 4630 |
AnyRegister output) |
| 4631 |
DEFINED_ON(mips64, loong64, riscv64); |
| 4632 |
|
| 4633 |
void compareExchangeJS(Scalar::Type arrayType, Synchronization sync, |
| 4634 |
const BaseIndex& mem, Register expected, |
| 4635 |
Register replacement, Register valueTemp, |
| 4636 |
Register offsetTemp, Register maskTemp, Register temp, |
| 4637 |
AnyRegister output) |
| 4638 |
DEFINED_ON(mips64, loong64, riscv64); |
| 4639 |
|
| 4640 |
void atomicExchangeJS(Scalar::Type arrayType, Synchronization sync, |
| 4641 |
const Address& mem, Register value, Register temp, |
| 4642 |
AnyRegister output) DEFINED_ON(arm, arm64, x86_shared); |
| 4643 |
|
| 4644 |
void atomicExchangeJS(Scalar::Type arrayType, Synchronization sync, |
| 4645 |
const BaseIndex& mem, Register value, Register temp, |
| 4646 |
AnyRegister output) DEFINED_ON(arm, arm64, x86_shared); |
| 4647 |
|
| 4648 |
void atomicExchangeJS(Scalar::Type arrayType, Synchronization sync, |
| 4649 |
const Address& mem, Register value, Register valueTemp, |
| 4650 |
Register offsetTemp, Register maskTemp, Register temp, |
| 4651 |
AnyRegister output) |
| 4652 |
DEFINED_ON(mips64, loong64, riscv64); |
| 4653 |
|
| 4654 |
void atomicExchangeJS(Scalar::Type arrayType, Synchronization sync, |
| 4655 |
const BaseIndex& mem, Register value, |
| 4656 |
Register valueTemp, Register offsetTemp, |
| 4657 |
Register maskTemp, Register temp, AnyRegister output) |
| 4658 |
DEFINED_ON(mips64, loong64, riscv64); |
| 4659 |
|
| 4660 |
void atomicFetchOpJS(Scalar::Type arrayType, Synchronization sync, |
| 4661 |
AtomicOp op, Register value, const Address& mem, |
| 4662 |
Register temp1, Register temp2, AnyRegister output) |
| 4663 |
DEFINED_ON(arm, arm64, x86_shared); |
| 4664 |
|
| 4665 |
void atomicFetchOpJS(Scalar::Type arrayType, Synchronization sync, |
| 4666 |
AtomicOp op, Register value, const BaseIndex& mem, |
| 4667 |
Register temp1, Register temp2, AnyRegister output) |
| 4668 |
DEFINED_ON(arm, arm64, x86_shared); |
| 4669 |
|
| 4670 |
void atomicFetchOpJS(Scalar::Type arrayType, Synchronization sync, |
| 4671 |
AtomicOp op, Imm32 value, const Address& mem, |
| 4672 |
Register temp1, Register temp2, AnyRegister output) |
| 4673 |
DEFINED_ON(x86_shared); |
| 4674 |
|
| 4675 |
void atomicFetchOpJS(Scalar::Type arrayType, Synchronization sync, |
| 4676 |
AtomicOp op, Imm32 value, const BaseIndex& mem, |
| 4677 |
Register temp1, Register temp2, AnyRegister output) |
| 4678 |
DEFINED_ON(x86_shared); |
| 4679 |
|
| 4680 |
void atomicFetchOpJS(Scalar::Type arrayType, Synchronization sync, |
| 4681 |
AtomicOp op, Register value, const Address& mem, |
| 4682 |
Register valueTemp, Register offsetTemp, |
| 4683 |
Register maskTemp, Register temp, AnyRegister output) |
| 4684 |
DEFINED_ON(mips64, loong64, riscv64); |
| 4685 |
|
| 4686 |
void atomicFetchOpJS(Scalar::Type arrayType, Synchronization sync, |
| 4687 |
AtomicOp op, Register value, const BaseIndex& mem, |
| 4688 |
Register valueTemp, Register offsetTemp, |
| 4689 |
Register maskTemp, Register temp, AnyRegister output) |
| 4690 |
DEFINED_ON(mips64, loong64, riscv64); |
| 4691 |
|
| 4692 |
void atomicEffectOpJS(Scalar::Type arrayType, Synchronization sync, |
| 4693 |
AtomicOp op, Register value, const Address& mem, |
| 4694 |
Register temp) DEFINED_ON(arm, arm64, x86_shared); |
| 4695 |
|
| 4696 |
void atomicEffectOpJS(Scalar::Type arrayType, Synchronization sync, |
| 4697 |
AtomicOp op, Register value, const BaseIndex& mem, |
| 4698 |
Register temp) DEFINED_ON(arm, arm64, x86_shared); |
| 4699 |
|
| 4700 |
void atomicEffectOpJS(Scalar::Type arrayType, Synchronization sync, |
| 4701 |
AtomicOp op, Imm32 value, const Address& mem, |
| 4702 |
Register temp) DEFINED_ON(x86_shared); |
| 4703 |
|
| 4704 |
void atomicEffectOpJS(Scalar::Type arrayType, Synchronization sync, |
| 4705 |
AtomicOp op, Imm32 value, const BaseIndex& mem, |
| 4706 |
Register temp) DEFINED_ON(x86_shared); |
| 4707 |
|
| 4708 |
void atomicEffectOpJS(Scalar::Type arrayType, Synchronization sync, |
| 4709 |
AtomicOp op, Register value, const Address& mem, |
| 4710 |
Register valueTemp, Register offsetTemp, |
| 4711 |
Register maskTemp) DEFINED_ON(mips64, loong64, riscv64); |
| 4712 |
|
| 4713 |
void atomicEffectOpJS(Scalar::Type arrayType, Synchronization sync, |
| 4714 |
AtomicOp op, Register value, const BaseIndex& mem, |
| 4715 |
Register valueTemp, Register offsetTemp, |
| 4716 |
Register maskTemp) DEFINED_ON(mips64, loong64, riscv64); |
| 4717 |
|
| 4718 |
void atomicIsLockFreeJS(Register value, Register output); |
| 4719 |
|
| 4720 |
void atomicPause() PER_SHARED_ARCH; |
| 4721 |
|
| 4722 |
// ======================================================================== |
| 4723 |
// Spectre Mitigations. |
| 4724 |
// |
| 4725 |
// Spectre attacks are side-channel attacks based on cache pollution or |
| 4726 |
// slow-execution of some instructions. We have multiple spectre mitigations |
| 4727 |
// possible: |
| 4728 |
// |
| 4729 |
// - Stop speculative executions, with memory barriers. Memory barriers |
| 4730 |
// force all branches depending on loads to be resolved, and thus |
| 4731 |
// resolve all miss-speculated paths. |
| 4732 |
// |
| 4733 |
// - Use conditional move instructions. Some CPUs have a branch predictor, |
| 4734 |
// and not a flag predictor. In such cases, using a conditional move |
| 4735 |
// instruction to zero some pointer/index is enough to add a |
| 4736 |
// data-dependency which prevents any futher executions until the load is |
| 4737 |
// resolved. |
| 4738 |
|
| 4739 |
void spectreMaskIndex32(Register index, Register length, Register output); |
| 4740 |
void spectreMaskIndex32(Register index, const Address& length, |
| 4741 |
Register output); |
| 4742 |
void spectreMaskIndexPtr(Register index, Register length, Register output); |
| 4743 |
void spectreMaskIndexPtr(Register index, const Address& length, |
| 4744 |
Register output); |
| 4745 |
|
| 4746 |
// The length must be a power of two. Performs a bounds check and Spectre |
| 4747 |
// index masking. |
| 4748 |
void boundsCheck32PowerOfTwo(Register index, uint32_t length, Label* failure); |
| 4749 |
|
| 4750 |
void speculationBarrier() PER_SHARED_ARCH; |
| 4751 |
|
| 4752 |
//}}} check_macroassembler_decl_style |
| 4753 |
public: |
| 4754 |
// Unsafe here means the caller is responsible for Spectre mitigations if |
| 4755 |
// needed. Prefer branchTestObjClass or one of the other masm helpers! |
| 4756 |
inline void loadObjClassUnsafe(Register obj, Register dest); |
| 4757 |
inline void loadObjShapeUnsafe(Register obj, Register dest); |
| 4758 |
|
| 4759 |
template <typename EmitPreBarrier> |
| 4760 |
inline void storeObjShape(Register shape, Register obj, |
| 4761 |
EmitPreBarrier emitPreBarrier); |
| 4762 |
template <typename EmitPreBarrier> |
| 4763 |
inline void storeObjShape(Shape* shape, Register obj, |
| 4764 |
EmitPreBarrier emitPreBarrier); |
| 4765 |
|
| 4766 |
inline void loadObjProto(Register obj, Register dest); |
| 4767 |
|
| 4768 |
inline void loadStringLength(Register str, Register dest); |
| 4769 |
|
| 4770 |
void loadStringChars(Register str, Register dest, CharEncoding encoding); |
| 4771 |
|
| 4772 |
void loadNonInlineStringChars(Register str, Register dest, |
| 4773 |
CharEncoding encoding); |
| 4774 |
void loadNonInlineStringCharsForStore(Register str, Register dest); |
| 4775 |
void storeNonInlineStringChars(Register chars, Register str); |
| 4776 |
|
| 4777 |
void loadInlineStringChars(Register str, Register dest, |
| 4778 |
CharEncoding encoding); |
| 4779 |
void loadInlineStringCharsForStore(Register str, Register dest); |
| 4780 |
|
| 4781 |
private: |
| 4782 |
enum class CharKind { CharCode, CodePoint }; |
| 4783 |
|
| 4784 |
void branchIfMaybeSplitSurrogatePair(Register leftChild, Register index, |
| 4785 |
Register scratch, Label* maybeSplit, |
| 4786 |
Label* notSplit); |
| 4787 |
|
| 4788 |
void loadRopeChild(CharKind kind, Register str, Register index, |
| 4789 |
Register output, Register maybeScratch, Label* isLinear, |
| 4790 |
Label* splitSurrogate); |
| 4791 |
|
| 4792 |
void branchIfCanLoadStringChar(CharKind kind, Register str, Register index, |
| 4793 |
Register scratch, Register maybeScratch, |
| 4794 |
Label* label); |
| 4795 |
void branchIfNotCanLoadStringChar(CharKind kind, Register str, Register index, |
| 4796 |
Register scratch, Register maybeScratch, |
| 4797 |
Label* label); |
| 4798 |
|
| 4799 |
void loadStringChar(CharKind kind, Register str, Register index, |
| 4800 |
Register output, Register scratch1, Register scratch2, |
| 4801 |
Label* fail); |
| 4802 |
|
| 4803 |
public: |
| 4804 |
void branchIfCanLoadStringChar(Register str, Register index, Register scratch, |
| 4805 |
Label* label) { |
| 4806 |
branchIfCanLoadStringChar(CharKind::CharCode, str, index, scratch, |
| 4807 |
InvalidReg, label); |
| 4808 |
} |
| 4809 |
void branchIfNotCanLoadStringChar(Register str, Register index, |
| 4810 |
Register scratch, Label* label) { |
| 4811 |
branchIfNotCanLoadStringChar(CharKind::CharCode, str, index, scratch, |
| 4812 |
InvalidReg, label); |
| 4813 |
} |
| 4814 |
|
| 4815 |
void branchIfCanLoadStringCodePoint(Register str, Register index, |
| 4816 |
Register scratch1, Register scratch2, |
| 4817 |
Label* label) { |
| 4818 |
branchIfCanLoadStringChar(CharKind::CodePoint, str, index, scratch1, |
| 4819 |
scratch2, label); |
| 4820 |
} |
| 4821 |
void branchIfNotCanLoadStringCodePoint(Register str, Register index, |
| 4822 |
Register scratch1, Register scratch2, |
| 4823 |
Label* label) { |
| 4824 |
branchIfNotCanLoadStringChar(CharKind::CodePoint, str, index, scratch1, |
| 4825 |
scratch2, label); |
| 4826 |
} |
| 4827 |
|
| 4828 |
void loadStringChar(Register str, Register index, Register output, |
| 4829 |
Register scratch1, Register scratch2, Label* fail) { |
| 4830 |
loadStringChar(CharKind::CharCode, str, index, output, scratch1, scratch2, |
| 4831 |
fail); |
| 4832 |
} |
| 4833 |
|
| 4834 |
void loadStringChar(Register str, int32_t index, Register output, |
| 4835 |
Register scratch1, Register scratch2, Label* fail); |
| 4836 |
|
| 4837 |
void loadStringCodePoint(Register str, Register index, Register output, |
| 4838 |
Register scratch1, Register scratch2, Label* fail) { |
| 4839 |
loadStringChar(CharKind::CodePoint, str, index, output, scratch1, scratch2, |
| 4840 |
fail); |
| 4841 |
} |
| 4842 |
|
| 4843 |
void loadRopeLeftChild(Register str, Register dest); |
| 4844 |
void loadRopeRightChild(Register str, Register dest); |
| 4845 |
void storeRopeChildren(Register left, Register right, Register str); |
| 4846 |
|
| 4847 |
void loadDependentStringBase(Register str, Register dest); |
| 4848 |
void storeDependentStringBase(Register base, Register str); |
| 4849 |
|
| 4850 |
void loadStringIndexValue(Register str, Register dest, Label* fail); |
| 4851 |
|
| 4852 |
/** |
| 4853 |
* Store the character in |src| to |dest|. |
| 4854 |
*/ |
| 4855 |
template <typename T> |
| 4856 |
void storeChar(const T& src, Address dest, CharEncoding encoding) { |
| 4857 |
if (encoding == CharEncoding::Latin1) { |
| 4858 |
store8(src, dest); |
| 4859 |
} else { |
| 4860 |
store16(src, dest); |
| 4861 |
} |
| 4862 |
} |
| 4863 |
|
| 4864 |
/** |
| 4865 |
* Load the character at |src| into |dest|. |
| 4866 |
*/ |
| 4867 |
template <typename T> |
| 4868 |
void loadChar(const T& src, Register dest, CharEncoding encoding) { |
| 4869 |
if (encoding == CharEncoding::Latin1) { |
| 4870 |
load8ZeroExtend(src, dest); |
| 4871 |
} else { |
| 4872 |
load16ZeroExtend(src, dest); |
| 4873 |
} |
| 4874 |
} |
| 4875 |
|
| 4876 |
/** |
| 4877 |
* Load the character at |chars[index + offset]| into |dest|. The optional |
| 4878 |
* offset argument is not scaled to the character encoding. |
| 4879 |
*/ |
| 4880 |
void loadChar(Register chars, Register index, Register dest, |
| 4881 |
CharEncoding encoding, int32_t offset = 0); |
| 4882 |
|
| 4883 |
/** |
| 4884 |
* Add |index| to |chars| so that |chars| now points at |chars[index]|. |
| 4885 |
*/ |
| 4886 |
void addToCharPtr(Register chars, Register index, CharEncoding encoding); |
| 4887 |
|
| 4888 |
/** |
| 4889 |
* Branch if |src| is not a lead surrogate character. |
| 4890 |
*/ |
| 4891 |
void branchIfNotLeadSurrogate(Register src, Label* label); |
| 4892 |
|
| 4893 |
private: |
| 4894 |
enum class SurrogateChar { Lead, Trail }; |
| 4895 |
void branchSurrogate(Assembler::Condition cond, Register src, |
| 4896 |
Register scratch, Label* label, |
| 4897 |
SurrogateChar surrogateChar); |
| 4898 |
|
| 4899 |
public: |
| 4900 |
/** |
| 4901 |
* Branch if |src| is a lead surrogate character. |
| 4902 |
*/ |
| 4903 |
void branchIfLeadSurrogate(Register src, Register scratch, Label* label) { |
| 4904 |
branchSurrogate(Assembler::Equal, src, scratch, label, SurrogateChar::Lead); |
| 4905 |
} |
| 4906 |
|
| 4907 |
/** |
| 4908 |
* Branch if |src| is not a lead surrogate character. |
| 4909 |
*/ |
| 4910 |
void branchIfNotLeadSurrogate(Register src, Register scratch, Label* label) { |
| 4911 |
branchSurrogate(Assembler::NotEqual, src, scratch, label, |
| 4912 |
SurrogateChar::Lead); |
| 4913 |
} |
| 4914 |
|
| 4915 |
/** |
| 4916 |
* Branch if |src| is not a trail surrogate character. |
| 4917 |
*/ |
| 4918 |
void branchIfNotTrailSurrogate(Register src, Register scratch, Label* label) { |
| 4919 |
branchSurrogate(Assembler::NotEqual, src, scratch, label, |
| 4920 |
SurrogateChar::Trail); |
| 4921 |
} |
| 4922 |
|
| 4923 |
private: |
| 4924 |
void loadStringFromUnit(Register unit, Register dest, |
| 4925 |
const StaticStrings& staticStrings); |
| 4926 |
void loadLengthTwoString(Register c1, Register c2, Register dest, |
| 4927 |
const StaticStrings& staticStrings); |
| 4928 |
|
| 4929 |
public: |
| 4930 |
/** |
| 4931 |
* Lookup the length-one string from the static strings cache. |
| 4932 |
*/ |
| 4933 |
void lookupStaticString(Register ch, Register dest, |
| 4934 |
const StaticStrings& staticStrings); |
| 4935 |
|
| 4936 |
/** |
| 4937 |
* Lookup the length-one string from the static strings cache. Jumps to |fail| |
| 4938 |
* when the string wasn't found in the strings cache. |
| 4939 |
*/ |
| 4940 |
void lookupStaticString(Register ch, Register dest, |
| 4941 |
const StaticStrings& staticStrings, Label* fail); |
| 4942 |
|
| 4943 |
/** |
| 4944 |
* Lookup the length-two string from the static strings cache. Jumps to |fail| |
| 4945 |
* when the string wasn't found in the strings cache. |
| 4946 |
* |
| 4947 |
* Clobbers |ch1| and |ch2|. |
| 4948 |
*/ |
| 4949 |
void lookupStaticString(Register ch1, Register ch2, Register dest, |
| 4950 |
const StaticStrings& staticStrings, Label* fail); |
| 4951 |
|
| 4952 |
/** |
| 4953 |
* Lookup the integer string from the static integer strings cache. Jumps to |
| 4954 |
* |fail| when the string wasn't found in the strings cache. |
| 4955 |
*/ |
| 4956 |
void lookupStaticIntString(Register integer, Register dest, Register scratch, |
| 4957 |
const StaticStrings& staticStrings, Label* fail); |
| 4958 |
void lookupStaticIntString(Register integer, Register dest, |
| 4959 |
const StaticStrings& staticStrings, Label* fail) { |
| 4960 |
lookupStaticIntString(integer, dest, dest, staticStrings, fail); |
| 4961 |
} |
| 4962 |
|
| 4963 |
/** |
| 4964 |
* Load the string representation of |input| in base |base|. Jumps to |fail| |
| 4965 |
* when the string representation needs to be allocated dynamically. |
| 4966 |
*/ |
| 4967 |
void loadInt32ToStringWithBase(Register input, Register base, Register dest, |
| 4968 |
Register scratch1, Register scratch2, |
| 4969 |
const StaticStrings& staticStrings, |
| 4970 |
const LiveRegisterSet& volatileRegs, |
| 4971 |
bool lowerCase, Label* fail); |
| 4972 |
void loadInt32ToStringWithBase(Register input, int32_t base, Register dest, |
| 4973 |
Register scratch1, Register scratch2, |
| 4974 |
const StaticStrings& staticStrings, |
| 4975 |
bool lowerCase, Label* fail); |
| 4976 |
|
| 4977 |
/** |
| 4978 |
* Load the BigInt digits from |bigInt| into |digits|. |
| 4979 |
*/ |
| 4980 |
void loadBigIntDigits(Register bigInt, Register digits); |
| 4981 |
|
| 4982 |
/** |
| 4983 |
* Load the first [u]int64 value from |bigInt| into |dest|. |
| 4984 |
*/ |
| 4985 |
void loadBigInt64(Register bigInt, Register64 dest); |
| 4986 |
|
| 4987 |
/** |
| 4988 |
* Load the first digit from |bigInt| into |dest|. |
| 4989 |
* |
| 4990 |
* Note: A BigInt digit is a pointer-sized value storing an unsigned number. |
| 4991 |
*/ |
| 4992 |
void loadBigIntDigit(Register bigInt, Register dest); |
| 4993 |
|
| 4994 |
/** |
| 4995 |
* Load the first digit from |bigInt| into |dest|. Jumps to |fail| when there |
| 4996 |
* is more than one BigInt digit. |
| 4997 |
* |
| 4998 |
* Note: A BigInt digit is a pointer-sized value storing an unsigned number. |
| 4999 |
*/ |
| 5000 |
void loadBigIntDigit(Register bigInt, Register dest, Label* fail); |
| 5001 |
|
| 5002 |
/** |
| 5003 |
* Load the number stored in |bigInt| into |dest|. Jumps to |fail| when the |
| 5004 |
* number can't be saved into a single pointer-sized register. |
| 5005 |
*/ |
| 5006 |
void loadBigIntPtr(Register bigInt, Register dest, Label* fail); |
| 5007 |
|
| 5008 |
/** |
| 5009 |
* Initialize a BigInt from |val|. Clobbers |val| when |temp| is invalid and |
| 5010 |
* |type == Scalar::BigInt64|! |
| 5011 |
*/ |
| 5012 |
void initializeBigInt64(Scalar::Type type, Register bigInt, Register64 val, |
| 5013 |
Register64 temp = Register64::Invalid()); |
| 5014 |
|
| 5015 |
/** |
| 5016 |
* Initialize a BigInt from the signed, pointer-sized register |val|. |
| 5017 |
* Clobbers |val|! |
| 5018 |
*/ |
| 5019 |
void initializeBigIntPtr(Register bigInt, Register val); |
| 5020 |
|
| 5021 |
/** |
| 5022 |
* Copy a BigInt. Jumps to |fail| on allocation failure or when the BigInt |
| 5023 |
* digits need to be heap allocated. |
| 5024 |
*/ |
| 5025 |
void copyBigIntWithInlineDigits(Register src, Register dest, Register temp, |
| 5026 |
gc::Heap initialHeap, Label* fail); |
| 5027 |
|
| 5028 |
/** |
| 5029 |
* Compare a BigInt and an Int32 value. Falls through to the false case. |
| 5030 |
*/ |
| 5031 |
void compareBigIntAndInt32(JSOp op, Register bigInt, Register int32, |
| 5032 |
Register scratch1, Register scratch2, |
| 5033 |
Label* ifTrue, Label* ifFalse); |
| 5034 |
|
| 5035 |
/** |
| 5036 |
* Compare a BigInt and an Int32 value. Falls through to the false case. |
| 5037 |
*/ |
| 5038 |
void compareBigIntAndInt32(JSOp op, Register bigInt, Imm32 int32, |
| 5039 |
Register scratch, Label* ifTrue, Label* ifFalse); |
| 5040 |
|
| 5041 |
/** |
| 5042 |
* Compare two BigInts for equality. Falls through if both BigInts are equal |
| 5043 |
* to each other. |
| 5044 |
* |
| 5045 |
* - When we jump to |notSameLength|, |temp1| holds the length of the right |
| 5046 |
* operand. |
| 5047 |
* - When we jump to |notSameDigit|, |temp2| points to the current digit of |
| 5048 |
* the left operand and |temp4| holds the current digit of the right |
| 5049 |
* operand. |
| 5050 |
*/ |
| 5051 |
void equalBigInts(Register left, Register right, Register temp1, |
| 5052 |
Register temp2, Register temp3, Register temp4, |
| 5053 |
Label* notSameSign, Label* notSameLength, |
| 5054 |
Label* notSameDigit); |
| 5055 |
|
| 5056 |
void loadJSContext(Register dest); |
| 5057 |
|
| 5058 |
void loadGlobalObjectData(Register dest); |
| 5059 |
|
| 5060 |
void loadRealmFuse(RealmFuses::FuseIndex index, Register dest); |
| 5061 |
|
| 5062 |
void switchToRealm(Register realm); |
| 5063 |
void switchToRealm(const void* realm, Register scratch); |
| 5064 |
void switchToObjectRealm(Register obj, Register scratch); |
| 5065 |
void switchToBaselineFrameRealm(Register scratch); |
| 5066 |
void switchToWasmInstanceRealm(Register scratch1, Register scratch2); |
| 5067 |
void debugAssertContextRealm(const void* realm, Register scratch); |
| 5068 |
|
| 5069 |
void guardObjectHasSameRealm(Register obj, Register scratch, Label* fail); |
| 5070 |
|
| 5071 |
template <typename ValueType> |
| 5072 |
void storeLocalAllocSite(ValueType value, Register scratch); |
| 5073 |
|
| 5074 |
void loadBaselineCompileQueue(Register dest); |
| 5075 |
|
| 5076 |
void loadJitActivation(Register dest); |
| 5077 |
|
| 5078 |
void guardSpecificAtom(Register str, JSAtom* atom, Register scratch, |
| 5079 |
const LiveRegisterSet& volatileRegs, Label* fail); |
| 5080 |
|
| 5081 |
void guardStringToInt32(Register str, Register output, Register scratch, |
| 5082 |
LiveRegisterSet volatileRegs, Label* fail); |
| 5083 |
|
| 5084 |
template <typename T> |
| 5085 |
void loadTypedOrValue(const T& src, TypedOrValueRegister dest) { |
| 5086 |
if (dest.hasValue()) { |
| 5087 |
loadValue(src, dest.valueReg()); |
| 5088 |
} else { |
| 5089 |
loadUnboxedValue(src, dest.type(), dest.typedReg()); |
| 5090 |
} |
| 5091 |
} |
| 5092 |
|
| 5093 |
template <typename T> |
| 5094 |
void storeTypedOrValue(TypedOrValueRegister src, const T& dest) { |
| 5095 |
if (src.hasValue()) { |
| 5096 |
storeValue(src.valueReg(), dest); |
| 5097 |
} else if (IsFloatingPointType(src.type())) { |
| 5098 |
FloatRegister reg = src.typedReg().fpu(); |
| 5099 |
if (src.type() == MIRType::Float32) { |
| 5100 |
ScratchDoubleScope fpscratch(*this); |
| 5101 |
convertFloat32ToDouble(reg, fpscratch); |
| 5102 |
boxDouble(fpscratch, dest); |
| 5103 |
} else { |
| 5104 |
boxDouble(reg, dest); |
| 5105 |
} |
| 5106 |
} else { |
| 5107 |
storeValue(ValueTypeFromMIRType(src.type()), src.typedReg().gpr(), dest); |
| 5108 |
} |
| 5109 |
} |
| 5110 |
|
| 5111 |
template <typename T> |
| 5112 |
void storeConstantOrRegister(const ConstantOrRegister& src, const T& dest) { |
| 5113 |
if (src.constant()) { |
| 5114 |
storeValue(src.value(), dest); |
| 5115 |
} else { |
| 5116 |
storeTypedOrValue(src.reg(), dest); |
| 5117 |
} |
| 5118 |
} |
| 5119 |
|
| 5120 |
void storeCallPointerResult(Register reg) { |
| 5121 |
if (reg != ReturnReg) { |
| 5122 |
mov(ReturnReg, reg); |
| 5123 |
} |
| 5124 |
} |
| 5125 |
|
| 5126 |
inline void storeCallBoolResult(Register reg); |
| 5127 |
inline void storeCallInt32Result(Register reg); |
| 5128 |
|
| 5129 |
void storeCallFloatResult(FloatRegister reg) { |
| 5130 |
if (reg.isSingle()) { |
| 5131 |
if (reg != ReturnFloat32Reg) { |
| 5132 |
moveFloat32(ReturnFloat32Reg, reg); |
| 5133 |
} |
| 5134 |
} else { |
| 5135 |
if (reg != ReturnDoubleReg) { |
| 5136 |
moveDouble(ReturnDoubleReg, reg); |
| 5137 |
} |
| 5138 |
} |
| 5139 |
} |
| 5140 |
|
| 5141 |
inline void storeCallResultValue(AnyRegister dest, JSValueType type); |
| 5142 |
|
| 5143 |
void storeCallResultValue(ValueOperand dest) { |
| 5144 |
#if defined(JS_NUNBOX32) |
| 5145 |
// reshuffle the return registers used for a call result to store into |
| 5146 |
// dest, using ReturnReg as a scratch register if necessary. This must |
| 5147 |
// only be called after returning from a call, at a point when the |
| 5148 |
// return register is not live. XXX would be better to allow wrappers |
| 5149 |
// to store the return value to different places. |
| 5150 |
if (dest.typeReg() == JSReturnReg_Data) { |
| 5151 |
if (dest.payloadReg() == JSReturnReg_Type) { |
| 5152 |
// swap the two registers. |
| 5153 |
mov(JSReturnReg_Type, ReturnReg); |
| 5154 |
mov(JSReturnReg_Data, JSReturnReg_Type); |
| 5155 |
mov(ReturnReg, JSReturnReg_Data); |
| 5156 |
} else { |
| 5157 |
mov(JSReturnReg_Data, dest.payloadReg()); |
| 5158 |
mov(JSReturnReg_Type, dest.typeReg()); |
| 5159 |
} |
| 5160 |
} else { |
| 5161 |
mov(JSReturnReg_Type, dest.typeReg()); |
| 5162 |
mov(JSReturnReg_Data, dest.payloadReg()); |
| 5163 |
} |
| 5164 |
#elif defined(JS_PUNBOX64) |
| 5165 |
if (dest.valueReg() != JSReturnReg) { |
| 5166 |
mov(JSReturnReg, dest.valueReg()); |
| 5167 |
} |
| 5168 |
#else |
| 5169 |
# error "Bad architecture" |
| 5170 |
#endif |
| 5171 |
} |
| 5172 |
|
| 5173 |
inline void storeCallResultValue(TypedOrValueRegister dest); |
| 5174 |
|
| 5175 |
private: |
| 5176 |
TrampolinePtr preBarrierTrampoline(MIRType type); |
| 5177 |
|
| 5178 |
template <typename T> |
| 5179 |
void unguardedCallPreBarrier(const T& address, MIRType type) { |
| 5180 |
Label done; |
| 5181 |
if (type == MIRType::Value) { |
| 5182 |
branchTestGCThing(Assembler::NotEqual, address, &done); |
| 5183 |
} else if (type == MIRType::Object || type == MIRType::String) { |
| 5184 |
branchPtr(Assembler::Equal, address, ImmWord(0), &done); |
| 5185 |
} |
| 5186 |
|
| 5187 |
Push(PreBarrierReg); |
| 5188 |
computeEffectiveAddress(address, PreBarrierReg); |
| 5189 |
|
| 5190 |
TrampolinePtr preBarrier = preBarrierTrampoline(type); |
| 5191 |
|
| 5192 |
call(preBarrier); |
| 5193 |
Pop(PreBarrierReg); |
| 5194 |
// On arm64, SP may be < PSP now (that's OK). |
| 5195 |
// eg testcase: tests/auto-regress/bug702915.js |
| 5196 |
bind(&done); |
| 5197 |
} |
| 5198 |
|
| 5199 |
public: |
| 5200 |
template <typename T> |
| 5201 |
void guardedCallPreBarrier(const T& address, MIRType type) { |
| 5202 |
Label done; |
| 5203 |
branchTestNeedsIncrementalBarrier(Assembler::Zero, &done); |
| 5204 |
unguardedCallPreBarrier(address, type); |
| 5205 |
bind(&done); |
| 5206 |
} |
| 5207 |
|
| 5208 |
// Like guardedCallPreBarrier, but unlike guardedCallPreBarrier this can be |
| 5209 |
// called from runtime-wide trampolines because it loads cx->zone (instead of |
| 5210 |
// baking in the current Zone) if JitContext::realm is nullptr. |
| 5211 |
template <typename T> |
| 5212 |
void guardedCallPreBarrierAnyZone(const T& address, MIRType type, |
| 5213 |
Register scratch) { |
| 5214 |
Label done; |
| 5215 |
branchTestNeedsIncrementalBarrierAnyZone(Assembler::Zero, &done, scratch); |
| 5216 |
unguardedCallPreBarrier(address, type); |
| 5217 |
bind(&done); |
| 5218 |
} |
| 5219 |
|
| 5220 |
enum class Uint32Mode { FailOnDouble, ForceDouble }; |
| 5221 |
|
| 5222 |
void boxUint32(Register source, ValueOperand dest, Uint32Mode uint32Mode, |
| 5223 |
Label* fail); |
| 5224 |
|
| 5225 |
static bool LoadRequiresCall(Scalar::Type type) { |
| 5226 |
return type == Scalar::Float16 && !MacroAssembler::SupportsFloat32To16(); |
| 5227 |
} |
| 5228 |
|
| 5229 |
static bool StoreRequiresCall(Scalar::Type type) { |
| 5230 |
return type == Scalar::Float16 && !MacroAssembler::SupportsFloat32To16(); |
| 5231 |
} |
| 5232 |
|
| 5233 |
template <typename T> |
| 5234 |
void loadFromTypedArray(Scalar::Type arrayType, const T& src, |
| 5235 |
AnyRegister dest, Register temp1, Register temp2, |
| 5236 |
Label* fail, LiveRegisterSet volatileLiveReg); |
| 5237 |
|
| 5238 |
void loadFromTypedArray(Scalar::Type arrayType, const BaseIndex& src, |
| 5239 |
const ValueOperand& dest, Uint32Mode uint32Mode, |
| 5240 |
Register temp, Label* fail, |
| 5241 |
LiveRegisterSet volatileLiveReg); |
| 5242 |
|
| 5243 |
void loadFromTypedBigIntArray(Scalar::Type arrayType, const BaseIndex& src, |
| 5244 |
const ValueOperand& dest, Register bigInt, |
| 5245 |
Register64 temp); |
| 5246 |
|
| 5247 |
template <typename S, typename T> |
| 5248 |
void storeToTypedIntArray(Scalar::Type arrayType, const S& value, |
| 5249 |
const T& dest) { |
| 5250 |
switch (arrayType) { |
| 5251 |
case Scalar::Int8: |
| 5252 |
case Scalar::Uint8: |
| 5253 |
case Scalar::Uint8Clamped: |
| 5254 |
store8(value, dest); |
| 5255 |
break; |
| 5256 |
case Scalar::Int16: |
| 5257 |
case Scalar::Uint16: |
| 5258 |
store16(value, dest); |
| 5259 |
break; |
| 5260 |
case Scalar::Int32: |
| 5261 |
case Scalar::Uint32: |
| 5262 |
store32(value, dest); |
| 5263 |
break; |
| 5264 |
default: |
| 5265 |
MOZ_CRASH("Invalid typed array type"); |
| 5266 |
} |
| 5267 |
} |
| 5268 |
|
| 5269 |
template <typename T> |
| 5270 |
void storeToTypedFloatArray(Scalar::Type arrayType, FloatRegister value, |
| 5271 |
const T& dest, Register temp, |
| 5272 |
LiveRegisterSet volatileLiveRegs); |
| 5273 |
|
| 5274 |
template <typename S, typename T> |
| 5275 |
void storeToTypedBigIntArray(const S& value, const T& dest) { |
| 5276 |
store64(value, dest); |
| 5277 |
} |
| 5278 |
|
| 5279 |
void memoryBarrierBefore(Synchronization sync); |
| 5280 |
void memoryBarrierAfter(Synchronization sync); |
| 5281 |
|
| 5282 |
using MacroAssemblerSpecific::convertDoubleToFloat16; |
| 5283 |
using MacroAssemblerSpecific::convertFloat32ToFloat16; |
| 5284 |
using MacroAssemblerSpecific::convertInt32ToFloat16; |
| 5285 |
using MacroAssemblerSpecific::loadFloat16; |
| 5286 |
|
| 5287 |
void convertDoubleToFloat16(FloatRegister src, FloatRegister dest, |
| 5288 |
Register temp, LiveRegisterSet volatileLiveRegs); |
| 5289 |
|
| 5290 |
void convertDoubleToFloat16(FloatRegister src, FloatRegister dest, |
| 5291 |
Register temp1, Register temp2); |
| 5292 |
|
| 5293 |
void convertFloat32ToFloat16(FloatRegister src, FloatRegister dest, |
| 5294 |
Register temp, LiveRegisterSet volatileLiveRegs); |
| 5295 |
|
| 5296 |
void convertInt32ToFloat16(Register src, FloatRegister dest, Register temp, |
| 5297 |
LiveRegisterSet volatileLiveRegs); |
| 5298 |
|
| 5299 |
template <typename T> |
| 5300 |
void loadFloat16(const T& src, FloatRegister dest, Register temp1, |
| 5301 |
Register temp2, LiveRegisterSet volatileLiveRegs); |
| 5302 |
|
| 5303 |
template <typename T> |
| 5304 |
void storeFloat16(FloatRegister src, const T& dest, Register temp, |
| 5305 |
LiveRegisterSet volatileLiveRegs); |
| 5306 |
|
| 5307 |
void moveFloat16ToGPR(FloatRegister src, Register dest, |
| 5308 |
LiveRegisterSet volatileLiveRegs); |
| 5309 |
|
| 5310 |
void moveGPRToFloat16(Register src, FloatRegister dest, Register temp, |
| 5311 |
LiveRegisterSet volatileLiveRegs); |
| 5312 |
|
| 5313 |
void debugAssertIsObject(const ValueOperand& val); |
| 5314 |
void debugAssertObjHasFixedSlots(Register obj, Register scratch); |
| 5315 |
|
| 5316 |
void debugAssertObjectHasClass(Register obj, Register scratch, |
| 5317 |
const JSClass* clasp); |
| 5318 |
|
| 5319 |
void debugAssertGCThingIsTenured(Register ptr, Register temp); |
| 5320 |
|
| 5321 |
void branchArrayIsNotPacked(Register array, Register temp1, Register temp2, |
| 5322 |
Label* label); |
| 5323 |
|
| 5324 |
void setIsPackedArray(Register obj, Register output, Register temp); |
| 5325 |
|
| 5326 |
void packedArrayPop(Register array, ValueOperand output, Register temp1, |
| 5327 |
Register temp2, Label* fail); |
| 5328 |
void packedArrayShift(Register array, ValueOperand output, Register temp1, |
| 5329 |
Register temp2, LiveRegisterSet volatileRegs, |
| 5330 |
Label* fail); |
| 5331 |
|
| 5332 |
void loadArgumentsObjectElement(Register obj, Register index, |
| 5333 |
ValueOperand output, Register temp, |
| 5334 |
Label* fail); |
| 5335 |
void loadArgumentsObjectElementHole(Register obj, Register index, |
| 5336 |
ValueOperand output, Register temp, |
| 5337 |
Label* fail); |
| 5338 |
void loadArgumentsObjectElementExists(Register obj, Register index, |
| 5339 |
Register output, Register temp, |
| 5340 |
Label* fail); |
| 5341 |
|
| 5342 |
void loadArgumentsObjectLength(Register obj, Register output, Label* fail); |
| 5343 |
void loadArgumentsObjectLength(Register obj, Register output); |
| 5344 |
|
| 5345 |
void branchTestArgumentsObjectFlags(Register obj, Register temp, |
| 5346 |
uint32_t flags, Condition cond, |
| 5347 |
Label* label); |
| 5348 |
|
| 5349 |
void typedArrayElementSize(Register obj, Register output); |
| 5350 |
|
| 5351 |
private: |
| 5352 |
// Shift |output| by the element shift of the ResizableTypedArray in |obj|. |
| 5353 |
void resizableTypedArrayElementShiftBy(Register obj, Register output, |
| 5354 |
Register scratch); |
| 5355 |
|
| 5356 |
public: |
| 5357 |
void branchIfClassIsNotTypedArray(Register clasp, Label* notTypedArray); |
| 5358 |
void branchIfClassIsNotFixedLengthTypedArray(Register clasp, |
| 5359 |
Label* notTypedArray); |
| 5360 |
void branchIfClassIsNotResizableTypedArray(Register clasp, |
| 5361 |
Label* notTypedArray); |
| 5362 |
|
| 5363 |
private: |
| 5364 |
enum class BranchIfDetached { No, Yes }; |
| 5365 |
|
| 5366 |
void branchIfHasDetachedArrayBuffer(BranchIfDetached branchIf, Register obj, |
| 5367 |
Register temp, Label* label); |
| 5368 |
|
| 5369 |
public: |
| 5370 |
void branchIfHasDetachedArrayBuffer(Register obj, Register temp, |
| 5371 |
Label* label) { |
| 5372 |
branchIfHasDetachedArrayBuffer(BranchIfDetached::Yes, obj, temp, label); |
| 5373 |
} |
| 5374 |
|
| 5375 |
void branchIfHasAttachedArrayBuffer(Register obj, Register temp, |
| 5376 |
Label* label) { |
| 5377 |
branchIfHasDetachedArrayBuffer(BranchIfDetached::No, obj, temp, label); |
| 5378 |
} |
| 5379 |
|
| 5380 |
void branchIfResizableArrayBufferViewOutOfBounds(Register obj, Register temp, |
| 5381 |
Label* label); |
| 5382 |
|
| 5383 |
void branchIfResizableArrayBufferViewInBounds(Register obj, Register temp, |
| 5384 |
Label* label); |
| 5385 |
|
| 5386 |
void branchIfNativeIteratorNotReusable(Register ni, Label* notReusable); |
| 5387 |
void branchNativeIteratorIndices(Condition cond, Register ni, Register temp, |
| 5388 |
NativeIteratorIndices kind, Label* label); |
| 5389 |
|
| 5390 |
void maybeLoadIteratorFromShape(Register obj, Register dest, Register temp, |
| 5391 |
Register temp2, Register temp3, |
| 5392 |
Label* failure); |
| 5393 |
|
| 5394 |
void iteratorMore(Register obj, ValueOperand output, Register temp); |
| 5395 |
void iteratorClose(Register obj, Register temp1, Register temp2, |
| 5396 |
Register temp3); |
| 5397 |
void registerIterator(Register enumeratorsList, Register iter, Register temp); |
| 5398 |
|
| 5399 |
void prepareOOBStoreElement(Register object, Register index, |
| 5400 |
Register elements, Register spectreTemp, |
| 5401 |
Label* failure, LiveRegisterSet volatileLiveRegs); |
| 5402 |
|
| 5403 |
void toHashableNonGCThing(ValueOperand value, ValueOperand result, |
| 5404 |
FloatRegister tempFloat); |
| 5405 |
|
| 5406 |
void toHashableValue(ValueOperand value, ValueOperand result, |
| 5407 |
FloatRegister tempFloat, Label* atomizeString, |
| 5408 |
Label* tagString); |
| 5409 |
|
| 5410 |
private: |
| 5411 |
void scrambleHashCode(Register result); |
| 5412 |
|
| 5413 |
public: |
| 5414 |
void prepareHashNonGCThing(ValueOperand value, Register result, |
| 5415 |
Register temp); |
| 5416 |
void prepareHashString(Register str, Register result, Register temp); |
| 5417 |
void prepareHashSymbol(Register sym, Register result); |
| 5418 |
void prepareHashBigInt(Register bigInt, Register result, Register temp1, |
| 5419 |
Register temp2, Register temp3); |
| 5420 |
void prepareHashObject(Register setObj, ValueOperand value, Register result, |
| 5421 |
Register temp1, Register temp2, Register temp3, |
| 5422 |
Register temp4); |
| 5423 |
void prepareHashValue(Register setObj, ValueOperand value, Register result, |
| 5424 |
Register temp1, Register temp2, Register temp3, |
| 5425 |
Register temp4); |
| 5426 |
|
| 5427 |
private: |
| 5428 |
enum class IsBigInt { No, Yes, Maybe }; |
| 5429 |
|
| 5430 |
/** |
| 5431 |
* Search for a value in a MapObject or SetObject. |
| 5432 |
* |
| 5433 |
* When we jump to |found|, |entryTemp| holds the found hashtable entry. |
| 5434 |
*/ |
| 5435 |
template <typename TableObject> |
| 5436 |
void orderedHashTableLookup(Register setOrMapObj, ValueOperand value, |
| 5437 |
Register hash, Register entryTemp, Register temp1, |
| 5438 |
Register temp3, Register temp4, Register temp5, |
| 5439 |
Label* found, IsBigInt isBigInt); |
| 5440 |
|
| 5441 |
void setObjectHas(Register setObj, ValueOperand value, Register hash, |
| 5442 |
Register result, Register temp1, Register temp2, |
| 5443 |
Register temp3, Register temp4, IsBigInt isBigInt); |
| 5444 |
|
| 5445 |
void mapObjectHas(Register mapObj, ValueOperand value, Register hash, |
| 5446 |
Register result, Register temp1, Register temp2, |
| 5447 |
Register temp3, Register temp4, IsBigInt isBigInt); |
| 5448 |
|
| 5449 |
void mapObjectGet(Register mapObj, ValueOperand value, Register hash, |
| 5450 |
ValueOperand result, Register temp1, Register temp2, |
| 5451 |
Register temp3, Register temp4, Register temp5, |
| 5452 |
IsBigInt isBigInt); |
| 5453 |
|
| 5454 |
public: |
| 5455 |
void setObjectHasNonBigInt(Register setObj, ValueOperand value, Register hash, |
| 5456 |
Register result, Register temp1, Register temp2) { |
| 5457 |
return setObjectHas(setObj, value, hash, result, temp1, temp2, InvalidReg, |
| 5458 |
InvalidReg, IsBigInt::No); |
| 5459 |
} |
| 5460 |
void setObjectHasBigInt(Register setObj, ValueOperand value, Register hash, |
| 5461 |
Register result, Register temp1, Register temp2, |
| 5462 |
Register temp3, Register temp4) { |
| 5463 |
return setObjectHas(setObj, value, hash, result, temp1, temp2, temp3, temp4, |
| 5464 |
IsBigInt::Yes); |
| 5465 |
} |
| 5466 |
void setObjectHasValue(Register setObj, ValueOperand value, Register hash, |
| 5467 |
Register result, Register temp1, Register temp2, |
| 5468 |
Register temp3, Register temp4) { |
| 5469 |
return setObjectHas(setObj, value, hash, result, temp1, temp2, temp3, temp4, |
| 5470 |
IsBigInt::Maybe); |
| 5471 |
} |
| 5472 |
|
| 5473 |
void mapObjectHasNonBigInt(Register mapObj, ValueOperand value, Register hash, |
| 5474 |
Register result, Register temp1, Register temp2) { |
| 5475 |
return mapObjectHas(mapObj, value, hash, result, temp1, temp2, InvalidReg, |
| 5476 |
InvalidReg, IsBigInt::No); |
| 5477 |
} |
| 5478 |
void mapObjectHasBigInt(Register mapObj, ValueOperand value, Register hash, |
| 5479 |
Register result, Register temp1, Register temp2, |
| 5480 |
Register temp3, Register temp4) { |
| 5481 |
return mapObjectHas(mapObj, value, hash, result, temp1, temp2, temp3, temp4, |
| 5482 |
IsBigInt::Yes); |
| 5483 |
} |
| 5484 |
void mapObjectHasValue(Register mapObj, ValueOperand value, Register hash, |
| 5485 |
Register result, Register temp1, Register temp2, |
| 5486 |
Register temp3, Register temp4) { |
| 5487 |
return mapObjectHas(mapObj, value, hash, result, temp1, temp2, temp3, temp4, |
| 5488 |
IsBigInt::Maybe); |
| 5489 |
} |
| 5490 |
|
| 5491 |
void mapObjectGetNonBigInt(Register mapObj, ValueOperand value, Register hash, |
| 5492 |
ValueOperand result, Register temp1, |
| 5493 |
Register temp2, Register temp3) { |
| 5494 |
return mapObjectGet(mapObj, value, hash, result, temp1, temp2, temp3, |
| 5495 |
InvalidReg, InvalidReg, IsBigInt::No); |
| 5496 |
} |
| 5497 |
void mapObjectGetBigInt(Register mapObj, ValueOperand value, Register hash, |
| 5498 |
ValueOperand result, Register temp1, Register temp2, |
| 5499 |
Register temp3, Register temp4, Register temp5) { |
| 5500 |
return mapObjectGet(mapObj, value, hash, result, temp1, temp2, temp3, temp4, |
| 5501 |
temp5, IsBigInt::Yes); |
| 5502 |
} |
| 5503 |
void mapObjectGetValue(Register mapObj, ValueOperand value, Register hash, |
| 5504 |
ValueOperand result, Register temp1, Register temp2, |
| 5505 |
Register temp3, Register temp4, Register temp5) { |
| 5506 |
return mapObjectGet(mapObj, value, hash, result, temp1, temp2, temp3, temp4, |
| 5507 |
temp5, IsBigInt::Maybe); |
| 5508 |
} |
| 5509 |
|
| 5510 |
private: |
| 5511 |
template <typename TableObject> |
| 5512 |
void loadOrderedHashTableCount(Register setOrMapObj, Register result); |
| 5513 |
|
| 5514 |
public: |
| 5515 |
void loadSetObjectSize(Register setObj, Register result); |
| 5516 |
void loadMapObjectSize(Register mapObj, Register result); |
| 5517 |
|
| 5518 |
// Inline version of js::ClampDoubleToUint8. |
| 5519 |
// This function clobbers the input register. |
| 5520 |
void clampDoubleToUint8(FloatRegister input, Register output) PER_ARCH; |
| 5521 |
|
| 5522 |
// If source is a double, load into dest. |
| 5523 |
// If source is int32, convert to double and store in dest. |
| 5524 |
// Else, branch to failure. |
| 5525 |
inline void ensureDouble(const ValueOperand& source, FloatRegister dest, |
| 5526 |
Label* failure); |
| 5527 |
|
| 5528 |
template <typename S> |
| 5529 |
void ensureDouble(const S& source, FloatRegister dest, Label* failure) { |
| 5530 |
Label isDouble, done; |
| 5531 |
branchTestDouble(Assembler::Equal, source, &isDouble); |
| 5532 |
branchTestInt32(Assembler::NotEqual, source, failure); |
| 5533 |
|
| 5534 |
convertInt32ToDouble(source, dest); |
| 5535 |
jump(&done); |
| 5536 |
|
| 5537 |
bind(&isDouble); |
| 5538 |
unboxDouble(source, dest); |
| 5539 |
|
| 5540 |
bind(&done); |
| 5541 |
} |
| 5542 |
|
| 5543 |
// Inline allocation. |
| 5544 |
private: |
| 5545 |
void checkAllocatorState(Register temp, gc::AllocKind allocKind, Label* fail); |
| 5546 |
bool shouldNurseryAllocate(gc::AllocKind allocKind, gc::Heap initialHeap); |
| 5547 |
void nurseryAllocateObject( |
| 5548 |
Register result, Register temp, gc::AllocKind allocKind, |
| 5549 |
size_t nDynamicSlots, Label* fail, |
| 5550 |
const AllocSiteInput& allocSite = AllocSiteInput()); |
| 5551 |
void bumpPointerAllocate(Register result, Register temp, Label* fail, |
| 5552 |
CompileZone* zone, JS::TraceKind traceKind, |
| 5553 |
uint32_t size, |
| 5554 |
const AllocSiteInput& allocSite = AllocSiteInput()); |
| 5555 |
void updateAllocSite(Register temp, Register result, CompileZone* zone, |
| 5556 |
Register site); |
| 5557 |
|
| 5558 |
void freeListAllocate(Register result, Register temp, gc::AllocKind allocKind, |
| 5559 |
Label* fail); |
| 5560 |
void allocateObject(Register result, Register temp, gc::AllocKind allocKind, |
| 5561 |
uint32_t nDynamicSlots, gc::Heap initialHeap, Label* fail, |
| 5562 |
const AllocSiteInput& allocSite = AllocSiteInput()); |
| 5563 |
void nurseryAllocateString(Register result, Register temp, |
| 5564 |
gc::AllocKind allocKind, Label* fail); |
| 5565 |
void allocateString(Register result, Register temp, gc::AllocKind allocKind, |
| 5566 |
gc::Heap initialHeap, Label* fail); |
| 5567 |
void nurseryAllocateBigInt(Register result, Register temp, Label* fail); |
| 5568 |
void copySlotsFromTemplate(Register obj, |
| 5569 |
const TemplateNativeObject& templateObj, |
| 5570 |
uint32_t start, uint32_t end); |
| 5571 |
void fillSlotsWithConstantValue(Address addr, Register temp, uint32_t start, |
| 5572 |
uint32_t end, const Value& v); |
| 5573 |
void fillSlotsWithUndefined(Address addr, Register temp, uint32_t start, |
| 5574 |
uint32_t end); |
| 5575 |
void fillSlotsWithUninitialized(Address addr, Register temp, uint32_t start, |
| 5576 |
uint32_t end); |
| 5577 |
|
| 5578 |
void initGCSlots(Register obj, Register temp, |
| 5579 |
const TemplateNativeObject& templateObj); |
| 5580 |
|
| 5581 |
public: |
| 5582 |
void createGCObject(Register result, Register temp, |
| 5583 |
const TemplateObject& templateObj, gc::Heap initialHeap, |
| 5584 |
Label* fail, bool initContents = true, |
| 5585 |
const AllocSiteInput& allocSite = AllocSiteInput()); |
| 5586 |
|
| 5587 |
void createPlainGCObject(Register result, Register shape, Register temp, |
| 5588 |
Register temp2, uint32_t numFixedSlots, |
| 5589 |
uint32_t numDynamicSlots, gc::AllocKind allocKind, |
| 5590 |
gc::Heap initialHeap, Label* fail, |
| 5591 |
const AllocSiteInput& allocSite, |
| 5592 |
bool initContents = true); |
| 5593 |
|
| 5594 |
// dynamicSlotsTemp is used to initialize the dynamic slots after allocating |
| 5595 |
// the object. If numUsedDynamicSlots == 0, it may be InvalidReg. |
| 5596 |
void createArrayWithFixedElements( |
| 5597 |
Register result, Register shape, Register temp, Register dynamicSlotsTemp, |
| 5598 |
uint32_t arrayLength, uint32_t arrayCapacity, |
| 5599 |
uint32_t numUsedDynamicSlots, uint32_t numDynamicSlots, |
| 5600 |
gc::AllocKind allocKind, gc::Heap initialHeap, Label* fail, |
| 5601 |
const AllocSiteInput& allocSite = AllocSiteInput()); |
| 5602 |
|
| 5603 |
void createFunctionClone(Register result, Register canonical, |
| 5604 |
Register envChain, Register temp, |
| 5605 |
gc::AllocKind allocKind, Label* fail, |
| 5606 |
const AllocSiteInput& allocSite); |
| 5607 |
|
| 5608 |
void initGCThing(Register obj, Register temp, |
| 5609 |
const TemplateObject& templateObj, bool initContents = true); |
| 5610 |
|
| 5611 |
enum class TypedArrayLength { Fixed, Dynamic }; |
| 5612 |
|
| 5613 |
void initTypedArraySlots(Register obj, Register temp, Register lengthReg, |
| 5614 |
LiveRegisterSet liveRegs, Label* fail, |
| 5615 |
FixedLengthTypedArrayObject* templateObj, |
| 5616 |
TypedArrayLength lengthKind); |
| 5617 |
|
| 5618 |
void newGCString(Register result, Register temp, gc::Heap initialHeap, |
| 5619 |
Label* fail); |
| 5620 |
void newGCFatInlineString(Register result, Register temp, |
| 5621 |
gc::Heap initialHeap, Label* fail); |
| 5622 |
|
| 5623 |
void newGCBigInt(Register result, Register temp, gc::Heap initialHeap, |
| 5624 |
Label* fail); |
| 5625 |
|
| 5626 |
private: |
| 5627 |
void branchIfNotStringCharsEquals(Register stringChars, |
| 5628 |
const JSLinearString* linear, Label* label); |
| 5629 |
|
| 5630 |
public: |
| 5631 |
// Returns true if |linear| is a (non-empty) string which can be compared |
| 5632 |
// using |compareStringChars|. |
| 5633 |
static bool canCompareStringCharsInline(const JSLinearString* linear); |
| 5634 |
|
| 5635 |
// Load the string characters in preparation for |compareStringChars|. |
| 5636 |
void loadStringCharsForCompare(Register input, const JSLinearString* linear, |
| 5637 |
Register stringChars, Label* fail); |
| 5638 |
|
| 5639 |
// Compare string characters based on the equality operator. The string |
| 5640 |
// characters must be at least as long as the length of |linear|. |
| 5641 |
void compareStringChars(JSOp op, Register stringChars, |
| 5642 |
const JSLinearString* linear, Register result); |
| 5643 |
|
| 5644 |
// Compares two strings for equality based on the JSOP. |
| 5645 |
// This checks for identical pointers, atoms and length and fails for |
| 5646 |
// everything else. |
| 5647 |
void compareStrings(JSOp op, Register left, Register right, Register result, |
| 5648 |
Label* fail); |
| 5649 |
|
| 5650 |
// Result of the typeof operation. Falls back to slow-path for proxies. |
| 5651 |
void typeOfObject(Register objReg, Register scratch, Label* slow, |
| 5652 |
Label* isObject, Label* isCallable, Label* isUndefined); |
| 5653 |
|
| 5654 |
// Implementation of IsCallable. Doesn't handle proxies. |
| 5655 |
void isCallable(Register obj, Register output, Label* isProxy) { |
| 5656 |
isCallableOrConstructor(true, obj, output, isProxy); |
| 5657 |
} |
| 5658 |
void isConstructor(Register obj, Register output, Label* isProxy) { |
| 5659 |
isCallableOrConstructor(false, obj, output, isProxy); |
| 5660 |
} |
| 5661 |
|
| 5662 |
void setIsCrossRealmArrayConstructor(Register obj, Register output); |
| 5663 |
|
| 5664 |
void setIsDefinitelyTypedArrayConstructor(Register obj, Register output); |
| 5665 |
|
| 5666 |
void loadMegamorphicCache(Register dest); |
| 5667 |
void tryFastAtomize(Register str, Register scratch, Register output, |
| 5668 |
Label* fail); |
| 5669 |
void loadMegamorphicSetPropCache(Register dest); |
| 5670 |
|
| 5671 |
void loadAtomOrSymbolAndHash(ValueOperand value, Register outId, |
| 5672 |
Register outHash, Label* cacheMiss); |
| 5673 |
|
| 5674 |
void loadAtomHash(Register id, Register hash, Label* done); |
| 5675 |
|
| 5676 |
void emitExtractValueFromMegamorphicCacheEntry( |
| 5677 |
Register obj, Register entry, Register scratch1, Register scratch2, |
| 5678 |
ValueOperand output, Label* cacheHit, Label* cacheMiss, |
| 5679 |
Label* cacheHitGetter); |
| 5680 |
|
| 5681 |
template <typename IdOperandType> |
| 5682 |
void emitMegamorphicCacheLookupByValueCommon( |
| 5683 |
IdOperandType id, Register obj, Register scratch1, Register scratch2, |
| 5684 |
Register outEntryPtr, Label* cacheMiss, Label* cacheMissWithEntry); |
| 5685 |
|
| 5686 |
void emitMegamorphicCacheLookup(PropertyKey id, Register obj, |
| 5687 |
Register scratch1, Register scratch2, |
| 5688 |
Register outEntryPtr, ValueOperand output, |
| 5689 |
Label* cacheHit, |
| 5690 |
Label* cacheHitGetter = nullptr); |
| 5691 |
|
| 5692 |
// NOTE: |id| must either be a ValueOperand or a Register. If it is a |
| 5693 |
// Register, we assume that it is an atom. |
| 5694 |
template <typename IdOperandType> |
| 5695 |
void emitMegamorphicCacheLookupByValue(IdOperandType id, Register obj, |
| 5696 |
Register scratch1, Register scratch2, |
| 5697 |
Register outEntryPtr, |
| 5698 |
ValueOperand output, Label* cacheHit, |
| 5699 |
Label* cacheHitGetter = nullptr); |
| 5700 |
|
| 5701 |
void emitMegamorphicCacheLookupExists(ValueOperand id, Register obj, |
| 5702 |
Register scratch1, Register scratch2, |
| 5703 |
Register outEntryPtr, Register output, |
| 5704 |
Label* cacheHit, bool hasOwn); |
| 5705 |
|
| 5706 |
// Given a PropertyIteratorObject with valid indices, extract the current |
| 5707 |
// PropertyIndex, storing the index in |outIndex| and the kind in |outKind| |
| 5708 |
void extractCurrentIndexAndKindFromIterator(Register iterator, |
| 5709 |
Register outIndex, |
| 5710 |
Register outKind); |
| 5711 |
|
| 5712 |
template <typename IdType> |
| 5713 |
#ifdef JS_CODEGEN_X86 |
| 5714 |
// See MegamorphicSetElement in LIROps.yaml |
| 5715 |
void emitMegamorphicCachedSetSlot( |
| 5716 |
IdType id, Register obj, Register scratch1, ValueOperand value, |
| 5717 |
const LiveRegisterSet& liveRegs, Label* cacheHit, |
| 5718 |
void (*emitPreBarrier)(MacroAssembler&, const Address&, MIRType)); |
| 5719 |
#else |
| 5720 |
void emitMegamorphicCachedSetSlot( |
| 5721 |
IdType id, Register obj, Register scratch1, Register scratch2, |
| 5722 |
Register scratch3, ValueOperand value, const LiveRegisterSet& liveRegs, |
| 5723 |
Label* cacheHit, |
| 5724 |
void (*emitPreBarrier)(MacroAssembler&, const Address&, MIRType)); |
| 5725 |
#endif |
| 5726 |
|
| 5727 |
void loadDOMExpandoValueGuardGeneration( |
| 5728 |
Register obj, ValueOperand output, |
| 5729 |
JS::ExpandoAndGeneration* expandoAndGeneration, uint64_t generation, |
| 5730 |
Label* fail); |
| 5731 |
|
| 5732 |
void guardNonNegativeIntPtrToInt32(Register reg, Label* fail); |
| 5733 |
|
| 5734 |
void loadArrayBufferByteLengthIntPtr(Register obj, Register output); |
| 5735 |
void loadArrayBufferViewByteOffsetIntPtr(Register obj, Register output); |
| 5736 |
void loadArrayBufferViewLengthIntPtr(Register obj, Register output); |
| 5737 |
|
| 5738 |
void loadGrowableSharedArrayBufferByteLengthIntPtr(Synchronization sync, |
| 5739 |
Register obj, |
| 5740 |
Register output); |
| 5741 |
|
| 5742 |
private: |
| 5743 |
enum class ResizableArrayBufferView { TypedArray, DataView }; |
| 5744 |
|
| 5745 |
void loadResizableArrayBufferViewLengthIntPtr(ResizableArrayBufferView view, |
| 5746 |
Synchronization sync, |
| 5747 |
Register obj, Register output, |
| 5748 |
Register scratch); |
| 5749 |
|
| 5750 |
public: |
| 5751 |
void loadResizableTypedArrayLengthIntPtr(Synchronization sync, Register obj, |
| 5752 |
Register output, Register scratch) { |
| 5753 |
loadResizableArrayBufferViewLengthIntPtr( |
| 5754 |
ResizableArrayBufferView::TypedArray, sync, obj, output, scratch); |
| 5755 |
} |
| 5756 |
|
| 5757 |
void loadResizableDataViewByteLengthIntPtr(Synchronization sync, Register obj, |
| 5758 |
Register output, |
| 5759 |
Register scratch) { |
| 5760 |
loadResizableArrayBufferViewLengthIntPtr(ResizableArrayBufferView::DataView, |
| 5761 |
sync, obj, output, scratch); |
| 5762 |
} |
| 5763 |
|
| 5764 |
void loadResizableTypedArrayByteOffsetMaybeOutOfBoundsIntPtr( |
| 5765 |
Register obj, Register output, Register scratch); |
| 5766 |
|
| 5767 |
void dateFillLocalTimeSlots(Register obj, Register scratch, |
| 5768 |
const LiveRegisterSet& volatileRegs); |
| 5769 |
|
| 5770 |
private: |
| 5771 |
void udiv32ByConstant(Register src, uint32_t divisor, Register dest); |
| 5772 |
|
| 5773 |
void umod32ByConstant(Register src, uint32_t divisor, Register dest, |
| 5774 |
Register scratch); |
| 5775 |
|
| 5776 |
template <typename GetTimeFn> |
| 5777 |
void dateTimeFromSecondsIntoYear(ValueOperand secondsIntoYear, |
| 5778 |
ValueOperand output, Register scratch1, |
| 5779 |
Register scratch2, GetTimeFn getTimeFn); |
| 5780 |
|
| 5781 |
public: |
| 5782 |
void dateHoursFromSecondsIntoYear(ValueOperand secondsIntoYear, |
| 5783 |
ValueOperand output, Register scratch1, |
| 5784 |
Register scratch2); |
| 5785 |
|
| 5786 |
void dateMinutesFromSecondsIntoYear(ValueOperand secondsIntoYear, |
| 5787 |
ValueOperand output, Register scratch1, |
| 5788 |
Register scratch2); |
| 5789 |
|
| 5790 |
void dateSecondsFromSecondsIntoYear(ValueOperand secondsIntoYear, |
| 5791 |
ValueOperand output, Register scratch1, |
| 5792 |
Register scratch2); |
| 5793 |
|
| 5794 |
void computeImplicitThis(Register env, ValueOperand output, Label* slowPath); |
| 5795 |
|
| 5796 |
private: |
| 5797 |
void isCallableOrConstructor(bool isCallable, Register obj, Register output, |
| 5798 |
Label* isProxy); |
| 5799 |
|
| 5800 |
public: |
| 5801 |
// Generates code used to complete a bailout. |
| 5802 |
void generateBailoutTail(Register scratch, Register bailoutInfo); |
| 5803 |
|
| 5804 |
public: |
| 5805 |
#ifndef JS_CODEGEN_ARM64 |
| 5806 |
// StackPointer manipulation functions. |
| 5807 |
// On ARM64, the StackPointer is implemented as two synchronized registers. |
| 5808 |
// Code shared across platforms must use these functions to be valid. |
| 5809 |
template <typename T> |
| 5810 |
inline void addToStackPtr(T t); |
| 5811 |
template <typename T> |
| 5812 |
inline void addStackPtrTo(T t); |
| 5813 |
|
| 5814 |
void subFromStackPtr(Imm32 imm32) |
| 5815 |
DEFINED_ON(mips64, loong64, riscv64, wasm32, arm, x86, x64); |
| 5816 |
void subFromStackPtr(Register reg); |
| 5817 |
|
| 5818 |
template <typename T> |
| 5819 |
void subStackPtrFrom(T t) { |
| 5820 |
subPtr(getStackPointer(), t); |
| 5821 |
} |
| 5822 |
|
| 5823 |
template <typename T> |
| 5824 |
void andToStackPtr(T t) { |
| 5825 |
andPtr(t, getStackPointer()); |
| 5826 |
} |
| 5827 |
|
| 5828 |
template <typename T> |
| 5829 |
void moveToStackPtr(T t) { |
| 5830 |
movePtr(t, getStackPointer()); |
| 5831 |
} |
| 5832 |
template <typename T> |
| 5833 |
void moveStackPtrTo(T t) { |
| 5834 |
movePtr(getStackPointer(), t); |
| 5835 |
} |
| 5836 |
|
| 5837 |
template <typename T> |
| 5838 |
void loadStackPtr(T t) { |
| 5839 |
loadPtr(t, getStackPointer()); |
| 5840 |
} |
| 5841 |
template <typename T> |
| 5842 |
void storeStackPtr(T t) { |
| 5843 |
storePtr(getStackPointer(), t); |
| 5844 |
} |
| 5845 |
|
| 5846 |
// StackPointer testing functions. |
| 5847 |
// On ARM64, sp can function as the zero register depending on context. |
| 5848 |
// Code shared across platforms must use these functions to be valid. |
| 5849 |
template <typename T> |
| 5850 |
inline void branchTestStackPtr(Condition cond, T t, Label* label); |
| 5851 |
template <typename T> |
| 5852 |
inline void branchStackPtr(Condition cond, T rhs, Label* label); |
| 5853 |
template <typename T> |
| 5854 |
inline void branchStackPtrRhs(Condition cond, T lhs, Label* label); |
| 5855 |
|
| 5856 |
// Move the stack pointer based on the requested amount. |
| 5857 |
inline void reserveStack(uint32_t amount); |
| 5858 |
#else // !JS_CODEGEN_ARM64 |
| 5859 |
void reserveStack(uint32_t amount); |
| 5860 |
#endif |
| 5861 |
|
| 5862 |
public: |
| 5863 |
void enableProfilingInstrumentation() { |
| 5864 |
emitProfilingInstrumentation_ = true; |
| 5865 |
} |
| 5866 |
|
| 5867 |
private: |
| 5868 |
// This class is used to surround call sites throughout the assembler. This |
| 5869 |
// is used by callWithABI, and callJit functions, except if suffixed by |
| 5870 |
// NoProfiler. |
| 5871 |
class MOZ_RAII AutoProfilerCallInstrumentation { |
| 5872 |
public: |
| 5873 |
explicit AutoProfilerCallInstrumentation(MacroAssembler& masm); |
| 5874 |
~AutoProfilerCallInstrumentation() = default; |
| 5875 |
}; |
| 5876 |
friend class AutoProfilerCallInstrumentation; |
| 5877 |
|
| 5878 |
void appendProfilerCallSite(CodeOffset label) { |
| 5879 |
propagateOOM(profilerCallSites_.append(label)); |
| 5880 |
} |
| 5881 |
|
| 5882 |
// Fix up the code pointers to be written for locations where profilerCallSite |
| 5883 |
// emitted moves of RIP to a register. |
| 5884 |
void linkProfilerCallSites(JitCode* code); |
| 5885 |
|
| 5886 |
// This field is used to manage profiling instrumentation output. If |
| 5887 |
// provided and enabled, then instrumentation will be emitted around call |
| 5888 |
// sites. |
| 5889 |
bool emitProfilingInstrumentation_; |
| 5890 |
|
| 5891 |
// Record locations of the call sites. |
| 5892 |
Vector<CodeOffset, 0, SystemAllocPolicy> profilerCallSites_; |
| 5893 |
|
| 5894 |
public: |
| 5895 |
void loadJitCodeRaw(Register func, Register dest); |
| 5896 |
void loadBaselineJitCodeRaw(Register func, Register dest, |
| 5897 |
Label* failure = nullptr); |
| 5898 |
void storeICScriptInJSContext(Register icScript); |
| 5899 |
|
| 5900 |
void loadBaselineFramePtr(Register framePtr, Register dest); |
| 5901 |
|
| 5902 |
void pushBaselineFramePtr(Register framePtr, Register scratch) { |
| 5903 |
loadBaselineFramePtr(framePtr, scratch); |
| 5904 |
push(scratch); |
| 5905 |
} |
| 5906 |
|
| 5907 |
void PushBaselineFramePtr(Register framePtr, Register scratch) { |
| 5908 |
loadBaselineFramePtr(framePtr, scratch); |
| 5909 |
Push(scratch); |
| 5910 |
} |
| 5911 |
|
| 5912 |
using MacroAssemblerSpecific::movePtr; |
| 5913 |
|
| 5914 |
void movePtr(TrampolinePtr ptr, Register dest) { |
| 5915 |
movePtr(ImmPtr(ptr.value), dest); |
| 5916 |
} |
| 5917 |
|
| 5918 |
private: |
| 5919 |
void handleFailure(); |
| 5920 |
|
| 5921 |
public: |
| 5922 |
Label* exceptionLabel() { |
| 5923 |
// Exceptions are currently handled the same way as sequential failures. |
| 5924 |
return &failureLabel_; |
| 5925 |
} |
| 5926 |
|
| 5927 |
Label* failureLabel() { return &failureLabel_; } |
| 5928 |
|
| 5929 |
void finish(); |
| 5930 |
void link(JitCode* code); |
| 5931 |
|
| 5932 |
void assumeUnreachable(const char* output); |
| 5933 |
|
| 5934 |
void printf(const char* output); |
| 5935 |
void printf(const char* output, Register value); |
| 5936 |
|
| 5937 |
void outOfLineTruncateSlow(FloatRegister src, Register dest, |
| 5938 |
bool widenFloatToDouble, bool compilingWasm, |
| 5939 |
wasm::BytecodeOffset callOffset); |
| 5940 |
|
| 5941 |
void convertInt32ValueToDouble(ValueOperand val); |
| 5942 |
|
| 5943 |
private: |
| 5944 |
enum class FloatingPointType { Double, Float32, Float16 }; |
| 5945 |
|
| 5946 |
void convertValueToFloatingPoint(ValueOperand value, FloatRegister output, |
| 5947 |
Register maybeTemp, |
| 5948 |
LiveRegisterSet volatileLiveRegs, |
| 5949 |
Label* fail, FloatingPointType outputType); |
| 5950 |
|
| 5951 |
public: |
| 5952 |
void convertValueToDouble(ValueOperand value, FloatRegister output, |
| 5953 |
Label* fail) { |
| 5954 |
convertValueToFloatingPoint(value, output, InvalidReg, LiveRegisterSet{}, |
| 5955 |
fail, FloatingPointType::Double); |
| 5956 |
} |
| 5957 |
|
| 5958 |
void convertValueToFloat32(ValueOperand value, FloatRegister output, |
| 5959 |
Label* fail) { |
| 5960 |
convertValueToFloatingPoint(value, output, InvalidReg, LiveRegisterSet{}, |
| 5961 |
fail, FloatingPointType::Float32); |
| 5962 |
} |
| 5963 |
|
| 5964 |
void convertValueToFloat16(ValueOperand value, FloatRegister output, |
| 5965 |
Register maybeTemp, |
| 5966 |
LiveRegisterSet volatileLiveRegs, Label* fail) { |
| 5967 |
convertValueToFloatingPoint(value, output, maybeTemp, volatileLiveRegs, |
| 5968 |
fail, FloatingPointType::Float16); |
| 5969 |
} |
| 5970 |
|
| 5971 |
// |
| 5972 |
// Functions for converting values to int. |
| 5973 |
// |
| 5974 |
|
| 5975 |
// This carries over the MToNumberInt32 operation on the ValueOperand |
| 5976 |
// input; see comment at the top of this class. |
| 5977 |
void convertValueToInt32(ValueOperand value, FloatRegister temp, |
| 5978 |
Register output, Label* fail, bool negativeZeroCheck, |
| 5979 |
IntConversionInputKind conversion); |
| 5980 |
|
| 5981 |
// This carries over the MTruncateToInt32 operation on the ValueOperand |
| 5982 |
// input; see the comment at the top of this class. |
| 5983 |
// |
| 5984 |
// Strings may be handled by providing labels to jump to. The subroutine, |
| 5985 |
// usually an OOL call, is passed the unboxed string in |stringReg| and should |
| 5986 |
// convert it to a double store into |temp|. |
| 5987 |
void truncateValueToInt32(ValueOperand value, Label* handleStringEntry, |
| 5988 |
Label* handleStringRejoin, |
| 5989 |
Label* truncateDoubleSlow, Register stringReg, |
| 5990 |
FloatRegister temp, Register output, Label* fail); |
| 5991 |
|
| 5992 |
void truncateValueToInt32(ValueOperand value, FloatRegister temp, |
| 5993 |
Register output, Label* fail) { |
| 5994 |
truncateValueToInt32(value, nullptr, nullptr, nullptr, InvalidReg, temp, |
| 5995 |
output, fail); |
| 5996 |
} |
| 5997 |
|
| 5998 |
// Convenience functions for clamping values to uint8. |
| 5999 |
// |
| 6000 |
// Strings are handled by providing labels to jump to. The subroutine, usually |
| 6001 |
// an OOL call, is passed the unboxed string in |stringReg| and should convert |
| 6002 |
// it to a double store into |temp|. |
| 6003 |
void clampValueToUint8(ValueOperand value, Label* handleStringEntry, |
| 6004 |
Label* handleStringRejoin, Register stringReg, |
| 6005 |
FloatRegister temp, Register output, Label* fail); |
| 6006 |
|
| 6007 |
[[nodiscard]] bool icBuildOOLFakeExitFrame(void* fakeReturnAddr, |
| 6008 |
AutoSaveLiveRegisters& save); |
| 6009 |
|
| 6010 |
// Align the stack pointer based on the number of arguments which are pushed |
| 6011 |
// on the stack, such that the JitFrameLayout would be correctly aligned on |
| 6012 |
// the JitStackAlignment. |
| 6013 |
void alignJitStackBasedOnNArgs(Register nargs, bool countIncludesThis); |
| 6014 |
void alignJitStackBasedOnNArgs(uint32_t argc, bool countIncludesThis); |
| 6015 |
|
| 6016 |
inline void assertStackAlignment(uint32_t alignment, int32_t offset = 0); |
| 6017 |
|
| 6018 |
void touchFrameValues(Register numStackValues, Register scratch1, |
| 6019 |
Register scratch2); |
| 6020 |
|
| 6021 |
#ifdef JS_64BIT |
| 6022 |
// See comment block "64-bit GPRs carrying 32-bit values" above. This asserts |
| 6023 |
// that the high bits of the register are appropriate for the architecture and |
| 6024 |
// the value in the low bits. |
| 6025 |
void debugAssertCanonicalInt32(Register r); |
| 6026 |
#endif |
| 6027 |
|
| 6028 |
#ifdef FUZZING_JS_FUZZILLI |
| 6029 |
void fuzzilliHashDouble(FloatRegister src, Register result, Register temp); |
| 6030 |
|
| 6031 |
void fuzzilliStoreHash(Register value, Register temp1, Register temp2); |
| 6032 |
#endif |
| 6033 |
}; |
| 6034 |
|
| 6035 |
// StackMacroAssembler checks no GC will happen while it's on the stack. |
| 6036 |
class MOZ_RAII StackMacroAssembler : public MacroAssembler { |
| 6037 |
JS::AutoCheckCannotGC nogc; |
| 6038 |
|
| 6039 |
public: |
| 6040 |
StackMacroAssembler(JSContext* cx, TempAllocator& alloc); |
| 6041 |
}; |
| 6042 |
|
| 6043 |
// WasmMacroAssembler does not contain GC pointers, so it doesn't need the no-GC |
| 6044 |
// checking StackMacroAssembler has. |
| 6045 |
class MOZ_RAII WasmMacroAssembler : public MacroAssembler { |
| 6046 |
public: |
| 6047 |
explicit WasmMacroAssembler(TempAllocator& alloc, bool limitedSize = true); |
| 6048 |
~WasmMacroAssembler() { assertNoGCThings(); } |
| 6049 |
}; |
| 6050 |
|
| 6051 |
// Heap-allocated MacroAssembler used for off-thread code generation. |
| 6052 |
// GC cancels off-thread compilations. |
| 6053 |
class OffThreadMacroAssembler : public MacroAssembler { |
| 6054 |
public: |
| 6055 |
OffThreadMacroAssembler(TempAllocator& alloc, CompileRealm* realm); |
| 6056 |
}; |
| 6057 |
|
| 6058 |
//{{{ check_macroassembler_style |
| 6059 |
inline uint32_t MacroAssembler::framePushed() const { return framePushed_; } |
| 6060 |
|
| 6061 |
inline void MacroAssembler::setFramePushed(uint32_t framePushed) { |
| 6062 |
framePushed_ = framePushed; |
| 6063 |
} |
| 6064 |
|
| 6065 |
inline void MacroAssembler::adjustFrame(int32_t value) { |
| 6066 |
MOZ_ASSERT_IF(value < 0, framePushed_ >= uint32_t(-value)); |
| 6067 |
setFramePushed(framePushed_ + value); |
| 6068 |
} |
| 6069 |
|
| 6070 |
inline void MacroAssembler::implicitPop(uint32_t bytes) { |
| 6071 |
MOZ_ASSERT(bytes % sizeof(intptr_t) == 0); |
| 6072 |
MOZ_ASSERT(bytes <= INT32_MAX); |
| 6073 |
adjustFrame(-int32_t(bytes)); |
| 6074 |
} |
| 6075 |
//}}} check_macroassembler_style |
| 6076 |
|
| 6077 |
static inline Assembler::DoubleCondition JSOpToDoubleCondition(JSOp op) { |
| 6078 |
switch (op) { |
| 6079 |
case JSOp::Eq: |
| 6080 |
case JSOp::StrictEq: |
| 6081 |
return Assembler::DoubleEqual; |
| 6082 |
case JSOp::Ne: |
| 6083 |
case JSOp::StrictNe: |
| 6084 |
return Assembler::DoubleNotEqualOrUnordered; |
| 6085 |
case JSOp::Lt: |
| 6086 |
return Assembler::DoubleLessThan; |
| 6087 |
case JSOp::Le: |
| 6088 |
return Assembler::DoubleLessThanOrEqual; |
| 6089 |
case JSOp::Gt: |
| 6090 |
return Assembler::DoubleGreaterThan; |
| 6091 |
case JSOp::Ge: |
| 6092 |
return Assembler::DoubleGreaterThanOrEqual; |
| 6093 |
default: |
| 6094 |
MOZ_CRASH("Unexpected comparison operation"); |
| 6095 |
} |
| 6096 |
} |
| 6097 |
|
| 6098 |
// Note: the op may have been inverted during lowering (to put constants in a |
| 6099 |
// position where they can be immediates), so it is important to use the |
| 6100 |
// lir->jsop() instead of the mir->jsop() when it is present. |
| 6101 |
static inline Assembler::Condition JSOpToCondition(JSOp op, bool isSigned) { |
| 6102 |
if (isSigned) { |
| 6103 |
switch (op) { |
| 6104 |
case JSOp::Eq: |
| 6105 |
case JSOp::StrictEq: |
| 6106 |
return Assembler::Equal; |
| 6107 |
case JSOp::Ne: |
| 6108 |
case JSOp::StrictNe: |
| 6109 |
return Assembler::NotEqual; |
| 6110 |
case JSOp::Lt: |
| 6111 |
return Assembler::LessThan; |
| 6112 |
case JSOp::Le: |
| 6113 |
return Assembler::LessThanOrEqual; |
| 6114 |
case JSOp::Gt: |
| 6115 |
return Assembler::GreaterThan; |
| 6116 |
case JSOp::Ge: |
| 6117 |
return Assembler::GreaterThanOrEqual; |
| 6118 |
default: |
| 6119 |
MOZ_CRASH("Unrecognized comparison operation"); |
| 6120 |
} |
| 6121 |
} else { |
| 6122 |
switch (op) { |
| 6123 |
case JSOp::Eq: |
| 6124 |
case JSOp::StrictEq: |
| 6125 |
return Assembler::Equal; |
| 6126 |
case JSOp::Ne: |
| 6127 |
case JSOp::StrictNe: |
| 6128 |
return Assembler::NotEqual; |
| 6129 |
case JSOp::Lt: |
| 6130 |
return Assembler::Below; |
| 6131 |
case JSOp::Le: |
| 6132 |
return Assembler::BelowOrEqual; |
| 6133 |
case JSOp::Gt: |
| 6134 |
return Assembler::Above; |
| 6135 |
case JSOp::Ge: |
| 6136 |
return Assembler::AboveOrEqual; |
| 6137 |
default: |
| 6138 |
MOZ_CRASH("Unrecognized comparison operation"); |
| 6139 |
} |
| 6140 |
} |
| 6141 |
} |
| 6142 |
|
| 6143 |
static inline size_t StackDecrementForCall(uint32_t alignment, |
| 6144 |
size_t bytesAlreadyPushed, |
| 6145 |
size_t bytesToPush) { |
| 6146 |
return bytesToPush + |
| 6147 |
ComputeByteAlignment(bytesAlreadyPushed + bytesToPush, alignment); |
| 6148 |
} |
| 6149 |
|
| 6150 |
// Helper for generatePreBarrier. |
| 6151 |
inline DynFn JitPreWriteBarrier(MIRType type); |
| 6152 |
} // namespace jit |
| 6153 |
|
| 6154 |
} // namespace js |
| 6155 |
|
| 6156 |
#endif /* jit_MacroAssembler_h */ |