Lines Matching refs:instr

538     HInstruction* instr = HInstruction::cast(value);
539 VisitInstruction(instr);
547 LInstruction* LChunkBuilder::Define(LTemplateInstruction<1, I, T>* instr,
550 instr->set_result(result);
551 return instr;
557 LTemplateInstruction<1, I, T>* instr) {
558 return Define(instr,
565 LTemplateInstruction<1, I, T>* instr, int index) {
566 return Define(instr,
573 LTemplateInstruction<1, I, T>* instr) {
574 return Define(instr,
581 LTemplateInstruction<1, I, T>* instr, Register reg) {
582 return Define(instr, ToUnallocated(reg));
588 LTemplateInstruction<1, I, T>* instr, DoubleRegister reg) {
589 return Define(instr, ToUnallocated(reg));
593 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) {
597 instr->set_environment(CreateEnvironment(hydrogen_env,
600 return instr;
604 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr,
609 instr->VerifyCall();
611 instr->MarkAsCall();
612 instr = AssignPointerMap(instr);
619 instruction_pending_deoptimization_environment_ = instr;
630 if (needs_environment && !instr->HasEnvironment()) {
631 instr = AssignEnvironment(instr);
634 return instr;
638 LInstruction* LChunkBuilder::AssignPointerMap(LInstruction* instr) {
639 ASSERT(!instr->HasPointerMap());
640 instr->set_pointer_map(new(zone()) LPointerMap(position_, zone()));
641 return instr;
672 LInstruction* LChunkBuilder::DoBlockEntry(HBlockEntry* instr) {
673 return new(zone()) LLabel(instr->block());
677 LInstruction* LChunkBuilder::DoDummyUse(HDummyUse* instr) {
678 return DefineAsRegister(new(zone()) LDummyUse(UseAny(instr->value())));
682 LInstruction* LChunkBuilder::DoEnvironmentMarker(HEnvironmentMarker* instr) {
688 LInstruction* LChunkBuilder::DoDeoptimize(HDeoptimize* instr) {
694 HBitwiseBinaryOperation* instr) {
695 if (instr->representation().IsTagged()) {
696 ASSERT(instr->left()->representation().IsTagged());
697 ASSERT(instr->right()->representation().IsTagged());
699 LOperand* left = UseFixed(instr->left(), r1);
700 LOperand* right = UseFixed(instr->right(), r0);
702 return MarkAsCall(DefineFixed(result, r0), instr);
705 ASSERT(instr->representation().IsSmiOrInteger32());
706 ASSERT(instr->left()->representation().Equals(instr->representation()));
707 ASSERT(instr->right()->representation().Equals(instr->representation()));
708 LOperand* left = UseRegisterAtStart(instr->left());
710 HValue* right_value = instr->right();
720 if (instr->representation().IsSmi() && constant_value > 0) {
721 for (HUseIterator it(instr->uses()); !it.Done(); it.Advance()) {
736 does_deopt = !instr->CheckFlag(HInstruction::kUint32);
738 for (HUseIterator it(instr->uses()); !it.Done(); it.Advance()) {
754 HArithmeticBinaryOperation* instr) {
755 ASSERT(instr->representation().IsDouble());
756 ASSERT(instr->left()->representation().IsDouble());
757 ASSERT(instr->right()->representation().IsDouble());
759 LOperand* left = UseRegisterAtStart(instr->left());
760 LOperand* right = UseRegisterAtStart(instr->right());
767 HArithmeticBinaryOperation* instr) {
773 HValue* left = instr->left();
774 HValue* right = instr->right();
781 return MarkAsCall(DefineFixed(result, r0), instr);
856 LInstruction* instr = current->CompileToLithium(this);
858 if (instr != NULL) {
870 if (!(instr->ClobbersRegisters() && instr->ClobbersDoubleRegisters())) {
873 for (UseIterator it(instr); !it.Done(); it.Advance()) {
877 if (instr->Output() != NULL) {
878 if (LUnallocated::cast(instr->Output())->HasFixedPolicy()) ++fixed;
880 for (TempIterator it(instr); !it.Done(); it.Advance()) {
888 instr->set_position(position_);
889 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) {
890 instr = AssignPointerMap(instr);
892 if (FLAG_stress_environments && !instr->HasEnvironment()) {
893 instr = AssignEnvironment(instr);
895 instr->set_hydrogen_value(current);
896 chunk_->AddInstruction(instr, current_block_);
986 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) {
987 return new(zone()) LGoto(instr->FirstSuccessor()->block_id());
991 LInstruction* LChunkBuilder::DoBranch(HBranch* instr) {
992 HValue* value = instr->value();
995 ? instr->FirstSuccessor()
996 : instr->SecondSuccessor();
1006 ToBooleanStub::Types expected = instr->expected_input_types();
1015 LInstruction* LChunkBuilder::DoDebugBreak(HDebugBreak* instr) {
1020 LInstruction* LChunkBuilder::DoCompareMap(HCompareMap* instr) {
1021 ASSERT(instr->value()->representation().IsTagged());
1022 LOperand* value = UseRegisterAtStart(instr->value());
1028 LInstruction* LChunkBuilder::DoArgumentsLength(HArgumentsLength* instr) {
1030 LOperand* value = UseRegister(instr->value());
1041 LInstruction* LChunkBuilder::DoInstanceOf(HInstanceOf* instr) {
1043 new(zone()) LInstanceOf(UseFixed(instr->left(), r0),
1044 UseFixed(instr->right(), r1));
1045 return MarkAsCall(DefineFixed(result, r0), instr);
1050 HInstanceOfKnownGlobal* instr) {
1052 new(zone()) LInstanceOfKnownGlobal(UseFixed(instr->left(), r0),
1054 return MarkAsCall(DefineFixed(result, r0), instr);
1058 LInstruction* LChunkBuilder::DoInstanceSize(HInstanceSize* instr) {
1059 LOperand* object = UseRegisterAtStart(instr->object());
1064 LInstruction* LChunkBuilder::DoWrapReceiver(HWrapReceiver* instr) {
1065 LOperand* receiver = UseRegisterAtStart(instr->receiver());
1066 LOperand* function = UseRegisterAtStart(instr->function());
1072 LInstruction* LChunkBuilder::DoApplyArguments(HApplyArguments* instr) {
1073 LOperand* function = UseFixed(instr->function(), r1);
1074 LOperand* receiver = UseFixed(instr->receiver(), r0);
1075 LOperand* length = UseFixed(instr->length(), r2);
1076 LOperand* elements = UseFixed(instr->elements(), r3);
1081 return MarkAsCall(DefineFixed(result, r0), instr, CAN_DEOPTIMIZE_EAGERLY);
1085 LInstruction* LChunkBuilder::DoPushArgument(HPushArgument* instr) {
1087 LOperand* argument = Use(instr->argument());
1101 LInstruction* LChunkBuilder::DoThisFunction(HThisFunction* instr) {
1102 return instr->HasNoUses()
1108 LInstruction* LChunkBuilder::DoContext(HContext* instr) {
1110 for (HUseIterator it(instr->uses()); !it.Done(); it.Advance()) {
1120 LInstruction* LChunkBuilder::DoOuterContext(HOuterContext* instr) {
1121 LOperand* context = UseRegisterAtStart(instr->value());
1126 LInstruction* LChunkBuilder::DoDeclareGlobals(HDeclareGlobals* instr) {
1127 return MarkAsCall(new(zone()) LDeclareGlobals, instr);
1131 LInstruction* LChunkBuilder::DoGlobalObject(HGlobalObject* instr) {
1132 LOperand* context = UseRegisterAtStart(instr->value());
1137 LInstruction* LChunkBuilder::DoGlobalReceiver(HGlobalReceiver* instr) {
1138 LOperand* global_object = UseRegisterAtStart(instr->value());
1144 HCallConstantFunction* instr) {
1145 argument_count_ -= instr->argument_count();
1146 return MarkAsCall(DefineFixed(new(zone()) LCallConstantFunction, r0), instr);
1150 LInstruction* LChunkBuilder::DoInvokeFunction(HInvokeFunction* instr) {
1151 LOperand* function = UseFixed(instr->function(), r1);
1152 argument_count_ -= instr->argument_count();
1154 return MarkAsCall(DefineFixed(result, r0), instr, CANNOT_DEOPTIMIZE_EAGERLY);
1158 LInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) {
1159 switch (instr->op()) {
1160 case kMathFloor: return DoMathFloor(instr);
1161 case kMathRound: return DoMathRound(instr);
1162 case kMathAbs: return DoMathAbs(instr);
1163 case kMathLog: return DoMathLog(instr);
1164 case kMathSin: return DoMathSin(instr);
1165 case kMathCos: return DoMathCos(instr);
1166 case kMathTan: return DoMathTan(instr);
1167 case kMathExp: return DoMathExp(instr);
1168 case kMathSqrt: return DoMathSqrt(instr);
1169 case kMathPowHalf: return DoMathPowHalf(instr);
1177 LInstruction* LChunkBuilder::DoMathFloor(HUnaryMathOperation* instr) {
1178 LOperand* input = UseRegister(instr->value());
1184 LInstruction* LChunkBuilder::DoMathRound(HUnaryMathOperation* instr) {
1185 LOperand* input = UseRegister(instr->value());
1192 LInstruction* LChunkBuilder::DoMathAbs(HUnaryMathOperation* instr) {
1193 LOperand* input = UseRegister(instr->value());
1199 LInstruction* LChunkBuilder::DoMathLog(HUnaryMathOperation* instr) {
1200 LOperand* input = UseFixedDouble(instr->value(), d2);
1202 return MarkAsCall(DefineFixedDouble(result, d2), instr);
1206 LInstruction* LChunkBuilder::DoMathSin(HUnaryMathOperation* instr) {
1207 LOperand* input = UseFixedDouble(instr->value(), d2);
1209 return MarkAsCall(DefineFixedDouble(result, d2), instr);
1213 LInstruction* LChunkBuilder::DoMathCos(HUnaryMathOperation* instr) {
1214 LOperand* input = UseFixedDouble(instr->value(), d2);
1216 return MarkAsCall(DefineFixedDouble(result, d2), instr);
1220 LInstruction* LChunkBuilder::DoMathTan(HUnaryMathOperation* instr) {
1221 LOperand* input = UseFixedDouble(instr->value(), d2);
1223 return MarkAsCall(DefineFixedDouble(result, d2), instr);
1227 LInstruction* LChunkBuilder::DoMathExp(HUnaryMathOperation* instr) {
1228 ASSERT(instr->representation().IsDouble());
1229 ASSERT(instr->value()->representation().IsDouble());
1230 LOperand* input = UseTempRegister(instr->value());
1239 LInstruction* LChunkBuilder::DoMathSqrt(HUnaryMathOperation* instr) {
1240 LOperand* input = UseRegister(instr->value());
1246 LInstruction* LChunkBuilder::DoMathPowHalf(HUnaryMathOperation* instr) {
1247 LOperand* input = UseFixedDouble(instr->value(), d2);
1254 LInstruction* LChunkBuilder::DoCallKeyed(HCallKeyed* instr) {
1255 ASSERT(instr->key()->representation().IsTagged());
1256 argument_count_ -= instr->argument_count();
1257 LOperand* key = UseFixed(instr->key(), r2);
1258 return MarkAsCall(DefineFixed(new(zone()) LCallKeyed(key), r0), instr);
1262 LInstruction* LChunkBuilder::DoCallNamed(HCallNamed* instr) {
1263 argument_count_ -= instr->argument_count();
1264 return MarkAsCall(DefineFixed(new(zone()) LCallNamed, r0), instr);
1268 LInstruction* LChunkBuilder::DoCallGlobal(HCallGlobal* instr) {
1269 argument_count_ -= instr->argument_count();
1270 return MarkAsCall(DefineFixed(new(zone()) LCallGlobal, r0), instr);
1274 LInstruction* LChunkBuilder::DoCallKnownGlobal(HCallKnownGlobal* instr) {
1275 argument_count_ -= instr->argument_count();
1276 return MarkAsCall(DefineFixed(new(zone()) LCallKnownGlobal, r0), instr);
1280 LInstruction* LChunkBuilder::DoCallNew(HCallNew* instr) {
1281 LOperand* constructor = UseFixed(instr->constructor(), r1);
1282 argument_count_ -= instr->argument_count();
1284 return MarkAsCall(DefineFixed(result, r0), instr);
1288 LInstruction* LChunkBuilder::DoCallNewArray(HCallNewArray* instr) {
1289 LOperand* constructor = UseFixed(instr->constructor(), r1);
1290 argument_count_ -= instr->argument_count();
1292 return MarkAsCall(DefineFixed(result, r0), instr);
1296 LInstruction* LChunkBuilder::DoCallFunction(HCallFunction* instr) {
1297 LOperand* function = UseFixed(instr->function(), r1);
1298 argument_count_ -= instr->argument_count();
1300 instr);
1304 LInstruction* LChunkBuilder::DoCallRuntime(HCallRuntime* instr) {
1305 argument_count_ -= instr->argument_count();
1306 return MarkAsCall(DefineFixed(new(zone()) LCallRuntime, r0), instr);
1310 LInstruction* LChunkBuilder::DoRor(HRor* instr) {
1311 return DoShift(Token::ROR, instr);
1315 LInstruction* LChunkBuilder::DoShr(HShr* instr) {
1316 return DoShift(Token::SHR, instr);
1320 LInstruction* LChunkBuilder::DoSar(HSar* instr) {
1321 return DoShift(Token::SAR, instr);
1325 LInstruction* LChunkBuilder::DoShl(HShl* instr) {
1326 return DoShift(Token::SHL, instr);
1330 LInstruction* LChunkBuilder::DoBitwise(HBitwise* instr) {
1331 if (instr->representation().IsSmiOrInteger32()) {
1332 ASSERT(instr->left()->representation().Equals(instr->representation()));
1333 ASSERT(instr->right()->representation().Equals(instr->representation()));
1335 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand());
1336 LOperand* right = UseOrConstantAtStart(instr->BetterRightOperand());
1339 ASSERT(instr->representation().IsTagged());
1340 ASSERT(instr->left()->representation().IsTagged());
1341 ASSERT(instr->right()->representation().IsTagged());
1343 LOperand* left = UseFixed(instr->left(), r1);
1344 LOperand* right = UseFixed(instr->right(), r0);
1345 LArithmeticT* result = new(zone()) LArithmeticT(instr->op(), left, right);
1346 return MarkAsCall(DefineFixed(result, r0), instr);
1351 LInstruction* LChunkBuilder::DoDiv(HDiv* instr) {
1352 if (instr->representation().IsDouble()) {
1353 return DoArithmeticD(Token::DIV, instr);
1354 } else if (instr->representation().IsSmiOrInteger32()) {
1355 ASSERT(instr->left()->representation().Equals(instr->representation()));
1356 ASSERT(instr->right()->representation().Equals(instr->representation()));
1357 if (instr->HasPowerOf2Divisor()) {
1358 ASSERT(!instr->CheckFlag(HValue::kCanBeDivByZero));
1359 LOperand* value = UseRegisterAtStart(instr->left());
1361 new(zone()) LDivI(value, UseOrConstant(instr->right()), NULL);
1364 LOperand* dividend = UseRegister(instr->left());
1365 LOperand* divisor = UseRegister(instr->right());
1370 return DoArithmeticT(Token::DIV, instr);
1428 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) {
1429 HValue* right = instr->right();
1430 LOperand* dividend = UseRegister(instr->left());
1444 LInstruction* LChunkBuilder::DoMod(HMod* instr) {
1445 HValue* left = instr->left();
1446 HValue* right = instr->right();
1447 if (instr->representation().IsSmiOrInteger32()) {
1448 ASSERT(instr->left()->representation().Equals(instr->representation()));
1449 ASSERT(instr->right()->representation().Equals(instr->representation()));
1450 if (instr->HasPowerOf2Divisor()) {
1456 instr->CheckFlag(HValue::kBailoutOnMinusZero))
1459 } else if (instr->fixed_right_arg().has_value) {
1470 instr->CheckFlag(HValue::kBailoutOnMinusZero)) ||
1472 instr->CanBeZero() &&
1473 instr->CheckFlag(HValue::kBailoutOnMinusZero)))
1484 instr->CanBeZero() &&
1485 instr->CheckFlag(HValue::kBailoutOnMinusZero)))
1489 } else if (instr->representation().IsTagged()) {
1490 return DoArithmeticT(Token::MOD, instr);
1492 ASSERT(instr->representation().IsDouble());
1499 return MarkAsCall(DefineFixedDouble(mod, d1), instr);
1504 LInstruction* LChunkBuilder::DoMul(HMul* instr) {
1505 if (instr->representation().IsSmiOrInteger32()) {
1506 ASSERT(instr->left()->representation().Equals(instr->representation()));
1507 ASSERT(instr->right()->representation().Equals(instr->representation()));
1509 LOperand* right = UseOrConstant(instr->BetterRightOperand());
1511 if (instr->CheckFlag(HValue::kBailoutOnMinusZero) &&
1512 (instr->CheckFlag(HValue::kCanOverflow) ||
1514 left = UseRegister(instr->BetterLeftOperand());
1517 left = UseRegisterAtStart(instr->BetterLeftOperand());
1520 if (instr->CheckFlag(HValue::kCanOverflow) ||
1521 instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
1526 } else if (instr->representation().IsDouble()) {
1527 if (instr->UseCount() == 1 && (instr->uses().value()->IsAdd() ||
1528 instr->uses().value()->IsSub())) {
1529 HBinaryOperation* use = HBinaryOperation::cast(instr->uses().value());
1531 if (use->IsAdd() && instr == use->left()) {
1536 if (instr == use->right() && use->IsAdd() && !use->left()->IsMul()) {
1541 if (instr == use->right() && use->IsSub()) {
1548 return DoArithmeticD(Token::MUL, instr);
1550 return DoArithmeticT(Token::MUL, instr);
1555 LInstruction* LChunkBuilder::DoSub(HSub* instr) {
1556 if (instr->representation().IsSmiOrInteger32()) {
1557 ASSERT(instr->left()->representation().Equals(instr->representation()));
1558 ASSERT(instr->right()->representation().Equals(instr->representation()));
1560 if (instr->left()->IsConstant()) {
1562 return DoRSub(instr);
1565 LOperand* left = UseRegisterAtStart(instr->left());
1566 LOperand* right = UseOrConstantAtStart(instr->right());
1569 if (instr->CheckFlag(HValue::kCanOverflow)) {
1573 } else if (instr->representation().IsDouble()) {
1574 if (instr->right()->IsMul()) {
1575 return DoMultiplySub(instr->left(), HMul::cast(instr->right()));
1578 return DoArithmeticD(Token::SUB, instr);
1580 return DoArithmeticT(Token::SUB, instr);
1585 LInstruction* LChunkBuilder::DoRSub(HSub* instr) {
1586 ASSERT(instr->representation().IsSmiOrInteger32());
1587 ASSERT(instr->left()->representation().Equals(instr->representation()));
1588 ASSERT(instr->right()->representation().Equals(instr->representation()));
1592 LOperand* left = UseRegisterAtStart(instr->right());
1593 LOperand* right = UseOrConstantAtStart(instr->left());
1596 if (instr->CheckFlag(HValue::kCanOverflow)) {
1623 LInstruction* LChunkBuilder::DoAdd(HAdd* instr) {
1624 if (instr->representation().IsSmiOrInteger32()) {
1625 ASSERT(instr->left()->representation().Equals(instr->representation()));
1626 ASSERT(instr->right()->representation().Equals(instr->representation()));
1627 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand());
1628 LOperand* right = UseOrConstantAtStart(instr->BetterRightOperand());
1631 if (instr->CheckFlag(HValue::kCanOverflow)) {
1635 } else if (instr->representation().IsDouble()) {
1636 if (instr->left()->IsMul()) {
1637 return DoMultiplyAdd(HMul::cast(instr->left()), instr->right());
1640 if (instr->right()->IsMul()) {
1641 ASSERT(!instr->left()->IsMul());
1642 return DoMultiplyAdd(HMul::cast(instr->right()), instr->left());
1645 return DoArithmeticD(Token::ADD, instr);
1647 ASSERT(instr->representation().IsTagged());
1648 return DoArithmeticT(Token::ADD, instr);
1653 LInstruction* LChunkBuilder::DoMathMinMax(HMathMinMax* instr) {
1656 if (instr->representation().IsSmiOrInteger32()) {
1657 ASSERT(instr->left()->representation().Equals(instr->representation()));
1658 ASSERT(instr->right()->representation().Equals(instr->representation()));
1659 left = UseRegisterAtStart(instr->BetterLeftOperand());
1660 right = UseOrConstantAtStart(instr->BetterRightOperand());
1662 ASSERT(instr->representation().IsDouble());
1663 ASSERT(instr->left()->representation().IsDouble());
1664 ASSERT(instr->right()->representation().IsDouble());
1665 left = UseRegisterAtStart(instr->left());
1666 right = UseRegisterAtStart(instr->right());
1672 LInstruction* LChunkBuilder::DoPower(HPower* instr) {
1673 ASSERT(instr->representation().IsDouble());
1676 Representation exponent_type = instr->right()->representation();
1677 ASSERT(instr->left()->representation().IsDouble());
1678 LOperand* left = UseFixedDouble(instr->left(), d1);
1680 UseFixedDouble(instr->right(), d2) :
1681 UseFixed(instr->right(), r2);
1684 instr,
1689 LInstruction* LChunkBuilder::DoRandom(HRandom* instr) {
1690 ASSERT(instr->representation().IsDouble());
1691 ASSERT(instr->global_object()->representation().IsTagged());
1692 LOperand* global_object = UseFixed(instr->global_object(), r0);
1694 return MarkAsCall(DefineFixedDouble(result, d7), instr);
1698 LInstruction* LChunkBuilder::DoCompareGeneric(HCompareGeneric* instr) {
1699 ASSERT(instr->left()->representation().IsTagged());
1700 ASSERT(instr->right()->representation().IsTagged());
1701 LOperand* left = UseFixed(instr->left(), r1);
1702 LOperand* right = UseFixed(instr->right(), r0);
1704 return MarkAsCall(DefineFixed(result, r0), instr);
1709 HCompareNumericAndBranch* instr) {
1710 Representation r = instr->representation();
1712 ASSERT(instr->left()->representation().Equals(r));
1713 ASSERT(instr->right()->representation().Equals(r));
1714 LOperand* left = UseRegisterOrConstantAtStart(instr->left());
1715 LOperand* right = UseRegisterOrConstantAtStart(instr->right());
1719 ASSERT(instr->left()->representation().IsDouble());
1720 ASSERT(instr->right()->representation().IsDouble());
1721 LOperand* left = UseRegisterAtStart(instr->left());
1722 LOperand* right = UseRegisterAtStart(instr->right());
1729 HCompareObjectEqAndBranch* instr) {
1730 LOperand* left = UseRegisterAtStart(instr->left());
1731 LOperand* right = UseRegisterAtStart(instr->right());
1737 HCompareHoleAndBranch* instr) {
1738 LOperand* object = UseRegisterAtStart(instr->object());
1743 LInstruction* LChunkBuilder::DoIsObjectAndBranch(HIsObjectAndBranch* instr) {
1744 ASSERT(instr->value()->representation().IsTagged());
1745 LOperand* value = UseRegisterAtStart(instr->value());
1751 LInstruction* LChunkBuilder::DoIsStringAndBranch(HIsStringAndBranch* instr) {
1752 ASSERT(instr->value()->representation().IsTagged());
1753 LOperand* value = UseRegisterAtStart(instr->value());
1759 LInstruction* LChunkBuilder::DoIsSmiAndBranch(HIsSmiAndBranch* instr) {
1760 ASSERT(instr->value()->representation().IsTagged());
1761 return new(zone()) LIsSmiAndBranch(Use(instr->value()));
1766 HIsUndetectableAndBranch* instr) {
1767 ASSERT(instr->value()->representation().IsTagged());
1768 LOperand* value = UseRegisterAtStart(instr->value());
1774 HStringCompareAndBranch* instr) {
1775 ASSERT(instr->left()->representation().IsTagged());
1776 ASSERT(instr->right()->representation().IsTagged());
1777 LOperand* left = UseFixed(instr->left(), r1);
1778 LOperand* right = UseFixed(instr->right(), r0);
1781 return MarkAsCall(result, instr);
1786 HHasInstanceTypeAndBranch* instr) {
1787 ASSERT(instr->value()->representation().IsTagged());
1788 LOperand* value = UseRegisterAtStart(instr->value());
1794 HGetCachedArrayIndex* instr) {
1795 ASSERT(instr->value()->representation().IsTagged());
1796 LOperand* value = UseRegisterAtStart(instr->value());
1803 HHasCachedArrayIndexAndBranch* instr) {
1804 ASSERT(instr->value()->representation().IsTagged());
1806 UseRegisterAtStart(instr->value()));
1811 HClassOfTestAndBranch* instr) {
1812 ASSERT(instr->value()->representation().IsTagged());
1813 LOperand* value = UseRegister(instr->value());
1818 LInstruction* LChunkBuilder::DoMapEnumLength(HMapEnumLength* instr) {
1819 LOperand* map = UseRegisterAtStart(instr->value());
1824 LInstruction* LChunkBuilder::DoElementsKind(HElementsKind* instr) {
1825 LOperand* object = UseRegisterAtStart(instr->value());
1830 LInstruction* LChunkBuilder::DoValueOf(HValueOf* instr) {
1831 LOperand* object = UseRegister(instr->value());
1837 LInstruction* LChunkBuilder::DoDateField(HDateField* instr) {
1838 LOperand* object = UseFixed(instr->value(), r0);
1840 new(zone()) LDateField(object, FixedTemp(r1), instr->index());
1841 return MarkAsCall(DefineFixed(result, r0), instr, CAN_DEOPTIMIZE_EAGERLY);
1845 LInstruction* LChunkBuilder::DoSeqStringSetChar(HSeqStringSetChar* instr) {
1846 LOperand* string = UseRegister(instr->string());
1847 LOperand* index = UseRegister(instr->index());
1848 LOperand* value = UseTempRegister(instr->value());
1850 new(zone()) LSeqStringSetChar(instr->encoding(), string, index, value);
1855 LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) {
1856 LOperand* value = UseRegisterOrConstantAtStart(instr->index());
1857 LOperand* length = UseRegister(instr->length());
1863 HBoundsCheckBaseIndexInformation* instr) {
1869 LInstruction* LChunkBuilder::DoThrow(HThrow* instr) {
1870 LOperand* value = UseFixed(instr->value(), r0);
1871 return MarkAsCall(new(zone()) LThrow(value), instr);
1875 LInstruction* LChunkBuilder::DoUseConst(HUseConst* instr) {
1888 LInstruction* LChunkBuilder::DoChange(HChange* instr) {
1889 Representation from = instr->from();
1890 Representation to = instr->to();
1893 LOperand* value = UseRegister(instr->value());
1901 LOperand* value = UseRegister(instr->value());
1905 HValue* val = instr->value();
1915 if (instr->value()->type().IsSmi()) {
1916 value = UseRegisterAtStart(instr->value());
1919 value = UseRegister(instr->value());
1921 LOperand* temp2 = instr->CanTruncateToInt32() ? TempRegister()
1935 LOperand* value = UseRegister(instr->value());
1946 LOperand* value = UseRegister(instr->value());
1951 LOperand* value = UseRegister(instr->value());
1953 LOperand* temp2 = instr->CanTruncateToInt32() ? TempRegister() : NULL;
1960 HValue* val = instr->value();
1972 HValue* val = instr->value();
1983 if (instr->value()->CheckFlag(HInstruction::kUint32)) {
1985 new(zone()) LUint32ToDouble(UseRegister(instr->value())));
1988 new(zone()) LInteger32ToDouble(Use(instr->value())));
1997 LInstruction* LChunkBuilder::DoCheckHeapObject(HCheckHeapObject* instr) {
1998 LOperand* value = UseRegisterAtStart(instr->value());
2003 LInstruction* LChunkBuilder::DoCheckSmi(HCheckSmi* instr) {
2004 LOperand* value = UseRegisterAtStart(instr->value());
2009 LInstruction* LChunkBuilder::DoIsNumberAndBranch(HIsNumberAndBranch* instr) {
2011 LIsNumberAndBranch(UseRegisterOrConstantAtStart(instr->value()));
2015 LInstruction* LChunkBuilder::DoCheckInstanceType(HCheckInstanceType* instr) {
2016 LOperand* value = UseRegisterAtStart(instr->value());
2022 LInstruction* LChunkBuilder::DoCheckFunction(HCheckFunction* instr) {
2023 LOperand* value = UseRegisterAtStart(instr->value());
2028 LInstruction* LChunkBuilder::DoCheckMaps(HCheckMaps* instr) {
2030 if (!instr->CanOmitMapChecks()) {
2031 value = UseRegisterAtStart(instr->value());
2032 if (instr->has_migration_target()) info()->MarkAsDeferredCalling();
2035 if (!instr->CanOmitMapChecks()) {
2037 if (instr->has_migration_target()) return AssignPointerMap(result);
2043 LInstruction* LChunkBuilder::DoClampToUint8(HClampToUint8* instr) {
2044 HValue* value = instr->value();
2061 LInstruction* LChunkBuilder::DoReturn(HReturn* instr) {
2062 LOperand* parameter_count = UseRegisterOrConstant(instr->parameter_count());
2063 return new(zone()) LReturn(UseFixed(instr->value(), r0),
2068 LInstruction* LChunkBuilder::DoConstant(HConstant* instr) {
2069 Representation r = instr->representation();
2087 LInstruction* LChunkBuilder::DoLoadGlobalCell(HLoadGlobalCell* instr) {
2089 return instr->RequiresHoleCheck()
2095 LInstruction* LChunkBuilder::DoLoadGlobalGeneric(HLoadGlobalGeneric* instr) {
2096 LOperand* global_object = UseFixed(instr->global_object(), r0);
2098 return MarkAsCall(DefineFixed(result, r0), instr);
2102 LInstruction* LChunkBuilder::DoStoreGlobalCell(HStoreGlobalCell* instr) {
2103 LOperand* value = UseRegister(instr->value());
2106 return instr->RequiresHoleCheck()
2112 LInstruction* LChunkBuilder::DoStoreGlobalGeneric(HStoreGlobalGeneric* instr) {
2113 LOperand* global_object = UseFixed(instr->global_object(), r1);
2114 LOperand* value = UseFixed(instr->value(), r0);
2117 return MarkAsCall(result, instr);
2121 LInstruction* LChunkBuilder::DoLoadContextSlot(HLoadContextSlot* instr) {
2122 LOperand* context = UseRegisterAtStart(instr->value());
2125 return instr->RequiresHoleCheck() ? AssignEnvironment(result) : result;
2129 LInstruction* LChunkBuilder::DoStoreContextSlot(HStoreContextSlot* instr) {
2132 if (instr->NeedsWriteBarrier()) {
2133 context = UseTempRegister(instr->context());
2134 value = UseTempRegister(instr->value());
2136 context = UseRegister(instr->context());
2137 value = UseRegister(instr->value());
2140 return instr->RequiresHoleCheck() ? AssignEnvironment(result) : result;
2144 LInstruction* LChunkBuilder::DoLoadNamedField(HLoadNamedField* instr) {
2145 LOperand* obj = UseRegisterAtStart(instr->object());
2150 LInstruction* LChunkBuilder::DoLoadNamedGeneric(HLoadNamedGeneric* instr) {
2151 LOperand* object = UseFixed(instr->object(), r0);
2153 return MarkAsCall(result, instr);
2158 HLoadFunctionPrototype* instr) {
2160 new(zone()) LLoadFunctionPrototype(UseRegister(instr->function()))));
2165 HLoadExternalArrayPointer* instr) {
2166 LOperand* input = UseRegisterAtStart(instr->value());
2171 LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) {
2172 ASSERT(instr->key()->representation().IsSmiOrInteger32());
2173 ElementsKind elements_kind = instr->elements_kind();
2174 LOperand* key = UseRegisterOrConstantAtStart(instr->key());
2177 if (!instr->is_external()) {
2179 if (instr->representation().IsDouble()) {
2180 obj = UseTempRegister(instr->elements());
2182 ASSERT(instr->representation().IsSmiOrTagged());
2183 obj = UseRegisterAtStart(instr->elements());
2188 (instr->representation().IsInteger32() &&
2191 (instr->representation().IsDouble() &&
2194 LOperand* external_pointer = UseRegister(instr->elements());
2201 bool can_deoptimize = instr->RequiresHoleCheck() ||
2207 LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) {
2208 LOperand* object = UseFixed(instr->object(), r1);
2209 LOperand* key = UseFixed(instr->key(), r0);
2213 return MarkAsCall(result, instr);
2217 LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) {
2218 ElementsKind elements_kind = instr->elements_kind();
2220 if (!instr->is_external()) {
2221 ASSERT(instr->elements()->representation().IsTagged());
2222 bool needs_write_barrier = instr->NeedsWriteBarrier();
2227 if (instr->value()->representation().IsDouble()) {
2228 object = UseRegisterAtStart(instr->elements());
2229 val = UseTempRegister(instr->value());
2230 key = UseRegisterOrConstantAtStart(instr->key());
2232 ASSERT(instr->value()->representation().IsSmiOrTagged());
2233 object = UseTempRegister(instr->elements());
2234 val = needs_write_barrier ? UseTempRegister(instr->value())
2235 : UseRegisterAtStart(instr->value());
2236 key = needs_write_barrier ? UseTempRegister(instr->key())
2237 : UseRegisterOrConstantAtStart(instr->key());
2244 (instr->value()->representation().IsInteger32() &&
2247 (instr->value()->representation().IsDouble() &&
2250 ASSERT(instr->elements()->representation().IsExternal());
2254 LOperand* val = val_is_temp_register ? UseTempRegister(instr->value())
2255 : UseRegister(instr->value());
2256 LOperand* key = UseRegisterOrConstantAtStart(instr->key());
2257 LOperand* external_pointer = UseRegister(instr->elements());
2262 LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) {
2263 LOperand* obj = UseFixed(instr->object(), r2);
2264 LOperand* key = UseFixed(instr->key(), r1);
2265 LOperand* val = UseFixed(instr->value(), r0);
2267 ASSERT(instr->object()->representation().IsTagged());
2268 ASSERT(instr->key()->representation().IsTagged());
2269 ASSERT(instr->value()->representation().IsTagged());
2271 return MarkAsCall(new(zone()) LStoreKeyedGeneric(obj, key, val), instr);
2276 HTransitionElementsKind* instr) {
2277 LOperand* object = UseRegister(instr->object());
2278 if (IsSimpleMapChangeTransition(instr->from_kind(), instr->to_kind())) {
2292 HTrapAllocationMemento* instr) {
2293 LOperand* object = UseRegister(instr->object());
2301 LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) {
2302 bool is_in_object = instr->access().IsInobject();
2303 bool needs_write_barrier = instr->NeedsWriteBarrier();
2304 bool needs_write_barrier_for_map = instr->has_transition() &&
2305 instr->NeedsWriteBarrierForMap();
2310 ? UseRegister(instr->object())
2311 : UseTempRegister(instr->object());
2314 ? UseRegister(instr->object())
2315 : UseRegisterAtStart(instr->object());
2320 (FLAG_track_fields && instr->field_representation().IsSmi())) {
2321 val = UseTempRegister(instr->value());
2323 instr->field_representation().IsDouble()) {
2324 val = UseRegisterAtStart(instr->value());
2326 val = UseRegister(instr->value());
2334 instr->field_representation().IsHeapObject()) {
2335 if (!instr->value()->type().IsHeapObject()) {
2343 LInstruction* LChunkBuilder::DoStoreNamedGeneric(HStoreNamedGeneric* instr) {
2344 LOperand* obj = UseFixed(instr->object(), r1);
2345 LOperand* val = UseFixed(instr->value(), r0);
2348 return MarkAsCall(result, instr);
2352 LInstruction* LChunkBuilder::DoStringAdd(HStringAdd* instr) {
2353 LOperand* left = UseRegisterAtStart(instr->left());
2354 LOperand* right = UseRegisterAtStart(instr->right());
2356 instr);
2360 LInstruction* LChunkBuilder::DoStringCharCodeAt(HStringCharCodeAt* instr) {
2361 LOperand* string = UseTempRegister(instr->string());
2362 LOperand* index = UseTempRegister(instr->index());
2368 LInstruction* LChunkBuilder::DoStringCharFromCode(HStringCharFromCode* instr) {
2369 LOperand* char_code = UseRegister(instr->value());
2375 LInstruction* LChunkBuilder::DoAllocate(HAllocate* instr) {
2377 LOperand* size = instr->size()->IsConstant()
2378 ? UseConstant(instr->size())
2379 : UseTempRegister(instr->size());
2387 LInstruction* LChunkBuilder::DoRegExpLiteral(HRegExpLiteral* instr) {
2388 return MarkAsCall(DefineFixed(new(zone()) LRegExpLiteral, r0), instr);
2392 LInstruction* LChunkBuilder::DoFunctionLiteral(HFunctionLiteral* instr) {
2393 return MarkAsCall(DefineFixed(new(zone()) LFunctionLiteral, r0), instr);
2397 LInstruction* LChunkBuilder::DoOsrEntry(HOsrEntry* instr) {
2400 current_block_->last_environment()->set_ast_id(instr->ast_id());
2405 LInstruction* LChunkBuilder::DoParameter(HParameter* instr) {
2407 if (instr->kind() == HParameter::STACK_PARAMETER) {
2408 int spill_index = chunk()->GetParameterStackSlot(instr->index());
2414 int index = static_cast<int>(instr->index());
2421 LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) {
2431 LInstruction* LChunkBuilder::DoCallStub(HCallStub* instr) {
2432 argument_count_ -= instr->argument_count();
2433 return MarkAsCall(DefineFixed(new(zone()) LCallStub, r0), instr);
2437 LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) {
2446 LInstruction* LChunkBuilder::DoCapturedObject(HCapturedObject* instr) {
2452 LInstruction* LChunkBuilder::DoAccessArgumentsAt(HAccessArgumentsAt* instr) {
2454 LOperand* args = UseRegister(instr->arguments());
2457 if (instr->length()->IsConstant() && instr->index()->IsConstant()) {
2458 length = UseRegisterOrConstant(instr->length());
2459 index = UseOrConstant(instr->index());
2461 length = UseTempRegister(instr->length());
2462 index = UseRegisterAtStart(instr->index());
2468 LInstruction* LChunkBuilder::DoToFastProperties(HToFastProperties* instr) {
2469 LOperand* object = UseFixed(instr->value(), r0);
2471 return MarkAsCall(DefineFixed(result, r0), instr);
2475 LInstruction* LChunkBuilder::DoTypeof(HTypeof* instr) {
2476 LTypeof* result = new(zone()) LTypeof(UseFixed(instr->value(), r0));
2477 return MarkAsCall(DefineFixed(result, r0), instr);
2481 LInstruction* LChunkBuilder::DoTypeofIsAndBranch(HTypeofIsAndBranch* instr) {
2482 return new(zone()) LTypeofIsAndBranch(UseTempRegister(instr->value()));
2487 HIsConstructCallAndBranch* instr) {
2492 LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) {
2496 env->set_ast_id(instr->ast_id());
2498 env->Drop(instr->pop_count());
2499 for (int i = instr->values()->length() - 1; i >= 0; --i) {
2500 HValue* value = instr->values()->at(i);
2501 if (instr->HasAssignedIndexAt(i)) {
2502 env->Bind(instr->GetAssignedIndexAt(i), value);
2510 if (pending_deoptimization_ast_id_ == instr->ast_id()) {
2526 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) {
2527 if (instr->is_function_entry()) {
2528 return MarkAsCall(new(zone()) LStackCheck, instr);
2530 ASSERT(instr->is_backwards_branch());
2536 LInstruction* LChunkBuilder::DoEnterInlined(HEnterInlined* instr) {
2539 HEnvironment* inner = outer->CopyForInlining(instr->closure(),
2540 instr->arguments_count(),
2541 instr->function(),
2543 instr->inlining_kind(),
2544 instr->undefined_receiver());
2546 if (instr->arguments_var() != NULL && instr->arguments_object()->IsLinked()) {
2547 inner->Bind(instr->arguments_var(), instr->arguments_object());
2549 inner->set_entry(instr);
2551 chunk_->AddInlinedClosure(instr->closure());
2556 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) {
2575 LInstruction* LChunkBuilder::DoForInPrepareMap(HForInPrepareMap* instr) {
2576 LOperand* object = UseFixed(instr->enumerable(), r0);
2578 return MarkAsCall(DefineFixed(result, r0), instr, CAN_DEOPTIMIZE_EAGERLY);
2582 LInstruction* LChunkBuilder::DoForInCacheArray(HForInCacheArray* instr) {
2583 LOperand* map = UseRegister(instr->map());
2588 LInstruction* LChunkBuilder::DoCheckMapValue(HCheckMapValue* instr) {
2589 LOperand* value = UseRegisterAtStart(instr->value());
2590 LOperand* map = UseRegisterAtStart(instr->map());
2595 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) {
2596 LOperand* object = UseRegister(instr->object());
2597 LOperand* index = UseRegister(instr->index());