Debian Codegraph @

js/src/jit/x86-shared/CodeGenerator-x86-shared.h

raw
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_x86_shared_CodeGenerator_x86_shared_h
8 #define jit_x86_shared_CodeGenerator_x86_shared_h
9
10 #include "jit/shared/CodeGenerator-shared.h"
11 #include "js/ScalarType.h" // js::Scalar::Type
12
13 namespace js {
14 namespace jit {
15
16 class CodeGeneratorX86Shared;
17 class ModOverflowCheck;
18 class OutOfLineTableSwitch;
19
20 using OutOfLineWasmTruncateCheck =
21 OutOfLineWasmTruncateCheckBase<CodeGeneratorX86Shared>;
22
23 class CodeGeneratorX86Shared : public CodeGeneratorShared {
24 friend class MoveResolverX86;
25
26 template <typename T>
27 void bailout(const T& t, LSnapshot* snapshot);
28
29 protected:
30 CodeGeneratorX86Shared(MIRGenerator* gen, LIRGraph* graph,
31 MacroAssembler* masm,
32 const wasm::CodeMetadata* wasmCodeMeta);
33
34 NonAssertingLabel deoptLabel_;
35
36 Operand ToOperand(const LAllocation& a);
37 Operand ToOperand(const LAllocation* a);
38 Operand ToOperand(const LDefinition* def);
39
40 #ifdef JS_PUNBOX64
41 Operand ToOperandOrRegister64(const LInt64Allocation& input);
42 #else
43 Register64 ToOperandOrRegister64(const LInt64Allocation& input);
44 #endif
45
46 MoveOperand toMoveOperand(LAllocation a) const;
47
48 void bailoutIf(Assembler::Condition condition, LSnapshot* snapshot);
49 void bailoutIf(Assembler::DoubleCondition condition, LSnapshot* snapshot);
50 void bailoutFrom(Label* label, LSnapshot* snapshot);
51 void bailout(LSnapshot* snapshot);
52
53 template <typename T1, typename T2>
54 void bailoutCmpPtr(Assembler::Condition c, T1 lhs, T2 rhs,
55 LSnapshot* snapshot) {
56 masm.cmpPtr(lhs, rhs);
57 bailoutIf(c, snapshot);
58 }
59 void bailoutTestPtr(Assembler::Condition c, Register lhs, Register rhs,
60 LSnapshot* snapshot) {
61 masm.testPtr(lhs, rhs);
62 bailoutIf(c, snapshot);
63 }
64 template <typename T1, typename T2>
65 void bailoutCmp32(Assembler::Condition c, T1 lhs, T2 rhs,
66 LSnapshot* snapshot) {
67 masm.cmp32(lhs, rhs);
68 bailoutIf(c, snapshot);
69 }
70 template <typename T1, typename T2>
71 void bailoutTest32(Assembler::Condition c, T1 lhs, T2 rhs,
72 LSnapshot* snapshot) {
73 masm.test32(lhs, rhs);
74 bailoutIf(c, snapshot);
75 }
76 void bailoutIfFalseBool(Register reg, LSnapshot* snapshot) {
77 masm.test32(reg, Imm32(0xFF));
78 bailoutIf(Assembler::Zero, snapshot);
79 }
80
81 bool generateOutOfLineCode();
82
83 // Emits a branch that directs control flow to the true block if |cond| is
84 // true, and the false block if |cond| is false.
85 void emitBranch(Assembler::Condition cond, MBasicBlock* ifTrue,
86 MBasicBlock* ifFalse);
87 void emitBranch(Assembler::DoubleCondition cond, MBasicBlock* ifTrue,
88 MBasicBlock* ifFalse, Assembler::NaNCond ifNaN);
89
90 void emitTableSwitchDispatch(MTableSwitch* mir, Register index,
91 Register base);
92
93 void generateInvalidateEpilogue();
94
95 template <typename T>
96 Operand toMemoryAccessOperand(T* lir, int32_t disp);
97
98 public:
99 void emitUndoALUOperationOOL(LInstruction* ins);
100
101 // Out of line visitors.
102 void visitModOverflowCheck(ModOverflowCheck* ool);
103 void visitOutOfLineTableSwitch(OutOfLineTableSwitch* ool);
104 void visitOutOfLineWasmTruncateCheck(OutOfLineWasmTruncateCheck* ool);
105 };
106
107 } // namespace jit
108 } // namespace js
109
110 #endif /* jit_x86_shared_CodeGenerator_x86_shared_h */