Lines Matching refs:instr

575     HInstruction* instr = HInstruction::cast(value);
576 VisitInstruction(instr);
583 LInstruction* LChunkBuilder::Define(LTemplateResultInstruction<1>* instr,
586 instr->set_result(result);
587 return instr;
592 LTemplateResultInstruction<1>* instr) {
593 return Define(instr,
599 LTemplateResultInstruction<1>* instr,
601 return Define(instr,
607 LTemplateResultInstruction<1>* instr) {
608 return Define(instr,
613 LInstruction* LChunkBuilder::DefineFixed(LTemplateResultInstruction<1>* instr,
615 return Define(instr, ToUnallocated(reg));
619 LInstruction* LChunkBuilder::DefineFixed(LTemplateResultInstruction<1>* instr,
621 return Define(instr, ToUnallocated(reg));
625 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) {
629 instr->set_environment(CreateEnvironment(hydrogen_env,
632 return instr;
636 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr,
642 instr->VerifyCall();
644 instr->MarkAsCall();
645 instr = AssignPointerMap(instr);
654 if (needs_environment && !instr->HasEnvironment()) {
655 instr = AssignEnvironment(instr);
657 instr->environment()->set_has_been_used();
660 return instr;
664 LInstruction* LChunkBuilder::AssignPointerMap(LInstruction* instr) {
665 DCHECK(!instr->HasPointerMap());
666 instr->set_pointer_map(new(zone()) LPointerMap(zone()));
667 return instr;
691 LInstruction* LChunkBuilder::DoBlockEntry(HBlockEntry* instr) {
692 return new(zone()) LLabel(instr->block());
696 LInstruction* LChunkBuilder::DoDummyUse(HDummyUse* instr) {
697 return DefineAsRegister(new(zone()) LDummyUse(UseAny(instr->value())));
701 LInstruction* LChunkBuilder::DoEnvironmentMarker(HEnvironmentMarker* instr) {
707 LInstruction* LChunkBuilder::DoDeoptimize(HDeoptimize* instr) {
713 HBitwiseBinaryOperation* instr) {
714 if (instr->representation().IsSmiOrInteger32()) {
715 DCHECK(instr->left()->representation().Equals(instr->representation()));
716 DCHECK(instr->right()->representation().Equals(instr->representation()));
717 LOperand* left = UseRegisterAtStart(instr->left());
719 HValue* right_value = instr->right();
729 if (instr->representation().IsSmi() && constant_value > 0) {
730 does_deopt = !instr->CheckUsesForFlag(HValue::kTruncatingToSmi);
740 does_deopt = !instr->CheckFlag(HInstruction::kUint32);
742 does_deopt = !instr->CheckUsesForFlag(HValue::kTruncatingToInt32);
750 return DoArithmeticT(op, instr);
756 HArithmeticBinaryOperation* instr) {
757 DCHECK(instr->representation().IsDouble());
758 DCHECK(instr->left()->representation().IsDouble());
759 DCHECK(instr->right()->representation().IsDouble());
761 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand());
762 LOperand* right = UseRegisterAtStart(instr->BetterRightOperand());
764 return MarkAsCall(DefineSameAsFirst(result), instr);
766 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand());
767 LOperand* right = UseRegisterAtStart(instr->BetterRightOperand());
775 HBinaryOperation* instr) {
776 HValue* left = instr->left();
777 HValue* right = instr->right();
780 LOperand* context = UseFixed(instr->context(), esi);
785 return MarkAsCall(DefineFixed(result, eax), instr);
860 LInstruction* instr = NULL;
863 instr = DefineAsRegister(new(zone()) LDummy());
866 instr = DefineAsRegister(new(zone())
889 instr = new(zone()) LGoto(successor);
891 instr = current->CompileToLithium(this);
898 if (instr != NULL) {
899 AddInstruction(instr, current);
906 void LChunkBuilder::AddInstruction(LInstruction* instr,
910 instr->set_hydrogen_value(hydrogen_val);
923 if (!(instr->ClobbersRegisters() &&
924 instr->ClobbersDoubleRegisters(isolate()))) {
927 for (UseIterator it(instr); !it.Done(); it.Advance()) {
931 if (instr->Output() != NULL) {
932 if (LUnallocated::cast(instr->Output())->HasFixedPolicy()) ++fixed;
934 for (TempIterator it(instr); !it.Done(); it.Advance()) {
942 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) {
943 instr = AssignPointerMap(instr);
945 if (FLAG_stress_environments && !instr->HasEnvironment()) {
946 instr = AssignEnvironment(instr);
948 if (instr->IsGoto() &&
949 (LGoto::cast(instr)->jumps_to_join() || next_block_->is_osr_entry())) {
958 chunk_->AddInstruction(instr, current_block_);
960 if (instr->IsCall()) {
965 instruction_needing_environment = instr;
982 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) {
983 return new(zone()) LGoto(instr->FirstSuccessor());
987 LInstruction* LChunkBuilder::DoBranch(HBranch* instr) {
988 HValue* value = instr->value();
991 ToBooleanStub::Types expected = instr->expected_input_types();
1009 LInstruction* LChunkBuilder::DoDebugBreak(HDebugBreak* instr) {
1014 LInstruction* LChunkBuilder::DoCompareMap(HCompareMap* instr) {
1015 DCHECK(instr->value()->representation().IsTagged());
1016 LOperand* value = UseRegisterAtStart(instr->value());
1033 LInstruction* LChunkBuilder::DoInstanceOf(HInstanceOf* instr) {
1034 LOperand* left = UseFixed(instr->left(), InstanceofStub::left());
1035 LOperand* right = UseFixed(instr->right(), InstanceofStub::right());
1036 LOperand* context = UseFixed(instr->context(), esi);
1038 return MarkAsCall(DefineFixed(result, eax), instr);
1043 HInstanceOfKnownGlobal* instr) {
1046 UseFixed(instr->context(), esi),
1047 UseFixed(instr->left(), InstanceofStub::left()),
1049 return MarkAsCall(DefineFixed(result, eax), instr);
1053 LInstruction* LChunkBuilder::DoWrapReceiver(HWrapReceiver* instr) {
1054 LOperand* receiver = UseRegister(instr->receiver());
1055 LOperand* function = UseRegister(instr->function());
1063 LInstruction* LChunkBuilder::DoApplyArguments(HApplyArguments* instr) {
1064 LOperand* function = UseFixed(instr->function(), edi);
1065 LOperand* receiver = UseFixed(instr->receiver(), eax);
1066 LOperand* length = UseFixed(instr->length(), ebx);
1067 LOperand* elements = UseFixed(instr->elements(), ecx);
1072 return MarkAsCall(DefineFixed(result, eax), instr, CAN_DEOPTIMIZE_EAGERLY);
1076 LInstruction* LChunkBuilder::DoPushArguments(HPushArguments* instr) {
1077 int argc = instr->OperandCount();
1079 LOperand* argument = UseAny(instr->argument(i));
1080 AddInstruction(new(zone()) LPushArgument(argument), instr);
1095 HInnerAllocatedObject* instr) {
1096 LOperand* base_object = UseRegisterAtStart(instr->base_object());
1097 LOperand* offset = UseRegisterOrConstantAtStart(instr->offset());
1103 LInstruction* LChunkBuilder::DoThisFunction(HThisFunction* instr) {
1104 return instr->HasNoUses()
1110 LInstruction* LChunkBuilder::DoContext(HContext* instr) {
1111 if (instr->HasNoUses()) return NULL;
1121 LInstruction* LChunkBuilder::DoDeclareGlobals(HDeclareGlobals* instr) {
1122 LOperand* context = UseFixed(instr->context(), esi);
1123 return MarkAsCall(new(zone()) LDeclareGlobals(context), instr);
1128 HCallJSFunction* instr) {
1129 LOperand* function = UseFixed(instr->function(), edi);
1133 return MarkAsCall(DefineFixed(result, eax), instr, CANNOT_DEOPTIMIZE_EAGERLY);
1138 HCallWithDescriptor* instr) {
1139 CallInterfaceDescriptor descriptor = instr->descriptor();
1140 LOperand* target = UseRegisterOrConstantAtStart(instr->target());
1141 ZoneList<LOperand*> ops(instr->OperandCount(), zone());
1143 for (int i = 1; i < instr->OperandCount(); i++) {
1145 UseFixed(instr->OperandAt(i), descriptor.GetParameterRegister(i - 1));
1151 return MarkAsCall(DefineFixed(result, eax), instr, CANNOT_DEOPTIMIZE_EAGERLY);
1156 HTailCallThroughMegamorphicCache* instr) {
1157 LOperand* context = UseFixed(instr->context(), esi);
1159 UseFixed(instr->receiver(), LoadDescriptor::ReceiverRegister());
1161 UseFixed(instr->name(), LoadDescriptor::NameRegister());
1168 LInstruction* LChunkBuilder::DoInvokeFunction(HInvokeFunction* instr) {
1169 LOperand* context = UseFixed(instr->context(), esi);
1170 LOperand* function = UseFixed(instr->function(), edi);
1172 return MarkAsCall(DefineFixed(result, eax), instr, CANNOT_DEOPTIMIZE_EAGERLY);
1176 LInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) {
1177 switch (instr->op()) {
1178 case kMathFloor: return DoMathFloor(instr);
1179 case kMathRound: return DoMathRound(instr);
1180 case kMathFround: return DoMathFround(instr);
1181 case kMathAbs: return DoMathAbs(instr);
1182 case kMathLog: return DoMathLog(instr);
1183 case kMathExp: return DoMathExp(instr);
1184 case kMathSqrt: return DoMathSqrt(instr);
1185 case kMathPowHalf: return DoMathPowHalf(instr);
1186 case kMathClz32: return DoMathClz32(instr);
1194 LInstruction* LChunkBuilder::DoMathFloor(HUnaryMathOperation* instr) {
1195 LOperand* input = UseRegisterAtStart(instr->value());
1201 LInstruction* LChunkBuilder::DoMathRound(HUnaryMathOperation* instr) {
1202 LOperand* input = UseRegisterAtStart(instr->value());
1208 LInstruction* LChunkBuilder::DoMathFround(HUnaryMathOperation* instr) {
1209 LOperand* input = UseRegister(instr->value());
1215 LInstruction* LChunkBuilder::DoMathAbs(HUnaryMathOperation* instr) {
1216 LOperand* context = UseAny(instr->context()); // Deferred use.
1217 LOperand* input = UseRegisterAtStart(instr->value());
1220 Representation r = instr->value()->representation();
1227 LInstruction* LChunkBuilder::DoMathLog(HUnaryMathOperation* instr) {
1228 DCHECK(instr->representation().IsDouble());
1229 DCHECK(instr->value()->representation().IsDouble());
1230 LOperand* input = UseRegisterAtStart(instr->value());
1231 return MarkAsCall(DefineSameAsFirst(new(zone()) LMathLog(input)), instr);
1235 LInstruction* LChunkBuilder::DoMathClz32(HUnaryMathOperation* instr) {
1236 LOperand* input = UseRegisterAtStart(instr->value());
1242 LInstruction* LChunkBuilder::DoMathExp(HUnaryMathOperation* instr) {
1243 DCHECK(instr->representation().IsDouble());
1244 DCHECK(instr->value()->representation().IsDouble());
1245 LOperand* value = UseRegisterAtStart(instr->value());
1249 return MarkAsCall(DefineSameAsFirst(result), instr);
1253 LInstruction* LChunkBuilder::DoMathSqrt(HUnaryMathOperation* instr) {
1254 LOperand* input = UseRegisterAtStart(instr->value());
1258 return MarkAsCall(DefineSameAsFirst(result), instr);
1262 LInstruction* LChunkBuilder::DoMathPowHalf(HUnaryMathOperation* instr) {
1263 LOperand* input = UseRegisterAtStart(instr->value());
1269 LInstruction* LChunkBuilder::DoCallNew(HCallNew* instr) {
1270 LOperand* context = UseFixed(instr->context(), esi);
1271 LOperand* constructor = UseFixed(instr->constructor(), edi);
1273 return MarkAsCall(DefineFixed(result, eax), instr);
1277 LInstruction* LChunkBuilder::DoCallNewArray(HCallNewArray* instr) {
1278 LOperand* context = UseFixed(instr->context(), esi);
1279 LOperand* constructor = UseFixed(instr->constructor(), edi);
1281 return MarkAsCall(DefineFixed(result, eax), instr);
1285 LInstruction* LChunkBuilder::DoCallFunction(HCallFunction* instr) {
1286 LOperand* context = UseFixed(instr->context(), esi);
1287 LOperand* function = UseFixed(instr->function(), edi);
1289 return MarkAsCall(DefineFixed(call, eax), instr);
1293 LInstruction* LChunkBuilder::DoCallRuntime(HCallRuntime* instr) {
1294 LOperand* context = UseFixed(instr->context(), esi);
1295 return MarkAsCall(DefineFixed(new(zone()) LCallRuntime(context), eax), instr);
1299 LInstruction* LChunkBuilder::DoRor(HRor* instr) {
1300 return DoShift(Token::ROR, instr);
1304 LInstruction* LChunkBuilder::DoShr(HShr* instr) {
1305 return DoShift(Token::SHR, instr);
1309 LInstruction* LChunkBuilder::DoSar(HSar* instr) {
1310 return DoShift(Token::SAR, instr);
1314 LInstruction* LChunkBuilder::DoShl(HShl* instr) {
1315 return DoShift(Token::SHL, instr);
1319 LInstruction* LChunkBuilder::DoBitwise(HBitwise* instr) {
1320 if (instr->representation().IsSmiOrInteger32()) {
1321 DCHECK(instr->left()->representation().Equals(instr->representation()));
1322 DCHECK(instr->right()->representation().Equals(instr->representation()));
1323 DCHECK(instr->CheckFlag(HValue::kTruncatingToInt32));
1325 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand());
1326 LOperand* right = UseOrConstantAtStart(instr->BetterRightOperand());
1329 return DoArithmeticT(instr->op(), instr);
1334 LInstruction* LChunkBuilder::DoDivByPowerOf2I(HDiv* instr) {
1335 DCHECK(instr->representation().IsSmiOrInteger32());
1336 DCHECK(instr->left()->representation().Equals(instr->representation()));
1337 DCHECK(instr->right()->representation().Equals(instr->representation()));
1338 LOperand* dividend = UseRegister(instr->left());
1339 int32_t divisor = instr->right()->GetInteger32Constant();
1342 if ((instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) ||
1343 (instr->CheckFlag(HValue::kCanOverflow) && divisor == -1) ||
1344 (!instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32) &&
1352 LInstruction* LChunkBuilder::DoDivByConstI(HDiv* instr) {
1353 DCHECK(instr->representation().IsInteger32());
1354 DCHECK(instr->left()->representation().Equals(instr->representation()));
1355 DCHECK(instr->right()->representation().Equals(instr->representation()));
1356 LOperand* dividend = UseRegister(instr->left());
1357 int32_t divisor = instr->right()->GetInteger32Constant();
1363 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) ||
1364 !instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32)) {
1371 LInstruction* LChunkBuilder::DoDivI(HDiv* instr) {
1372 DCHECK(instr->representation().IsSmiOrInteger32());
1373 DCHECK(instr->left()->representation().Equals(instr->representation()));
1374 DCHECK(instr->right()->representation().Equals(instr->representation()));
1375 LOperand* dividend = UseFixed(instr->left(), eax);
1376 LOperand* divisor = UseRegister(instr->right());
1380 if (instr->CheckFlag(HValue::kCanBeDivByZero) ||
1381 instr->CheckFlag(HValue::kBailoutOnMinusZero) ||
1382 instr->CheckFlag(HValue::kCanOverflow) ||
1383 !instr->CheckFlag(HValue::kAllUsesTruncatingToInt32)) {
1390 LInstruction* LChunkBuilder::DoDiv(HDiv* instr) {
1391 if (instr->representation().IsSmiOrInteger32()) {
1392 if (instr->RightIsPowerOf2()) {
1393 return DoDivByPowerOf2I(instr);
1394 } else if (instr->right()->IsConstant()) {
1395 return DoDivByConstI(instr);
1397 return DoDivI(instr);
1399 } else if (instr->representation().IsDouble()) {
1400 return DoArithmeticD(Token::DIV, instr);
1402 return DoArithmeticT(Token::DIV, instr);
1407 LInstruction* LChunkBuilder::DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr) {
1408 LOperand* dividend = UseRegisterAtStart(instr->left());
1409 int32_t divisor = instr->right()->GetInteger32Constant();
1412 if ((instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) ||
1413 (instr->CheckFlag(HValue::kLeftCanBeMinInt) && divisor == -1)) {
1420 LInstruction* LChunkBuilder::DoFlooringDivByConstI(HMathFloorOfDiv* instr) {
1421 DCHECK(instr->representation().IsInteger32());
1422 DCHECK(instr->left()->representation().Equals(instr->representation()));
1423 DCHECK(instr->right()->representation().Equals(instr->representation()));
1424 LOperand* dividend = UseRegister(instr->left());
1425 int32_t divisor = instr->right()->GetInteger32Constant();
1429 ((divisor > 0 && !instr->CheckFlag(HValue::kLeftCanBeNegative)) ||
1430 (divisor < 0 && !instr->CheckFlag(HValue::kLeftCanBePositive))) ?
1440 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0)) {
1447 LInstruction* LChunkBuilder::DoFlooringDivI(HMathFloorOfDiv* instr) {
1448 DCHECK(instr->representation().IsSmiOrInteger32());
1449 DCHECK(instr->left()->representation().Equals(instr->representation()));
1450 DCHECK(instr->right()->representation().Equals(instr->representation()));
1451 LOperand* dividend = UseFixed(instr->left(), eax);
1452 LOperand* divisor = UseRegister(instr->right());
1456 if (instr->CheckFlag(HValue::kCanBeDivByZero) ||
1457 instr->CheckFlag(HValue::kBailoutOnMinusZero) ||
1458 instr->CheckFlag(HValue::kCanOverflow)) {
1465 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) {
1466 if (instr->RightIsPowerOf2()) {
1467 return DoFlooringDivByPowerOf2I(instr);
1468 } else if (instr->right()->IsConstant()) {
1469 return DoFlooringDivByConstI(instr);
1471 return DoFlooringDivI(instr);
1476 LInstruction* LChunkBuilder::DoModByPowerOf2I(HMod* instr) {
1477 DCHECK(instr->representation().IsSmiOrInteger32());
1478 DCHECK(instr->left()->representation().Equals(instr->representation()));
1479 DCHECK(instr->right()->representation().Equals(instr->representation()));
1480 LOperand* dividend = UseRegisterAtStart(instr->left());
1481 int32_t divisor = instr->right()->GetInteger32Constant();
1484 if (instr->CheckFlag(HValue::kLeftCanBeNegative) &&
1485 instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
1492 LInstruction* LChunkBuilder::DoModByConstI(HMod* instr) {
1493 DCHECK(instr->representation().IsSmiOrInteger32());
1494 DCHECK(instr->left()->representation().Equals(instr->representation()));
1495 DCHECK(instr->right()->representation().Equals(instr->representation()));
1496 LOperand* dividend = UseRegister(instr->left());
1497 int32_t divisor = instr->right()->GetInteger32Constant();
1502 if (divisor == 0 || instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
1509 LInstruction* LChunkBuilder::DoModI(HMod* instr) {
1510 DCHECK(instr->representation().IsSmiOrInteger32());
1511 DCHECK(instr->left()->representation().Equals(instr->representation()));
1512 DCHECK(instr->right()->representation().Equals(instr->representation()));
1513 LOperand* dividend = UseFixed(instr->left(), eax);
1514 LOperand* divisor = UseRegister(instr->right());
1518 if (instr->CheckFlag(HValue::kCanBeDivByZero) ||
1519 instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
1526 LInstruction* LChunkBuilder::DoMod(HMod* instr) {
1527 if (instr->representation().IsSmiOrInteger32()) {
1528 if (instr->RightIsPowerOf2()) {
1529 return DoModByPowerOf2I(instr);
1530 } else if (instr->right()->IsConstant()) {
1531 return DoModByConstI(instr);
1533 return DoModI(instr);
1535 } else if (instr->representation().IsDouble()) {
1536 return DoArithmeticD(Token::MOD, instr);
1538 return DoArithmeticT(Token::MOD, instr);
1543 LInstruction* LChunkBuilder::DoMul(HMul* instr) {
1544 if (instr->representation().IsSmiOrInteger32()) {
1545 DCHECK(instr->left()->representation().Equals(instr->representation()));
1546 DCHECK(instr->right()->representation().Equals(instr->representation()));
1547 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand());
1548 LOperand* right = UseOrConstant(instr->BetterRightOperand());
1550 if (instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
1554 if (instr->CheckFlag(HValue::kCanOverflow) ||
1555 instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
1559 } else if (instr->representation().IsDouble()) {
1560 return DoArithmeticD(Token::MUL, instr);
1562 return DoArithmeticT(Token::MUL, instr);
1567 LInstruction* LChunkBuilder::DoSub(HSub* instr) {
1568 if (instr->representation().IsSmiOrInteger32()) {
1569 DCHECK(instr->left()->representation().Equals(instr->representation()));
1570 DCHECK(instr->right()->representation().Equals(instr->representation()));
1571 LOperand* left = UseRegisterAtStart(instr->left());
1572 LOperand* right = UseOrConstantAtStart(instr->right());
1575 if (instr->CheckFlag(HValue::kCanOverflow)) {
1579 } else if (instr->representation().IsDouble()) {
1580 return DoArithmeticD(Token::SUB, instr);
1582 return DoArithmeticT(Token::SUB, instr);
1587 LInstruction* LChunkBuilder::DoAdd(HAdd* instr) {
1588 if (instr->representation().IsSmiOrInteger32()) {
1589 DCHECK(instr->left()->representation().Equals(instr->representation()));
1590 DCHECK(instr->right()->representation().Equals(instr->representation()));
1595 bool use_lea = LAddI::UseLea(instr);
1596 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand());
1597 HValue* right_candidate = instr->BetterRightOperand();
1602 bool can_overflow = instr->CheckFlag(HValue::kCanOverflow);
1610 } else if (instr->representation().IsDouble()) {
1611 return DoArithmeticD(Token::ADD, instr);
1612 } else if (instr->representation().IsExternal()) {
1613 DCHECK(instr->left()->representation().IsExternal());
1614 DCHECK(instr->right()->representation().IsInteger32());
1615 DCHECK(!instr->CheckFlag(HValue::kCanOverflow));
1616 bool use_lea = LAddI::UseLea(instr);
1617 LOperand* left = UseRegisterAtStart(instr->left());
1618 HValue* right_candidate = instr->right();
1628 return DoArithmeticT(Token::ADD, instr);
1633 LInstruction* LChunkBuilder::DoMathMinMax(HMathMinMax* instr) {
1638 if (instr->representation().IsSmiOrInteger32()) {
1639 DCHECK(instr->left()->representation().Equals(instr->representation()));
1640 DCHECK(instr->right()->representation().Equals(instr->representation()));
1641 left = UseRegisterAtStart(instr->BetterLeftOperand());
1642 right = UseOrConstantAtStart(instr->BetterRightOperand());
1644 DCHECK(instr->representation().IsDouble());
1645 DCHECK(instr->left()->representation().IsDouble());
1646 DCHECK(instr->right()->representation().IsDouble());
1647 left = UseRegisterAtStart(instr->left());
1648 right = UseRegisterAtStart(instr->right());
1655 LInstruction* LChunkBuilder::DoPower(HPower* instr) {
1657 DCHECK(instr->representation().IsDouble());
1658 DCHECK(instr->left()->representation().IsDouble());
1659 LOperand* left = UseRegisterAtStart(instr->left());
1660 LOperand* right = UseRegisterAtStart(instr->right());
1662 return MarkAsCall(DefineSameAsFirst(result), instr);
1666 LInstruction* LChunkBuilder::DoCompareGeneric(HCompareGeneric* instr) {
1667 DCHECK(instr->left()->representation().IsSmiOrTagged());
1668 DCHECK(instr->right()->representation().IsSmiOrTagged());
1669 LOperand* context = UseFixed(instr->context(), esi);
1670 LOperand* left = UseFixed(instr->left(), edx);
1671 LOperand* right = UseFixed(instr->right(), eax);
1673 return MarkAsCall(DefineFixed(result, eax), instr);
1678 HCompareNumericAndBranch* instr) {
1679 Representation r = instr->representation();
1681 DCHECK(instr->left()->representation().Equals(r));
1682 DCHECK(instr->right()->representation().Equals(r));
1683 LOperand* left = UseRegisterOrConstantAtStart(instr->left());
1684 LOperand* right = UseOrConstantAtStart(instr->right());
1688 DCHECK(instr->left()->representation().IsDouble());
1689 DCHECK(instr->right()->representation().IsDouble());
1692 if (CanBeImmediateConstant(instr->left()) &&
1693 CanBeImmediateConstant(instr->right())) {
1696 left = UseConstant(instr->left());
1697 right = UseConstant(instr->right());
1699 left = UseRegisterAtStart(instr->left());
1700 right = UseRegisterAtStart(instr->right());
1708 HCompareObjectEqAndBranch* instr) {
1709 LOperand* left = UseRegisterAtStart(instr->left());
1710 LOperand* right = UseOrConstantAtStart(instr->right());
1716 HCompareHoleAndBranch* instr) {
1717 LOperand* value = UseRegisterAtStart(instr->value());
1723 HCompareMinusZeroAndBranch* instr) {
1724 LOperand* value = UseRegisterAtStart(instr->value());
1729 LInstruction* LChunkBuilder::DoIsObjectAndBranch(HIsObjectAndBranch* instr) {
1730 DCHECK(instr->value()->representation().IsSmiOrTagged());
1732 return new(zone()) LIsObjectAndBranch(UseRegister(instr->value()), temp);
1736 LInstruction* LChunkBuilder::DoIsStringAndBranch(HIsStringAndBranch* instr) {
1737 DCHECK(instr->value()->representation().IsTagged());
1739 return new(zone()) LIsStringAndBranch(UseRegister(instr->value()), temp);
1743 LInstruction* LChunkBuilder::DoIsSmiAndBranch(HIsSmiAndBranch* instr) {
1744 DCHECK(instr->value()->representation().IsTagged());
1745 return new(zone()) LIsSmiAndBranch(Use(instr->value()));
1750 HIsUndetectableAndBranch* instr) {
1751 DCHECK(instr->value()->representation().IsTagged());
1753 UseRegisterAtStart(instr->value()), TempRegister());
1758 HStringCompareAndBranch* instr) {
1759 DCHECK(instr->left()->representation().IsTagged());
1760 DCHECK(instr->right()->representation().IsTagged());
1761 LOperand* context = UseFixed(instr->context(), esi);
1762 LOperand* left = UseFixed(instr->left(), edx);
1763 LOperand* right = UseFixed(instr->right(), eax);
1768 return MarkAsCall(result, instr);
1773 HHasInstanceTypeAndBranch* instr) {
1774 DCHECK(instr->value()->representation().IsTagged());
1776 UseRegisterAtStart(instr->value()),
1782 HGetCachedArrayIndex* instr) {
1783 DCHECK(instr->value()->representation().IsTagged());
1784 LOperand* value = UseRegisterAtStart(instr->value());
1791 HHasCachedArrayIndexAndBranch* instr) {
1792 DCHECK(instr->value()->representation().IsTagged());
1794 UseRegisterAtStart(instr->value()));
1799 HClassOfTestAndBranch* instr) {
1800 DCHECK(instr->value()->representation().IsTagged());
1801 return new(zone()) LClassOfTestAndBranch(UseRegister(instr->value()),
1807 LInstruction* LChunkBuilder::DoMapEnumLength(HMapEnumLength* instr) {
1808 LOperand* map = UseRegisterAtStart(instr->value());
1813 LInstruction* LChunkBuilder::DoDateField(HDateField* instr) {
1814 LOperand* date = UseFixed(instr->value(), eax);
1816 new(zone()) LDateField(date, FixedTemp(ecx), instr->index());
1817 return MarkAsCall(DefineFixed(result, eax), instr, CAN_DEOPTIMIZE_EAGERLY);
1821 LInstruction* LChunkBuilder::DoSeqStringGetChar(HSeqStringGetChar* instr) {
1822 LOperand* string = UseRegisterAtStart(instr->string());
1823 LOperand* index = UseRegisterOrConstantAtStart(instr->index());
1828 LOperand* LChunkBuilder::GetSeqStringSetCharOperand(HSeqStringSetChar* instr) {
1829 if (instr->encoding() == String::ONE_BYTE_ENCODING) {
1831 return UseFixed(instr->value(), eax);
1833 return UseFixedOrConstant(instr->value(), eax);
1837 return UseRegisterAtStart(instr->value());
1839 return UseRegisterOrConstantAtStart(instr->value());
1845 LInstruction* LChunkBuilder::DoSeqStringSetChar(HSeqStringSetChar* instr) {
1846 LOperand* string = UseRegisterAtStart(instr->string());
1848 ? UseRegisterAtStart(instr->index())
1849 : UseRegisterOrConstantAtStart(instr->index());
1850 LOperand* value = GetSeqStringSetCharOperand(instr);
1851 LOperand* context = FLAG_debug_code ? UseFixed(instr->context(), esi) : NULL;
1855 result = MarkAsCall(result, instr);
1861 LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) {
1862 if (!FLAG_debug_code && instr->skip_check()) return NULL;
1863 LOperand* index = UseRegisterOrConstantAtStart(instr->index());
1865 ? UseOrConstantAtStart(instr->length())
1866 : UseAtStart(instr->length());
1868 if (!FLAG_debug_code || !instr->skip_check()) {
1876 HBoundsCheckBaseIndexInformation* instr) {
1882 LInstruction* LChunkBuilder::DoAbnormalExit(HAbnormalExit* instr) {
1889 LInstruction* LChunkBuilder::DoUseConst(HUseConst* instr) {
1902 LInstruction* LChunkBuilder::DoChange(HChange* instr) {
1903 Representation from = instr->from();
1904 Representation to = instr->to();
1905 HValue* val = instr->value();
1953 bool truncating = instr->CanTruncateToInt32();
1962 if (!instr->CheckFlag(HValue::kCanOverflow)) {
1979 if (instr->CheckFlag(HValue::kCanOverflow)) {
1997 LInstruction* LChunkBuilder::DoCheckHeapObject(HCheckHeapObject* instr) {
1998 LOperand* value = UseAtStart(instr->value());
2000 if (!instr->value()->type().IsHeapObject()) {
2007 LInstruction* LChunkBuilder::DoCheckSmi(HCheckSmi* instr) {
2008 LOperand* value = UseRegisterAtStart(instr->value());
2013 LInstruction* LChunkBuilder::DoCheckInstanceType(HCheckInstanceType* instr) {
2014 LOperand* value = UseRegisterAtStart(instr->value());
2021 LInstruction* LChunkBuilder::DoCheckValue(HCheckValue* instr) {
2026 LOperand* value = instr->object_in_new_space()
2027 ? UseRegisterAtStart(instr->value()) : UseAtStart(instr->value());
2032 LInstruction* LChunkBuilder::DoCheckMaps(HCheckMaps* instr) {
2033 if (instr->IsStabilityCheck()) return new(zone()) LCheckMaps;
2034 LOperand* value = UseRegisterAtStart(instr->value());
2036 if (instr->HasMigrationTarget()) {
2044 LInstruction* LChunkBuilder::DoClampToUint8(HClampToUint8* instr) {
2045 HValue* value = instr->value();
2055 LOperand* value = UseRegister(instr->value());
2064 LInstruction* LChunkBuilder::DoDoubleBits(HDoubleBits* instr) {
2065 HValue* value = instr->value();
2071 LInstruction* LChunkBuilder::DoConstructDouble(HConstructDouble* instr) {
2072 LOperand* lo = UseRegister(instr->lo());
2073 LOperand* hi = UseRegister(instr->hi());
2078 LInstruction* LChunkBuilder::DoReturn(HReturn* instr) {
2079 LOperand* context = info()->IsStub() ? UseFixed(instr->context(), esi) : NULL;
2080 LOperand* parameter_count = UseRegisterOrConstant(instr->parameter_count());
2082 UseFixed(instr->value(), eax), context, parameter_count);
2086 LInstruction* LChunkBuilder::DoConstant(HConstant* instr) {
2087 Representation r = instr->representation();
2105 LInstruction* LChunkBuilder::DoLoadGlobalCell(HLoadGlobalCell* instr) {
2107 return instr->RequiresHoleCheck()
2113 LInstruction* LChunkBuilder::DoLoadGlobalGeneric(HLoadGlobalGeneric* instr) {
2114 LOperand* context = UseFixed(instr->context(), esi);
2116 UseFixed(instr->global_object(), LoadDescriptor::ReceiverRegister());
2124 return MarkAsCall(DefineFixed(result, eax), instr);
2128 LInstruction* LChunkBuilder::DoStoreGlobalCell(HStoreGlobalCell* instr) {
2130 new(zone()) LStoreGlobalCell(UseRegister(instr->value()));
2131 return instr->RequiresHoleCheck() ? AssignEnvironment(result) : result;
2135 LInstruction* LChunkBuilder::DoLoadContextSlot(HLoadContextSlot* instr) {
2136 LOperand* context = UseRegisterAtStart(instr->value());
2139 if (instr->RequiresHoleCheck() && instr->DeoptimizesOnHole()) {
2146 LInstruction* LChunkBuilder::DoStoreContextSlot(HStoreContextSlot* instr) {
2149 LOperand* context = UseRegister(instr->context());
2150 if (instr->NeedsWriteBarrier()) {
2151 value = UseTempRegister(instr->value());
2154 value = UseRegister(instr->value());
2158 if (instr->RequiresHoleCheck() && instr->DeoptimizesOnHole()) {
2165 LInstruction* LChunkBuilder::DoLoadNamedField(HLoadNamedField* instr) {
2166 LOperand* obj = (instr->access().IsExternalMemory() &&
2167 instr->access().offset() == 0)
2168 ? UseRegisterOrConstantAtStart(instr->object())
2169 : UseRegisterAtStart(instr->object());
2174 LInstruction* LChunkBuilder::DoLoadNamedGeneric(HLoadNamedGeneric* instr) {
2175 LOperand* context = UseFixed(instr->context(), esi);
2177 UseFixed(instr->object(), LoadDescriptor::ReceiverRegister());
2184 return MarkAsCall(DefineFixed(result, eax), instr);
2189 HLoadFunctionPrototype* instr) {
2191 new(zone()) LLoadFunctionPrototype(UseRegister(instr->function()),
2196 LInstruction* LChunkBuilder::DoLoadRoot(HLoadRoot* instr) {
2201 LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) {
2202 DCHECK(instr->key()->representation().IsSmiOrInteger32());
2203 ElementsKind elements_kind = instr->elements_kind();
2205 instr->key()->representation(), elements_kind);
2207 ? UseTempRegister(instr->key())
2208 : UseRegisterOrConstantAtStart(instr->key());
2211 if (!instr->is_typed_elements()) {
2212 LOperand* obj = UseRegisterAtStart(instr->elements());
2216 (instr->representation().IsInteger32() &&
2217 !(IsDoubleOrFloatElementsKind(instr->elements_kind()))) ||
2218 (instr->representation().IsDouble() &&
2219 (IsDoubleOrFloatElementsKind(instr->elements_kind()))));
2220 LOperand* backing_store = UseRegister(instr->elements());
2224 if ((instr->is_external() || instr->is_fixed_typed_array()) ?
2226 ((instr->elements_kind() == EXTERNAL_UINT32_ELEMENTS ||
2227 instr->elements_kind() == UINT32_ELEMENTS) &&
2228 !instr->CheckFlag(HInstruction::kUint32)) :
2231 instr->RequiresHoleCheck()) {
2238 LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) {
2239 LOperand* context = UseFixed(instr->context(), esi);
2241 UseFixed(instr->object(), LoadDescriptor::ReceiverRegister());
2242 LOperand* key = UseFixed(instr->key(), LoadDescriptor::NameRegister());
2249 return MarkAsCall(DefineFixed(result, eax), instr);
2253 LOperand* LChunkBuilder::GetStoreKeyedValueOperand(HStoreKeyed* instr) {
2254 ElementsKind elements_kind = instr->elements_kind();
2265 return UseFixed(instr->value(), eax);
2269 return UseRegisterAtStart(instr->value());
2272 return UseRegister(instr->value());
2276 LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) {
2277 if (!instr->is_typed_elements()) {
2278 DCHECK(instr->elements()->representation().IsTagged());
2279 DCHECK(instr->key()->representation().IsInteger32() ||
2280 instr->key()->representation().IsSmi());
2282 if (instr->value()->representation().IsDouble()) {
2283 LOperand* object = UseRegisterAtStart(instr->elements());
2285 LOperand* val = instr->IsConstantHoleStore()
2287 : UseRegisterAtStart(instr->value());
2288 LOperand* key = UseRegisterOrConstantAtStart(instr->key());
2291 DCHECK(instr->value()->representation().IsSmiOrTagged());
2292 bool needs_write_barrier = instr->NeedsWriteBarrier();
2294 LOperand* obj = UseRegister(instr->elements());
2298 val = UseTempRegister(instr->value());
2299 key = UseTempRegister(instr->key());
2301 val = UseRegisterOrConstantAtStart(instr->value());
2302 key = UseRegisterOrConstantAtStart(instr->key());
2308 ElementsKind elements_kind = instr->elements_kind();
2310 (instr->value()->representation().IsInteger32() &&
2312 (instr->value()->representation().IsDouble() &&
2314 DCHECK((instr->is_fixed_typed_array() &&
2315 instr->elements()->representation().IsTagged()) ||
2316 (instr->is_external() &&
2317 instr->elements()->representation().IsExternal()));
2319 LOperand* backing_store = UseRegister(instr->elements());
2320 LOperand* val = GetStoreKeyedValueOperand(instr);
2322 instr->key()->representation(), elements_kind);
2324 ? UseTempRegister(instr->key())
2325 : UseRegisterOrConstantAtStart(instr->key());
2330 LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) {
2331 LOperand* context = UseFixed(instr->context(), esi);
2333 UseFixed(instr->object(), StoreDescriptor::ReceiverRegister());
2334 LOperand* key = UseFixed(instr->key(), StoreDescriptor::NameRegister());
2335 LOperand* value = UseFixed(instr->value(), StoreDescriptor::ValueRegister());
2337 DCHECK(instr->object()->representation().IsTagged());
2338 DCHECK(instr->key()->representation().IsTagged());
2339 DCHECK(instr->value()->representation().IsTagged());
2343 return MarkAsCall(result, instr);
2348 HTransitionElementsKind* instr) {
2349 if (IsSimpleMapChangeTransition(instr->from_kind(), instr->to_kind())) {
2350 LOperand* object = UseRegister(instr->object());
2358 LOperand* object = UseFixed(instr->object(), eax);
2359 LOperand* context = UseFixed(instr->context(), esi);
2362 return MarkAsCall(result, instr);
2368 HTrapAllocationMemento* instr) {
2369 LOperand* object = UseRegister(instr->object());
2377 LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) {
2378 bool is_in_object = instr->access().IsInobject();
2379 bool is_external_location = instr->access().IsExternalMemory() &&
2380 instr->access().offset() == 0;
2381 bool needs_write_barrier = instr->NeedsWriteBarrier();
2382 bool needs_write_barrier_for_map = instr->has_transition() &&
2383 instr->NeedsWriteBarrierForMap();
2388 ? UseRegister(instr->object())
2389 : UseTempRegister(instr->object());
2394 obj = UseRegisterOrConstant(instr->object());
2397 ? UseRegister(instr->object())
2398 : UseRegisterAtStart(instr->object());
2401 bool can_be_constant = instr->value()->IsConstant() &&
2402 HConstant::cast(instr->value())->NotInNewSpace() &&
2403 !instr->field_representation().IsDouble();
2406 if (instr->field_representation().IsInteger8() ||
2407 instr->field_representation().IsUInteger8()) {
2410 val = UseFixed(instr->value(), eax);
2412 val = UseTempRegister(instr->value());
2414 val = UseRegisterOrConstant(instr->value());
2415 } else if (instr->field_representation().IsDouble()) {
2416 val = UseRegisterAtStart(instr->value());
2418 val = UseRegister(instr->value());
2433 LInstruction* LChunkBuilder::DoStoreNamedGeneric(HStoreNamedGeneric* instr) {
2434 LOperand* context = UseFixed(instr->context(), esi);
2436 UseFixed(instr->object(), StoreDescriptor::ReceiverRegister());
2437 LOperand* value = UseFixed(instr->value(), StoreDescriptor::ValueRegister());
2441 return MarkAsCall(result, instr);
2445 LInstruction* LChunkBuilder::DoStringAdd(HStringAdd* instr) {
2446 LOperand* context = UseFixed(instr->context(), esi);
2447 LOperand* left = UseFixed(instr->left(), edx);
2448 LOperand* right = UseFixed(instr->right(), eax);
2450 return MarkAsCall(DefineFixed(string_add, eax), instr);
2454 LInstruction* LChunkBuilder::DoStringCharCodeAt(HStringCharCodeAt* instr) {
2455 LOperand* string = UseTempRegister(instr->string());
2456 LOperand* index = UseTempRegister(instr->index());
2457 LOperand* context = UseAny(instr->context());
2464 LInstruction* LChunkBuilder::DoStringCharFromCode(HStringCharFromCode* instr) {
2465 LOperand* char_code = UseRegister(instr->value());
2466 LOperand* context = UseAny(instr->context());
2473 LInstruction* LChunkBuilder::DoAllocate(HAllocate* instr) {
2475 LOperand* context = UseAny(instr->context());
2476 LOperand* size = instr->size()->IsConstant()
2477 ? UseConstant(instr->size())
2478 : UseTempRegister(instr->size());
2485 LInstruction* LChunkBuilder::DoRegExpLiteral(HRegExpLiteral* instr) {
2486 LOperand* context = UseFixed(instr->context(), esi);
2488 DefineFixed(new(zone()) LRegExpLiteral(context), eax), instr);
2492 LInstruction* LChunkBuilder::DoFunctionLiteral(HFunctionLiteral* instr) {
2493 LOperand* context = UseFixed(instr->context(), esi);
2495 DefineFixed(new(zone()) LFunctionLiteral(context), eax), instr);
2499 LInstruction* LChunkBuilder::DoOsrEntry(HOsrEntry* instr) {
2502 current_block_->last_environment()->set_ast_id(instr->ast_id());
2507 LInstruction* LChunkBuilder::DoParameter(HParameter* instr) {
2509 if (instr->kind() == HParameter::STACK_PARAMETER) {
2510 int spill_index = chunk()->GetParameterStackSlot(instr->index());
2516 int index = static_cast<int>(instr->index());
2523 LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) {
2526 int env_index = instr->index();
2528 if (instr->environment()->is_parameter_index(env_index)) {
2531 spill_index = env_index - instr->environment()->first_local_index();
2546 LInstruction* LChunkBuilder::DoCallStub(HCallStub* instr) {
2547 LOperand* context = UseFixed(instr->context(), esi);
2549 return MarkAsCall(DefineFixed(result, eax), instr);
2553 LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) {
2562 LInstruction* LChunkBuilder::DoCapturedObject(HCapturedObject* instr) {
2563 instr->ReplayEnvironment(current_block_->last_environment());
2570 LInstruction* LChunkBuilder::DoAccessArgumentsAt(HAccessArgumentsAt* instr) {
2572 LOperand* args = UseRegister(instr->arguments());
2575 if (instr->length()->IsConstant() && instr->index()->IsConstant()) {
2576 length = UseRegisterOrConstant(instr->length());
2577 index = UseOrConstant(instr->index());
2579 length = UseTempRegister(instr->length());
2580 index = Use(instr->index());
2586 LInstruction* LChunkBuilder::DoToFastProperties(HToFastProperties* instr) {
2587 LOperand* object = UseFixed(instr->value(), eax);
2589 return MarkAsCall(DefineFixed(result, eax), instr);
2593 LInstruction* LChunkBuilder::DoTypeof(HTypeof* instr) {
2594 LOperand* context = UseFixed(instr->context(), esi);
2595 LOperand* value = UseAtStart(instr->value());
2597 return MarkAsCall(DefineFixed(result, eax), instr);
2601 LInstruction* LChunkBuilder::DoTypeofIsAndBranch(HTypeofIsAndBranch* instr) {
2602 return new(zone()) LTypeofIsAndBranch(UseTempRegister(instr->value()));
2607 HIsConstructCallAndBranch* instr) {
2612 LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) {
2613 instr->ReplayEnvironment(current_block_->last_environment());
2618 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) {
2620 if (instr->is_function_entry()) {
2621 LOperand* context = UseFixed(instr->context(), esi);
2622 return MarkAsCall(new(zone()) LStackCheck(context), instr);
2624 DCHECK(instr->is_backwards_branch());
2625 LOperand* context = UseAny(instr->context());
2632 LInstruction* LChunkBuilder::DoEnterInlined(HEnterInlined* instr) {
2634 outer->set_ast_id(instr->ReturnId());
2636 HEnvironment* inner = outer->CopyForInlining(instr->closure(),
2637 instr->arguments_count(),
2638 instr->function(),
2640 instr->inlining_kind());
2642 if (instr->arguments_var() != NULL && instr->arguments_object()->IsLinked()) {
2643 inner->Bind(instr->arguments_var(), instr->arguments_object());
2645 inner->BindContext(instr->closure_context());
2646 inner->set_entry(instr);
2648 chunk_->AddInlinedClosure(instr->closure());
2653 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) {
2661 DCHECK(instr->argument_delta() == -argument_count);
2671 LInstruction* LChunkBuilder::DoForInPrepareMap(HForInPrepareMap* instr) {
2672 LOperand* context = UseFixed(instr->context(), esi);
2673 LOperand* object = UseFixed(instr->enumerable(), eax);
2675 return MarkAsCall(DefineFixed(result, eax), instr, CAN_DEOPTIMIZE_EAGERLY);
2679 LInstruction* LChunkBuilder::DoForInCacheArray(HForInCacheArray* instr) {
2680 LOperand* map = UseRegister(instr->map());
2686 LInstruction* LChunkBuilder::DoCheckMapValue(HCheckMapValue* instr) {
2687 LOperand* value = UseRegisterAtStart(instr->value());
2688 LOperand* map = UseRegisterAtStart(instr->map());
2693 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) {
2694 LOperand* object = UseRegister(instr->object());
2695 LOperand* index = UseTempRegister(instr->index());
2702 LInstruction* LChunkBuilder::DoStoreFrameContext(HStoreFrameContext* instr) {
2703 LOperand* context = UseRegisterAtStart(instr->context());
2709 HAllocateBlockContext* instr) {
2710 LOperand* context = UseFixed(instr->context(), esi);
2711 LOperand* function = UseRegisterAtStart(instr->function());
2714 return MarkAsCall(DefineFixed(result, esi), instr);