Lines Matching refs:instr

164 LInstruction* LChunkBuilder::DoDebugBreak(HDebugBreak* instr) {
525 HInstruction* instr = HInstruction::cast(value);
526 VisitInstruction(instr);
533 LInstruction* LChunkBuilder::Define(LTemplateResultInstruction<1>* instr,
536 instr->set_result(result);
537 return instr;
542 LTemplateResultInstruction<1>* instr) {
543 return Define(instr,
549 LTemplateResultInstruction<1>* instr, int index) {
550 return Define(instr,
556 LTemplateResultInstruction<1>* instr) {
557 return Define(instr,
563 LTemplateResultInstruction<1>* instr, Register reg) {
564 return Define(instr, ToUnallocated(reg));
569 LTemplateResultInstruction<1>* instr, DoubleRegister reg) {
570 return Define(instr, ToUnallocated(reg));
574 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) {
578 instr->set_environment(CreateEnvironment(hydrogen_env,
581 return instr;
585 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr,
590 instr->VerifyCall();
592 instr->MarkAsCall();
593 instr = AssignPointerMap(instr);
602 if (needs_environment && !instr->HasEnvironment()) {
603 instr = AssignEnvironment(instr);
605 instr->environment()->set_has_been_used();
608 return instr;
612 LInstruction* LChunkBuilder::AssignPointerMap(LInstruction* instr) {
613 DCHECK(!instr->HasPointerMap());
614 instr->set_pointer_map(new(zone()) LPointerMap(zone()));
615 return instr;
659 LInstruction* LChunkBuilder::DoBlockEntry(HBlockEntry* instr) {
660 return new(zone()) LLabel(instr->block());
664 LInstruction* LChunkBuilder::DoDummyUse(HDummyUse* instr) {
665 return DefineAsRegister(new(zone()) LDummyUse(UseAny(instr->value())));
669 LInstruction* LChunkBuilder::DoEnvironmentMarker(HEnvironmentMarker* instr) {
675 LInstruction* LChunkBuilder::DoDeoptimize(HDeoptimize* instr) {
681 HBitwiseBinaryOperation* instr) {
682 if (instr->representation().IsSmiOrInteger32()) {
683 DCHECK(instr->left()->representation().Equals(instr->representation()));
684 DCHECK(instr->right()->representation().Equals(instr->representation()));
685 LOperand* left = UseRegisterAtStart(instr->left());
687 HValue* right_value = instr->right();
697 if (instr->representation().IsSmi() && constant_value > 0) {
698 does_deopt = !instr->CheckUsesForFlag(HValue::kTruncatingToSmi);
708 does_deopt = !instr->CheckFlag(HInstruction::kUint32);
710 does_deopt = !instr->CheckUsesForFlag(HValue::kTruncatingToInt32);
718 return DoArithmeticT(op, instr);
724 HArithmeticBinaryOperation* instr) {
725 DCHECK(instr->representation().IsDouble());
726 DCHECK(instr->left()->representation().IsDouble());
727 DCHECK(instr->right()->representation().IsDouble());
729 LOperand* left = UseFixedDouble(instr->left(), f2);
730 LOperand* right = UseFixedDouble(instr->right(), f4);
735 return MarkAsCall(DefineFixedDouble(result, f2), instr);
737 LOperand* left = UseRegisterAtStart(instr->left());
738 LOperand* right = UseRegisterAtStart(instr->right());
746 HBinaryOperation* instr) {
747 HValue* left = instr->left();
748 HValue* right = instr->right();
751 LOperand* context = UseFixed(instr->context(), cp);
756 return MarkAsCall(DefineFixed(result, v0), instr);
831 LInstruction* instr = NULL;
834 instr = DefineAsRegister(new(zone()) LDummy());
837 instr = DefineAsRegister(new(zone())
852 instr = new(zone()) LGoto(successor);
854 instr = current->CompileToLithium(this);
861 if (instr != NULL) {
862 AddInstruction(instr, current);
869 void LChunkBuilder::AddInstruction(LInstruction* instr,
873 instr->set_hydrogen_value(hydrogen_val);
886 if (!(instr->ClobbersRegisters() &&
887 instr->ClobbersDoubleRegisters(isolate()))) {
890 for (UseIterator it(instr); !it.Done(); it.Advance()) {
894 if (instr->Output() != NULL) {
895 if (LUnallocated::cast(instr->Output())->HasFixedPolicy()) ++fixed;
897 for (TempIterator it(instr); !it.Done(); it.Advance()) {
905 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) {
906 instr = AssignPointerMap(instr);
908 if (FLAG_stress_environments && !instr->HasEnvironment()) {
909 instr = AssignEnvironment(instr);
911 chunk_->AddInstruction(instr, current_block_);
913 if (instr->IsCall()) {
918 instruction_needing_environment = instr;
935 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) {
936 return new(zone()) LGoto(instr->FirstSuccessor());
940 LInstruction* LChunkBuilder::DoBranch(HBranch* instr) {
941 HValue* value = instr->value();
944 ToBooleanStub::Types expected = instr->expected_input_types();
959 LInstruction* LChunkBuilder::DoCompareMap(HCompareMap* instr) {
960 DCHECK(instr->value()->representation().IsTagged());
961 LOperand* value = UseRegisterAtStart(instr->value());
980 LInstruction* LChunkBuilder::DoInstanceOf(HInstanceOf* instr) {
981 LOperand* context = UseFixed(instr->context(), cp);
983 new(zone()) LInstanceOf(context, UseFixed(instr->left(), a0),
984 UseFixed(instr->right(), a1));
985 return MarkAsCall(DefineFixed(result, v0), instr);
990 HInstanceOfKnownGlobal* instr) {
993 UseFixed(instr->context(), cp),
994 UseFixed(instr->left(), a0),
996 return MarkAsCall(DefineFixed(result, v0), instr);
1000 LInstruction* LChunkBuilder::DoWrapReceiver(HWrapReceiver* instr) {
1001 LOperand* receiver = UseRegisterAtStart(instr->receiver());
1002 LOperand* function = UseRegisterAtStart(instr->function());
1008 LInstruction* LChunkBuilder::DoApplyArguments(HApplyArguments* instr) {
1009 LOperand* function = UseFixed(instr->function(), a1);
1010 LOperand* receiver = UseFixed(instr->receiver(), a0);
1011 LOperand* length = UseFixed(instr->length(), a2);
1012 LOperand* elements = UseFixed(instr->elements(), a3);
1017 return MarkAsCall(DefineFixed(result, v0), instr, CAN_DEOPTIMIZE_EAGERLY);
1021 LInstruction* LChunkBuilder::DoPushArguments(HPushArguments* instr) {
1022 int argc = instr->OperandCount();
1024 LOperand* argument = Use(instr->argument(i));
1025 AddInstruction(new(zone()) LPushArgument(argument), instr);
1040 HInnerAllocatedObject* instr) {
1041 LOperand* base_object = UseRegisterAtStart(instr->base_object());
1042 LOperand* offset = UseRegisterOrConstantAtStart(instr->offset());
1048 LInstruction* LChunkBuilder::DoThisFunction(HThisFunction* instr) {
1049 return instr->HasNoUses()
1055 LInstruction* LChunkBuilder::DoContext(HContext* instr) {
1056 if (instr->HasNoUses()) return NULL;
1066 LInstruction* LChunkBuilder::DoDeclareGlobals(HDeclareGlobals* instr) {
1067 LOperand* context = UseFixed(instr->context(), cp);
1068 return MarkAsCall(new(zone()) LDeclareGlobals(context), instr);
1073 HCallJSFunction* instr) {
1074 LOperand* function = UseFixed(instr->function(), a1);
1078 return MarkAsCall(DefineFixed(result, v0), instr);
1083 HCallWithDescriptor* instr) {
1084 CallInterfaceDescriptor descriptor = instr->descriptor();
1086 LOperand* target = UseRegisterOrConstantAtStart(instr->target());
1087 ZoneList<LOperand*> ops(instr->OperandCount(), zone());
1089 for (int i = 1; i < instr->OperandCount(); i++) {
1091 UseFixed(instr->OperandAt(i), descriptor.GetParameterRegister(i - 1));
1097 return MarkAsCall(DefineFixed(result, v0), instr);
1102 HTailCallThroughMegamorphicCache* instr) {
1103 LOperand* context = UseFixed(instr->context(), cp);
1105 UseFixed(instr->receiver(), LoadDescriptor::ReceiverRegister());
1107 UseFixed(instr->name(), LoadDescriptor::NameRegister());
1114 LInstruction* LChunkBuilder::DoInvokeFunction(HInvokeFunction* instr) {
1115 LOperand* context = UseFixed(instr->context(), cp);
1116 LOperand* function = UseFixed(instr->function(), a1);
1118 return MarkAsCall(DefineFixed(result, v0), instr, CANNOT_DEOPTIMIZE_EAGERLY);
1122 LInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) {
1123 switch (instr->op()) {
1125 return DoMathFloor(instr);
1127 return DoMathRound(instr);
1129 return DoMathFround(instr);
1131 return DoMathAbs(instr);
1133 return DoMathLog(instr);
1135 return DoMathExp(instr);
1137 return DoMathSqrt(instr);
1139 return DoMathPowHalf(instr);
1141 return DoMathClz32(instr);
1149 LInstruction* LChunkBuilder::DoMathLog(HUnaryMathOperation* instr) {
1150 DCHECK(instr->representation().IsDouble());
1151 DCHECK(instr->value()->representation().IsDouble());
1152 LOperand* input = UseFixedDouble(instr->value(), f4);
1153 return MarkAsCall(DefineFixedDouble(new(zone()) LMathLog(input), f4), instr);
1157 LInstruction* LChunkBuilder::DoMathClz32(HUnaryMathOperation* instr) {
1158 LOperand* input = UseRegisterAtStart(instr->value());
1164 LInstruction* LChunkBuilder::DoMathExp(HUnaryMathOperation* instr) {
1165 DCHECK(instr->representation().IsDouble());
1166 DCHECK(instr->value()->representation().IsDouble());
1167 LOperand* input = UseRegister(instr->value());
1176 LInstruction* LChunkBuilder::DoMathPowHalf(HUnaryMathOperation* instr) {
1178 LOperand* input = UseFixedDouble(instr->value(), f8);
1185 LInstruction* LChunkBuilder::DoMathFround(HUnaryMathOperation* instr) {
1186 LOperand* input = UseRegister(instr->value());
1192 LInstruction* LChunkBuilder::DoMathAbs(HUnaryMathOperation* instr) {
1193 Representation r = instr->value()->representation();
1196 : UseFixed(instr->context(), cp);
1197 LOperand* input = UseRegister(instr->value());
1206 LInstruction* LChunkBuilder::DoMathFloor(HUnaryMathOperation* instr) {
1207 LOperand* input = UseRegister(instr->value());
1214 LInstruction* LChunkBuilder::DoMathSqrt(HUnaryMathOperation* instr) {
1215 LOperand* input = UseRegister(instr->value());
1221 LInstruction* LChunkBuilder::DoMathRound(HUnaryMathOperation* instr) {
1222 LOperand* input = UseRegister(instr->value());
1229 LInstruction* LChunkBuilder::DoCallNew(HCallNew* instr) {
1230 LOperand* context = UseFixed(instr->context(), cp);
1231 LOperand* constructor = UseFixed(instr->constructor(), a1);
1233 return MarkAsCall(DefineFixed(result, v0), instr);
1237 LInstruction* LChunkBuilder::DoCallNewArray(HCallNewArray* instr) {
1238 LOperand* context = UseFixed(instr->context(), cp);
1239 LOperand* constructor = UseFixed(instr->constructor(), a1);
1241 return MarkAsCall(DefineFixed(result, v0), instr);
1245 LInstruction* LChunkBuilder::DoCallFunction(HCallFunction* instr) {
1246 LOperand* context = UseFixed(instr->context(), cp);
1247 LOperand* function = UseFixed(instr->function(), a1);
1249 return MarkAsCall(DefineFixed(call, v0), instr);
1253 LInstruction* LChunkBuilder::DoCallRuntime(HCallRuntime* instr) {
1254 LOperand* context = UseFixed(instr->context(), cp);
1255 return MarkAsCall(DefineFixed(new(zone()) LCallRuntime(context), v0), instr);
1259 LInstruction* LChunkBuilder::DoRor(HRor* instr) {
1260 return DoShift(Token::ROR, instr);
1264 LInstruction* LChunkBuilder::DoShr(HShr* instr) {
1265 return DoShift(Token::SHR, instr);
1269 LInstruction* LChunkBuilder::DoSar(HSar* instr) {
1270 return DoShift(Token::SAR, instr);
1274 LInstruction* LChunkBuilder::DoShl(HShl* instr) {
1275 return DoShift(Token::SHL, instr);
1279 LInstruction* LChunkBuilder::DoBitwise(HBitwise* instr) {
1280 if (instr->representation().IsSmiOrInteger32()) {
1281 DCHECK(instr->left()->representation().Equals(instr->representation()));
1282 DCHECK(instr->right()->representation().Equals(instr->representation()));
1283 DCHECK(instr->CheckFlag(HValue::kTruncatingToInt32));
1285 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand());
1286 LOperand* right = UseOrConstantAtStart(instr->BetterRightOperand());
1289 return DoArithmeticT(instr->op(), instr);
1294 LInstruction* LChunkBuilder::DoDivByPowerOf2I(HDiv* instr) {
1295 DCHECK(instr->representation().IsSmiOrInteger32());
1296 DCHECK(instr->left()->representation().Equals(instr->representation()));
1297 DCHECK(instr->right()->representation().Equals(instr->representation()));
1298 LOperand* dividend = UseRegister(instr->left());
1299 int32_t divisor = instr->right()->GetInteger32Constant();
1302 if ((instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) ||
1303 (instr->CheckFlag(HValue::kCanOverflow) && divisor == -1) ||
1304 (!instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32) &&
1312 LInstruction* LChunkBuilder::DoDivByConstI(HDiv* instr) {
1313 DCHECK(instr->representation().IsInteger32());
1314 DCHECK(instr->left()->representation().Equals(instr->representation()));
1315 DCHECK(instr->right()->representation().Equals(instr->representation()));
1316 LOperand* dividend = UseRegister(instr->left());
1317 int32_t divisor = instr->right()->GetInteger32Constant();
1321 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) ||
1322 !instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32)) {
1329 LInstruction* LChunkBuilder::DoDivI(HDiv* instr) {
1330 DCHECK(instr->representation().IsSmiOrInteger32());
1331 DCHECK(instr->left()->representation().Equals(instr->representation()));
1332 DCHECK(instr->right()->representation().Equals(instr->representation()));
1333 LOperand* dividend = UseRegister(instr->left());
1334 LOperand* divisor = UseRegister(instr->right());
1335 LOperand* temp = instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32)
1339 if (instr->CheckFlag(HValue::kCanBeDivByZero) ||
1340 instr->CheckFlag(HValue::kBailoutOnMinusZero) ||
1341 (instr->CheckFlag(HValue::kCanOverflow) &&
1342 !instr->CheckFlag(HValue::kAllUsesTruncatingToInt32)) ||
1343 (!instr->IsMathFloorOfDiv() &&
1344 !instr->CheckFlag(HValue::kAllUsesTruncatingToInt32))) {
1351 LInstruction* LChunkBuilder::DoDiv(HDiv* instr) {
1352 if (instr->representation().IsSmiOrInteger32()) {
1353 if (instr->RightIsPowerOf2()) {
1354 return DoDivByPowerOf2I(instr);
1355 } else if (instr->right()->IsConstant()) {
1356 return DoDivByConstI(instr);
1358 return DoDivI(instr);
1360 } else if (instr->representation().IsDouble()) {
1361 return DoArithmeticD(Token::DIV, instr);
1363 return DoArithmeticT(Token::DIV, instr);
1368 LInstruction* LChunkBuilder::DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr) {
1369 LOperand* dividend = UseRegisterAtStart(instr->left());
1370 int32_t divisor = instr->right()->GetInteger32Constant();
1373 if ((instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) ||
1374 (instr->CheckFlag(HValue::kLeftCanBeMinInt) && divisor == -1)) {
1381 LInstruction* LChunkBuilder::DoFlooringDivByConstI(HMathFloorOfDiv* instr) {
1382 DCHECK(instr->representation().IsInteger32());
1383 DCHECK(instr->left()->representation().Equals(instr->representation()));
1384 DCHECK(instr->right()->representation().Equals(instr->representation()));
1385 LOperand* dividend = UseRegister(instr->left());
1386 int32_t divisor = instr->right()->GetInteger32Constant();
1388 ((divisor > 0 && !instr->CheckFlag(HValue::kLeftCanBeNegative)) ||
1389 (divisor < 0 && !instr->CheckFlag(HValue::kLeftCanBePositive))) ?
1394 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0)) {
1401 LInstruction* LChunkBuilder::DoFlooringDivI(HMathFloorOfDiv* instr) {
1402 DCHECK(instr->representation().IsSmiOrInteger32());
1403 DCHECK(instr->left()->representation().Equals(instr->representation()));
1404 DCHECK(instr->right()->representation().Equals(instr->representation()));
1405 LOperand* dividend = UseRegister(instr->left());
1406 LOperand* divisor = UseRegister(instr->right());
1412 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) {
1413 if (instr->RightIsPowerOf2()) {
1414 return DoFlooringDivByPowerOf2I(instr);
1415 } else if (instr->right()->IsConstant()) {
1416 return DoFlooringDivByConstI(instr);
1418 return DoFlooringDivI(instr);
1423 LInstruction* LChunkBuilder::DoModByPowerOf2I(HMod* instr) {
1424 DCHECK(instr->representation().IsSmiOrInteger32());
1425 DCHECK(instr->left()->representation().Equals(instr->representation()));
1426 DCHECK(instr->right()->representation().Equals(instr->representation()));
1427 LOperand* dividend = UseRegisterAtStart(instr->left());
1428 int32_t divisor = instr->right()->GetInteger32Constant();
1431 if (instr->CheckFlag(HValue::kLeftCanBeNegative) &&
1432 instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
1439 LInstruction* LChunkBuilder::DoModByConstI(HMod* instr) {
1440 DCHECK(instr->representation().IsSmiOrInteger32());
1441 DCHECK(instr->left()->representation().Equals(instr->representation()));
1442 DCHECK(instr->right()->representation().Equals(instr->representation()));
1443 LOperand* dividend = UseRegister(instr->left());
1444 int32_t divisor = instr->right()->GetInteger32Constant();
1447 if (divisor == 0 || instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
1454 LInstruction* LChunkBuilder::DoModI(HMod* instr) {
1455 DCHECK(instr->representation().IsSmiOrInteger32());
1456 DCHECK(instr->left()->representation().Equals(instr->representation()));
1457 DCHECK(instr->right()->representation().Equals(instr->representation()));
1458 LOperand* dividend = UseRegister(instr->left());
1459 LOperand* divisor = UseRegister(instr->right());
1462 if (instr->CheckFlag(HValue::kCanBeDivByZero) ||
1463 instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
1470 LInstruction* LChunkBuilder::DoMod(HMod* instr) {
1471 if (instr->representation().IsSmiOrInteger32()) {
1472 return instr->RightIsPowerOf2() ? DoModByPowerOf2I(instr) : DoModI(instr);
1473 } else if (instr->representation().IsDouble()) {
1474 return DoArithmeticD(Token::MOD, instr);
1476 return DoArithmeticT(Token::MOD, instr);
1481 LInstruction* LChunkBuilder::DoMul(HMul* instr) {
1482 if (instr->representation().IsSmiOrInteger32()) {
1483 DCHECK(instr->left()->representation().Equals(instr->representation()));
1484 DCHECK(instr->right()->representation().Equals(instr->representation()));
1485 HValue* left = instr->BetterLeftOperand();
1486 HValue* right = instr->BetterRightOperand();
1489 bool can_overflow = instr->CheckFlag(HValue::kCanOverflow);
1490 bool bailout_on_minus_zero = instr->CheckFlag(HValue::kBailoutOnMinusZero);
1522 } else if (instr->representation().IsDouble()) {
1524 if (instr->HasOneUse() && instr->uses().value()->IsAdd()) {
1525 HAdd* add = HAdd::cast(instr->uses().value());
1526 if (instr == add->left()) {
1531 if (instr == add->right() && !add->left()->IsMul()) {
1538 return DoArithmeticD(Token::MUL, instr);
1540 return DoArithmeticT(Token::MUL, instr);
1545 LInstruction* LChunkBuilder::DoSub(HSub* instr) {
1546 if (instr->representation().IsSmiOrInteger32()) {
1547 DCHECK(instr->left()->representation().Equals(instr->representation()));
1548 DCHECK(instr->right()->representation().Equals(instr->representation()));
1549 LOperand* left = UseRegisterAtStart(instr->left());
1550 LOperand* right = UseOrConstantAtStart(instr->right());
1553 if (instr->CheckFlag(HValue::kCanOverflow)) {
1557 } else if (instr->representation().IsDouble()) {
1558 return DoArithmeticD(Token::SUB, instr);
1560 return DoArithmeticT(Token::SUB, instr);
1574 LInstruction* LChunkBuilder::DoAdd(HAdd* instr) {
1575 if (instr->representation().IsSmiOrInteger32()) {
1576 DCHECK(instr->left()->representation().Equals(instr->representation()));
1577 DCHECK(instr->right()->representation().Equals(instr->representation()));
1578 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand());
1579 LOperand* right = UseOrConstantAtStart(instr->BetterRightOperand());
1582 if (instr->CheckFlag(HValue::kCanOverflow)) {
1586 } else if (instr->representation().IsExternal()) {
1587 DCHECK(instr->left()->representation().IsExternal());
1588 DCHECK(instr->right()->representation().IsInteger32());
1589 DCHECK(!instr->CheckFlag(HValue::kCanOverflow));
1590 LOperand* left = UseRegisterAtStart(instr->left());
1591 LOperand* right = UseOrConstantAtStart(instr->right());
1595 } else if (instr->representation().IsDouble()) {
1597 if (instr->left()->IsMul())
1598 return DoMultiplyAdd(HMul::cast(instr->left()), instr->right());
1600 if (instr->right()->IsMul()) {
1601 DCHECK(!instr->left()->IsMul());
1602 return DoMultiplyAdd(HMul::cast(instr->right()), instr->left());
1605 return DoArithmeticD(Token::ADD, instr);
1607 return DoArithmeticT(Token::ADD, instr);
1612 LInstruction* LChunkBuilder::DoMathMinMax(HMathMinMax* instr) {
1615 if (instr->representation().IsSmiOrInteger32()) {
1616 DCHECK(instr->left()->representation().Equals(instr->representation()));
1617 DCHECK(instr->right()->representation().Equals(instr->representation()));
1618 left = UseRegisterAtStart(instr->BetterLeftOperand());
1619 right = UseOrConstantAtStart(instr->BetterRightOperand());
1621 DCHECK(instr->representation().IsDouble());
1622 DCHECK(instr->left()->representation().IsDouble());
1623 DCHECK(instr->right()->representation().IsDouble());
1624 left = UseRegisterAtStart(instr->left());
1625 right = UseRegisterAtStart(instr->right());
1631 LInstruction* LChunkBuilder::DoPower(HPower* instr) {
1632 DCHECK(instr->representation().IsDouble());
1635 Representation exponent_type = instr->right()->representation();
1636 DCHECK(instr->left()->representation().IsDouble());
1637 LOperand* left = UseFixedDouble(instr->left(), f2);
1640 ? UseFixedDouble(instr->right(), f4)
1641 : UseFixed(instr->right(), MathPowTaggedDescriptor::exponent());
1644 instr,
1649 LInstruction* LChunkBuilder::DoCompareGeneric(HCompareGeneric* instr) {
1650 DCHECK(instr->left()->representation().IsTagged());
1651 DCHECK(instr->right()->representation().IsTagged());
1652 LOperand* context = UseFixed(instr->context(), cp);
1653 LOperand* left = UseFixed(instr->left(), a1);
1654 LOperand* right = UseFixed(instr->right(), a0);
1656 return MarkAsCall(DefineFixed(result, v0), instr);
1661 HCompareNumericAndBranch* instr) {
1662 Representation r = instr->representation();
1664 DCHECK(instr->left()->representation().Equals(r));
1665 DCHECK(instr->right()->representation().Equals(r));
1666 LOperand* left = UseRegisterOrConstantAtStart(instr->left());
1667 LOperand* right = UseRegisterOrConstantAtStart(instr->right());
1671 DCHECK(instr->left()->representation().IsDouble());
1672 DCHECK(instr->right()->representation().IsDouble());
1673 LOperand* left = UseRegisterAtStart(instr->left());
1674 LOperand* right = UseRegisterAtStart(instr->right());
1681 HCompareObjectEqAndBranch* instr) {
1682 LOperand* left = UseRegisterAtStart(instr->left());
1683 LOperand* right = UseRegisterAtStart(instr->right());
1689 HCompareHoleAndBranch* instr) {
1690 LOperand* value = UseRegisterAtStart(instr->value());
1696 HCompareMinusZeroAndBranch* instr) {
1697 LOperand* value = UseRegister(instr->value());
1703 LInstruction* LChunkBuilder::DoIsObjectAndBranch(HIsObjectAndBranch* instr) {
1704 DCHECK(instr->value()->representation().IsTagged());
1706 return new(zone()) LIsObjectAndBranch(UseRegisterAtStart(instr->value()),
1711 LInstruction* LChunkBuilder::DoIsStringAndBranch(HIsStringAndBranch* instr) {
1712 DCHECK(instr->value()->representation().IsTagged());
1714 return new(zone()) LIsStringAndBranch(UseRegisterAtStart(instr->value()),
1719 LInstruction* LChunkBuilder::DoIsSmiAndBranch(HIsSmiAndBranch* instr) {
1720 DCHECK(instr->value()->representation().IsTagged());
1721 return new(zone()) LIsSmiAndBranch(Use(instr->value()));
1726 HIsUndetectableAndBranch* instr) {
1727 DCHECK(instr->value()->representation().IsTagged());
1729 UseRegisterAtStart(instr->value()), TempRegister());
1734 HStringCompareAndBranch* instr) {
1735 DCHECK(instr->left()->representation().IsTagged());
1736 DCHECK(instr->right()->representation().IsTagged());
1737 LOperand* context = UseFixed(instr->context(), cp);
1738 LOperand* left = UseFixed(instr->left(), a1);
1739 LOperand* right = UseFixed(instr->right(), a0);
1742 return MarkAsCall(result, instr);
1747 HHasInstanceTypeAndBranch* instr) {
1748 DCHECK(instr->value()->representation().IsTagged());
1749 LOperand* value = UseRegisterAtStart(instr->value());
1755 HGetCachedArrayIndex* instr) {
1756 DCHECK(instr->value()->representation().IsTagged());
1757 LOperand* value = UseRegisterAtStart(instr->value());
1764 HHasCachedArrayIndexAndBranch* instr) {
1765 DCHECK(instr->value()->representation().IsTagged());
1767 UseRegisterAtStart(instr->value()));
1772 HClassOfTestAndBranch* instr) {
1773 DCHECK(instr->value()->representation().IsTagged());
1774 return new(zone()) LClassOfTestAndBranch(UseRegister(instr->value()),
1779 LInstruction* LChunkBuilder::DoMapEnumLength(HMapEnumLength* instr) {
1780 LOperand* map = UseRegisterAtStart(instr->value());
1785 LInstruction* LChunkBuilder::DoDateField(HDateField* instr) {
1786 LOperand* object = UseFixed(instr->value(), a0);
1788 new(zone()) LDateField(object, FixedTemp(a1), instr->index());
1789 return MarkAsCall(DefineFixed(result, v0), instr, CAN_DEOPTIMIZE_EAGERLY);
1793 LInstruction* LChunkBuilder::DoSeqStringGetChar(HSeqStringGetChar* instr) {
1794 LOperand* string = UseRegisterAtStart(instr->string());
1795 LOperand* index = UseRegisterOrConstantAtStart(instr->index());
1800 LInstruction* LChunkBuilder::DoSeqStringSetChar(HSeqStringSetChar* instr) {
1801 LOperand* string = UseRegisterAtStart(instr->string());
1803 ? UseRegisterAtStart(instr->index())
1804 : UseRegisterOrConstantAtStart(instr->index());
1805 LOperand* value = UseRegisterAtStart(instr->value());
1806 LOperand* context = FLAG_debug_code ? UseFixed(instr->context(), cp) : NULL;
1811 LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) {
1812 if (!FLAG_debug_code && instr->skip_check()) return NULL;
1813 LOperand* index = UseRegisterOrConstantAtStart(instr->index());
1815 ? UseRegisterOrConstantAtStart(instr->length())
1816 : UseRegisterAtStart(instr->length());
1818 if (!FLAG_debug_code || !instr->skip_check()) {
1826 HBoundsCheckBaseIndexInformation* instr) {
1832 LInstruction* LChunkBuilder::DoAbnormalExit(HAbnormalExit* instr) {
1839 LInstruction* LChunkBuilder::DoUseConst(HUseConst* instr) {
1852 LInstruction* LChunkBuilder::DoChange(HChange* instr) {
1853 Representation from = instr->from();
1854 Representation to = instr->to();
1855 HValue* val = instr->value();
1908 if (!instr->CanTruncateToInt32()) result = AssignEnvironment(result);
1929 if (instr->CheckFlag(HValue::kCanOverflow)) {
1947 LInstruction* LChunkBuilder::DoCheckHeapObject(HCheckHeapObject* instr) {
1948 LOperand* value = UseRegisterAtStart(instr->value());
1950 if (!instr->value()->type().IsHeapObject()) {
1957 LInstruction* LChunkBuilder::DoCheckSmi(HCheckSmi* instr) {
1958 LOperand* value = UseRegisterAtStart(instr->value());
1963 LInstruction* LChunkBuilder::DoCheckInstanceType(HCheckInstanceType* instr) {
1964 LOperand* value = UseRegisterAtStart(instr->value());
1970 LInstruction* LChunkBuilder::DoCheckValue(HCheckValue* instr) {
1971 LOperand* value = UseRegisterAtStart(instr->value());
1976 LInstruction* LChunkBuilder::DoCheckMaps(HCheckMaps* instr) {
1977 if (instr->IsStabilityCheck()) return new(zone()) LCheckMaps;
1978 LOperand* value = UseRegisterAtStart(instr->value());
1980 if (instr->HasMigrationTarget()) {
1988 LInstruction* LChunkBuilder::DoClampToUint8(HClampToUint8* instr) {
1989 HValue* value = instr->value();
2007 LInstruction* LChunkBuilder::DoDoubleBits(HDoubleBits* instr) {
2008 HValue* value = instr->value();
2014 LInstruction* LChunkBuilder::DoConstructDouble(HConstructDouble* instr) {
2015 LOperand* lo = UseRegister(instr->lo());
2016 LOperand* hi = UseRegister(instr->hi());
2021 LInstruction* LChunkBuilder::DoReturn(HReturn* instr) {
2023 ? UseFixed(instr->context(), cp)
2025 LOperand* parameter_count = UseRegisterOrConstant(instr->parameter_count());
2026 return new(zone()) LReturn(UseFixed(instr->value(), v0), context,
2031 LInstruction* LChunkBuilder::DoConstant(HConstant* instr) {
2032 Representation r = instr->representation();
2050 LInstruction* LChunkBuilder::DoLoadGlobalCell(HLoadGlobalCell* instr) {
2052 return instr->RequiresHoleCheck()
2058 LInstruction* LChunkBuilder::DoLoadGlobalGeneric(HLoadGlobalGeneric* instr) {
2059 LOperand* context = UseFixed(instr->context(), cp);
2061 UseFixed(instr->global_object(), LoadDescriptor::ReceiverRegister());
2068 return MarkAsCall(DefineFixed(result, v0), instr);
2072 LInstruction* LChunkBuilder::DoStoreGlobalCell(HStoreGlobalCell* instr) {
2073 LOperand* value = UseRegister(instr->value());
2076 return instr->RequiresHoleCheck()
2082 LInstruction* LChunkBuilder::DoLoadContextSlot(HLoadContextSlot* instr) {
2083 LOperand* context = UseRegisterAtStart(instr->value());
2086 if (instr->RequiresHoleCheck() && instr->DeoptimizesOnHole()) {
2093 LInstruction* LChunkBuilder::DoStoreContextSlot(HStoreContextSlot* instr) {
2096 if (instr->NeedsWriteBarrier()) {
2097 context = UseTempRegister(instr->context());
2098 value = UseTempRegister(instr->value());
2100 context = UseRegister(instr->context());
2101 value = UseRegister(instr->value());
2104 if (instr->RequiresHoleCheck() && instr->DeoptimizesOnHole()) {
2111 LInstruction* LChunkBuilder::DoLoadNamedField(HLoadNamedField* instr) {
2112 LOperand* obj = UseRegisterAtStart(instr->object());
2117 LInstruction* LChunkBuilder::DoLoadNamedGeneric(HLoadNamedGeneric* instr) {
2118 LOperand* context = UseFixed(instr->context(), cp);
2120 UseFixed(instr->object(), LoadDescriptor::ReceiverRegister());
2128 return MarkAsCall(result, instr);
2133 HLoadFunctionPrototype* instr) {
2135 new(zone()) LLoadFunctionPrototype(UseRegister(instr->function()))));
2139 LInstruction* LChunkBuilder::DoLoadRoot(HLoadRoot* instr) {
2144 LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) {
2145 DCHECK(instr->key()->representation().IsSmiOrInteger32());
2146 ElementsKind elements_kind = instr->elements_kind();
2147 LOperand* key = UseRegisterOrConstantAtStart(instr->key());
2150 if (!instr->is_typed_elements()) {
2152 if (instr->representation().IsDouble()) {
2153 obj = UseRegister(instr->elements());
2155 DCHECK(instr->representation().IsSmiOrTagged() ||
2156 instr->representation().IsInteger32());
2157 obj = UseRegisterAtStart(instr->elements());
2162 (instr->representation().IsInteger32() &&
2164 (instr->representation().IsDouble() &&
2166 LOperand* backing_store = UseRegister(instr->elements());
2170 if ((instr->is_external() || instr->is_fixed_typed_array()) ?
2174 !instr->CheckFlag(HInstruction::kUint32)) :
2177 instr->RequiresHoleCheck()) {
2184 LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) {
2185 LOperand* context = UseFixed(instr->context(), cp);
2187 UseFixed(instr->object(), LoadDescriptor::ReceiverRegister());
2188 LOperand* key = UseFixed(instr->key(), LoadDescriptor::NameRegister());
2197 return MarkAsCall(result, instr);
2201 LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) {
2202 if (!instr->is_typed_elements()) {
2203 DCHECK(instr->elements()->representation().IsTagged());
2204 bool needs_write_barrier = instr->NeedsWriteBarrier();
2209 if (instr->value()->representation().IsDouble()) {
2210 object = UseRegisterAtStart(instr->elements());
2211 key = UseRegisterOrConstantAtStart(instr->key());
2212 val = UseRegister(instr->value());
2214 DCHECK(instr->value()->representation().IsSmiOrTagged() ||
2215 instr->value()->representation().IsInteger32());
2217 object = UseTempRegister(instr->elements());
2218 val = UseTempRegister(instr->value());
2219 key = UseTempRegister(instr->key());
2221 object = UseRegisterAtStart(instr->elements());
2222 val = UseRegisterAtStart(instr->value());
2223 key = UseRegisterOrConstantAtStart(instr->key());
2231 (instr->value()->representation().IsInteger32() &&
2232 !IsDoubleOrFloatElementsKind(instr->elements_kind())) ||
2233 (instr->value()->representation().IsDouble() &&
2234 IsDoubleOrFloatElementsKind(instr->elements_kind())));
2235 DCHECK((instr->is_fixed_typed_array() &&
2236 instr->elements()->representation().IsTagged()) ||
2237 (instr->is_external() &&
2238 instr->elements()->representation().IsExternal()));
2239 LOperand* val = UseRegister(instr->value());
2240 LOperand* key = UseRegisterOrConstantAtStart(instr->key());
2241 LOperand* backing_store = UseRegister(instr->elements());
2246 LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) {
2247 LOperand* context = UseFixed(instr->context(), cp);
2249 UseFixed(instr->object(), StoreDescriptor::ReceiverRegister());
2250 LOperand* key = UseFixed(instr->key(), StoreDescriptor::NameRegister());
2251 LOperand* val = UseFixed(instr->value(), StoreDescriptor::ValueRegister());
2253 DCHECK(instr->object()->representation().IsTagged());
2254 DCHECK(instr->key()->representation().IsTagged());
2255 DCHECK(instr->value()->representation().IsTagged());
2258 new(zone()) LStoreKeyedGeneric(context, obj, key, val), instr);
2263 HTransitionElementsKind* instr) {
2264 if (IsSimpleMapChangeTransition(instr->from_kind(), instr->to_kind())) {
2265 LOperand* object = UseRegister(instr->object());
2271 LOperand* object = UseFixed(instr->object(), a0);
2272 LOperand* context = UseFixed(instr->context(), cp);
2275 return MarkAsCall(result, instr);
2281 HTrapAllocationMemento* instr) {
2282 LOperand* object = UseRegister(instr->object());
2290 LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) {
2291 bool is_in_object = instr->access().IsInobject();
2292 bool needs_write_barrier = instr->NeedsWriteBarrier();
2293 bool needs_write_barrier_for_map = instr->has_transition() &&
2294 instr->NeedsWriteBarrierForMap();
2299 ? UseRegister(instr->object())
2300 : UseTempRegister(instr->object());
2303 ? UseRegister(instr->object())
2304 : UseRegisterAtStart(instr->object());
2309 val = UseTempRegister(instr->value());
2310 } else if (instr->field_representation().IsDouble()) {
2311 val = UseRegisterAtStart(instr->value());
2313 val = UseRegister(instr->value());
2323 LInstruction* LChunkBuilder::DoStoreNamedGeneric(HStoreNamedGeneric* instr) {
2324 LOperand* context = UseFixed(instr->context(), cp);
2326 UseFixed(instr->object(), StoreDescriptor::ReceiverRegister());
2327 LOperand* val = UseFixed(instr->value(), StoreDescriptor::ValueRegister());
2330 return MarkAsCall(result, instr);
2334 LInstruction* LChunkBuilder::DoStringAdd(HStringAdd* instr) {
2335 LOperand* context = UseFixed(instr->context(), cp);
2336 LOperand* left = UseFixed(instr->left(), a1);
2337 LOperand* right = UseFixed(instr->right(), a0);
2340 instr);
2344 LInstruction* LChunkBuilder::DoStringCharCodeAt(HStringCharCodeAt* instr) {
2345 LOperand* string = UseTempRegister(instr->string());
2346 LOperand* index = UseTempRegister(instr->index());
2347 LOperand* context = UseAny(instr->context());
2354 LInstruction* LChunkBuilder::DoStringCharFromCode(HStringCharFromCode* instr) {
2355 LOperand* char_code = UseRegister(instr->value());
2356 LOperand* context = UseAny(instr->context());
2363 LInstruction* LChunkBuilder::DoAllocate(HAllocate* instr) {
2365 LOperand* context = UseAny(instr->context());
2366 LOperand* size = UseRegisterOrConstant(instr->size());
2374 LInstruction* LChunkBuilder::DoRegExpLiteral(HRegExpLiteral* instr) {
2375 LOperand* context = UseFixed(instr->context(), cp);
2377 DefineFixed(new(zone()) LRegExpLiteral(context), v0), instr);
2381 LInstruction* LChunkBuilder::DoFunctionLiteral(HFunctionLiteral* instr) {
2382 LOperand* context = UseFixed(instr->context(), cp);
2384 DefineFixed(new(zone()) LFunctionLiteral(context), v0), instr);
2388 LInstruction* LChunkBuilder::DoOsrEntry(HOsrEntry* instr) {
2391 current_block_->last_environment()->set_ast_id(instr->ast_id());
2396 LInstruction* LChunkBuilder::DoParameter(HParameter* instr) {
2398 if (instr->kind() == HParameter::STACK_PARAMETER) {
2399 int spill_index = chunk()->GetParameterStackSlot(instr->index());
2405 int index = static_cast<int>(instr->index());
2412 LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) {
2415 int env_index = instr->index();
2417 if (instr->environment()->is_parameter_index(env_index)) {
2420 spill_index = env_index - instr->environment()->first_local_index();
2430 LInstruction* LChunkBuilder::DoCallStub(HCallStub* instr) {
2431 LOperand* context = UseFixed(instr->context(), cp);
2432 return MarkAsCall(DefineFixed(new(zone()) LCallStub(context), v0), instr);
2436 LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) {
2445 LInstruction* LChunkBuilder::DoCapturedObject(HCapturedObject* instr) {
2446 instr->ReplayEnvironment(current_block_->last_environment());
2453 LInstruction* LChunkBuilder::DoAccessArgumentsAt(HAccessArgumentsAt* instr) {
2455 LOperand* args = UseRegister(instr->arguments());
2456 LOperand* length = UseRegisterOrConstantAtStart(instr->length());
2457 LOperand* index = UseRegisterOrConstantAtStart(instr->index());
2462 LInstruction* LChunkBuilder::DoToFastProperties(HToFastProperties* instr) {
2463 LOperand* object = UseFixed(instr->value(), a0);
2465 return MarkAsCall(DefineFixed(result, v0), instr);
2469 LInstruction* LChunkBuilder::DoTypeof(HTypeof* instr) {
2470 LOperand* context = UseFixed(instr->context(), cp);
2471 LTypeof* result = new(zone()) LTypeof(context, UseFixed(instr->value(), a0));
2472 return MarkAsCall(DefineFixed(result, v0), instr);
2476 LInstruction* LChunkBuilder::DoTypeofIsAndBranch(HTypeofIsAndBranch* instr) {
2477 return new(zone()) LTypeofIsAndBranch(UseTempRegister(instr->value()));
2482 HIsConstructCallAndBranch* instr) {
2487 LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) {
2488 instr->ReplayEnvironment(current_block_->last_environment());
2493 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) {
2494 if (instr->is_function_entry()) {
2495 LOperand* context = UseFixed(instr->context(), cp);
2496 return MarkAsCall(new(zone()) LStackCheck(context), instr);
2498 DCHECK(instr->is_backwards_branch());
2499 LOperand* context = UseAny(instr->context());
2506 LInstruction* LChunkBuilder::DoEnterInlined(HEnterInlined* instr) {
2508 outer->set_ast_id(instr->ReturnId());
2510 HEnvironment* inner = outer->CopyForInlining(instr->closure(),
2511 instr->arguments_count(),
2512 instr->function(),
2514 instr->inlining_kind());
2516 if (instr->arguments_var() != NULL && instr->arguments_object()->IsLinked()) {
2517 inner->Bind(instr->arguments_var(), instr->arguments_object());
2519 inner->BindContext(instr->closure_context());
2520 inner->set_entry(instr);
2522 chunk_->AddInlinedClosure(instr->closure());
2527 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) {
2535 DCHECK(instr->argument_delta() == -argument_count);
2546 LInstruction* LChunkBuilder::DoForInPrepareMap(HForInPrepareMap* instr) {
2547 LOperand* context = UseFixed(instr->context(), cp);
2548 LOperand* object = UseFixed(instr->enumerable(), a0);
2550 return MarkAsCall(DefineFixed(result, v0), instr, CAN_DEOPTIMIZE_EAGERLY);
2554 LInstruction* LChunkBuilder::DoForInCacheArray(HForInCacheArray* instr) {
2555 LOperand* map = UseRegister(instr->map());
2560 LInstruction* LChunkBuilder::DoCheckMapValue(HCheckMapValue* instr) {
2561 LOperand* value = UseRegisterAtStart(instr->value());
2562 LOperand* map = UseRegisterAtStart(instr->map());
2567 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) {
2568 LOperand* object = UseRegister(instr->object());
2569 LOperand* index = UseTempRegister(instr->index());
2576 LInstruction* LChunkBuilder::DoStoreFrameContext(HStoreFrameContext* instr) {
2577 LOperand* context = UseRegisterAtStart(instr->context());
2583 HAllocateBlockContext* instr) {
2584 LOperand* context = UseFixed(instr->context(), cp);
2585 LOperand* function = UseRegisterAtStart(instr->function());
2588 return MarkAsCall(DefineFixed(result, cp), instr);