| 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_arm_MacroAssembler_arm_h |
| 8 |
#define jit_arm_MacroAssembler_arm_h |
| 9 |
|
| 10 |
#include "mozilla/DebugOnly.h" |
| 11 |
|
| 12 |
#include "jit/arm/Assembler-arm.h" |
| 13 |
#include "jit/MoveResolver.h" |
| 14 |
#include "vm/BytecodeUtil.h" |
| 15 |
#include "wasm/WasmBuiltins.h" |
| 16 |
#include "wasm/WasmCodegenTypes.h" |
| 17 |
|
| 18 |
using js::wasm::FaultingCodeOffsetPair; |
| 19 |
|
| 20 |
namespace js { |
| 21 |
namespace jit { |
| 22 |
|
| 23 |
static Register CallReg = ip; |
| 24 |
static const int defaultShift = 3; |
| 25 |
static_assert(1 << defaultShift == sizeof(JS::Value)); |
| 26 |
|
| 27 |
// See documentation for ScratchTagScope and ScratchTagScopeRelease in |
| 28 |
// MacroAssembler-x64.h. |
| 29 |
|
| 30 |
class ScratchTagScope { |
| 31 |
const ValueOperand& v_; |
| 32 |
|
| 33 |
public: |
| 34 |
ScratchTagScope(MacroAssembler&, const ValueOperand& v) : v_(v) {} |
| 35 |
operator Register() { return v_.typeReg(); } |
| 36 |
void release() {} |
| 37 |
void reacquire() {} |
| 38 |
}; |
| 39 |
|
| 40 |
class ScratchTagScopeRelease { |
| 41 |
public: |
| 42 |
explicit ScratchTagScopeRelease(ScratchTagScope*) {} |
| 43 |
}; |
| 44 |
|
| 45 |
// MacroAssemblerARM is inheriting form Assembler defined in |
| 46 |
// Assembler-arm.{h,cpp} |
| 47 |
class MacroAssemblerARM : public Assembler { |
| 48 |
private: |
| 49 |
// Perform a downcast. Should be removed by Bug 996602. |
| 50 |
MacroAssembler& asMasm(); |
| 51 |
const MacroAssembler& asMasm() const; |
| 52 |
|
| 53 |
protected: |
| 54 |
// On ARM, some instructions require a second scratch register. This |
| 55 |
// register defaults to lr, since it's non-allocatable (as it can be |
| 56 |
// clobbered by some instructions). Allow the baseline compiler to override |
| 57 |
// this though, since baseline IC stubs rely on lr holding the return |
| 58 |
// address. |
| 59 |
Register secondScratchReg_; |
| 60 |
|
| 61 |
public: |
| 62 |
Register getSecondScratchReg() const { return secondScratchReg_; } |
| 63 |
|
| 64 |
public: |
| 65 |
// Higher level tag testing code. |
| 66 |
// TODO: Can probably remove the Operand versions. |
| 67 |
Operand ToPayload(Operand base) const { |
| 68 |
return Operand(Register::FromCode(base.base()), base.disp()); |
| 69 |
} |
| 70 |
Address ToPayload(const Address& base) const { return base; } |
| 71 |
BaseIndex ToPayload(const BaseIndex& base) const { return base; } |
| 72 |
|
| 73 |
protected: |
| 74 |
Operand ToType(Operand base) const { |
| 75 |
return Operand(Register::FromCode(base.base()), |
| 76 |
base.disp() + sizeof(void*)); |
| 77 |
} |
| 78 |
Address ToType(const Address& base) const { |
| 79 |
return ToType(Operand(base)).toAddress(); |
| 80 |
} |
| 81 |
BaseIndex ToType(const BaseIndex& base) const { |
| 82 |
return BaseIndex(base.base, base.index, base.scale, |
| 83 |
base.offset + sizeof(void*)); |
| 84 |
} |
| 85 |
|
| 86 |
Address ToPayloadAfterStackPush(const Address& base) const { |
| 87 |
// If we are based on StackPointer, pass over the type tag just pushed. |
| 88 |
if (base.base == StackPointer) { |
| 89 |
return Address(base.base, base.offset + sizeof(void*)); |
| 90 |
} |
| 91 |
return ToPayload(base); |
| 92 |
} |
| 93 |
|
| 94 |
public: |
| 95 |
MacroAssemblerARM() : secondScratchReg_(lr) {} |
| 96 |
|
| 97 |
void setSecondScratchReg(Register reg) { |
| 98 |
MOZ_ASSERT(reg != ScratchRegister); |
| 99 |
secondScratchReg_ = reg; |
| 100 |
} |
| 101 |
|
| 102 |
void convertBoolToInt32(Register source, Register dest); |
| 103 |
void convertInt32ToDouble(Register src, FloatRegister dest); |
| 104 |
void convertInt32ToDouble(const Address& src, FloatRegister dest); |
| 105 |
void convertInt32ToDouble(const BaseIndex& src, FloatRegister dest); |
| 106 |
void convertUInt32ToFloat32(Register src, FloatRegister dest); |
| 107 |
void convertUInt32ToDouble(Register src, FloatRegister dest); |
| 108 |
void convertDoubleToFloat32(FloatRegister src, FloatRegister dest, |
| 109 |
Condition c = Always); |
| 110 |
void convertDoubleToInt32(FloatRegister src, Register dest, Label* fail, |
| 111 |
bool negativeZeroCheck = true); |
| 112 |
void convertDoubleToPtr(FloatRegister src, Register dest, Label* fail, |
| 113 |
bool negativeZeroCheck = true) { |
| 114 |
convertDoubleToInt32(src, dest, fail, negativeZeroCheck); |
| 115 |
} |
| 116 |
void convertFloat32ToInt32(FloatRegister src, Register dest, Label* fail, |
| 117 |
bool negativeZeroCheck = true); |
| 118 |
|
| 119 |
void convertFloat32ToDouble(FloatRegister src, FloatRegister dest); |
| 120 |
void convertInt32ToFloat32(Register src, FloatRegister dest); |
| 121 |
void convertInt32ToFloat32(const Address& src, FloatRegister dest); |
| 122 |
|
| 123 |
void convertDoubleToFloat16(FloatRegister src, FloatRegister dest) { |
| 124 |
MOZ_CRASH("Not supported for this target"); |
| 125 |
} |
| 126 |
void convertFloat16ToDouble(FloatRegister src, FloatRegister dest) { |
| 127 |
MOZ_CRASH("Not supported for this target"); |
| 128 |
} |
| 129 |
void convertFloat32ToFloat16(FloatRegister src, FloatRegister dest); |
| 130 |
void convertFloat16ToFloat32(FloatRegister src, FloatRegister dest); |
| 131 |
void convertInt32ToFloat16(Register src, FloatRegister dest); |
| 132 |
|
| 133 |
void wasmTruncateToInt32(FloatRegister input, Register output, |
| 134 |
MIRType fromType, bool isUnsigned, bool isSaturating, |
| 135 |
Label* oolEntry); |
| 136 |
void outOfLineWasmTruncateToIntCheck(FloatRegister input, MIRType fromType, |
| 137 |
MIRType toType, TruncFlags flags, |
| 138 |
Label* rejoin, |
| 139 |
const wasm::TrapSiteDesc& trapSiteDesc); |
| 140 |
|
| 141 |
// Somewhat direct wrappers for the low-level assembler funcitons |
| 142 |
// bitops. Attempt to encode a virtual alu instruction using two real |
| 143 |
// instructions. |
| 144 |
private: |
| 145 |
bool alu_dbl(Register src1, Imm32 imm, Register dest, ALUOp op, SBit s, |
| 146 |
Condition c); |
| 147 |
|
| 148 |
public: |
| 149 |
void ma_alu(Register src1, Imm32 imm, Register dest, |
| 150 |
AutoRegisterScope& scratch, ALUOp op, SBit s = LeaveCC, |
| 151 |
Condition c = Always); |
| 152 |
void ma_alu(Register src1, Operand2 op2, Register dest, ALUOp op, |
| 153 |
SBit s = LeaveCC, Condition c = Always); |
| 154 |
void ma_alu(Register src1, Operand op2, Register dest, ALUOp op, |
| 155 |
SBit s = LeaveCC, Condition c = Always); |
| 156 |
void ma_nop(); |
| 157 |
|
| 158 |
BufferOffset ma_movPatchable(Imm32 imm, Register dest, |
| 159 |
Assembler::Condition c); |
| 160 |
BufferOffset ma_movPatchable(ImmPtr imm, Register dest, |
| 161 |
Assembler::Condition c); |
| 162 |
|
| 163 |
// To be used with Iter := InstructionIterator or BufferInstructionIterator. |
| 164 |
template <class Iter> |
| 165 |
static void ma_mov_patch(Imm32 imm, Register dest, Assembler::Condition c, |
| 166 |
RelocStyle rs, Iter iter); |
| 167 |
|
| 168 |
// ALU based ops |
| 169 |
// mov |
| 170 |
void ma_mov(Register src, Register dest, SBit s = LeaveCC, |
| 171 |
Condition c = Always); |
| 172 |
|
| 173 |
void ma_mov(Imm32 imm, Register dest, Condition c = Always); |
| 174 |
void ma_mov(ImmWord imm, Register dest, Condition c = Always); |
| 175 |
|
| 176 |
void ma_mov(ImmGCPtr ptr, Register dest); |
| 177 |
|
| 178 |
// Shifts (just a move with a shifting op2) |
| 179 |
void ma_lsl(Imm32 shift, Register src, Register dst); |
| 180 |
void ma_lsr(Imm32 shift, Register src, Register dst); |
| 181 |
void ma_asr(Imm32 shift, Register src, Register dst); |
| 182 |
void ma_ror(Imm32 shift, Register src, Register dst); |
| 183 |
void ma_rol(Imm32 shift, Register src, Register dst); |
| 184 |
|
| 185 |
void ma_lsl(Register shift, Register src, Register dst); |
| 186 |
void ma_lsr(Register shift, Register src, Register dst); |
| 187 |
void ma_asr(Register shift, Register src, Register dst); |
| 188 |
void ma_ror(Register shift, Register src, Register dst); |
| 189 |
void ma_rol(Register shift, Register src, Register dst, |
| 190 |
AutoRegisterScope& scratch); |
| 191 |
|
| 192 |
// Move not (dest <- ~src) |
| 193 |
void ma_mvn(Register src1, Register dest, SBit s = LeaveCC, |
| 194 |
Condition c = Always); |
| 195 |
|
| 196 |
// Negate (dest <- -src) implemented as rsb dest, src, 0 |
| 197 |
void ma_neg(Register src, Register dest, SBit s = LeaveCC, |
| 198 |
Condition c = Always); |
| 199 |
|
| 200 |
void ma_neg(Register64 src, Register64 dest); |
| 201 |
|
| 202 |
// And |
| 203 |
void ma_and(Register src, Register dest, SBit s = LeaveCC, |
| 204 |
Condition c = Always); |
| 205 |
|
| 206 |
void ma_and(Register src1, Register src2, Register dest, SBit s = LeaveCC, |
| 207 |
Condition c = Always); |
| 208 |
|
| 209 |
void ma_and(Imm32 imm, Register dest, AutoRegisterScope& scratch, |
| 210 |
SBit s = LeaveCC, Condition c = Always); |
| 211 |
|
| 212 |
void ma_and(Imm32 imm, Register src1, Register dest, |
| 213 |
AutoRegisterScope& scratch, SBit s = LeaveCC, |
| 214 |
Condition c = Always); |
| 215 |
|
| 216 |
// Bit clear (dest <- dest & ~imm) or (dest <- src1 & ~src2) |
| 217 |
void ma_bic(Imm32 imm, Register dest, AutoRegisterScope& scratch, |
| 218 |
SBit s = LeaveCC, Condition c = Always); |
| 219 |
|
| 220 |
// Exclusive or |
| 221 |
void ma_eor(Register src, Register dest, SBit s = LeaveCC, |
| 222 |
Condition c = Always); |
| 223 |
|
| 224 |
void ma_eor(Register src1, Register src2, Register dest, SBit s = LeaveCC, |
| 225 |
Condition c = Always); |
| 226 |
|
| 227 |
void ma_eor(Imm32 imm, Register dest, AutoRegisterScope& scratch, |
| 228 |
SBit s = LeaveCC, Condition c = Always); |
| 229 |
|
| 230 |
void ma_eor(Imm32 imm, Register src1, Register dest, |
| 231 |
AutoRegisterScope& scratch, SBit s = LeaveCC, |
| 232 |
Condition c = Always); |
| 233 |
|
| 234 |
// Or |
| 235 |
void ma_orr(Register src, Register dest, SBit s = LeaveCC, |
| 236 |
Condition c = Always); |
| 237 |
|
| 238 |
void ma_orr(Register src1, Register src2, Register dest, SBit s = LeaveCC, |
| 239 |
Condition c = Always); |
| 240 |
|
| 241 |
void ma_orr(Imm32 imm, Register dest, AutoRegisterScope& scratch, |
| 242 |
SBit s = LeaveCC, Condition c = Always); |
| 243 |
|
| 244 |
void ma_orr(Imm32 imm, Register src1, Register dest, |
| 245 |
AutoRegisterScope& scratch, SBit s = LeaveCC, |
| 246 |
Condition c = Always); |
| 247 |
|
| 248 |
// Arithmetic based ops. |
| 249 |
// Add with carry: |
| 250 |
void ma_adc(Imm32 imm, Register dest, AutoRegisterScope& scratch, |
| 251 |
SBit s = LeaveCC, Condition c = Always); |
| 252 |
void ma_adc(Register src, Register dest, SBit s = LeaveCC, |
| 253 |
Condition c = Always); |
| 254 |
void ma_adc(Register src1, Register src2, Register dest, SBit s = LeaveCC, |
| 255 |
Condition c = Always); |
| 256 |
void ma_adc(Register src1, Imm32 op, Register dest, |
| 257 |
AutoRegisterScope& scratch, SBit s = LeaveCC, |
| 258 |
Condition c = Always); |
| 259 |
|
| 260 |
// Add: |
| 261 |
void ma_add(Imm32 imm, Register dest, AutoRegisterScope& scratch, |
| 262 |
SBit s = LeaveCC, Condition c = Always); |
| 263 |
void ma_add(Register src1, Register dest, SBit s = LeaveCC, |
| 264 |
Condition c = Always); |
| 265 |
void ma_add(Register src1, Register src2, Register dest, SBit s = LeaveCC, |
| 266 |
Condition c = Always); |
| 267 |
void ma_add(Register src1, Operand op, Register dest, SBit s = LeaveCC, |
| 268 |
Condition c = Always); |
| 269 |
void ma_add(Register src1, Imm32 op, Register dest, |
| 270 |
AutoRegisterScope& scratch, SBit s = LeaveCC, |
| 271 |
Condition c = Always); |
| 272 |
|
| 273 |
// Subtract with carry: |
| 274 |
void ma_sbc(Imm32 imm, Register dest, AutoRegisterScope& scratch, |
| 275 |
SBit s = LeaveCC, Condition c = Always); |
| 276 |
void ma_sbc(Register src1, Register dest, SBit s = LeaveCC, |
| 277 |
Condition c = Always); |
| 278 |
void ma_sbc(Register src1, Register src2, Register dest, SBit s = LeaveCC, |
| 279 |
Condition c = Always); |
| 280 |
|
| 281 |
// Subtract: |
| 282 |
void ma_sub(Imm32 imm, Register dest, AutoRegisterScope& scratch, |
| 283 |
SBit s = LeaveCC, Condition c = Always); |
| 284 |
void ma_sub(Register src1, Register dest, SBit s = LeaveCC, |
| 285 |
Condition c = Always); |
| 286 |
void ma_sub(Register src1, Register src2, Register dest, SBit s = LeaveCC, |
| 287 |
Condition c = Always); |
| 288 |
void ma_sub(Register src1, Operand op, Register dest, SBit s = LeaveCC, |
| 289 |
Condition c = Always); |
| 290 |
void ma_sub(Register src1, Imm32 op, Register dest, |
| 291 |
AutoRegisterScope& scratch, SBit s = LeaveCC, |
| 292 |
Condition c = Always); |
| 293 |
|
| 294 |
// Reverse subtract: |
| 295 |
void ma_rsb(Imm32 imm, Register dest, AutoRegisterScope& scratch, |
| 296 |
SBit s = LeaveCC, Condition c = Always); |
| 297 |
void ma_rsb(Register src1, Register dest, SBit s = LeaveCC, |
| 298 |
Condition c = Always); |
| 299 |
void ma_rsb(Register src1, Register src2, Register dest, SBit s = LeaveCC, |
| 300 |
Condition c = Always); |
| 301 |
void ma_rsb(Register src1, Imm32 op2, Register dest, |
| 302 |
AutoRegisterScope& scratch, SBit s = LeaveCC, |
| 303 |
Condition c = Always); |
| 304 |
|
| 305 |
// Reverse subtract with carry: |
| 306 |
void ma_rsc(Imm32 imm, Register dest, AutoRegisterScope& scratch, |
| 307 |
SBit s = LeaveCC, Condition c = Always); |
| 308 |
void ma_rsc(Register src1, Register dest, SBit s = LeaveCC, |
| 309 |
Condition c = Always); |
| 310 |
void ma_rsc(Register src1, Register src2, Register dest, SBit s = LeaveCC, |
| 311 |
Condition c = Always); |
| 312 |
|
| 313 |
// Compares/tests. |
| 314 |
// Compare negative (sets condition codes as src1 + src2 would): |
| 315 |
void ma_cmn(Register src1, Imm32 imm, AutoRegisterScope& scratch, |
| 316 |
Condition c = Always); |
| 317 |
void ma_cmn(Register src1, Register src2, Condition c = Always); |
| 318 |
void ma_cmn(Register src1, Operand op, Condition c = Always); |
| 319 |
|
| 320 |
// Compare (src - src2): |
| 321 |
void ma_cmp(Register src1, Imm32 imm, AutoRegisterScope& scratch, |
| 322 |
Condition c = Always); |
| 323 |
void ma_cmp(Register src1, ImmTag tag, Condition c = Always); |
| 324 |
void ma_cmp(Register src1, ImmWord ptr, AutoRegisterScope& scratch, |
| 325 |
Condition c = Always); |
| 326 |
void ma_cmp(Register src1, ImmGCPtr ptr, AutoRegisterScope& scratch, |
| 327 |
Condition c = Always); |
| 328 |
void ma_cmp(Register src1, Operand op, AutoRegisterScope& scratch, |
| 329 |
AutoRegisterScope& scratch2, Condition c = Always); |
| 330 |
void ma_cmp(Register src1, Register src2, Condition c = Always); |
| 331 |
|
| 332 |
// Test for equality, (src1 ^ src2): |
| 333 |
void ma_teq(Register src1, Imm32 imm, AutoRegisterScope& scratch, |
| 334 |
Condition c = Always); |
| 335 |
void ma_teq(Register src1, Register src2, Condition c = Always); |
| 336 |
void ma_teq(Register src1, Operand op, Condition c = Always); |
| 337 |
|
| 338 |
// Test (src1 & src2): |
| 339 |
void ma_tst(Register src1, Imm32 imm, AutoRegisterScope& scratch, |
| 340 |
Condition c = Always); |
| 341 |
void ma_tst(Register src1, Register src2, Condition c = Always); |
| 342 |
void ma_tst(Register src1, Operand op, Condition c = Always); |
| 343 |
|
| 344 |
// Multiplies. For now, there are only two that we care about. |
| 345 |
void ma_mul(Register src1, Register src2, Register dest); |
| 346 |
void ma_mul(Register src1, Imm32 imm, Register dest, |
| 347 |
AutoRegisterScope& scratch); |
| 348 |
Condition ma_check_mul(Register src1, Register src2, Register dest, |
| 349 |
AutoRegisterScope& scratch, Condition cond); |
| 350 |
Condition ma_check_mul(Register src1, Imm32 imm, Register dest, |
| 351 |
AutoRegisterScope& scratch, Condition cond); |
| 352 |
|
| 353 |
void ma_umull(Register src1, Imm32 imm, Register destHigh, Register destLow, |
| 354 |
AutoRegisterScope& scratch); |
| 355 |
void ma_umull(Register src1, Register src2, Register destHigh, |
| 356 |
Register destLow); |
| 357 |
|
| 358 |
// Fast mod, uses scratch registers, and thus needs to be in the assembler |
| 359 |
// implicitly assumes that we can overwrite dest at the beginning of the |
| 360 |
// sequence. |
| 361 |
void ma_mod_mask(Register src, Register dest, Register hold, Register tmp, |
| 362 |
AutoRegisterScope& scratch, AutoRegisterScope& scratch2, |
| 363 |
int32_t shift); |
| 364 |
|
| 365 |
// Mod - depends on integer divide instructions being supported. |
| 366 |
void ma_smod(Register num, Register div, Register dest, |
| 367 |
AutoRegisterScope& scratch); |
| 368 |
void ma_umod(Register num, Register div, Register dest, |
| 369 |
AutoRegisterScope& scratch); |
| 370 |
|
| 371 |
// Division - depends on integer divide instructions being supported. |
| 372 |
void ma_sdiv(Register num, Register div, Register dest, |
| 373 |
Condition cond = Always); |
| 374 |
void ma_udiv(Register num, Register div, Register dest, |
| 375 |
Condition cond = Always); |
| 376 |
// Misc operations |
| 377 |
void ma_clz(Register src, Register dest, Condition cond = Always); |
| 378 |
void ma_ctz(Register src, Register dest, AutoRegisterScope& scratch); |
| 379 |
// Memory: |
| 380 |
// Shortcut for when we know we're transferring 32 bits of data. |
| 381 |
void ma_dtr(LoadStore ls, Register rn, Imm32 offset, Register rt, |
| 382 |
AutoRegisterScope& scratch, Index mode = Offset, |
| 383 |
Condition cc = Always); |
| 384 |
FaultingCodeOffset ma_dtr(LoadStore ls, Register rt, const Address& addr, |
| 385 |
AutoRegisterScope& scratch, Index mode, |
| 386 |
Condition cc); |
| 387 |
|
| 388 |
FaultingCodeOffset ma_str(Register rt, DTRAddr addr, Index mode = Offset, |
| 389 |
Condition cc = Always); |
| 390 |
FaultingCodeOffset ma_str(Register rt, const Address& addr, |
| 391 |
AutoRegisterScope& scratch, Index mode = Offset, |
| 392 |
Condition cc = Always); |
| 393 |
|
| 394 |
FaultingCodeOffset ma_ldr(DTRAddr addr, Register rt, Index mode = Offset, |
| 395 |
Condition cc = Always); |
| 396 |
FaultingCodeOffset ma_ldr(const Address& addr, Register rt, |
| 397 |
AutoRegisterScope& scratch, Index mode = Offset, |
| 398 |
Condition cc = Always); |
| 399 |
|
| 400 |
FaultingCodeOffset ma_ldrb(DTRAddr addr, Register rt, Index mode = Offset, |
| 401 |
Condition cc = Always); |
| 402 |
FaultingCodeOffset ma_ldrh(EDtrAddr addr, Register rt, Index mode = Offset, |
| 403 |
Condition cc = Always); |
| 404 |
FaultingCodeOffset ma_ldrsh(EDtrAddr addr, Register rt, Index mode = Offset, |
| 405 |
Condition cc = Always); |
| 406 |
FaultingCodeOffset ma_ldrsb(EDtrAddr addr, Register rt, Index mode = Offset, |
| 407 |
Condition cc = Always); |
| 408 |
void ma_ldrd(EDtrAddr addr, Register rt, mozilla::DebugOnly<Register> rt2, |
| 409 |
Index mode = Offset, Condition cc = Always); |
| 410 |
FaultingCodeOffset ma_strb(Register rt, DTRAddr addr, Index mode = Offset, |
| 411 |
Condition cc = Always); |
| 412 |
FaultingCodeOffset ma_strh(Register rt, EDtrAddr addr, Index mode = Offset, |
| 413 |
Condition cc = Always); |
| 414 |
void ma_strd(Register rt, mozilla::DebugOnly<Register> rt2, EDtrAddr addr, |
| 415 |
Index mode = Offset, Condition cc = Always); |
| 416 |
|
| 417 |
// Specialty for moving N bits of data, where n == 8,16,32,64. |
| 418 |
BufferOffset ma_dataTransferN(LoadStore ls, int size, bool IsSigned, |
| 419 |
Register rn, Register rm, Register rt, |
| 420 |
AutoRegisterScope& scratch, Index mode = Offset, |
| 421 |
Condition cc = Always, Scale scale = TimesOne); |
| 422 |
|
| 423 |
BufferOffset ma_dataTransferN(LoadStore ls, int size, bool IsSigned, |
| 424 |
Register rn, Register rm, Register rt, |
| 425 |
Index mode = Offset, Condition cc = Always); |
| 426 |
|
| 427 |
BufferOffset ma_dataTransferN(LoadStore ls, int size, bool IsSigned, |
| 428 |
Register rn, Imm32 offset, Register rt, |
| 429 |
AutoRegisterScope& scratch, Index mode = Offset, |
| 430 |
Condition cc = Always); |
| 431 |
|
| 432 |
void ma_pop(Register r); |
| 433 |
void ma_popn_pc(Imm32 n, AutoRegisterScope& scratch, |
| 434 |
AutoRegisterScope& scratch2); |
| 435 |
void ma_push(Register r); |
| 436 |
void ma_push_sp(Register r, AutoRegisterScope& scratch); |
| 437 |
|
| 438 |
void ma_vpop(VFPRegister r); |
| 439 |
void ma_vpush(VFPRegister r); |
| 440 |
|
| 441 |
// Barriers. |
| 442 |
void ma_dmb(BarrierOption option = BarrierSY); |
| 443 |
void ma_dsb(BarrierOption option = BarrierSY); |
| 444 |
|
| 445 |
// Branches when done from within arm-specific code. |
| 446 |
BufferOffset ma_b(Label* dest, Condition c = Always); |
| 447 |
void ma_b(void* target, Condition c = Always); |
| 448 |
void ma_bx(Register dest, Condition c = Always); |
| 449 |
|
| 450 |
// This is almost NEVER necessary, we'll basically never be calling a label |
| 451 |
// except, possibly in the crazy bailout-table case. |
| 452 |
void ma_bl(Label* dest, Condition c = Always); |
| 453 |
|
| 454 |
void ma_blx(Register dest, Condition c = Always); |
| 455 |
|
| 456 |
// VFP/ALU: |
| 457 |
void ma_vadd(FloatRegister src1, FloatRegister src2, FloatRegister dst); |
| 458 |
void ma_vsub(FloatRegister src1, FloatRegister src2, FloatRegister dst); |
| 459 |
|
| 460 |
void ma_vmul(FloatRegister src1, FloatRegister src2, FloatRegister dst); |
| 461 |
void ma_vdiv(FloatRegister src1, FloatRegister src2, FloatRegister dst); |
| 462 |
|
| 463 |
void ma_vneg(FloatRegister src, FloatRegister dest, Condition cc = Always); |
| 464 |
void ma_vmov(FloatRegister src, FloatRegister dest, Condition cc = Always); |
| 465 |
void ma_vmov_f32(FloatRegister src, FloatRegister dest, |
| 466 |
Condition cc = Always); |
| 467 |
void ma_vabs(FloatRegister src, FloatRegister dest, Condition cc = Always); |
| 468 |
void ma_vabs_f32(FloatRegister src, FloatRegister dest, |
| 469 |
Condition cc = Always); |
| 470 |
|
| 471 |
void ma_vsqrt(FloatRegister src, FloatRegister dest, Condition cc = Always); |
| 472 |
void ma_vsqrt_f32(FloatRegister src, FloatRegister dest, |
| 473 |
Condition cc = Always); |
| 474 |
|
| 475 |
void ma_vimm(double value, FloatRegister dest, Condition cc = Always); |
| 476 |
void ma_vimm_f32(float value, FloatRegister dest, Condition cc = Always); |
| 477 |
|
| 478 |
void ma_vcmp(FloatRegister src1, FloatRegister src2, Condition cc = Always); |
| 479 |
void ma_vcmp_f32(FloatRegister src1, FloatRegister src2, |
| 480 |
Condition cc = Always); |
| 481 |
void ma_vcmpz(FloatRegister src1, Condition cc = Always); |
| 482 |
void ma_vcmpz_f32(FloatRegister src1, Condition cc = Always); |
| 483 |
|
| 484 |
void ma_vadd_f32(FloatRegister src1, FloatRegister src2, FloatRegister dst); |
| 485 |
void ma_vsub_f32(FloatRegister src1, FloatRegister src2, FloatRegister dst); |
| 486 |
|
| 487 |
void ma_vmul_f32(FloatRegister src1, FloatRegister src2, FloatRegister dst); |
| 488 |
void ma_vdiv_f32(FloatRegister src1, FloatRegister src2, FloatRegister dst); |
| 489 |
|
| 490 |
void ma_vneg_f32(FloatRegister src, FloatRegister dest, |
| 491 |
Condition cc = Always); |
| 492 |
|
| 493 |
// Source is F64, dest is I32: |
| 494 |
void ma_vcvt_F64_I32(FloatRegister src, FloatRegister dest, |
| 495 |
Condition cc = Always); |
| 496 |
void ma_vcvt_F64_U32(FloatRegister src, FloatRegister dest, |
| 497 |
Condition cc = Always); |
| 498 |
|
| 499 |
// Source is I32, dest is F64: |
| 500 |
void ma_vcvt_I32_F64(FloatRegister src, FloatRegister dest, |
| 501 |
Condition cc = Always); |
| 502 |
void ma_vcvt_U32_F64(FloatRegister src, FloatRegister dest, |
| 503 |
Condition cc = Always); |
| 504 |
|
| 505 |
// Source is F32, dest is I32: |
| 506 |
void ma_vcvt_F32_I32(FloatRegister src, FloatRegister dest, |
| 507 |
Condition cc = Always); |
| 508 |
void ma_vcvt_F32_U32(FloatRegister src, FloatRegister dest, |
| 509 |
Condition cc = Always); |
| 510 |
|
| 511 |
// Source is I32, dest is F32: |
| 512 |
void ma_vcvt_I32_F32(FloatRegister src, FloatRegister dest, |
| 513 |
Condition cc = Always); |
| 514 |
void ma_vcvt_U32_F32(FloatRegister src, FloatRegister dest, |
| 515 |
Condition cc = Always); |
| 516 |
|
| 517 |
// Transfer (do not coerce) a float into a gpr. |
| 518 |
void ma_vxfer(VFPRegister src, Register dest, Condition cc = Always); |
| 519 |
// Transfer (do not coerce) a double into a couple of gpr. |
| 520 |
void ma_vxfer(VFPRegister src, Register dest1, Register dest2, |
| 521 |
Condition cc = Always); |
| 522 |
|
| 523 |
// Transfer (do not coerce) a gpr into a float |
| 524 |
void ma_vxfer(Register src, FloatRegister dest, Condition cc = Always); |
| 525 |
// Transfer (do not coerce) a couple of gpr into a double |
| 526 |
void ma_vxfer(Register src1, Register src2, FloatRegister dest, |
| 527 |
Condition cc = Always); |
| 528 |
|
| 529 |
BufferOffset ma_vdtr(LoadStore ls, const Address& addr, VFPRegister dest, |
| 530 |
AutoRegisterScope& scratch, Condition cc = Always); |
| 531 |
|
| 532 |
BufferOffset ma_vldr(VFPAddr addr, VFPRegister dest, Condition cc = Always); |
| 533 |
BufferOffset ma_vldr(const Address& addr, VFPRegister dest, |
| 534 |
AutoRegisterScope& scratch, Condition cc = Always); |
| 535 |
BufferOffset ma_vldr(VFPRegister src, Register base, Register index, |
| 536 |
AutoRegisterScope& scratch, int32_t shift = defaultShift, |
| 537 |
Condition cc = Always); |
| 538 |
|
| 539 |
BufferOffset ma_vstr(VFPRegister src, VFPAddr addr, Condition cc = Always); |
| 540 |
BufferOffset ma_vstr(VFPRegister src, const Address& addr, |
| 541 |
AutoRegisterScope& scratch, Condition cc = Always); |
| 542 |
BufferOffset ma_vstr(VFPRegister src, Register base, Register index, |
| 543 |
AutoRegisterScope& scratch, AutoRegisterScope& scratch2, |
| 544 |
int32_t shift, int32_t offset, Condition cc = Always); |
| 545 |
BufferOffset ma_vstr(VFPRegister src, Register base, Register index, |
| 546 |
AutoRegisterScope& scratch, int32_t shift, |
| 547 |
Condition cc = Always); |
| 548 |
|
| 549 |
void ma_call(ImmPtr dest); |
| 550 |
|
| 551 |
// Float registers can only be loaded/stored in continuous runs when using |
| 552 |
// vstm/vldm. This function breaks set into continuous runs and loads/stores |
| 553 |
// them at [rm]. rm will be modified and left in a state logically suitable |
| 554 |
// for the next load/store. Returns the offset from [dm] for the logical |
| 555 |
// next load/store. |
| 556 |
int32_t transferMultipleByRuns(FloatRegisterSet set, LoadStore ls, |
| 557 |
Register rm, DTMMode mode) { |
| 558 |
if (mode == IA) { |
| 559 |
return transferMultipleByRunsImpl<FloatRegisterForwardIterator>( |
| 560 |
set, ls, rm, mode, 1); |
| 561 |
} |
| 562 |
if (mode == DB) { |
| 563 |
return transferMultipleByRunsImpl<FloatRegisterBackwardIterator>( |
| 564 |
set, ls, rm, mode, -1); |
| 565 |
} |
| 566 |
MOZ_CRASH("Invalid data transfer addressing mode"); |
| 567 |
} |
| 568 |
|
| 569 |
// `outAny` is valid if and only if `out64` == Register64::Invalid(). |
| 570 |
void wasmLoadImpl(const wasm::MemoryAccessDesc& access, Register memoryBase, |
| 571 |
Register ptr, Register ptrScratch, AnyRegister outAny, |
| 572 |
Register64 out64); |
| 573 |
|
| 574 |
// `valAny` is valid if and only if `val64` == Register64::Invalid(). |
| 575 |
void wasmStoreImpl(const wasm::MemoryAccessDesc& access, AnyRegister valAny, |
| 576 |
Register64 val64, Register memoryBase, Register ptr, |
| 577 |
Register ptrScratch); |
| 578 |
|
| 579 |
private: |
| 580 |
// Implementation for transferMultipleByRuns so we can use different |
| 581 |
// iterators for forward/backward traversals. The sign argument should be 1 |
| 582 |
// if we traverse forwards, -1 if we traverse backwards. |
| 583 |
template <typename RegisterIterator> |
| 584 |
int32_t transferMultipleByRunsImpl(FloatRegisterSet set, LoadStore ls, |
| 585 |
Register rm, DTMMode mode, int32_t sign) { |
| 586 |
MOZ_ASSERT(sign == 1 || sign == -1); |
| 587 |
|
| 588 |
int32_t delta = sign * sizeof(float); |
| 589 |
int32_t offset = 0; |
| 590 |
// Build up a new set, which is the sum of all of the single and double |
| 591 |
// registers. This set can have up to 48 registers in it total |
| 592 |
// s0-s31 and d16-d31 |
| 593 |
FloatRegisterSet mod = set.reduceSetForPush(); |
| 594 |
|
| 595 |
RegisterIterator iter(mod); |
| 596 |
while (iter.more()) { |
| 597 |
startFloatTransferM(ls, rm, mode, WriteBack); |
| 598 |
int32_t reg = (*iter).code(); |
| 599 |
do { |
| 600 |
offset += delta; |
| 601 |
if ((*iter).isDouble()) { |
| 602 |
offset += delta; |
| 603 |
} |
| 604 |
transferFloatReg(*iter); |
| 605 |
} while ((++iter).more() && int32_t((*iter).code()) == (reg += sign)); |
| 606 |
finishFloatTransfer(); |
| 607 |
} |
| 608 |
return offset; |
| 609 |
} |
| 610 |
}; |
| 611 |
|
| 612 |
class MacroAssembler; |
| 613 |
|
| 614 |
class MacroAssemblerARMCompat : public MacroAssemblerARM { |
| 615 |
private: |
| 616 |
// Perform a downcast. Should be removed by Bug 996602. |
| 617 |
MacroAssembler& asMasm(); |
| 618 |
const MacroAssembler& asMasm() const; |
| 619 |
|
| 620 |
public: |
| 621 |
MacroAssemblerARMCompat() {} |
| 622 |
|
| 623 |
public: |
| 624 |
// Jumps + other functions that should be called from non-arm specific |
| 625 |
// code. Basically, an x86 front end on top of the ARM code. |
| 626 |
void j(Condition code, Label* dest) { as_b(dest, code); } |
| 627 |
void j(Label* dest) { as_b(dest, Always); } |
| 628 |
|
| 629 |
void mov(Register src, Register dest) { ma_mov(src, dest); } |
| 630 |
void mov(ImmWord imm, Register dest) { ma_mov(Imm32(imm.value), dest); } |
| 631 |
void mov(ImmPtr imm, Register dest) { |
| 632 |
mov(ImmWord(uintptr_t(imm.value)), dest); |
| 633 |
} |
| 634 |
void mov(CodeLabel* label, Register dest); |
| 635 |
|
| 636 |
void branch(JitCode* c) { |
| 637 |
BufferOffset bo = m_buffer.nextOffset(); |
| 638 |
addPendingJump(bo, ImmPtr(c->raw()), RelocationKind::JITCODE); |
| 639 |
ScratchRegisterScope scratch(asMasm()); |
| 640 |
ma_movPatchable(ImmPtr(c->raw()), scratch, Always); |
| 641 |
ma_bx(scratch); |
| 642 |
} |
| 643 |
void branch(const Register reg) { ma_bx(reg); } |
| 644 |
void nop() { ma_nop(); } |
| 645 |
void shortJumpSizedNop() { ma_nop(); } |
| 646 |
void ret() { ma_pop(pc); } |
| 647 |
void retn(Imm32 n) { |
| 648 |
ScratchRegisterScope scratch(asMasm()); |
| 649 |
SecondScratchRegisterScope scratch2(asMasm()); |
| 650 |
ma_popn_pc(n, scratch, scratch2); |
| 651 |
} |
| 652 |
void push(Imm32 imm) { |
| 653 |
ScratchRegisterScope scratch(asMasm()); |
| 654 |
ma_mov(imm, scratch); |
| 655 |
ma_push(scratch); |
| 656 |
} |
| 657 |
void push(ImmWord imm) { push(Imm32(imm.value)); } |
| 658 |
void push(ImmGCPtr imm) { |
| 659 |
ScratchRegisterScope scratch(asMasm()); |
| 660 |
ma_mov(imm, scratch); |
| 661 |
ma_push(scratch); |
| 662 |
} |
| 663 |
void push(const Address& addr) { |
| 664 |
ScratchRegisterScope scratch(asMasm()); |
| 665 |
SecondScratchRegisterScope scratch2(asMasm()); |
| 666 |
ma_ldr(addr, scratch, scratch2); |
| 667 |
ma_push(scratch); |
| 668 |
} |
| 669 |
void push(Register reg) { |
| 670 |
if (reg == sp) { |
| 671 |
ScratchRegisterScope scratch(asMasm()); |
| 672 |
ma_push_sp(reg, scratch); |
| 673 |
} else { |
| 674 |
ma_push(reg); |
| 675 |
} |
| 676 |
} |
| 677 |
void push(FloatRegister reg) { |
| 678 |
MOZ_ASSERT(reg.isFloat(), "simd128 not supported"); |
| 679 |
ma_vpush(VFPRegister(reg)); |
| 680 |
} |
| 681 |
void pushWithPadding(Register reg, const Imm32 extraSpace) { |
| 682 |
ScratchRegisterScope scratch(asMasm()); |
| 683 |
Imm32 totSpace = Imm32(extraSpace.value + 4); |
| 684 |
ma_dtr(IsStore, sp, totSpace, reg, scratch, PreIndex); |
| 685 |
} |
| 686 |
void pushWithPadding(Imm32 imm, const Imm32 extraSpace) { |
| 687 |
ScratchRegisterScope scratch(asMasm()); |
| 688 |
SecondScratchRegisterScope scratch2(asMasm()); |
| 689 |
Imm32 totSpace = Imm32(extraSpace.value + 4); |
| 690 |
ma_mov(imm, scratch); |
| 691 |
ma_dtr(IsStore, sp, totSpace, scratch, scratch2, PreIndex); |
| 692 |
} |
| 693 |
|
| 694 |
void pop(Register reg) { ma_pop(reg); } |
| 695 |
void pop(FloatRegister reg) { |
| 696 |
MOZ_ASSERT(reg.isFloat(), "simd128 not supported"); |
| 697 |
ma_vpop(VFPRegister(reg)); |
| 698 |
} |
| 699 |
|
| 700 |
void popN(Register reg, Imm32 extraSpace) { |
| 701 |
ScratchRegisterScope scratch(asMasm()); |
| 702 |
Imm32 totSpace = Imm32(extraSpace.value + 4); |
| 703 |
ma_dtr(IsLoad, sp, totSpace, reg, scratch, PostIndex); |
| 704 |
} |
| 705 |
|
| 706 |
CodeOffset toggledJump(Label* label); |
| 707 |
|
| 708 |
// Emit a BLX or NOP instruction. ToggleCall can be used to patch this |
| 709 |
// instruction. |
| 710 |
CodeOffset toggledCall(JitCode* target, bool enabled); |
| 711 |
|
| 712 |
CodeOffset pushWithPatch(ImmWord imm) { |
| 713 |
ScratchRegisterScope scratch(asMasm()); |
| 714 |
CodeOffset label = movWithPatch(imm, scratch); |
| 715 |
ma_push(scratch); |
| 716 |
return label; |
| 717 |
} |
| 718 |
|
| 719 |
CodeOffset movWithPatch(ImmWord imm, Register dest) { |
| 720 |
CodeOffset label = CodeOffset(currentOffset()); |
| 721 |
ma_movPatchable(Imm32(imm.value), dest, Always); |
| 722 |
return label; |
| 723 |
} |
| 724 |
CodeOffset movWithPatch(ImmPtr imm, Register dest) { |
| 725 |
return movWithPatch(ImmWord(uintptr_t(imm.value)), dest); |
| 726 |
} |
| 727 |
|
| 728 |
void jump(Label* label) { as_b(label); } |
| 729 |
void jump(JitCode* code) { branch(code); } |
| 730 |
void jump(ImmPtr ptr) { |
| 731 |
ScratchRegisterScope scratch(asMasm()); |
| 732 |
movePtr(ptr, scratch); |
| 733 |
ma_bx(scratch); |
| 734 |
} |
| 735 |
void jump(TrampolinePtr code) { jump(ImmPtr(code.value)); } |
| 736 |
void jump(Register reg) { ma_bx(reg); } |
| 737 |
void jump(const Address& addr) { |
| 738 |
ScratchRegisterScope scratch(asMasm()); |
| 739 |
SecondScratchRegisterScope scratch2(asMasm()); |
| 740 |
ma_ldr(addr, scratch, scratch2); |
| 741 |
ma_bx(scratch); |
| 742 |
} |
| 743 |
|
| 744 |
void negl(Register reg) { ma_neg(reg, reg, SetCC); } |
| 745 |
void test32(Register lhs, Register rhs) { ma_tst(lhs, rhs); } |
| 746 |
void test32(Register lhs, Imm32 imm) { |
| 747 |
ScratchRegisterScope scratch(asMasm()); |
| 748 |
ma_tst(lhs, imm, scratch); |
| 749 |
} |
| 750 |
void test32(const Address& addr, Imm32 imm) { |
| 751 |
ScratchRegisterScope scratch(asMasm()); |
| 752 |
SecondScratchRegisterScope scratch2(asMasm()); |
| 753 |
ma_ldr(addr, scratch, scratch2); |
| 754 |
ma_tst(scratch, imm, scratch2); |
| 755 |
} |
| 756 |
void testPtr(Register lhs, Register rhs) { test32(lhs, rhs); } |
| 757 |
|
| 758 |
void splitTagForTest(const ValueOperand& value, ScratchTagScope& tag) { |
| 759 |
MOZ_ASSERT(value.typeReg() == tag); |
| 760 |
} |
| 761 |
|
| 762 |
// Higher level tag testing code. |
| 763 |
Condition testInt32(Condition cond, const ValueOperand& value); |
| 764 |
Condition testBoolean(Condition cond, const ValueOperand& value); |
| 765 |
Condition testDouble(Condition cond, const ValueOperand& value); |
| 766 |
Condition testNull(Condition cond, const ValueOperand& value); |
| 767 |
Condition testUndefined(Condition cond, const ValueOperand& value); |
| 768 |
Condition testString(Condition cond, const ValueOperand& value); |
| 769 |
Condition testSymbol(Condition cond, const ValueOperand& value); |
| 770 |
Condition testBigInt(Condition cond, const ValueOperand& value); |
| 771 |
Condition testObject(Condition cond, const ValueOperand& value); |
| 772 |
Condition testNumber(Condition cond, const ValueOperand& value); |
| 773 |
Condition testMagic(Condition cond, const ValueOperand& value); |
| 774 |
|
| 775 |
Condition testPrimitive(Condition cond, const ValueOperand& value); |
| 776 |
Condition testGCThing(Condition cond, const ValueOperand& value); |
| 777 |
|
| 778 |
// Register-based tests. |
| 779 |
Condition testInt32(Condition cond, Register tag); |
| 780 |
Condition testBoolean(Condition cond, Register tag); |
| 781 |
Condition testNull(Condition cond, Register tag); |
| 782 |
Condition testUndefined(Condition cond, Register tag); |
| 783 |
Condition testString(Condition cond, Register tag); |
| 784 |
Condition testSymbol(Condition cond, Register tag); |
| 785 |
Condition testBigInt(Condition cond, Register tag); |
| 786 |
Condition testObject(Condition cond, Register tag); |
| 787 |
Condition testDouble(Condition cond, Register tag); |
| 788 |
Condition testNumber(Condition cond, Register tag); |
| 789 |
Condition testMagic(Condition cond, Register tag); |
| 790 |
Condition testPrimitive(Condition cond, Register tag); |
| 791 |
Condition testGCThing(Condition cond, Register tag); |
| 792 |
|
| 793 |
Condition testGCThing(Condition cond, const Address& address); |
| 794 |
Condition testMagic(Condition cond, const Address& address); |
| 795 |
Condition testInt32(Condition cond, const Address& address); |
| 796 |
Condition testDouble(Condition cond, const Address& address); |
| 797 |
Condition testBoolean(Condition cond, const Address& address); |
| 798 |
Condition testNull(Condition cond, const Address& address); |
| 799 |
Condition testUndefined(Condition cond, const Address& address); |
| 800 |
Condition testString(Condition cond, const Address& address); |
| 801 |
Condition testSymbol(Condition cond, const Address& address); |
| 802 |
Condition testBigInt(Condition cond, const Address& address); |
| 803 |
Condition testObject(Condition cond, const Address& address); |
| 804 |
Condition testNumber(Condition cond, const Address& address); |
| 805 |
|
| 806 |
Condition testUndefined(Condition cond, const BaseIndex& src); |
| 807 |
Condition testNull(Condition cond, const BaseIndex& src); |
| 808 |
Condition testBoolean(Condition cond, const BaseIndex& src); |
| 809 |
Condition testString(Condition cond, const BaseIndex& src); |
| 810 |
Condition testSymbol(Condition cond, const BaseIndex& src); |
| 811 |
Condition testBigInt(Condition cond, const BaseIndex& src); |
| 812 |
Condition testInt32(Condition cond, const BaseIndex& src); |
| 813 |
Condition testObject(Condition cond, const BaseIndex& src); |
| 814 |
Condition testDouble(Condition cond, const BaseIndex& src); |
| 815 |
Condition testMagic(Condition cond, const BaseIndex& src); |
| 816 |
Condition testGCThing(Condition cond, const BaseIndex& src); |
| 817 |
|
| 818 |
// Unboxing code. |
| 819 |
void unboxNonDouble(const ValueOperand& operand, Register dest, |
| 820 |
JSValueType type); |
| 821 |
void unboxNonDouble(const Address& src, Register dest, JSValueType type); |
| 822 |
void unboxNonDouble(const BaseIndex& src, Register dest, JSValueType type); |
| 823 |
void unboxInt32(const ValueOperand& src, Register dest) { |
| 824 |
unboxNonDouble(src, dest, JSVAL_TYPE_INT32); |
| 825 |
} |
| 826 |
void unboxInt32(const Address& src, Register dest) { |
| 827 |
unboxNonDouble(src, dest, JSVAL_TYPE_INT32); |
| 828 |
} |
| 829 |
void unboxInt32(const BaseIndex& src, Register dest) { |
| 830 |
unboxNonDouble(src, dest, JSVAL_TYPE_INT32); |
| 831 |
} |
| 832 |
void unboxBoolean(const ValueOperand& src, Register dest) { |
| 833 |
unboxNonDouble(src, dest, JSVAL_TYPE_BOOLEAN); |
| 834 |
} |
| 835 |
void unboxBoolean(const Address& src, Register dest) { |
| 836 |
unboxNonDouble(src, dest, JSVAL_TYPE_BOOLEAN); |
| 837 |
} |
| 838 |
void unboxBoolean(const BaseIndex& src, Register dest) { |
| 839 |
unboxNonDouble(src, dest, JSVAL_TYPE_BOOLEAN); |
| 840 |
} |
| 841 |
void unboxString(const ValueOperand& src, Register dest) { |
| 842 |
unboxNonDouble(src, dest, JSVAL_TYPE_STRING); |
| 843 |
} |
| 844 |
void unboxString(const Address& src, Register dest) { |
| 845 |
unboxNonDouble(src, dest, JSVAL_TYPE_STRING); |
| 846 |
} |
| 847 |
void unboxSymbol(const ValueOperand& src, Register dest) { |
| 848 |
unboxNonDouble(src, dest, JSVAL_TYPE_SYMBOL); |
| 849 |
} |
| 850 |
void unboxSymbol(const Address& src, Register dest) { |
| 851 |
unboxNonDouble(src, dest, JSVAL_TYPE_SYMBOL); |
| 852 |
} |
| 853 |
void unboxBigInt(const ValueOperand& src, Register dest) { |
| 854 |
unboxNonDouble(src, dest, JSVAL_TYPE_BIGINT); |
| 855 |
} |
| 856 |
void unboxBigInt(const Address& src, Register dest) { |
| 857 |
unboxNonDouble(src, dest, JSVAL_TYPE_BIGINT); |
| 858 |
} |
| 859 |
void unboxObject(const ValueOperand& src, Register dest) { |
| 860 |
unboxNonDouble(src, dest, JSVAL_TYPE_OBJECT); |
| 861 |
} |
| 862 |
void unboxObject(const Address& src, Register dest) { |
| 863 |
unboxNonDouble(src, dest, JSVAL_TYPE_OBJECT); |
| 864 |
} |
| 865 |
void unboxObject(const BaseIndex& src, Register dest) { |
| 866 |
unboxNonDouble(src, dest, JSVAL_TYPE_OBJECT); |
| 867 |
} |
| 868 |
void unboxObjectOrNull(const ValueOperand& src, Register dest) { |
| 869 |
// Due to Spectre mitigation logic (see Value.h), if the value is an Object |
| 870 |
// then this yields the object; otherwise it yields zero (null), as desired. |
| 871 |
unboxNonDouble(src, dest, JSVAL_TYPE_OBJECT); |
| 872 |
} |
| 873 |
void unboxObjectOrNull(const Address& src, Register dest) { |
| 874 |
unboxNonDouble(src, dest, JSVAL_TYPE_OBJECT); |
| 875 |
} |
| 876 |
void unboxObjectOrNull(const BaseIndex& src, Register dest) { |
| 877 |
unboxNonDouble(src, dest, JSVAL_TYPE_OBJECT); |
| 878 |
} |
| 879 |
void unboxDouble(const ValueOperand& src, FloatRegister dest); |
| 880 |
void unboxDouble(const Address& src, FloatRegister dest); |
| 881 |
void unboxDouble(const BaseIndex& src, FloatRegister dest); |
| 882 |
|
| 883 |
void unboxValue(const ValueOperand& src, AnyRegister dest, JSValueType type); |
| 884 |
|
| 885 |
// See comment in MacroAssembler-x64.h. |
| 886 |
void unboxGCThingForGCBarrier(const Address& src, Register dest) { |
| 887 |
load32(ToPayload(src), dest); |
| 888 |
} |
| 889 |
|
| 890 |
void unboxWasmAnyRefGCThingForGCBarrier(const Address& src, Register dest) { |
| 891 |
load32(ToPayload(src), dest); |
| 892 |
{ |
| 893 |
ScratchRegisterScope scratch(asMasm()); |
| 894 |
ma_and(Imm32(wasm::AnyRef::GCThingMask), dest, scratch); |
| 895 |
} |
| 896 |
} |
| 897 |
|
| 898 |
void getWasmAnyRefGCThingChunk(Register src, Register dest) { |
| 899 |
ScratchRegisterScope scratch(asMasm()); |
| 900 |
ma_and(Imm32(wasm::AnyRef::GCThingChunkMask), src, dest, scratch); |
| 901 |
} |
| 902 |
|
| 903 |
void notBoolean(const ValueOperand& val) { |
| 904 |
as_eor(val.payloadReg(), val.payloadReg(), Imm8(1)); |
| 905 |
} |
| 906 |
|
| 907 |
template <typename T> |
| 908 |
void fallibleUnboxPtrImpl(const T& src, Register dest, JSValueType type, |
| 909 |
Label* fail); |
| 910 |
|
| 911 |
// Boxing code. |
| 912 |
void boxDouble(FloatRegister src, const ValueOperand& dest, FloatRegister); |
| 913 |
void boxNonDouble(JSValueType type, Register src, const ValueOperand& dest); |
| 914 |
|
| 915 |
// Extended unboxing API. If the payload is already in a register, returns |
| 916 |
// that register. Otherwise, provides a move to the given scratch register, |
| 917 |
// and returns that. |
| 918 |
[[nodiscard]] Register extractObject(const Address& address, |
| 919 |
Register scratch); |
| 920 |
[[nodiscard]] Register extractObject(const ValueOperand& value, |
| 921 |
Register scratch) { |
| 922 |
unboxNonDouble(value, value.payloadReg(), JSVAL_TYPE_OBJECT); |
| 923 |
return value.payloadReg(); |
| 924 |
} |
| 925 |
[[nodiscard]] Register extractSymbol(const ValueOperand& value, |
| 926 |
Register scratch) { |
| 927 |
unboxNonDouble(value, value.payloadReg(), JSVAL_TYPE_SYMBOL); |
| 928 |
return value.payloadReg(); |
| 929 |
} |
| 930 |
[[nodiscard]] Register extractInt32(const ValueOperand& value, |
| 931 |
Register scratch) { |
| 932 |
return value.payloadReg(); |
| 933 |
} |
| 934 |
[[nodiscard]] Register extractBoolean(const ValueOperand& value, |
| 935 |
Register scratch) { |
| 936 |
return value.payloadReg(); |
| 937 |
} |
| 938 |
[[nodiscard]] Register extractTag(const Address& address, Register scratch); |
| 939 |
[[nodiscard]] Register extractTag(const BaseIndex& address, Register scratch); |
| 940 |
[[nodiscard]] Register extractTag(const ValueOperand& value, |
| 941 |
Register scratch) { |
| 942 |
return value.typeReg(); |
| 943 |
} |
| 944 |
|
| 945 |
void loadInt32OrDouble(const Address& src, FloatRegister dest); |
| 946 |
void loadInt32OrDouble(Register base, Register index, FloatRegister dest, |
| 947 |
int32_t shift = defaultShift); |
| 948 |
void loadConstantDouble(double dp, FloatRegister dest); |
| 949 |
|
| 950 |
// Treat the value as a boolean, and set condition codes accordingly. |
| 951 |
Condition testInt32Truthy(bool truthy, const ValueOperand& operand); |
| 952 |
Condition testBooleanTruthy(bool truthy, const ValueOperand& operand); |
| 953 |
Condition testDoubleTruthy(bool truthy, FloatRegister reg); |
| 954 |
Condition testStringTruthy(bool truthy, const ValueOperand& value); |
| 955 |
Condition testBigIntTruthy(bool truthy, const ValueOperand& value); |
| 956 |
|
| 957 |
void loadConstantFloat32(float f, FloatRegister dest); |
| 958 |
|
| 959 |
void loadUnboxedValue(Address address, MIRType type, AnyRegister dest) { |
| 960 |
if (dest.isFloat()) { |
| 961 |
loadInt32OrDouble(address, dest.fpu()); |
| 962 |
} else { |
| 963 |
ScratchRegisterScope scratch(asMasm()); |
| 964 |
ma_ldr(address, dest.gpr(), scratch); |
| 965 |
} |
| 966 |
} |
| 967 |
|
| 968 |
void loadUnboxedValue(BaseIndex address, MIRType type, AnyRegister dest) { |
| 969 |
if (dest.isFloat()) { |
| 970 |
loadInt32OrDouble(address.base, address.index, dest.fpu(), address.scale); |
| 971 |
} else { |
| 972 |
load32(address, dest.gpr()); |
| 973 |
} |
| 974 |
} |
| 975 |
|
| 976 |
template <typename T> |
| 977 |
void storeUnboxedPayload(ValueOperand value, T address, size_t nbytes, |
| 978 |
JSValueType) { |
| 979 |
switch (nbytes) { |
| 980 |
case 4: |
| 981 |
storePtr(value.payloadReg(), address); |
| 982 |
return; |
| 983 |
case 1: |
| 984 |
store8(value.payloadReg(), address); |
| 985 |
return; |
| 986 |
default: |
| 987 |
MOZ_CRASH("Bad payload width"); |
| 988 |
} |
| 989 |
} |
| 990 |
|
| 991 |
void storeValue(ValueOperand val, const Address& dst); |
| 992 |
void storeValue(ValueOperand val, const BaseIndex& dest); |
| 993 |
void storeValue(JSValueType type, Register reg, BaseIndex dest) { |
| 994 |
ScratchRegisterScope scratch(asMasm()); |
| 995 |
SecondScratchRegisterScope scratch2(asMasm()); |
| 996 |
|
| 997 |
int32_t payloadoffset = dest.offset + NUNBOX32_PAYLOAD_OFFSET; |
| 998 |
int32_t typeoffset = dest.offset + NUNBOX32_TYPE_OFFSET; |
| 999 |
|
| 1000 |
ma_alu(dest.base, lsl(dest.index, dest.scale), scratch, OpAdd); |
| 1001 |
|
| 1002 |
// Store the payload. |
| 1003 |
if (payloadoffset < 4096 && payloadoffset > -4096) { |
| 1004 |
ma_str(reg, DTRAddr(scratch, DtrOffImm(payloadoffset))); |
| 1005 |
} else { |
| 1006 |
ma_str(reg, Address(scratch, payloadoffset), scratch2); |
| 1007 |
} |
| 1008 |
|
| 1009 |
// Store the type. |
| 1010 |
if (typeoffset < 4096 && typeoffset > -4096) { |
| 1011 |
// Encodable as DTRAddr, so only two instructions needed. |
| 1012 |
ma_mov(ImmTag(JSVAL_TYPE_TO_TAG(type)), scratch2); |
| 1013 |
ma_str(scratch2, DTRAddr(scratch, DtrOffImm(typeoffset))); |
| 1014 |
} else { |
| 1015 |
// Since there are only two scratch registers, the offset must be |
| 1016 |
// applied early using a third instruction to be safe. |
| 1017 |
ma_add(Imm32(typeoffset), scratch, scratch2); |
| 1018 |
ma_mov(ImmTag(JSVAL_TYPE_TO_TAG(type)), scratch2); |
| 1019 |
ma_str(scratch2, DTRAddr(scratch, DtrOffImm(0))); |
| 1020 |
} |
| 1021 |
} |
| 1022 |
void storeValue(JSValueType type, Register reg, Address dest) { |
| 1023 |
ScratchRegisterScope scratch(asMasm()); |
| 1024 |
SecondScratchRegisterScope scratch2(asMasm()); |
| 1025 |
|
| 1026 |
ma_str(reg, dest, scratch2); |
| 1027 |
ma_mov(ImmTag(JSVAL_TYPE_TO_TAG(type)), scratch); |
| 1028 |
ma_str(scratch, Address(dest.base, dest.offset + NUNBOX32_TYPE_OFFSET), |
| 1029 |
scratch2); |
| 1030 |
} |
| 1031 |
void storeValue(const Value& val, const Address& dest) { |
| 1032 |
ScratchRegisterScope scratch(asMasm()); |
| 1033 |
SecondScratchRegisterScope scratch2(asMasm()); |
| 1034 |
|
| 1035 |
ma_mov(Imm32(val.toNunboxTag()), scratch); |
| 1036 |
ma_str(scratch, ToType(dest), scratch2); |
| 1037 |
if (val.isGCThing()) { |
| 1038 |
ma_mov(ImmGCPtr(val.toGCThing()), scratch); |
| 1039 |
} else { |
| 1040 |
ma_mov(Imm32(val.toNunboxPayload()), scratch); |
| 1041 |
} |
| 1042 |
ma_str(scratch, ToPayload(dest), scratch2); |
| 1043 |
} |
| 1044 |
void storeValue(const Value& val, BaseIndex dest) { |
| 1045 |
ScratchRegisterScope scratch(asMasm()); |
| 1046 |
SecondScratchRegisterScope scratch2(asMasm()); |
| 1047 |
|
| 1048 |
int32_t typeoffset = dest.offset + NUNBOX32_TYPE_OFFSET; |
| 1049 |
int32_t payloadoffset = dest.offset + NUNBOX32_PAYLOAD_OFFSET; |
| 1050 |
|
| 1051 |
ma_alu(dest.base, lsl(dest.index, dest.scale), scratch, OpAdd); |
| 1052 |
|
| 1053 |
// Store the type. |
| 1054 |
if (typeoffset < 4096 && typeoffset > -4096) { |
| 1055 |
ma_mov(Imm32(val.toNunboxTag()), scratch2); |
| 1056 |
ma_str(scratch2, DTRAddr(scratch, DtrOffImm(typeoffset))); |
| 1057 |
} else { |
| 1058 |
ma_add(Imm32(typeoffset), scratch, scratch2); |
| 1059 |
ma_mov(Imm32(val.toNunboxTag()), scratch2); |
| 1060 |
ma_str(scratch2, DTRAddr(scratch, DtrOffImm(0))); |
| 1061 |
// Restore scratch for the payload store. |
| 1062 |
ma_alu(dest.base, lsl(dest.index, dest.scale), scratch, OpAdd); |
| 1063 |
} |
| 1064 |
|
| 1065 |
// Store the payload, marking if necessary. |
| 1066 |
if (payloadoffset < 4096 && payloadoffset > -4096) { |
| 1067 |
if (val.isGCThing()) { |
| 1068 |
ma_mov(ImmGCPtr(val.toGCThing()), scratch2); |
| 1069 |
} else { |
| 1070 |
ma_mov(Imm32(val.toNunboxPayload()), scratch2); |
| 1071 |
} |
| 1072 |
ma_str(scratch2, DTRAddr(scratch, DtrOffImm(payloadoffset))); |
| 1073 |
} else { |
| 1074 |
ma_add(Imm32(payloadoffset), scratch, scratch2); |
| 1075 |
if (val.isGCThing()) { |
| 1076 |
ma_mov(ImmGCPtr(val.toGCThing()), scratch2); |
| 1077 |
} else { |
| 1078 |
ma_mov(Imm32(val.toNunboxPayload()), scratch2); |
| 1079 |
} |
| 1080 |
ma_str(scratch2, DTRAddr(scratch, DtrOffImm(0))); |
| 1081 |
} |
| 1082 |
} |
| 1083 |
void storeValue(const Address& src, const Address& dest, Register temp) { |
| 1084 |
load32(ToType(src), temp); |
| 1085 |
store32(temp, ToType(dest)); |
| 1086 |
|
| 1087 |
load32(ToPayload(src), temp); |
| 1088 |
store32(temp, ToPayload(dest)); |
| 1089 |
} |
| 1090 |
|
| 1091 |
void storePrivateValue(Register src, const Address& dest) { |
| 1092 |
store32(Imm32(0), ToType(dest)); |
| 1093 |
store32(src, ToPayload(dest)); |
| 1094 |
} |
| 1095 |
void storePrivateValue(ImmGCPtr imm, const Address& dest) { |
| 1096 |
store32(Imm32(0), ToType(dest)); |
| 1097 |
storePtr(imm, ToPayload(dest)); |
| 1098 |
} |
| 1099 |
|
| 1100 |
void loadValue(Address src, ValueOperand val); |
| 1101 |
void loadValue(Operand dest, ValueOperand val) { |
| 1102 |
loadValue(dest.toAddress(), val); |
| 1103 |
} |
| 1104 |
void loadValue(const BaseIndex& addr, ValueOperand val); |
| 1105 |
|
| 1106 |
// Like loadValue but guaranteed to not use LDRD or LDM instructions (these |
| 1107 |
// don't support unaligned accesses). |
| 1108 |
void loadUnalignedValue(const Address& src, ValueOperand dest); |
| 1109 |
|
| 1110 |
void tagValue(JSValueType type, Register payload, ValueOperand dest); |
| 1111 |
|
| 1112 |
void pushValue(ValueOperand val); |
| 1113 |
void popValue(ValueOperand val); |
| 1114 |
void pushValue(const Value& val) { |
| 1115 |
push(Imm32(val.toNunboxTag())); |
| 1116 |
if (val.isGCThing()) { |
| 1117 |
push(ImmGCPtr(val.toGCThing())); |
| 1118 |
} else { |
| 1119 |
push(Imm32(val.toNunboxPayload())); |
| 1120 |
} |
| 1121 |
} |
| 1122 |
void pushValue(JSValueType type, Register reg) { |
| 1123 |
push(ImmTag(JSVAL_TYPE_TO_TAG(type))); |
| 1124 |
ma_push(reg); |
| 1125 |
} |
| 1126 |
void pushValue(const Address& addr); |
| 1127 |
void pushValue(const BaseIndex& addr, Register scratch); |
| 1128 |
|
| 1129 |
void storePayload(const Value& val, const Address& dest); |
| 1130 |
void storePayload(Register src, const Address& dest); |
| 1131 |
void storePayload(const Value& val, const BaseIndex& dest); |
| 1132 |
void storePayload(Register src, const BaseIndex& dest); |
| 1133 |
void storeTypeTag(ImmTag tag, const Address& dest); |
| 1134 |
void storeTypeTag(ImmTag tag, const BaseIndex& dest); |
| 1135 |
|
| 1136 |
void handleFailureWithHandlerTail(Label* profilerExitTail, Label* bailoutTail, |
| 1137 |
uint32_t* returnValueCheckOffset); |
| 1138 |
|
| 1139 |
///////////////////////////////////////////////////////////////// |
| 1140 |
// Common interface. |
| 1141 |
///////////////////////////////////////////////////////////////// |
| 1142 |
public: |
| 1143 |
void not32(Register reg); |
| 1144 |
|
| 1145 |
void move32(Imm32 imm, Register dest); |
| 1146 |
void move32(Register src, Register dest); |
| 1147 |
|
| 1148 |
void movePtr(Register src, Register dest); |
| 1149 |
void movePtr(ImmWord imm, Register dest); |
| 1150 |
void movePtr(ImmPtr imm, Register dest); |
| 1151 |
void movePtr(wasm::SymbolicAddress imm, Register dest); |
| 1152 |
void movePtr(ImmGCPtr imm, Register dest); |
| 1153 |
|
| 1154 |
FaultingCodeOffset load8SignExtend(const Address& address, Register dest); |
| 1155 |
FaultingCodeOffset load8SignExtend(const BaseIndex& src, Register dest); |
| 1156 |
|
| 1157 |
FaultingCodeOffset load8ZeroExtend(const Address& address, Register dest); |
| 1158 |
FaultingCodeOffset load8ZeroExtend(const BaseIndex& src, Register dest); |
| 1159 |
|
| 1160 |
FaultingCodeOffset load16SignExtend(const Address& address, Register dest); |
| 1161 |
FaultingCodeOffset load16SignExtend(const BaseIndex& src, Register dest); |
| 1162 |
|
| 1163 |
template <typename S> |
| 1164 |
void load16UnalignedSignExtend(const S& src, Register dest) { |
| 1165 |
// load16SignExtend uses |ldrsh|, which supports unaligned access. |
| 1166 |
load16SignExtend(src, dest); |
| 1167 |
} |
| 1168 |
|
| 1169 |
FaultingCodeOffset load16ZeroExtend(const Address& address, Register dest); |
| 1170 |
FaultingCodeOffset load16ZeroExtend(const BaseIndex& src, Register dest); |
| 1171 |
|
| 1172 |
template <typename S> |
| 1173 |
void load16UnalignedZeroExtend(const S& src, Register dest) { |
| 1174 |
// load16ZeroExtend uses |ldrh|, which supports unaligned access. |
| 1175 |
load16ZeroExtend(src, dest); |
| 1176 |
} |
| 1177 |
|
| 1178 |
FaultingCodeOffset load32(const Address& address, Register dest); |
| 1179 |
FaultingCodeOffset load32(const BaseIndex& address, Register dest); |
| 1180 |
void load32(AbsoluteAddress address, Register dest); |
| 1181 |
|
| 1182 |
template <typename S> |
| 1183 |
void load32Unaligned(const S& src, Register dest) { |
| 1184 |
// load32 uses |ldr|, which supports unaligned access. |
| 1185 |
load32(src, dest); |
| 1186 |
} |
| 1187 |
|
| 1188 |
FaultingCodeOffsetPair load64(const Address& address, Register64 dest) { |
| 1189 |
FaultingCodeOffset fco1, fco2; |
| 1190 |
bool highBeforeLow = address.base == dest.low; |
| 1191 |
if (highBeforeLow) { |
| 1192 |
fco1 = load32(HighWord(address), dest.high); |
| 1193 |
fco2 = load32(LowWord(address), dest.low); |
| 1194 |
} else { |
| 1195 |
fco1 = load32(LowWord(address), dest.low); |
| 1196 |
fco2 = load32(HighWord(address), dest.high); |
| 1197 |
} |
| 1198 |
return FaultingCodeOffsetPair(fco1, fco2); |
| 1199 |
} |
| 1200 |
FaultingCodeOffsetPair load64(const BaseIndex& address, Register64 dest) { |
| 1201 |
// If you run into this, relax your register allocation constraints. |
| 1202 |
MOZ_RELEASE_ASSERT( |
| 1203 |
!((address.base == dest.low || address.base == dest.high) && |
| 1204 |
(address.index == dest.low || address.index == dest.high))); |
| 1205 |
FaultingCodeOffset fco1, fco2; |
| 1206 |
bool highBeforeLow = address.base == dest.low || address.index == dest.low; |
| 1207 |
if (highBeforeLow) { |
| 1208 |
fco1 = load32(HighWord(address), dest.high); |
| 1209 |
fco2 = load32(LowWord(address), dest.low); |
| 1210 |
} else { |
| 1211 |
fco1 = load32(LowWord(address), dest.low); |
| 1212 |
fco2 = load32(HighWord(address), dest.high); |
| 1213 |
} |
| 1214 |
return FaultingCodeOffsetPair(fco1, fco2); |
| 1215 |
} |
| 1216 |
|
| 1217 |
template <typename S> |
| 1218 |
void load64Unaligned(const S& src, Register64 dest) { |
| 1219 |
// load64 calls load32, which supports unaligned accesses. |
| 1220 |
load64(src, dest); |
| 1221 |
} |
| 1222 |
|
| 1223 |
FaultingCodeOffset loadPtr(const Address& address, Register dest); |
| 1224 |
FaultingCodeOffset loadPtr(const BaseIndex& src, Register dest); |
| 1225 |
void loadPtr(AbsoluteAddress address, Register dest); |
| 1226 |
void loadPtr(wasm::SymbolicAddress address, Register dest); |
| 1227 |
|
| 1228 |
void loadPrivate(const Address& address, Register dest); |
| 1229 |
|
| 1230 |
FaultingCodeOffset loadDouble(const Address& addr, FloatRegister dest); |
| 1231 |
FaultingCodeOffset loadDouble(const BaseIndex& src, FloatRegister dest); |
| 1232 |
|
| 1233 |
FaultingCodeOffset loadFloat32(const Address& addr, FloatRegister dest); |
| 1234 |
FaultingCodeOffset loadFloat32(const BaseIndex& src, FloatRegister dest); |
| 1235 |
|
| 1236 |
FaultingCodeOffset loadFloat16(const Address& addr, FloatRegister dest, |
| 1237 |
Register scratch); |
| 1238 |
FaultingCodeOffset loadFloat16(const BaseIndex& src, FloatRegister dest, |
| 1239 |
Register scratch); |
| 1240 |
|
| 1241 |
FaultingCodeOffset store8(Register src, const Address& address); |
| 1242 |
void store8(Imm32 imm, const Address& address); |
| 1243 |
FaultingCodeOffset store8(Register src, const BaseIndex& address); |
| 1244 |
void store8(Imm32 imm, const BaseIndex& address); |
| 1245 |
|
| 1246 |
FaultingCodeOffset store16(Register src, const Address& address); |
| 1247 |
void store16(Imm32 imm, const Address& address); |
| 1248 |
FaultingCodeOffset store16(Register src, const BaseIndex& address); |
| 1249 |
void store16(Imm32 imm, const BaseIndex& address); |
| 1250 |
|
| 1251 |
template <typename S, typename T> |
| 1252 |
void store16Unaligned(const S& src, const T& dest) { |
| 1253 |
// store16 uses |strh|, which supports unaligned access. |
| 1254 |
store16(src, dest); |
| 1255 |
} |
| 1256 |
|
| 1257 |
void store32(Register src, AbsoluteAddress address); |
| 1258 |
FaultingCodeOffset store32(Register src, const Address& address); |
| 1259 |
FaultingCodeOffset store32(Register src, const BaseIndex& address); |
| 1260 |
void store32(Imm32 src, const Address& address); |
| 1261 |
void store32(Imm32 src, const BaseIndex& address); |
| 1262 |
|
| 1263 |
template <typename S, typename T> |
| 1264 |
void store32Unaligned(const S& src, const T& dest) { |
| 1265 |
// store32 uses |str|, which supports unaligned access. |
| 1266 |
store32(src, dest); |
| 1267 |
} |
| 1268 |
|
| 1269 |
FaultingCodeOffsetPair store64(Register64 src, Address address) { |
| 1270 |
FaultingCodeOffset fco1 = store32(src.low, LowWord(address)); |
| 1271 |
FaultingCodeOffset fco2 = store32(src.high, HighWord(address)); |
| 1272 |
return FaultingCodeOffsetPair(fco1, fco2); |
| 1273 |
} |
| 1274 |
|
| 1275 |
FaultingCodeOffsetPair store64(Register64 src, const BaseIndex& address) { |
| 1276 |
FaultingCodeOffset fco1 = store32(src.low, LowWord(address)); |
| 1277 |
FaultingCodeOffset fco2 = store32(src.high, HighWord(address)); |
| 1278 |
return FaultingCodeOffsetPair(fco1, fco2); |
| 1279 |
} |
| 1280 |
|
| 1281 |
void store64(Imm64 imm, Address address) { |
| 1282 |
store32(imm.low(), LowWord(address)); |
| 1283 |
store32(imm.hi(), HighWord(address)); |
| 1284 |
} |
| 1285 |
|
| 1286 |
void store64(Imm64 imm, const BaseIndex& address) { |
| 1287 |
store32(imm.low(), LowWord(address)); |
| 1288 |
store32(imm.hi(), HighWord(address)); |
| 1289 |
} |
| 1290 |
|
| 1291 |
template <typename S, typename T> |
| 1292 |
void store64Unaligned(const S& src, const T& dest) { |
| 1293 |
// store64 calls store32, which supports unaligned access. |
| 1294 |
store64(src, dest); |
| 1295 |
} |
| 1296 |
|
| 1297 |
void storePtr(ImmWord imm, const Address& address); |
| 1298 |
void storePtr(ImmWord imm, const BaseIndex& address); |
| 1299 |
void storePtr(ImmPtr imm, const Address& address); |
| 1300 |
void storePtr(ImmPtr imm, const BaseIndex& address); |
| 1301 |
void storePtr(ImmGCPtr imm, const Address& address); |
| 1302 |
void storePtr(ImmGCPtr imm, const BaseIndex& address); |
| 1303 |
FaultingCodeOffset storePtr(Register src, const Address& address); |
| 1304 |
FaultingCodeOffset storePtr(Register src, const BaseIndex& address); |
| 1305 |
void storePtr(Register src, AbsoluteAddress dest); |
| 1306 |
|
| 1307 |
void moveDouble(FloatRegister src, FloatRegister dest, |
| 1308 |
Condition cc = Always) { |
| 1309 |
ma_vmov(src, dest, cc); |
| 1310 |
} |
| 1311 |
|
| 1312 |
inline void incrementInt32Value(const Address& addr); |
| 1313 |
|
| 1314 |
void cmp32(Register lhs, Imm32 rhs); |
| 1315 |
void cmp32(Register lhs, Register rhs); |
| 1316 |
void cmp32(const Address& lhs, Imm32 rhs); |
| 1317 |
void cmp32(const Address& lhs, Register rhs); |
| 1318 |
|
| 1319 |
void cmpPtr(Register lhs, Register rhs); |
| 1320 |
void cmpPtr(Register lhs, ImmWord rhs); |
| 1321 |
void cmpPtr(Register lhs, ImmPtr rhs); |
| 1322 |
void cmpPtr(Register lhs, ImmGCPtr rhs); |
| 1323 |
void cmpPtr(Register lhs, Imm32 rhs); |
| 1324 |
void cmpPtr(const Address& lhs, Register rhs); |
| 1325 |
void cmpPtr(const Address& lhs, ImmWord rhs); |
| 1326 |
void cmpPtr(const Address& lhs, ImmPtr rhs); |
| 1327 |
void cmpPtr(const Address& lhs, ImmGCPtr rhs); |
| 1328 |
void cmpPtr(const Address& lhs, Imm32 rhs); |
| 1329 |
|
| 1330 |
template <typename T1, typename T2> |
| 1331 |
inline void cmp64SetAliased(Condition cond, T1 lhs, T2 rhs, Register dest); |
| 1332 |
|
| 1333 |
template <typename T1, typename T2> |
| 1334 |
inline void cmp64SetNonAliased(Condition cond, T1 lhs, T2 rhs, Register dest); |
| 1335 |
|
| 1336 |
template <typename T1, typename T2> |
| 1337 |
inline void branch64Impl(Condition cond, T1 lhs, T2 rhs, Label* success, |
| 1338 |
Label* fail); |
| 1339 |
|
| 1340 |
void setStackArg(Register reg, uint32_t arg); |
| 1341 |
|
| 1342 |
void breakpoint(); |
| 1343 |
// Conditional breakpoint. |
| 1344 |
void breakpoint(Condition cc); |
| 1345 |
|
| 1346 |
// Trigger the simulator's interactive read-eval-print loop. |
| 1347 |
// The message will be printed at the stopping point. |
| 1348 |
// (On non-simulator builds, does nothing.) |
| 1349 |
void simulatorStop(const char* msg); |
| 1350 |
|
| 1351 |
// Evaluate srcDest = minmax<isMax>{Float32,Double}(srcDest, other). |
| 1352 |
// Checks for NaN if canBeNaN is true. |
| 1353 |
void minMaxDouble(FloatRegister srcDest, FloatRegister other, bool canBeNaN, |
| 1354 |
bool isMax); |
| 1355 |
void minMaxFloat32(FloatRegister srcDest, FloatRegister other, bool canBeNaN, |
| 1356 |
bool isMax); |
| 1357 |
|
| 1358 |
void compareDouble(FloatRegister lhs, FloatRegister rhs); |
| 1359 |
|
| 1360 |
void compareFloat(FloatRegister lhs, FloatRegister rhs); |
| 1361 |
|
| 1362 |
void checkStackAlignment(); |
| 1363 |
|
| 1364 |
void emitSet(Assembler::Condition cond, Register dest) { |
| 1365 |
ma_mov(Imm32(0), dest); |
| 1366 |
ma_mov(Imm32(1), dest, cond); |
| 1367 |
} |
| 1368 |
|
| 1369 |
void testNullSet(Condition cond, const ValueOperand& value, Register dest) { |
| 1370 |
cond = testNull(cond, value); |
| 1371 |
emitSet(cond, dest); |
| 1372 |
} |
| 1373 |
|
| 1374 |
void testObjectSet(Condition cond, const ValueOperand& value, Register dest) { |
| 1375 |
cond = testObject(cond, value); |
| 1376 |
emitSet(cond, dest); |
| 1377 |
} |
| 1378 |
|
| 1379 |
void testUndefinedSet(Condition cond, const ValueOperand& value, |
| 1380 |
Register dest) { |
| 1381 |
cond = testUndefined(cond, value); |
| 1382 |
emitSet(cond, dest); |
| 1383 |
} |
| 1384 |
|
| 1385 |
protected: |
| 1386 |
bool buildOOLFakeExitFrame(void* fakeReturnAddr); |
| 1387 |
|
| 1388 |
public: |
| 1389 |
void computeEffectiveAddress(const Address& address, Register dest) { |
| 1390 |
ScratchRegisterScope scratch(asMasm()); |
| 1391 |
ma_add(address.base, Imm32(address.offset), dest, scratch, LeaveCC); |
| 1392 |
} |
| 1393 |
void computeEffectiveAddress(const BaseIndex& address, Register dest) { |
| 1394 |
ScratchRegisterScope scratch(asMasm()); |
| 1395 |
ma_alu(address.base, lsl(address.index, address.scale), dest, OpAdd, |
| 1396 |
LeaveCC); |
| 1397 |
if (address.offset) { |
| 1398 |
ma_add(dest, Imm32(address.offset), dest, scratch, LeaveCC); |
| 1399 |
} |
| 1400 |
} |
| 1401 |
void floor(FloatRegister input, Register output, Label* handleNotAnInt); |
| 1402 |
void floorf(FloatRegister input, Register output, Label* handleNotAnInt); |
| 1403 |
void ceil(FloatRegister input, Register output, Label* handleNotAnInt); |
| 1404 |
void ceilf(FloatRegister input, Register output, Label* handleNotAnInt); |
| 1405 |
void round(FloatRegister input, Register output, Label* handleNotAnInt, |
| 1406 |
FloatRegister tmp); |
| 1407 |
void roundf(FloatRegister input, Register output, Label* handleNotAnInt, |
| 1408 |
FloatRegister tmp); |
| 1409 |
void trunc(FloatRegister input, Register output, Label* handleNotAnInt); |
| 1410 |
void truncf(FloatRegister input, Register output, Label* handleNotAnInt); |
| 1411 |
|
| 1412 |
void lea(Operand addr, Register dest) { |
| 1413 |
ScratchRegisterScope scratch(asMasm()); |
| 1414 |
ma_add(addr.baseReg(), Imm32(addr.disp()), dest, scratch); |
| 1415 |
} |
| 1416 |
|
| 1417 |
void abiret() { as_bx(lr); } |
| 1418 |
|
| 1419 |
void moveFloat32(FloatRegister src, FloatRegister dest, |
| 1420 |
Condition cc = Always) { |
| 1421 |
as_vmov(VFPRegister(dest).singleOverlay(), VFPRegister(src).singleOverlay(), |
| 1422 |
cc); |
| 1423 |
} |
| 1424 |
|
| 1425 |
// Instrumentation for entering and leaving the profiler. |
| 1426 |
void profilerEnterFrame(Register framePtr, Register scratch); |
| 1427 |
void profilerExitFrame(); |
| 1428 |
}; |
| 1429 |
|
| 1430 |
using MacroAssemblerSpecific = MacroAssemblerARMCompat; |
| 1431 |
|
| 1432 |
} // namespace jit |
| 1433 |
} // namespace js |
| 1434 |
|
| 1435 |
#endif /* jit_arm_MacroAssembler_arm_h */ |