js/src/jit/arm/Lowering-arm.cpp

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rw-r--r--

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

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 #include "mozilla/MathAlgorithms.h"
michael@0 8
michael@0 9 #include "jit/arm/Assembler-arm.h"
michael@0 10 #include "jit/Lowering.h"
michael@0 11 #include "jit/MIR.h"
michael@0 12
michael@0 13 #include "jit/shared/Lowering-shared-inl.h"
michael@0 14
michael@0 15 using namespace js;
michael@0 16 using namespace js::jit;
michael@0 17
michael@0 18 using mozilla::FloorLog2;
michael@0 19
michael@0 20 bool
michael@0 21 LIRGeneratorARM::useBox(LInstruction *lir, size_t n, MDefinition *mir,
michael@0 22 LUse::Policy policy, bool useAtStart)
michael@0 23 {
michael@0 24 JS_ASSERT(mir->type() == MIRType_Value);
michael@0 25 if (!ensureDefined(mir))
michael@0 26 return false;
michael@0 27 lir->setOperand(n, LUse(mir->virtualRegister(), policy, useAtStart));
michael@0 28 lir->setOperand(n + 1, LUse(VirtualRegisterOfPayload(mir), policy, useAtStart));
michael@0 29 return true;
michael@0 30 }
michael@0 31
michael@0 32 bool
michael@0 33 LIRGeneratorARM::useBoxFixed(LInstruction *lir, size_t n, MDefinition *mir, Register reg1,
michael@0 34 Register reg2)
michael@0 35 {
michael@0 36 JS_ASSERT(mir->type() == MIRType_Value);
michael@0 37 JS_ASSERT(reg1 != reg2);
michael@0 38
michael@0 39 if (!ensureDefined(mir))
michael@0 40 return false;
michael@0 41 lir->setOperand(n, LUse(reg1, mir->virtualRegister()));
michael@0 42 lir->setOperand(n + 1, LUse(reg2, VirtualRegisterOfPayload(mir)));
michael@0 43 return true;
michael@0 44 }
michael@0 45
michael@0 46 LAllocation
michael@0 47 LIRGeneratorARM::useByteOpRegister(MDefinition *mir)
michael@0 48 {
michael@0 49 return useRegister(mir);
michael@0 50 }
michael@0 51
michael@0 52 LAllocation
michael@0 53 LIRGeneratorARM::useByteOpRegisterOrNonDoubleConstant(MDefinition *mir)
michael@0 54 {
michael@0 55 return useRegisterOrNonDoubleConstant(mir);
michael@0 56 }
michael@0 57
michael@0 58 bool
michael@0 59 LIRGeneratorARM::lowerConstantDouble(double d, MInstruction *mir)
michael@0 60 {
michael@0 61 return define(new(alloc()) LDouble(d), mir);
michael@0 62 }
michael@0 63
michael@0 64 bool
michael@0 65 LIRGeneratorARM::lowerConstantFloat32(float d, MInstruction *mir)
michael@0 66 {
michael@0 67 return define(new(alloc()) LFloat32(d), mir);
michael@0 68 }
michael@0 69
michael@0 70 bool
michael@0 71 LIRGeneratorARM::visitConstant(MConstant *ins)
michael@0 72 {
michael@0 73 if (ins->type() == MIRType_Double)
michael@0 74 return lowerConstantDouble(ins->value().toDouble(), ins);
michael@0 75
michael@0 76 if (ins->type() == MIRType_Float32)
michael@0 77 return lowerConstantFloat32(ins->value().toDouble(), ins);
michael@0 78
michael@0 79 // Emit non-double constants at their uses.
michael@0 80 if (ins->canEmitAtUses())
michael@0 81 return emitAtUses(ins);
michael@0 82
michael@0 83 return LIRGeneratorShared::visitConstant(ins);
michael@0 84 }
michael@0 85
michael@0 86 bool
michael@0 87 LIRGeneratorARM::visitBox(MBox *box)
michael@0 88 {
michael@0 89 MDefinition *inner = box->getOperand(0);
michael@0 90
michael@0 91 // If the box wrapped a double, it needs a new register.
michael@0 92 if (IsFloatingPointType(inner->type()))
michael@0 93 return defineBox(new(alloc()) LBoxFloatingPoint(useRegisterAtStart(inner), tempCopy(inner, 0),
michael@0 94 inner->type()), box);
michael@0 95
michael@0 96 if (box->canEmitAtUses())
michael@0 97 return emitAtUses(box);
michael@0 98
michael@0 99 if (inner->isConstant())
michael@0 100 return defineBox(new(alloc()) LValue(inner->toConstant()->value()), box);
michael@0 101
michael@0 102 LBox *lir = new(alloc()) LBox(use(inner), inner->type());
michael@0 103
michael@0 104 // Otherwise, we should not define a new register for the payload portion
michael@0 105 // of the output, so bypass defineBox().
michael@0 106 uint32_t vreg = getVirtualRegister();
michael@0 107 if (vreg >= MAX_VIRTUAL_REGISTERS)
michael@0 108 return false;
michael@0 109
michael@0 110 // Note that because we're using PASSTHROUGH, we do not change the type of
michael@0 111 // the definition. We also do not define the first output as "TYPE",
michael@0 112 // because it has no corresponding payload at (vreg + 1). Also note that
michael@0 113 // although we copy the input's original type for the payload half of the
michael@0 114 // definition, this is only for clarity. PASSTHROUGH definitions are
michael@0 115 // ignored.
michael@0 116 lir->setDef(0, LDefinition(vreg, LDefinition::GENERAL));
michael@0 117 lir->setDef(1, LDefinition(inner->virtualRegister(), LDefinition::TypeFrom(inner->type()),
michael@0 118 LDefinition::PASSTHROUGH));
michael@0 119 box->setVirtualRegister(vreg);
michael@0 120 return add(lir);
michael@0 121 }
michael@0 122
michael@0 123 bool
michael@0 124 LIRGeneratorARM::visitUnbox(MUnbox *unbox)
michael@0 125 {
michael@0 126 // An unbox on arm reads in a type tag (either in memory or a register) and
michael@0 127 // a payload. Unlike most instructions conusming a box, we ask for the type
michael@0 128 // second, so that the result can re-use the first input.
michael@0 129 MDefinition *inner = unbox->getOperand(0);
michael@0 130
michael@0 131 if (!ensureDefined(inner))
michael@0 132 return false;
michael@0 133
michael@0 134 if (IsFloatingPointType(unbox->type())) {
michael@0 135 LUnboxFloatingPoint *lir = new(alloc()) LUnboxFloatingPoint(unbox->type());
michael@0 136 if (unbox->fallible() && !assignSnapshot(lir, unbox->bailoutKind()))
michael@0 137 return false;
michael@0 138 if (!useBox(lir, LUnboxFloatingPoint::Input, inner))
michael@0 139 return false;
michael@0 140 return define(lir, unbox);
michael@0 141 }
michael@0 142
michael@0 143 // Swap the order we use the box pieces so we can re-use the payload register.
michael@0 144 LUnbox *lir = new(alloc()) LUnbox;
michael@0 145 lir->setOperand(0, usePayloadInRegisterAtStart(inner));
michael@0 146 lir->setOperand(1, useType(inner, LUse::REGISTER));
michael@0 147
michael@0 148 if (unbox->fallible() && !assignSnapshot(lir, unbox->bailoutKind()))
michael@0 149 return false;
michael@0 150
michael@0 151 // Note that PASSTHROUGH here is illegal, since types and payloads form two
michael@0 152 // separate intervals. If the type becomes dead before the payload, it
michael@0 153 // could be used as a Value without the type being recoverable. Unbox's
michael@0 154 // purpose is to eagerly kill the definition of a type tag, so keeping both
michael@0 155 // alive (for the purpose of gcmaps) is unappealing. Instead, we create a
michael@0 156 // new virtual register.
michael@0 157 return defineReuseInput(lir, unbox, 0);
michael@0 158 }
michael@0 159
michael@0 160 bool
michael@0 161 LIRGeneratorARM::visitReturn(MReturn *ret)
michael@0 162 {
michael@0 163 MDefinition *opd = ret->getOperand(0);
michael@0 164 JS_ASSERT(opd->type() == MIRType_Value);
michael@0 165
michael@0 166 LReturn *ins = new(alloc()) LReturn;
michael@0 167 ins->setOperand(0, LUse(JSReturnReg_Type));
michael@0 168 ins->setOperand(1, LUse(JSReturnReg_Data));
michael@0 169 return fillBoxUses(ins, 0, opd) && add(ins);
michael@0 170 }
michael@0 171
michael@0 172 // x = !y
michael@0 173 bool
michael@0 174 LIRGeneratorARM::lowerForALU(LInstructionHelper<1, 1, 0> *ins, MDefinition *mir, MDefinition *input)
michael@0 175 {
michael@0 176 ins->setOperand(0, useRegister(input));
michael@0 177 return define(ins, mir,
michael@0 178 LDefinition(LDefinition::TypeFrom(mir->type()), LDefinition::DEFAULT));
michael@0 179 }
michael@0 180
michael@0 181 // z = x+y
michael@0 182 bool
michael@0 183 LIRGeneratorARM::lowerForALU(LInstructionHelper<1, 2, 0> *ins, MDefinition *mir, MDefinition *lhs, MDefinition *rhs)
michael@0 184 {
michael@0 185 ins->setOperand(0, useRegister(lhs));
michael@0 186 ins->setOperand(1, useRegisterOrConstant(rhs));
michael@0 187 return define(ins, mir,
michael@0 188 LDefinition(LDefinition::TypeFrom(mir->type()), LDefinition::DEFAULT));
michael@0 189 }
michael@0 190
michael@0 191 bool
michael@0 192 LIRGeneratorARM::lowerForFPU(LInstructionHelper<1, 1, 0> *ins, MDefinition *mir, MDefinition *input)
michael@0 193 {
michael@0 194 ins->setOperand(0, useRegister(input));
michael@0 195 return define(ins, mir,
michael@0 196 LDefinition(LDefinition::TypeFrom(mir->type()), LDefinition::DEFAULT));
michael@0 197
michael@0 198 }
michael@0 199
michael@0 200 bool
michael@0 201 LIRGeneratorARM::lowerForFPU(LInstructionHelper<1, 2, 0> *ins, MDefinition *mir, MDefinition *lhs, MDefinition *rhs)
michael@0 202 {
michael@0 203 ins->setOperand(0, useRegister(lhs));
michael@0 204 ins->setOperand(1, useRegister(rhs));
michael@0 205 return define(ins, mir,
michael@0 206 LDefinition(LDefinition::TypeFrom(mir->type()), LDefinition::DEFAULT));
michael@0 207 }
michael@0 208
michael@0 209 bool
michael@0 210 LIRGeneratorARM::lowerForBitAndAndBranch(LBitAndAndBranch *baab, MInstruction *mir,
michael@0 211 MDefinition *lhs, MDefinition *rhs)
michael@0 212 {
michael@0 213 baab->setOperand(0, useRegisterAtStart(lhs));
michael@0 214 baab->setOperand(1, useRegisterOrConstantAtStart(rhs));
michael@0 215 return add(baab, mir);
michael@0 216 }
michael@0 217
michael@0 218 bool
michael@0 219 LIRGeneratorARM::defineUntypedPhi(MPhi *phi, size_t lirIndex)
michael@0 220 {
michael@0 221 LPhi *type = current->getPhi(lirIndex + VREG_TYPE_OFFSET);
michael@0 222 LPhi *payload = current->getPhi(lirIndex + VREG_DATA_OFFSET);
michael@0 223
michael@0 224 uint32_t typeVreg = getVirtualRegister();
michael@0 225 if (typeVreg >= MAX_VIRTUAL_REGISTERS)
michael@0 226 return false;
michael@0 227
michael@0 228 phi->setVirtualRegister(typeVreg);
michael@0 229
michael@0 230 uint32_t payloadVreg = getVirtualRegister();
michael@0 231 if (payloadVreg >= MAX_VIRTUAL_REGISTERS)
michael@0 232 return false;
michael@0 233 JS_ASSERT(typeVreg + 1 == payloadVreg);
michael@0 234
michael@0 235 type->setDef(0, LDefinition(typeVreg, LDefinition::TYPE));
michael@0 236 payload->setDef(0, LDefinition(payloadVreg, LDefinition::PAYLOAD));
michael@0 237 annotate(type);
michael@0 238 annotate(payload);
michael@0 239 return true;
michael@0 240 }
michael@0 241
michael@0 242 void
michael@0 243 LIRGeneratorARM::lowerUntypedPhiInput(MPhi *phi, uint32_t inputPosition, LBlock *block, size_t lirIndex)
michael@0 244 {
michael@0 245 // oh god, what is this code?
michael@0 246 MDefinition *operand = phi->getOperand(inputPosition);
michael@0 247 LPhi *type = block->getPhi(lirIndex + VREG_TYPE_OFFSET);
michael@0 248 LPhi *payload = block->getPhi(lirIndex + VREG_DATA_OFFSET);
michael@0 249 type->setOperand(inputPosition, LUse(operand->virtualRegister() + VREG_TYPE_OFFSET, LUse::ANY));
michael@0 250 payload->setOperand(inputPosition, LUse(VirtualRegisterOfPayload(operand), LUse::ANY));
michael@0 251 }
michael@0 252
michael@0 253 bool
michael@0 254 LIRGeneratorARM::lowerForShift(LInstructionHelper<1, 2, 0> *ins, MDefinition *mir, MDefinition *lhs, MDefinition *rhs)
michael@0 255 {
michael@0 256
michael@0 257 ins->setOperand(0, useRegister(lhs));
michael@0 258 ins->setOperand(1, useRegisterOrConstant(rhs));
michael@0 259 return define(ins, mir);
michael@0 260 }
michael@0 261
michael@0 262 bool
michael@0 263 LIRGeneratorARM::lowerDivI(MDiv *div)
michael@0 264 {
michael@0 265 if (div->isUnsigned())
michael@0 266 return lowerUDiv(div);
michael@0 267
michael@0 268 // Division instructions are slow. Division by constant denominators can be
michael@0 269 // rewritten to use other instructions.
michael@0 270 if (div->rhs()->isConstant()) {
michael@0 271 int32_t rhs = div->rhs()->toConstant()->value().toInt32();
michael@0 272 // Check for division by a positive power of two, which is an easy and
michael@0 273 // important case to optimize. Note that other optimizations are also
michael@0 274 // possible; division by negative powers of two can be optimized in a
michael@0 275 // similar manner as positive powers of two, and division by other
michael@0 276 // constants can be optimized by a reciprocal multiplication technique.
michael@0 277 int32_t shift = FloorLog2(rhs);
michael@0 278 if (rhs > 0 && 1 << shift == rhs) {
michael@0 279 LDivPowTwoI *lir = new(alloc()) LDivPowTwoI(useRegisterAtStart(div->lhs()), shift);
michael@0 280 if (div->fallible() && !assignSnapshot(lir, Bailout_BaselineInfo))
michael@0 281 return false;
michael@0 282 return define(lir, div);
michael@0 283 }
michael@0 284 }
michael@0 285
michael@0 286 if (hasIDIV()) {
michael@0 287 LDivI *lir = new(alloc()) LDivI(useRegister(div->lhs()), useRegister(div->rhs()), temp());
michael@0 288 if (div->fallible() && !assignSnapshot(lir, Bailout_BaselineInfo))
michael@0 289 return false;
michael@0 290 return define(lir, div);
michael@0 291 }
michael@0 292
michael@0 293 LSoftDivI *lir = new(alloc()) LSoftDivI(useFixedAtStart(div->lhs(), r0), useFixedAtStart(div->rhs(), r1),
michael@0 294 tempFixed(r1), tempFixed(r2), tempFixed(r3));
michael@0 295 if (div->fallible() && !assignSnapshot(lir, Bailout_BaselineInfo))
michael@0 296 return false;
michael@0 297 return defineFixed(lir, div, LAllocation(AnyRegister(r0)));
michael@0 298 }
michael@0 299
michael@0 300 bool
michael@0 301 LIRGeneratorARM::lowerMulI(MMul *mul, MDefinition *lhs, MDefinition *rhs)
michael@0 302 {
michael@0 303 LMulI *lir = new(alloc()) LMulI;
michael@0 304 if (mul->fallible() && !assignSnapshot(lir, Bailout_BaselineInfo))
michael@0 305 return false;
michael@0 306 return lowerForALU(lir, mul, lhs, rhs);
michael@0 307 }
michael@0 308
michael@0 309 bool
michael@0 310 LIRGeneratorARM::lowerModI(MMod *mod)
michael@0 311 {
michael@0 312 if (mod->isUnsigned())
michael@0 313 return lowerUMod(mod);
michael@0 314
michael@0 315 if (mod->rhs()->isConstant()) {
michael@0 316 int32_t rhs = mod->rhs()->toConstant()->value().toInt32();
michael@0 317 int32_t shift = FloorLog2(rhs);
michael@0 318 if (rhs > 0 && 1 << shift == rhs) {
michael@0 319 LModPowTwoI *lir = new(alloc()) LModPowTwoI(useRegister(mod->lhs()), shift);
michael@0 320 if (mod->fallible() && !assignSnapshot(lir, Bailout_BaselineInfo))
michael@0 321 return false;
michael@0 322 return define(lir, mod);
michael@0 323 } else if (shift < 31 && (1 << (shift+1)) - 1 == rhs) {
michael@0 324 LModMaskI *lir = new(alloc()) LModMaskI(useRegister(mod->lhs()), temp(), temp(), shift+1);
michael@0 325 if (mod->fallible() && !assignSnapshot(lir, Bailout_BaselineInfo))
michael@0 326 return false;
michael@0 327 return define(lir, mod);
michael@0 328 }
michael@0 329 }
michael@0 330
michael@0 331 if (hasIDIV()) {
michael@0 332 LModI *lir = new(alloc()) LModI(useRegister(mod->lhs()), useRegister(mod->rhs()), temp());
michael@0 333 if (mod->fallible() && !assignSnapshot(lir, Bailout_BaselineInfo))
michael@0 334 return false;
michael@0 335 return define(lir, mod);
michael@0 336 }
michael@0 337
michael@0 338 LSoftModI *lir = new(alloc()) LSoftModI(useFixedAtStart(mod->lhs(), r0), useFixedAtStart(mod->rhs(), r1),
michael@0 339 tempFixed(r0), tempFixed(r2), tempFixed(r3),
michael@0 340 temp(LDefinition::GENERAL));
michael@0 341 if (mod->fallible() && !assignSnapshot(lir, Bailout_BaselineInfo))
michael@0 342 return false;
michael@0 343 return defineFixed(lir, mod, LAllocation(AnyRegister(r1)));
michael@0 344 }
michael@0 345
michael@0 346 bool
michael@0 347 LIRGeneratorARM::visitPowHalf(MPowHalf *ins)
michael@0 348 {
michael@0 349 MDefinition *input = ins->input();
michael@0 350 JS_ASSERT(input->type() == MIRType_Double);
michael@0 351 LPowHalfD *lir = new(alloc()) LPowHalfD(useRegisterAtStart(input));
michael@0 352 return defineReuseInput(lir, ins, 0);
michael@0 353 }
michael@0 354
michael@0 355 LTableSwitch *
michael@0 356 LIRGeneratorARM::newLTableSwitch(const LAllocation &in, const LDefinition &inputCopy,
michael@0 357 MTableSwitch *tableswitch)
michael@0 358 {
michael@0 359 return new(alloc()) LTableSwitch(in, inputCopy, tableswitch);
michael@0 360 }
michael@0 361
michael@0 362 LTableSwitchV *
michael@0 363 LIRGeneratorARM::newLTableSwitchV(MTableSwitch *tableswitch)
michael@0 364 {
michael@0 365 return new(alloc()) LTableSwitchV(temp(), tempDouble(), tableswitch);
michael@0 366 }
michael@0 367
michael@0 368 bool
michael@0 369 LIRGeneratorARM::visitGuardShape(MGuardShape *ins)
michael@0 370 {
michael@0 371 JS_ASSERT(ins->obj()->type() == MIRType_Object);
michael@0 372
michael@0 373 LDefinition tempObj = temp(LDefinition::OBJECT);
michael@0 374 LGuardShape *guard = new(alloc()) LGuardShape(useRegister(ins->obj()), tempObj);
michael@0 375 if (!assignSnapshot(guard, ins->bailoutKind()))
michael@0 376 return false;
michael@0 377 if (!add(guard, ins))
michael@0 378 return false;
michael@0 379 return redefine(ins, ins->obj());
michael@0 380 }
michael@0 381
michael@0 382 bool
michael@0 383 LIRGeneratorARM::visitGuardObjectType(MGuardObjectType *ins)
michael@0 384 {
michael@0 385 JS_ASSERT(ins->obj()->type() == MIRType_Object);
michael@0 386
michael@0 387 LDefinition tempObj = temp(LDefinition::OBJECT);
michael@0 388 LGuardObjectType *guard = new(alloc()) LGuardObjectType(useRegister(ins->obj()), tempObj);
michael@0 389 if (!assignSnapshot(guard))
michael@0 390 return false;
michael@0 391 if (!add(guard, ins))
michael@0 392 return false;
michael@0 393 return redefine(ins, ins->obj());
michael@0 394 }
michael@0 395
michael@0 396 bool
michael@0 397 LIRGeneratorARM::lowerUrshD(MUrsh *mir)
michael@0 398 {
michael@0 399 MDefinition *lhs = mir->lhs();
michael@0 400 MDefinition *rhs = mir->rhs();
michael@0 401
michael@0 402 JS_ASSERT(lhs->type() == MIRType_Int32);
michael@0 403 JS_ASSERT(rhs->type() == MIRType_Int32);
michael@0 404
michael@0 405 LUrshD *lir = new(alloc()) LUrshD(useRegister(lhs), useRegisterOrConstant(rhs), temp());
michael@0 406 return define(lir, mir);
michael@0 407 }
michael@0 408
michael@0 409 bool
michael@0 410 LIRGeneratorARM::visitAsmJSNeg(MAsmJSNeg *ins)
michael@0 411 {
michael@0 412 if (ins->type() == MIRType_Int32)
michael@0 413 return define(new(alloc()) LNegI(useRegisterAtStart(ins->input())), ins);
michael@0 414
michael@0 415 if(ins->type() == MIRType_Float32)
michael@0 416 return define(new(alloc()) LNegF(useRegisterAtStart(ins->input())), ins);
michael@0 417
michael@0 418 JS_ASSERT(ins->type() == MIRType_Double);
michael@0 419 return define(new(alloc()) LNegD(useRegisterAtStart(ins->input())), ins);
michael@0 420 }
michael@0 421
michael@0 422 bool
michael@0 423 LIRGeneratorARM::lowerUDiv(MDiv *div)
michael@0 424 {
michael@0 425 MDefinition *lhs = div->getOperand(0);
michael@0 426 MDefinition *rhs = div->getOperand(1);
michael@0 427
michael@0 428 if (hasIDIV()) {
michael@0 429 LUDiv *lir = new(alloc()) LUDiv;
michael@0 430 lir->setOperand(0, useRegister(lhs));
michael@0 431 lir->setOperand(1, useRegister(rhs));
michael@0 432 if (div->fallible() && !assignSnapshot(lir, Bailout_BaselineInfo))
michael@0 433 return false;
michael@0 434 return define(lir, div);
michael@0 435 } else {
michael@0 436 LSoftUDivOrMod *lir = new(alloc()) LSoftUDivOrMod(useFixedAtStart(lhs, r0), useFixedAtStart(rhs, r1),
michael@0 437 tempFixed(r1), tempFixed(r2), tempFixed(r3));
michael@0 438 if (div->fallible() && !assignSnapshot(lir, Bailout_BaselineInfo))
michael@0 439 return false;
michael@0 440 return defineFixed(lir, div, LAllocation(AnyRegister(r0)));
michael@0 441 }
michael@0 442 }
michael@0 443
michael@0 444 bool
michael@0 445 LIRGeneratorARM::lowerUMod(MMod *mod)
michael@0 446 {
michael@0 447 MDefinition *lhs = mod->getOperand(0);
michael@0 448 MDefinition *rhs = mod->getOperand(1);
michael@0 449
michael@0 450 if (hasIDIV()) {
michael@0 451 LUMod *lir = new(alloc()) LUMod;
michael@0 452 lir->setOperand(0, useRegister(lhs));
michael@0 453 lir->setOperand(1, useRegister(rhs));
michael@0 454 if (mod->fallible() && !assignSnapshot(lir, Bailout_BaselineInfo))
michael@0 455 return false;
michael@0 456 return define(lir, mod);
michael@0 457 } else {
michael@0 458 LSoftUDivOrMod *lir = new(alloc()) LSoftUDivOrMod(useFixedAtStart(lhs, r0), useFixedAtStart(rhs, r1),
michael@0 459 tempFixed(r0), tempFixed(r2), tempFixed(r3));
michael@0 460 if (mod->fallible() && !assignSnapshot(lir, Bailout_BaselineInfo))
michael@0 461 return false;
michael@0 462 return defineFixed(lir, mod, LAllocation(AnyRegister(r1)));
michael@0 463 }
michael@0 464 }
michael@0 465
michael@0 466 bool
michael@0 467 LIRGeneratorARM::visitAsmJSUnsignedToDouble(MAsmJSUnsignedToDouble *ins)
michael@0 468 {
michael@0 469 JS_ASSERT(ins->input()->type() == MIRType_Int32);
michael@0 470 LAsmJSUInt32ToDouble *lir = new(alloc()) LAsmJSUInt32ToDouble(useRegisterAtStart(ins->input()));
michael@0 471 return define(lir, ins);
michael@0 472 }
michael@0 473
michael@0 474 bool
michael@0 475 LIRGeneratorARM::visitAsmJSUnsignedToFloat32(MAsmJSUnsignedToFloat32 *ins)
michael@0 476 {
michael@0 477 JS_ASSERT(ins->input()->type() == MIRType_Int32);
michael@0 478 LAsmJSUInt32ToFloat32 *lir = new(alloc()) LAsmJSUInt32ToFloat32(useRegisterAtStart(ins->input()));
michael@0 479 return define(lir, ins);
michael@0 480 }
michael@0 481
michael@0 482 bool
michael@0 483 LIRGeneratorARM::visitAsmJSLoadHeap(MAsmJSLoadHeap *ins)
michael@0 484 {
michael@0 485 MDefinition *ptr = ins->ptr();
michael@0 486 JS_ASSERT(ptr->type() == MIRType_Int32);
michael@0 487 LAllocation ptrAlloc;
michael@0 488
michael@0 489 // For the ARM it is best to keep the 'ptr' in a register if a bounds check is needed.
michael@0 490 if (ptr->isConstant() && ins->skipBoundsCheck()) {
michael@0 491 int32_t ptrValue = ptr->toConstant()->value().toInt32();
michael@0 492 // A bounds check is only skipped for a positive index.
michael@0 493 JS_ASSERT(ptrValue >= 0);
michael@0 494 ptrAlloc = LAllocation(ptr->toConstant()->vp());
michael@0 495 } else
michael@0 496 ptrAlloc = useRegisterAtStart(ptr);
michael@0 497
michael@0 498 return define(new(alloc()) LAsmJSLoadHeap(ptrAlloc), ins);
michael@0 499 }
michael@0 500
michael@0 501 bool
michael@0 502 LIRGeneratorARM::visitAsmJSStoreHeap(MAsmJSStoreHeap *ins)
michael@0 503 {
michael@0 504 MDefinition *ptr = ins->ptr();
michael@0 505 JS_ASSERT(ptr->type() == MIRType_Int32);
michael@0 506 LAllocation ptrAlloc;
michael@0 507
michael@0 508 if (ptr->isConstant() && ins->skipBoundsCheck()) {
michael@0 509 JS_ASSERT(ptr->toConstant()->value().toInt32() >= 0);
michael@0 510 ptrAlloc = LAllocation(ptr->toConstant()->vp());
michael@0 511 } else
michael@0 512 ptrAlloc = useRegisterAtStart(ptr);
michael@0 513
michael@0 514 return add(new(alloc()) LAsmJSStoreHeap(ptrAlloc, useRegisterAtStart(ins->value())), ins);
michael@0 515 }
michael@0 516
michael@0 517 bool
michael@0 518 LIRGeneratorARM::visitAsmJSLoadFuncPtr(MAsmJSLoadFuncPtr *ins)
michael@0 519 {
michael@0 520 return define(new(alloc()) LAsmJSLoadFuncPtr(useRegister(ins->index()), temp()), ins);
michael@0 521 }
michael@0 522
michael@0 523 bool
michael@0 524 LIRGeneratorARM::lowerTruncateDToInt32(MTruncateToInt32 *ins)
michael@0 525 {
michael@0 526 MDefinition *opd = ins->input();
michael@0 527 JS_ASSERT(opd->type() == MIRType_Double);
michael@0 528
michael@0 529 return define(new(alloc()) LTruncateDToInt32(useRegister(opd), LDefinition::BogusTemp()), ins);
michael@0 530 }
michael@0 531
michael@0 532 bool
michael@0 533 LIRGeneratorARM::lowerTruncateFToInt32(MTruncateToInt32 *ins)
michael@0 534 {
michael@0 535 MDefinition *opd = ins->input();
michael@0 536 JS_ASSERT(opd->type() == MIRType_Float32);
michael@0 537
michael@0 538 return define(new(alloc()) LTruncateFToInt32(useRegister(opd), LDefinition::BogusTemp()), ins);
michael@0 539 }
michael@0 540
michael@0 541 bool
michael@0 542 LIRGeneratorARM::visitStoreTypedArrayElementStatic(MStoreTypedArrayElementStatic *ins)
michael@0 543 {
michael@0 544 MOZ_ASSUME_UNREACHABLE("NYI");
michael@0 545 }
michael@0 546
michael@0 547 bool
michael@0 548 LIRGeneratorARM::visitForkJoinGetSlice(MForkJoinGetSlice *ins)
michael@0 549 {
michael@0 550 MOZ_ASSUME_UNREACHABLE("NYI");
michael@0 551 }
michael@0 552
michael@0 553 //__aeabi_uidiv

mercurial