| 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_wasm32_Assembler_wasm32_h |
| 8 |
#define jit_wasm32_Assembler_wasm32_h |
| 9 |
|
| 10 |
#include "mozilla/Assertions.h" |
| 11 |
|
| 12 |
#include <cstdint> |
| 13 |
|
| 14 |
#include "jit/Registers.h" |
| 15 |
#include "jit/RegisterSets.h" |
| 16 |
#include "jit/shared/Assembler-shared.h" |
| 17 |
#include "jit/wasm32/Architecture-wasm32.h" |
| 18 |
#include "js/Value.h" |
| 19 |
|
| 20 |
namespace js::jit { |
| 21 |
|
| 22 |
struct ImmTag : public Imm32 { |
| 23 |
explicit ImmTag(JSValueTag mask) : Imm32(int32_t(mask)) {} |
| 24 |
}; |
| 25 |
|
| 26 |
struct ImmType : public ImmTag { |
| 27 |
explicit ImmType(JSValueType type) : ImmTag(JSVAL_TYPE_TO_TAG(type)) {} |
| 28 |
}; |
| 29 |
|
| 30 |
class MacroAssembler; |
| 31 |
|
| 32 |
static constexpr Register StackPointer{Registers::StackPointer}; |
| 33 |
static constexpr Register FramePointer{Registers::FramePointer}; |
| 34 |
|
| 35 |
static constexpr Register ReturnReg{Registers::invalid_reg2}; |
| 36 |
static constexpr FloatRegister ReturnFloat32Reg = {FloatRegisters::invalid_reg}; |
| 37 |
static constexpr FloatRegister ReturnDoubleReg = {FloatRegisters::invalid_reg}; |
| 38 |
static constexpr FloatRegister ReturnSimd128Reg = {FloatRegisters::invalid_reg}; |
| 39 |
static constexpr FloatRegister ScratchSimd128Reg = { |
| 40 |
FloatRegisters::invalid_reg}; |
| 41 |
static constexpr FloatRegister InvalidFloatReg = {FloatRegisters::invalid_reg}; |
| 42 |
|
| 43 |
struct ScratchFloat32Scope : FloatRegister { |
| 44 |
explicit ScratchFloat32Scope(MacroAssembler& masm) {} |
| 45 |
}; |
| 46 |
|
| 47 |
struct ScratchDoubleScope : FloatRegister { |
| 48 |
explicit ScratchDoubleScope(MacroAssembler& masm) {} |
| 49 |
}; |
| 50 |
|
| 51 |
static constexpr Register OsrFrameReg{Registers::invalid_reg}; |
| 52 |
static constexpr Register PreBarrierReg{Registers::invalid_reg}; |
| 53 |
static constexpr Register InterpreterPCReg{Registers::invalid_reg}; |
| 54 |
static constexpr Register CallTempReg0{Registers::invalid_reg}; |
| 55 |
static constexpr Register CallTempReg1{Registers::invalid_reg}; |
| 56 |
static constexpr Register CallTempReg2{Registers::invalid_reg}; |
| 57 |
static constexpr Register CallTempReg3{Registers::invalid_reg}; |
| 58 |
static constexpr Register CallTempReg4{Registers::invalid_reg}; |
| 59 |
static constexpr Register CallTempReg5{Registers::invalid_reg}; |
| 60 |
static constexpr Register InvalidReg{Registers::invalid_reg}; |
| 61 |
static constexpr Register CallTempNonArgRegs[] = {InvalidReg, InvalidReg}; |
| 62 |
static const uint32_t NumCallTempNonArgRegs = std::size(CallTempNonArgRegs); |
| 63 |
|
| 64 |
static constexpr Register IntArgReg0{Registers::invalid_reg}; |
| 65 |
static constexpr Register IntArgReg1{Registers::invalid_reg}; |
| 66 |
static constexpr Register IntArgReg2{Registers::invalid_reg}; |
| 67 |
static constexpr Register IntArgReg3{Registers::invalid_reg}; |
| 68 |
static constexpr Register HeapReg{Registers::invalid_reg}; |
| 69 |
|
| 70 |
static constexpr Register RegExpMatcherRegExpReg{Registers::invalid_reg}; |
| 71 |
static constexpr Register RegExpMatcherStringReg{Registers::invalid_reg}; |
| 72 |
static constexpr Register RegExpMatcherLastIndexReg{Registers::invalid_reg}; |
| 73 |
|
| 74 |
static constexpr Register RegExpExecTestRegExpReg{Registers::invalid_reg}; |
| 75 |
static constexpr Register RegExpExecTestStringReg{Registers::invalid_reg}; |
| 76 |
|
| 77 |
static constexpr Register RegExpSearcherRegExpReg{Registers::invalid_reg}; |
| 78 |
static constexpr Register RegExpSearcherStringReg{Registers::invalid_reg}; |
| 79 |
static constexpr Register RegExpSearcherLastIndexReg{Registers::invalid_reg}; |
| 80 |
|
| 81 |
// Uses |invalid_reg2| to avoid static_assert failures. |
| 82 |
static constexpr Register JSReturnReg_Type{Registers::invalid_reg2}; |
| 83 |
static constexpr Register JSReturnReg_Data{Registers::invalid_reg2}; |
| 84 |
static constexpr Register JSReturnReg{Registers::invalid_reg2}; |
| 85 |
|
| 86 |
#if defined(JS_NUNBOX32) |
| 87 |
static constexpr ValueOperand JSReturnOperand(Register{Registers::r2}, |
| 88 |
Register{Registers::r3}); |
| 89 |
static constexpr Register64 ReturnReg64(InvalidReg, InvalidReg); |
| 90 |
#elif defined(JS_PUNBOX64) |
| 91 |
static constexpr ValueOperand JSReturnOperand(InvalidReg); |
| 92 |
static constexpr Register64 ReturnReg64(InvalidReg); |
| 93 |
#else |
| 94 |
# error "Bad architecture" |
| 95 |
#endif |
| 96 |
|
| 97 |
static constexpr Register ABINonArgReg0{Registers::invalid_reg}; |
| 98 |
static constexpr Register ABINonArgReg1{Registers::invalid_reg}; |
| 99 |
static constexpr Register ABINonArgReg2{Registers::invalid_reg}; |
| 100 |
static constexpr Register ABINonArgReg3{Registers::invalid_reg}; |
| 101 |
static constexpr Register ABINonArgReturnReg0{Registers::invalid_reg}; |
| 102 |
static constexpr Register ABINonArgReturnReg1{Registers::invalid_reg}; |
| 103 |
static constexpr Register ABINonVolatileReg{Registers::invalid_reg}; |
| 104 |
static constexpr Register ABINonArgReturnVolatileReg{Registers::invalid_reg}; |
| 105 |
|
| 106 |
static constexpr FloatRegister ABINonArgDoubleReg = { |
| 107 |
FloatRegisters::invalid_reg}; |
| 108 |
|
| 109 |
static constexpr Register WasmTableCallScratchReg0{Registers::invalid_reg}; |
| 110 |
static constexpr Register WasmTableCallScratchReg1{Registers::invalid_reg}; |
| 111 |
static constexpr Register WasmTableCallSigReg{Registers::invalid_reg}; |
| 112 |
static constexpr Register WasmTableCallIndexReg{Registers::invalid_reg}; |
| 113 |
static constexpr Register InstanceReg{Registers::invalid_reg}; |
| 114 |
static constexpr Register WasmJitEntryReturnScratch{Registers::invalid_reg}; |
| 115 |
static constexpr Register WasmCallRefCallScratchReg0{Registers::invalid_reg}; |
| 116 |
static constexpr Register WasmCallRefCallScratchReg1{Registers::invalid_reg}; |
| 117 |
static constexpr Register WasmCallRefReg{Registers::invalid_reg}; |
| 118 |
static constexpr Register WasmTailCallInstanceScratchReg{ |
| 119 |
Registers::invalid_reg}; |
| 120 |
static constexpr Register WasmTailCallRAScratchReg{Registers::invalid_reg}; |
| 121 |
static constexpr Register WasmTailCallFPScratchReg{Registers::invalid_reg}; |
| 122 |
|
| 123 |
static constexpr uint32_t ABIStackAlignment = 4; |
| 124 |
static constexpr uint32_t CodeAlignment = 16; |
| 125 |
static constexpr uint32_t JitStackAlignment = 8; |
| 126 |
static constexpr uint32_t JitStackValueAlignment = |
| 127 |
JitStackAlignment / sizeof(Value); |
| 128 |
|
| 129 |
static const Scale ScalePointer = TimesOne; |
| 130 |
|
| 131 |
static constexpr uint32_t Int32SizeLog2 = 2; |
| 132 |
|
| 133 |
struct MemoryArgument { |
| 134 |
uint32_t align; |
| 135 |
uint32_t offset; |
| 136 |
}; |
| 137 |
|
| 138 |
class AssemblerWasm32 : public AssemblerShared {}; |
| 139 |
|
| 140 |
class Assembler : public AssemblerWasm32 { |
| 141 |
public: |
| 142 |
enum Condition { |
| 143 |
Equal, |
| 144 |
NotEqual, |
| 145 |
Above, |
| 146 |
AboveOrEqual, |
| 147 |
Below, |
| 148 |
BelowOrEqual, |
| 149 |
GreaterThan, |
| 150 |
GreaterThanOrEqual, |
| 151 |
LessThan, |
| 152 |
LessThanOrEqual, |
| 153 |
Overflow, |
| 154 |
CarrySet, |
| 155 |
CarryClear, |
| 156 |
Signed, |
| 157 |
NotSigned, |
| 158 |
Zero, |
| 159 |
NonZero, |
| 160 |
Always, |
| 161 |
}; |
| 162 |
|
| 163 |
enum DoubleCondition { |
| 164 |
DoubleOrdered, |
| 165 |
DoubleEqual, |
| 166 |
DoubleNotEqual, |
| 167 |
DoubleGreaterThan, |
| 168 |
DoubleGreaterThanOrEqual, |
| 169 |
DoubleLessThan, |
| 170 |
DoubleLessThanOrEqual, |
| 171 |
DoubleUnordered, |
| 172 |
DoubleEqualOrUnordered, |
| 173 |
DoubleNotEqualOrUnordered, |
| 174 |
DoubleGreaterThanOrUnordered, |
| 175 |
DoubleGreaterThanOrEqualOrUnordered, |
| 176 |
DoubleLessThanOrUnordered, |
| 177 |
DoubleLessThanOrEqualOrUnordered |
| 178 |
}; |
| 179 |
|
| 180 |
static Condition InvertCondition(Condition) { MOZ_CRASH(); } |
| 181 |
|
| 182 |
static DoubleCondition InvertCondition(DoubleCondition) { MOZ_CRASH(); } |
| 183 |
|
| 184 |
template <typename T, typename S> |
| 185 |
static void PatchDataWithValueCheck(CodeLocationLabel, T, S) { |
| 186 |
MOZ_CRASH(); |
| 187 |
} |
| 188 |
static void PatchWrite_Imm32(CodeLocationLabel, Imm32) { MOZ_CRASH(); } |
| 189 |
|
| 190 |
static void PatchWrite_NearCall(CodeLocationLabel, CodeLocationLabel) { |
| 191 |
MOZ_CRASH(); |
| 192 |
} |
| 193 |
static uint32_t PatchWrite_NearCallSize() { MOZ_CRASH(); } |
| 194 |
|
| 195 |
static void ToggleToJmp(CodeLocationLabel) { MOZ_CRASH(); } |
| 196 |
static void ToggleToCmp(CodeLocationLabel) { MOZ_CRASH(); } |
| 197 |
static void ToggleCall(CodeLocationLabel, bool) { MOZ_CRASH(); } |
| 198 |
|
| 199 |
static void Bind(uint8_t*, const CodeLabel&) { MOZ_CRASH(); } |
| 200 |
|
| 201 |
static uintptr_t GetPointer(uint8_t*) { MOZ_CRASH(); } |
| 202 |
|
| 203 |
static bool HasRoundInstruction(RoundingMode) { return false; } |
| 204 |
|
| 205 |
void verifyHeapAccessDisassembly(uint32_t begin, uint32_t end, |
| 206 |
const Disassembler::HeapAccess& heapAccess) { |
| 207 |
MOZ_CRASH(); |
| 208 |
} |
| 209 |
|
| 210 |
void setUnlimitedBuffer() { MOZ_CRASH(); } |
| 211 |
}; |
| 212 |
|
| 213 |
class Operand { |
| 214 |
public: |
| 215 |
explicit Operand(const Address&) { MOZ_CRASH(); } |
| 216 |
explicit Operand(const Register) { MOZ_CRASH(); } |
| 217 |
explicit Operand(const FloatRegister) { MOZ_CRASH(); } |
| 218 |
explicit Operand(Register, Imm32) { MOZ_CRASH(); } |
| 219 |
explicit Operand(Register, int32_t) { MOZ_CRASH(); } |
| 220 |
}; |
| 221 |
|
| 222 |
class ABIArgGenerator { |
| 223 |
public: |
| 224 |
ABIArgGenerator() = default; |
| 225 |
ABIArg next(MIRType) { MOZ_CRASH(); } |
| 226 |
ABIArg& current() { MOZ_CRASH(); } |
| 227 |
uint32_t stackBytesConsumedSoFar() const { MOZ_CRASH(); } |
| 228 |
void increaseStackOffset(uint32_t) { MOZ_CRASH(); } |
| 229 |
}; |
| 230 |
|
| 231 |
} // namespace js::jit |
| 232 |
|
| 233 |
#endif /* jit_wasm32_Assembler_wasm32_h */ |