WasmBCDefs.h (5229B)
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 * 4 * Copyright 2016 Mozilla Foundation 5 * 6 * Licensed under the Apache License, Version 2.0 (the "License"); 7 * you may not use this file except in compliance with the License. 8 * You may obtain a copy of the License at 9 * 10 * http://www.apache.org/licenses/LICENSE-2.0 11 * 12 * Unless required by applicable law or agreed to in writing, software 13 * distributed under the License is distributed on an "AS IS" BASIS, 14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 * See the License for the specific language governing permissions and 16 * limitations under the License. 17 */ 18 19 // This is an INTERNAL header for Wasm baseline compiler: common configuration 20 // and simple definitions; all include directives. 21 22 #ifndef wasm_wasm_baseline_defs_h 23 #define wasm_wasm_baseline_defs_h 24 25 #include "jit/AtomicOp.h" 26 #include "jit/IonTypes.h" 27 #include "jit/JitAllocPolicy.h" 28 #include "jit/Label.h" 29 #include "jit/RegisterAllocator.h" 30 #include "jit/Registers.h" 31 #include "jit/RegisterSets.h" 32 #if defined(JS_CODEGEN_ARM) 33 # include "jit/arm/Assembler-arm.h" 34 #endif 35 #if defined(JS_CODEGEN_X64) || defined(JS_CODEGEN_X86) 36 # include "jit/x86-shared/Architecture-x86-shared.h" 37 # include "jit/x86-shared/Assembler-x86-shared.h" 38 #endif 39 #if defined(JS_CODEGEN_MIPS64) 40 # include "jit/mips-shared/Assembler-mips-shared.h" 41 # include "jit/mips64/Assembler-mips64.h" 42 #endif 43 #if defined(JS_CODEGEN_LOONG64) 44 # include "jit/loong64/Assembler-loong64.h" 45 #endif 46 #if defined(JS_CODEGEN_RISCV64) 47 # include "jit/riscv64/Assembler-riscv64.h" 48 #endif 49 #include "js/ScalarType.h" 50 #include "util/Memory.h" 51 #include "wasm/WasmCodegenTypes.h" 52 #include "wasm/WasmDebugFrame.h" 53 #include "wasm/WasmGC.h" 54 #include "wasm/WasmGcObject.h" 55 #include "wasm/WasmGenerator.h" 56 #include "wasm/WasmInstance.h" 57 #include "wasm/WasmOpIter.h" 58 #include "wasm/WasmSignalHandlers.h" 59 #include "wasm/WasmStubs.h" 60 #include "wasm/WasmValidate.h" 61 62 namespace js { 63 namespace wasm { 64 65 using HandleNaNSpecially = bool; 66 using InvertBranch = bool; 67 using IsKnownNotZero = bool; 68 using IsUnsigned = bool; 69 using IsRemainder = bool; 70 using NeedsBoundsCheck = bool; 71 using WantResult = bool; 72 using ZeroOnOverflow = bool; 73 74 class BaseStackFrame; 75 76 enum class RestoreState { 77 // Don't reload anything 78 None, 79 // Reload just the pinned registers, assuming the instance is still valid 80 PinnedRegs, 81 // Reload the instance register, pinned registers, and perform a realm switch 82 All, 83 }; 84 enum class RhsDestOp { True = true }; 85 86 // Compiler configuration. 87 // 88 // The following internal configuration #defines are used. The configuration is 89 // partly below in this file, partly in WasmBCRegDefs.h. 90 // 91 // RABALDR_PIN_INSTANCE 92 // InstanceReg is not allocatable and always holds the current Instance*, 93 // except in known contexts where it could have been clobbered, such as after 94 // certain calls. 95 // 96 // RABALDR_ZERO_EXTENDS 97 // The canonical representation of a 32-bit value in a 64-bit register is 98 // zero-extended. For 64-bit platforms only. See comment block "64-bit GPRs 99 // carrying 32-bit values" in MacroAssembler.h. 100 // 101 // RABALDR_CHUNKY_STACK 102 // The platform must allocate the CPU stack in chunks and not word-at-a-time 103 // due to SP alignment requirements (ARM64 for now). 104 // 105 // RABALDR_INT_DIV_I64_CALLOUT 106 // The platform calls out to the runtime to divide i64/u64. 107 // 108 // RABALDR_I64_TO_FLOAT_CALLOUT 109 // The platform calls out to the runtime for i64 -> fXX conversions. 110 // 111 // RABALDR_FLOAT_TO_I64_CALLOUT 112 // The platform calls out to the runtime for fXX -> i64 conversions. 113 // 114 // RABALDR_SCRATCH_<TypeName> 115 // The baseline compiler has its own scratch registers for the given type, it 116 // does not use the MacroAssembler's scratch. This is really an anachronism - 117 // the baseline compiler should never use the MacroAssembler's scratches. 118 // 119 // RABALDR_SCRATCH_F32_ALIASES_F64 120 // On a platform where the baseline compiler has its own F32 and F64 121 // scratches, these are the same register. 122 123 #ifdef JS_CODEGEN_X64 124 # define RABALDR_ZERO_EXTENDS 125 # define RABALDR_PIN_INSTANCE 126 #endif 127 128 #ifdef JS_CODEGEN_ARM64 129 # define RABALDR_CHUNKY_STACK 130 # define RABALDR_ZERO_EXTENDS 131 # define RABALDR_PIN_INSTANCE 132 #endif 133 134 #ifdef JS_CODEGEN_X86 135 # define RABALDR_INT_DIV_I64_CALLOUT 136 #endif 137 138 #ifdef JS_CODEGEN_ARM 139 # define RABALDR_INT_DIV_I64_CALLOUT 140 # define RABALDR_I64_TO_FLOAT_CALLOUT 141 # define RABALDR_FLOAT_TO_I64_CALLOUT 142 #endif 143 144 #ifdef JS_CODEGEN_MIPS64 145 # define RABALDR_PIN_INSTANCE 146 #endif 147 148 #ifdef JS_CODEGEN_LOONG64 149 # define RABALDR_PIN_INSTANCE 150 #endif 151 152 #ifdef JS_CODEGEN_RISCV64 153 # define RABALDR_PIN_INSTANCE 154 #endif 155 156 // Max number of pushes onto the value stack for any opcode or emitter that 157 // does not push a variable, unbounded amount (anything with multiple 158 // results). This includes also intermediate pushes such as values pushed as 159 // parameters for builtin calls. 160 // 161 // This limit is set quite high on purpose, so as to avoid brittleness. The 162 // true max value is likely no more than four or five. 163 164 static constexpr size_t MaxPushesPerOpcode = 10; 165 166 } // namespace wasm 167 } // namespace js 168 169 #endif // wasm_wasm_baseline_defs_h