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

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* -*- Mode: C++; tab-width: 8; indent-tabs-mode: nil; c-basic-offset: 4 -*-
michael@0 2 * vim: set ts=8 sts=4 et sw=4 tw=99:
michael@0 3 * This Source Code Form is subject to the terms of the Mozilla Public
michael@0 4 * License, v. 2.0. If a copy of the MPL was not distributed with this
michael@0 5 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
michael@0 6
michael@0 7 #ifndef jit_shared_CodeGenerator_x86_shared_h
michael@0 8 #define jit_shared_CodeGenerator_x86_shared_h
michael@0 9
michael@0 10 #include "jit/shared/CodeGenerator-shared.h"
michael@0 11
michael@0 12 namespace js {
michael@0 13 namespace jit {
michael@0 14
michael@0 15 class OutOfLineBailout;
michael@0 16 class OutOfLineUndoALUOperation;
michael@0 17 class MulNegativeZeroCheck;
michael@0 18 class ModOverflowCheck;
michael@0 19 class ReturnZero;
michael@0 20 class OutOfLineTableSwitch;
michael@0 21
michael@0 22 class CodeGeneratorX86Shared : public CodeGeneratorShared
michael@0 23 {
michael@0 24 friend class MoveResolverX86;
michael@0 25
michael@0 26 CodeGeneratorX86Shared *thisFromCtor() {
michael@0 27 return this;
michael@0 28 }
michael@0 29
michael@0 30 template <typename T>
michael@0 31 bool bailout(const T &t, LSnapshot *snapshot);
michael@0 32
michael@0 33 protected:
michael@0 34 // Label for the common return path.
michael@0 35 NonAssertingLabel returnLabel_;
michael@0 36 NonAssertingLabel deoptLabel_;
michael@0 37
michael@0 38 inline Operand ToOperand(const LAllocation &a) {
michael@0 39 if (a.isGeneralReg())
michael@0 40 return Operand(a.toGeneralReg()->reg());
michael@0 41 if (a.isFloatReg())
michael@0 42 return Operand(a.toFloatReg()->reg());
michael@0 43 return Operand(StackPointer, ToStackOffset(&a));
michael@0 44 }
michael@0 45 inline Operand ToOperand(const LAllocation *a) {
michael@0 46 return ToOperand(*a);
michael@0 47 }
michael@0 48 inline Operand ToOperand(const LDefinition *def) {
michael@0 49 return ToOperand(def->output());
michael@0 50 }
michael@0 51
michael@0 52 MoveOperand toMoveOperand(const LAllocation *a) const;
michael@0 53
michael@0 54 bool bailoutIf(Assembler::Condition condition, LSnapshot *snapshot);
michael@0 55 bool bailoutIf(Assembler::DoubleCondition condition, LSnapshot *snapshot);
michael@0 56 bool bailoutFrom(Label *label, LSnapshot *snapshot);
michael@0 57 bool bailout(LSnapshot *snapshot);
michael@0 58
michael@0 59 template <typename T1, typename T2>
michael@0 60 bool bailoutCmpPtr(Assembler::Condition c, T1 lhs, T2 rhs, LSnapshot *snapshot) {
michael@0 61 masm.cmpPtr(lhs, rhs);
michael@0 62 return bailoutIf(c, snapshot);
michael@0 63 }
michael@0 64 bool bailoutTestPtr(Assembler::Condition c, Register lhs, Register rhs, LSnapshot *snapshot) {
michael@0 65 masm.testPtr(lhs, rhs);
michael@0 66 return bailoutIf(c, snapshot);
michael@0 67 }
michael@0 68 template <typename T1, typename T2>
michael@0 69 bool bailoutCmp32(Assembler::Condition c, T1 lhs, T2 rhs, LSnapshot *snapshot) {
michael@0 70 masm.cmp32(lhs, rhs);
michael@0 71 return bailoutIf(c, snapshot);
michael@0 72 }
michael@0 73 template <typename T1, typename T2>
michael@0 74 bool bailoutTest32(Assembler::Condition c, T1 lhs, T2 rhs, LSnapshot *snapshot) {
michael@0 75 masm.test32(lhs, rhs);
michael@0 76 return bailoutIf(c, snapshot);
michael@0 77 }
michael@0 78
michael@0 79 protected:
michael@0 80 bool generatePrologue();
michael@0 81 bool generateAsmJSPrologue(Label *stackOverflowLabe);
michael@0 82 bool generateEpilogue();
michael@0 83 bool generateOutOfLineCode();
michael@0 84
michael@0 85 Operand createArrayElementOperand(Register elements, const LAllocation *index);
michael@0 86
michael@0 87 void emitCompare(MCompare::CompareType type, const LAllocation *left, const LAllocation *right);
michael@0 88
michael@0 89 // Emits a branch that directs control flow to the true block if |cond| is
michael@0 90 // true, and the false block if |cond| is false.
michael@0 91 void emitBranch(Assembler::Condition cond, MBasicBlock *ifTrue, MBasicBlock *ifFalse,
michael@0 92 Assembler::NaNCond ifNaN = Assembler::NaN_HandledByCond);
michael@0 93 void emitBranch(Assembler::DoubleCondition cond, MBasicBlock *ifTrue, MBasicBlock *ifFalse);
michael@0 94
michael@0 95 void testNullEmitBranch(Assembler::Condition cond, const ValueOperand &value,
michael@0 96 MBasicBlock *ifTrue, MBasicBlock *ifFalse)
michael@0 97 {
michael@0 98 cond = masm.testNull(cond, value);
michael@0 99 emitBranch(cond, ifTrue, ifFalse);
michael@0 100 }
michael@0 101 void testUndefinedEmitBranch(Assembler::Condition cond, const ValueOperand &value,
michael@0 102 MBasicBlock *ifTrue, MBasicBlock *ifFalse)
michael@0 103 {
michael@0 104 cond = masm.testUndefined(cond, value);
michael@0 105 emitBranch(cond, ifTrue, ifFalse);
michael@0 106 }
michael@0 107
michael@0 108 bool emitTableSwitchDispatch(MTableSwitch *mir, const Register &index, const Register &base);
michael@0 109
michael@0 110 public:
michael@0 111 CodeGeneratorX86Shared(MIRGenerator *gen, LIRGraph *graph, MacroAssembler *masm);
michael@0 112
michael@0 113 public:
michael@0 114 // Instruction visitors.
michael@0 115 virtual bool visitDouble(LDouble *ins);
michael@0 116 virtual bool visitFloat32(LFloat32 *ins);
michael@0 117 virtual bool visitMinMaxD(LMinMaxD *ins);
michael@0 118 virtual bool visitAbsD(LAbsD *ins);
michael@0 119 virtual bool visitAbsF(LAbsF *ins);
michael@0 120 virtual bool visitSqrtD(LSqrtD *ins);
michael@0 121 virtual bool visitSqrtF(LSqrtF *ins);
michael@0 122 virtual bool visitPowHalfD(LPowHalfD *ins);
michael@0 123 virtual bool visitAddI(LAddI *ins);
michael@0 124 virtual bool visitSubI(LSubI *ins);
michael@0 125 virtual bool visitMulI(LMulI *ins);
michael@0 126 virtual bool visitDivI(LDivI *ins);
michael@0 127 virtual bool visitDivPowTwoI(LDivPowTwoI *ins);
michael@0 128 virtual bool visitDivOrModConstantI(LDivOrModConstantI *ins);
michael@0 129 virtual bool visitModI(LModI *ins);
michael@0 130 virtual bool visitModPowTwoI(LModPowTwoI *ins);
michael@0 131 virtual bool visitBitNotI(LBitNotI *ins);
michael@0 132 virtual bool visitBitOpI(LBitOpI *ins);
michael@0 133 virtual bool visitShiftI(LShiftI *ins);
michael@0 134 virtual bool visitUrshD(LUrshD *ins);
michael@0 135 virtual bool visitTestIAndBranch(LTestIAndBranch *test);
michael@0 136 virtual bool visitTestDAndBranch(LTestDAndBranch *test);
michael@0 137 virtual bool visitTestFAndBranch(LTestFAndBranch *test);
michael@0 138 virtual bool visitCompare(LCompare *comp);
michael@0 139 virtual bool visitCompareAndBranch(LCompareAndBranch *comp);
michael@0 140 virtual bool visitCompareD(LCompareD *comp);
michael@0 141 virtual bool visitCompareDAndBranch(LCompareDAndBranch *comp);
michael@0 142 virtual bool visitCompareF(LCompareF *comp);
michael@0 143 virtual bool visitCompareFAndBranch(LCompareFAndBranch *comp);
michael@0 144 virtual bool visitBitAndAndBranch(LBitAndAndBranch *baab);
michael@0 145 virtual bool visitNotI(LNotI *comp);
michael@0 146 virtual bool visitNotD(LNotD *comp);
michael@0 147 virtual bool visitNotF(LNotF *comp);
michael@0 148 virtual bool visitMathD(LMathD *math);
michael@0 149 virtual bool visitMathF(LMathF *math);
michael@0 150 virtual bool visitFloor(LFloor *lir);
michael@0 151 virtual bool visitFloorF(LFloorF *lir);
michael@0 152 virtual bool visitRound(LRound *lir);
michael@0 153 virtual bool visitRoundF(LRoundF *lir);
michael@0 154 virtual bool visitGuardShape(LGuardShape *guard);
michael@0 155 virtual bool visitGuardObjectType(LGuardObjectType *guard);
michael@0 156 virtual bool visitGuardClass(LGuardClass *guard);
michael@0 157 virtual bool visitEffectiveAddress(LEffectiveAddress *ins);
michael@0 158 virtual bool visitUDivOrMod(LUDivOrMod *ins);
michael@0 159 virtual bool visitAsmJSPassStackArg(LAsmJSPassStackArg *ins);
michael@0 160
michael@0 161 bool visitForkJoinGetSlice(LForkJoinGetSlice *ins);
michael@0 162
michael@0 163 bool visitNegI(LNegI *lir);
michael@0 164 bool visitNegD(LNegD *lir);
michael@0 165 bool visitNegF(LNegF *lir);
michael@0 166
michael@0 167 // Out of line visitors.
michael@0 168 bool visitOutOfLineBailout(OutOfLineBailout *ool);
michael@0 169 bool visitOutOfLineUndoALUOperation(OutOfLineUndoALUOperation *ool);
michael@0 170 bool visitMulNegativeZeroCheck(MulNegativeZeroCheck *ool);
michael@0 171 bool visitModOverflowCheck(ModOverflowCheck *ool);
michael@0 172 bool visitReturnZero(ReturnZero *ool);
michael@0 173 bool visitOutOfLineTableSwitch(OutOfLineTableSwitch *ool);
michael@0 174 bool generateInvalidateEpilogue();
michael@0 175 };
michael@0 176
michael@0 177 // An out-of-line bailout thunk.
michael@0 178 class OutOfLineBailout : public OutOfLineCodeBase<CodeGeneratorX86Shared>
michael@0 179 {
michael@0 180 LSnapshot *snapshot_;
michael@0 181
michael@0 182 public:
michael@0 183 OutOfLineBailout(LSnapshot *snapshot)
michael@0 184 : snapshot_(snapshot)
michael@0 185 { }
michael@0 186
michael@0 187 bool accept(CodeGeneratorX86Shared *codegen);
michael@0 188
michael@0 189 LSnapshot *snapshot() const {
michael@0 190 return snapshot_;
michael@0 191 }
michael@0 192 };
michael@0 193
michael@0 194 } // namespace jit
michael@0 195 } // namespace js
michael@0 196
michael@0 197 #endif /* jit_shared_CodeGenerator_x86_shared_h */

mercurial