js/src/jit/shared/CodeGenerator-shared-inl.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_shared_inl_h
michael@0 8 #define jit_shared_CodeGenerator_shared_inl_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 static inline int32_t
michael@0 16 ToInt32(const LAllocation *a)
michael@0 17 {
michael@0 18 if (a->isConstantValue())
michael@0 19 return a->toConstant()->toInt32();
michael@0 20 if (a->isConstantIndex())
michael@0 21 return a->toConstantIndex()->index();
michael@0 22 MOZ_ASSUME_UNREACHABLE("this is not a constant!");
michael@0 23 }
michael@0 24 static inline double
michael@0 25 ToDouble(const LAllocation *a)
michael@0 26 {
michael@0 27 return a->toConstant()->toNumber();
michael@0 28 }
michael@0 29
michael@0 30 static inline Register
michael@0 31 ToRegister(const LAllocation &a)
michael@0 32 {
michael@0 33 JS_ASSERT(a.isGeneralReg());
michael@0 34 return a.toGeneralReg()->reg();
michael@0 35 }
michael@0 36
michael@0 37 static inline Register
michael@0 38 ToRegister(const LAllocation *a)
michael@0 39 {
michael@0 40 return ToRegister(*a);
michael@0 41 }
michael@0 42
michael@0 43 static inline Register
michael@0 44 ToRegister(const LDefinition *def)
michael@0 45 {
michael@0 46 return ToRegister(*def->output());
michael@0 47 }
michael@0 48
michael@0 49 static inline Register
michael@0 50 ToTempRegisterOrInvalid(const LDefinition *def)
michael@0 51 {
michael@0 52 if (def->isBogusTemp())
michael@0 53 return InvalidReg;
michael@0 54 return ToRegister(def);
michael@0 55 }
michael@0 56
michael@0 57 static inline Register
michael@0 58 ToTempUnboxRegister(const LDefinition *def)
michael@0 59 {
michael@0 60 return ToTempRegisterOrInvalid(def);
michael@0 61 }
michael@0 62
michael@0 63 static inline Register
michael@0 64 ToRegisterOrInvalid(const LDefinition *a)
michael@0 65 {
michael@0 66 return a ? ToRegister(a) : InvalidReg;
michael@0 67 }
michael@0 68
michael@0 69 static inline FloatRegister
michael@0 70 ToFloatRegister(const LAllocation &a)
michael@0 71 {
michael@0 72 JS_ASSERT(a.isFloatReg());
michael@0 73 return a.toFloatReg()->reg();
michael@0 74 }
michael@0 75
michael@0 76 static inline FloatRegister
michael@0 77 ToFloatRegister(const LAllocation *a)
michael@0 78 {
michael@0 79 return ToFloatRegister(*a);
michael@0 80 }
michael@0 81
michael@0 82 static inline FloatRegister
michael@0 83 ToFloatRegister(const LDefinition *def)
michael@0 84 {
michael@0 85 return ToFloatRegister(*def->output());
michael@0 86 }
michael@0 87
michael@0 88 static inline AnyRegister
michael@0 89 ToAnyRegister(const LAllocation &a)
michael@0 90 {
michael@0 91 JS_ASSERT(a.isGeneralReg() || a.isFloatReg());
michael@0 92 if (a.isGeneralReg())
michael@0 93 return AnyRegister(ToRegister(a));
michael@0 94 return AnyRegister(ToFloatRegister(a));
michael@0 95 }
michael@0 96
michael@0 97 static inline AnyRegister
michael@0 98 ToAnyRegister(const LAllocation *a)
michael@0 99 {
michael@0 100 return ToAnyRegister(*a);
michael@0 101 }
michael@0 102
michael@0 103 static inline AnyRegister
michael@0 104 ToAnyRegister(const LDefinition *def)
michael@0 105 {
michael@0 106 return ToAnyRegister(def->output());
michael@0 107 }
michael@0 108
michael@0 109 static inline Int32Key
michael@0 110 ToInt32Key(const LAllocation *a)
michael@0 111 {
michael@0 112 if (a->isConstant())
michael@0 113 return Int32Key(ToInt32(a));
michael@0 114 return Int32Key(ToRegister(a));
michael@0 115 }
michael@0 116
michael@0 117 static inline ValueOperand
michael@0 118 GetValueOutput(LInstruction *ins)
michael@0 119 {
michael@0 120 #if defined(JS_NUNBOX32)
michael@0 121 return ValueOperand(ToRegister(ins->getDef(TYPE_INDEX)),
michael@0 122 ToRegister(ins->getDef(PAYLOAD_INDEX)));
michael@0 123 #elif defined(JS_PUNBOX64)
michael@0 124 return ValueOperand(ToRegister(ins->getDef(0)));
michael@0 125 #else
michael@0 126 #error "Unknown"
michael@0 127 #endif
michael@0 128 }
michael@0 129
michael@0 130 static inline ValueOperand
michael@0 131 GetTempValue(const Register &type, const Register &payload)
michael@0 132 {
michael@0 133 #if defined(JS_NUNBOX32)
michael@0 134 return ValueOperand(type, payload);
michael@0 135 #elif defined(JS_PUNBOX64)
michael@0 136 (void)type;
michael@0 137 return ValueOperand(payload);
michael@0 138 #else
michael@0 139 #error "Unknown"
michael@0 140 #endif
michael@0 141 }
michael@0 142
michael@0 143 void
michael@0 144 CodeGeneratorShared::saveLive(LInstruction *ins)
michael@0 145 {
michael@0 146 JS_ASSERT(!ins->isCall());
michael@0 147 LSafepoint *safepoint = ins->safepoint();
michael@0 148 masm.PushRegsInMask(safepoint->liveRegs());
michael@0 149 }
michael@0 150
michael@0 151 void
michael@0 152 CodeGeneratorShared::restoreLive(LInstruction *ins)
michael@0 153 {
michael@0 154 JS_ASSERT(!ins->isCall());
michael@0 155 LSafepoint *safepoint = ins->safepoint();
michael@0 156 masm.PopRegsInMask(safepoint->liveRegs());
michael@0 157 }
michael@0 158
michael@0 159 void
michael@0 160 CodeGeneratorShared::restoreLiveIgnore(LInstruction *ins, RegisterSet ignore)
michael@0 161 {
michael@0 162 JS_ASSERT(!ins->isCall());
michael@0 163 LSafepoint *safepoint = ins->safepoint();
michael@0 164 masm.PopRegsInMaskIgnore(safepoint->liveRegs(), ignore);
michael@0 165 }
michael@0 166
michael@0 167 void
michael@0 168 CodeGeneratorShared::saveLiveVolatile(LInstruction *ins)
michael@0 169 {
michael@0 170 JS_ASSERT(!ins->isCall());
michael@0 171 LSafepoint *safepoint = ins->safepoint();
michael@0 172 RegisterSet regs = RegisterSet::Intersect(safepoint->liveRegs(), RegisterSet::Volatile());
michael@0 173 masm.PushRegsInMask(regs);
michael@0 174 }
michael@0 175
michael@0 176 void
michael@0 177 CodeGeneratorShared::restoreLiveVolatile(LInstruction *ins)
michael@0 178 {
michael@0 179 JS_ASSERT(!ins->isCall());
michael@0 180 LSafepoint *safepoint = ins->safepoint();
michael@0 181 RegisterSet regs = RegisterSet::Intersect(safepoint->liveRegs(), RegisterSet::Volatile());
michael@0 182 masm.PopRegsInMask(regs);
michael@0 183 }
michael@0 184
michael@0 185 } // ion
michael@0 186 } // js
michael@0 187
michael@0 188 #endif /* jit_shared_CodeGenerator_shared_inl_h */

mercurial