Home | History | Annotate | Download | only in arm

Lines Matching refs:instr

518     HInstruction* instr = HInstruction::cast(value);
519 VisitInstruction(instr);
526 LInstruction* LChunkBuilder::Define(LTemplateResultInstruction<1>* instr,
529 instr->set_result(result);
530 return instr;
535 LTemplateResultInstruction<1>* instr) {
536 return Define(instr,
542 LTemplateResultInstruction<1>* instr, int index) {
543 return Define(instr,
549 LTemplateResultInstruction<1>* instr) {
550 return Define(instr,
556 LTemplateResultInstruction<1>* instr, Register reg) {
557 return Define(instr, ToUnallocated(reg));
562 LTemplateResultInstruction<1>* instr, DoubleRegister reg) {
563 return Define(instr, ToUnallocated(reg));
567 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) {
571 instr->set_environment(CreateEnvironment(hydrogen_env,
574 return instr;
578 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr,
583 instr->VerifyCall();
585 instr->MarkAsCall();
586 instr = AssignPointerMap(instr);
595 if (needs_environment && !instr->HasEnvironment()) {
596 instr = AssignEnvironment(instr);
598 instr->environment()->set_has_been_used();
601 return instr;
605 LInstruction* LChunkBuilder::AssignPointerMap(LInstruction* instr) {
606 DCHECK(!instr->HasPointerMap());
607 instr->set_pointer_map(new(zone()) LPointerMap(zone()));
608 return instr;
652 LInstruction* LChunkBuilder::DoBlockEntry(HBlockEntry* instr) {
653 return new(zone()) LLabel(instr->block());
657 LInstruction* LChunkBuilder::DoDummyUse(HDummyUse* instr) {
658 return DefineAsRegister(new(zone()) LDummyUse(UseAny(instr->value())));
662 LInstruction* LChunkBuilder::DoEnvironmentMarker(HEnvironmentMarker* instr) {
668 LInstruction* LChunkBuilder::DoDeoptimize(HDeoptimize* instr) {
674 HBitwiseBinaryOperation* instr) {
675 if (instr->representation().IsSmiOrInteger32()) {
676 DCHECK(instr->left()->representation().Equals(instr->representation()));
677 DCHECK(instr->right()->representation().Equals(instr->representation()));
678 LOperand* left = UseRegisterAtStart(instr->left());
680 HValue* right_value = instr->right();
690 if (instr->representation().IsSmi() && constant_value > 0) {
691 does_deopt = !instr->CheckUsesForFlag(HValue::kTruncatingToSmi);
701 does_deopt = !instr->CheckFlag(HInstruction::kUint32);
703 does_deopt = !instr->CheckUsesForFlag(HValue::kTruncatingToInt32);
711 return DoArithmeticT(op, instr);
717 HArithmeticBinaryOperation* instr) {
718 DCHECK(instr->representation().IsDouble());
719 DCHECK(instr->left()->representation().IsDouble());
720 DCHECK(instr->right()->representation().IsDouble());
722 LOperand* left = UseFixedDouble(instr->left(), d0);
723 LOperand* right = UseFixedDouble(instr->right(), d1);
725 return MarkAsCall(DefineFixedDouble(result, d0), instr);
727 LOperand* left = UseRegisterAtStart(instr->left());
728 LOperand* right = UseRegisterAtStart(instr->right());
736 HBinaryOperation* instr) {
737 HValue* left = instr->left();
738 HValue* right = instr->right();
741 LOperand* context = UseFixed(instr->context(), cp);
746 return MarkAsCall(DefineFixed(result, r0), instr);
821 LInstruction* instr = NULL;
824 instr = DefineAsRegister(new(zone()) LDummy());
827 instr = DefineAsRegister(new(zone())
842 instr = new(zone()) LGoto(successor);
844 instr = current->CompileToLithium(this);
851 if (instr != NULL) {
852 AddInstruction(instr, current);
859 void LChunkBuilder::AddInstruction(LInstruction* instr,
863 instr->set_hydrogen_value(hydrogen_val);
876 if (!(instr->ClobbersRegisters() &&
877 instr->ClobbersDoubleRegisters(isolate()))) {
880 for (UseIterator it(instr); !it.Done(); it.Advance()) {
884 if (instr->Output() != NULL) {
885 if (LUnallocated::cast(instr->Output())->HasFixedPolicy()) ++fixed;
887 for (TempIterator it(instr); !it.Done(); it.Advance()) {
895 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) {
896 instr = AssignPointerMap(instr);
898 if (FLAG_stress_environments && !instr->HasEnvironment()) {
899 instr = AssignEnvironment(instr);
901 chunk_->AddInstruction(instr, current_block_);
903 if (instr->IsCall()) {
908 instruction_needing_environment = instr;
925 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) {
926 return new(zone()) LGoto(instr->FirstSuccessor());
930 LInstruction* LChunkBuilder::DoBranch(HBranch* instr) {
931 HValue* value = instr->value();
934 ToBooleanStub::Types expected = instr->expected_input_types();
949 LInstruction* LChunkBuilder::DoDebugBreak(HDebugBreak* instr) {
954 LInstruction* LChunkBuilder::DoCompareMap(HCompareMap* instr) {
955 DCHECK(instr->value()->representation().IsTagged());
956 LOperand* value = UseRegisterAtStart(instr->value());
962 LInstruction* LChunkBuilder::DoArgumentsLength(HArgumentsLength* instr) {
964 LOperand* value = UseRegister(instr->value());
975 LInstruction* LChunkBuilder::DoInstanceOf(HInstanceOf* instr) {
976 LOperand* context = UseFixed(instr->context(), cp);
978 new(zone()) LInstanceOf(context, UseFixed(instr->left(), r0),
979 UseFixed(instr->right(), r1));
980 return MarkAsCall(DefineFixed(result, r0), instr);
985 HInstanceOfKnownGlobal* instr) {
988 UseFixed(instr->context(), cp),
989 UseFixed(instr->left(), r0),
991 return MarkAsCall(DefineFixed(result, r0), instr);
995 LInstruction* LChunkBuilder::DoWrapReceiver(HWrapReceiver* instr) {
996 LOperand* receiver = UseRegisterAtStart(instr->receiver());
997 LOperand* function = UseRegisterAtStart(instr->function());
1003 LInstruction* LChunkBuilder::DoApplyArguments(HApplyArguments* instr) {
1004 LOperand* function = UseFixed(instr->function(), r1);
1005 LOperand* receiver = UseFixed(instr->receiver(), r0);
1006 LOperand* length = UseFixed(instr->length(), r2);
1007 LOperand* elements = UseFixed(instr->elements(), r3);
1012 return MarkAsCall(DefineFixed(result, r0), instr, CAN_DEOPTIMIZE_EAGERLY);
1016 LInstruction* LChunkBuilder::DoPushArguments(HPushArguments* instr) {
1017 int argc = instr->OperandCount();
1019 LOperand* argument = Use(instr->argument(i));
1020 AddInstruction(new(zone()) LPushArgument(argument), instr);
1035 HInnerAllocatedObject* instr) {
1036 LOperand* base_object = UseRegisterAtStart(instr->base_object());
1037 LOperand* offset = UseRegisterOrConstantAtStart(instr->offset());
1043 LInstruction* LChunkBuilder::DoThisFunction(HThisFunction* instr) {
1044 return instr->HasNoUses()
1050 LInstruction* LChunkBuilder::DoContext(HContext* instr) {
1051 if (instr->HasNoUses()) return NULL;
1061 LInstruction* LChunkBuilder::DoDeclareGlobals(HDeclareGlobals* instr) {
1062 LOperand* context = UseFixed(instr->context(), cp);
1063 return MarkAsCall(new(zone()) LDeclareGlobals(context), instr);
1068 HCallJSFunction* instr) {
1069 LOperand* function = UseFixed(instr->function(), r1);
1073 return MarkAsCall(DefineFixed(result, r0), instr);
1078 HCallWithDescriptor* instr) {
1079 CallInterfaceDescriptor descriptor = instr->descriptor();
1081 LOperand* target = UseRegisterOrConstantAtStart(instr->target());
1082 ZoneList<LOperand*> ops(instr->OperandCount(), zone());
1084 for (int i = 1; i < instr->OperandCount(); i++) {
1086 UseFixed(instr->OperandAt(i), descriptor.GetParameterRegister(i - 1));
1092 return MarkAsCall(DefineFixed(result, r0), instr);
1097 HTailCallThroughMegamorphicCache* instr) {
1098 LOperand* context = UseFixed(instr->context(), cp);
1100 UseFixed(instr->receiver(), LoadDescriptor::ReceiverRegister());
1102 UseFixed(instr->name(), LoadDescriptor::NameRegister());
1109 LInstruction* LChunkBuilder::DoInvokeFunction(HInvokeFunction* instr) {
1110 LOperand* context = UseFixed(instr->context(), cp);
1111 LOperand* function = UseFixed(instr->function(), r1);
1113 return MarkAsCall(DefineFixed(result, r0), instr, CANNOT_DEOPTIMIZE_EAGERLY);
1117 LInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) {
1118 switch (instr->op()) {
1120 return DoMathFloor(instr);
1122 return DoMathRound(instr);
1124 return DoMathFround(instr);
1126 return DoMathAbs(instr);
1128 return DoMathLog(instr);
1130 return DoMathExp(instr);
1132 return DoMathSqrt(instr);
1134 return DoMathPowHalf(instr);
1136 return DoMathClz32(instr);
1144 LInstruction* LChunkBuilder::DoMathFloor(HUnaryMathOperation* instr) {
1145 LOperand* input = UseRegister(instr->value());
1151 LInstruction* LChunkBuilder::DoMathRound(HUnaryMathOperation* instr) {
1152 LOperand* input = UseRegister(instr->value());
1159 LInstruction* LChunkBuilder::DoMathFround(HUnaryMathOperation* instr) {
1160 LOperand* input = UseRegister(instr->value());
1166 LInstruction* LChunkBuilder::DoMathAbs(HUnaryMathOperation* instr) {
1167 Representation r = instr->value()->representation();
1170 : UseFixed(instr->context(), cp);
1171 LOperand* input = UseRegister(instr->value());
1180 LInstruction* LChunkBuilder::DoMathLog(HUnaryMathOperation* instr) {
1181 DCHECK(instr->representation().IsDouble());
1182 DCHECK(instr->value()->representation().IsDouble());
1183 LOperand* input = UseFixedDouble(instr->value(), d0);
1184 return MarkAsCall(DefineFixedDouble(new(zone()) LMathLog(input), d0), instr);
1188 LInstruction* LChunkBuilder::DoMathClz32(HUnaryMathOperation* instr) {
1189 LOperand* input = UseRegisterAtStart(instr->value());
1195 LInstruction* LChunkBuilder::DoMathExp(HUnaryMathOperation* instr) {
1196 DCHECK(instr->representation().IsDouble());
1197 DCHECK(instr->value()->representation().IsDouble());
1198 LOperand* input = UseRegister(instr->value());
1207 LInstruction* LChunkBuilder::DoMathSqrt(HUnaryMathOperation* instr) {
1208 LOperand* input = UseRegisterAtStart(instr->value());
1214 LInstruction* LChunkBuilder::DoMathPowHalf(HUnaryMathOperation* instr) {
1215 LOperand* input = UseRegisterAtStart(instr->value());
1221 LInstruction* LChunkBuilder::DoCallNew(HCallNew* instr) {
1222 LOperand* context = UseFixed(instr->context(), cp);
1223 LOperand* constructor = UseFixed(instr->constructor(), r1);
1225 return MarkAsCall(DefineFixed(result, r0), instr);
1229 LInstruction* LChunkBuilder::DoCallNewArray(HCallNewArray* instr) {
1230 LOperand* context = UseFixed(instr->context(), cp);
1231 LOperand* constructor = UseFixed(instr->constructor(), r1);
1233 return MarkAsCall(DefineFixed(result, r0), instr);
1237 LInstruction* LChunkBuilder::DoCallFunction(HCallFunction* instr) {
1238 LOperand* context = UseFixed(instr->context(), cp);
1239 LOperand* function = UseFixed(instr->function(), r1);
1241 return MarkAsCall(DefineFixed(call, r0), instr);
1245 LInstruction* LChunkBuilder::DoCallRuntime(HCallRuntime* instr) {
1246 LOperand* context = UseFixed(instr->context(), cp);
1247 return MarkAsCall(DefineFixed(new(zone()) LCallRuntime(context), r0), instr);
1251 LInstruction* LChunkBuilder::DoRor(HRor* instr) {
1252 return DoShift(Token::ROR, instr);
1256 LInstruction* LChunkBuilder::DoShr(HShr* instr) {
1257 return DoShift(Token::SHR, instr);
1261 LInstruction* LChunkBuilder::DoSar(HSar* instr) {
1262 return DoShift(Token::SAR, instr);
1266 LInstruction* LChunkBuilder::DoShl(HShl* instr) {
1267 return DoShift(Token::SHL, instr);
1271 LInstruction* LChunkBuilder::DoBitwise(HBitwise* instr) {
1272 if (instr->representation().IsSmiOrInteger32()) {
1273 DCHECK(instr->left()->representation().Equals(instr->representation()));
1274 DCHECK(instr->right()->representation().Equals(instr->representation()));
1275 DCHECK(instr->CheckFlag(HValue::kTruncatingToInt32));
1277 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand());
1278 LOperand* right = UseOrConstantAtStart(instr->BetterRightOperand());
1281 return DoArithmeticT(instr->op(), instr);
1286 LInstruction* LChunkBuilder::DoDivByPowerOf2I(HDiv* instr) {
1287 DCHECK(instr->representation().IsSmiOrInteger32());
1288 DCHECK(instr->left()->representation().Equals(instr->representation()));
1289 DCHECK(instr->right()->representation().Equals(instr->representation()));
1290 LOperand* dividend = UseRegister(instr->left());
1291 int32_t divisor = instr->right()->GetInteger32Constant();
1294 if ((instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) ||
1295 (instr->CheckFlag(HValue::kCanOverflow) && divisor == -1) ||
1296 (!instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32) &&
1304 LInstruction* LChunkBuilder::DoDivByConstI(HDiv* instr) {
1305 DCHECK(instr->representation().IsInteger32());
1306 DCHECK(instr->left()->representation().Equals(instr->representation()));
1307 DCHECK(instr->right()->representation().Equals(instr->representation()));
1308 LOperand* dividend = UseRegister(instr->left());
1309 int32_t divisor = instr->right()->GetInteger32Constant();
1313 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) ||
1314 !instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32)) {
1321 LInstruction* LChunkBuilder::DoDivI(HDiv* instr) {
1322 DCHECK(instr->representation().IsSmiOrInteger32());
1323 DCHECK(instr->left()->representation().Equals(instr->representation()));
1324 DCHECK(instr->right()->representation().Equals(instr->representation()));
1325 LOperand* dividend = UseRegister(instr->left());
1326 LOperand* divisor = UseRegister(instr->right());
1331 if (instr->CheckFlag(HValue::kCanBeDivByZero) ||
1332 instr->CheckFlag(HValue::kBailoutOnMinusZero) ||
1333 (instr->CheckFlag(HValue::kCanOverflow) &&
1335 !instr->CheckFlag(HValue::kAllUsesTruncatingToInt32))) ||
1336 (!instr->IsMathFloorOfDiv() &&
1337 !instr->CheckFlag(HValue::kAllUsesTruncatingToInt32))) {
1344 LInstruction* LChunkBuilder::DoDiv(HDiv* instr) {
1345 if (instr->representation().IsSmiOrInteger32()) {
1346 if (instr->RightIsPowerOf2()) {
1347 return DoDivByPowerOf2I(instr);
1348 } else if (instr->right()->IsConstant()) {
1349 return DoDivByConstI(instr);
1351 return DoDivI(instr);
1353 } else if (instr->representation().IsDouble()) {
1354 return DoArithmeticD(Token::DIV, instr);
1356 return DoArithmeticT(Token::DIV, instr);
1361 LInstruction* LChunkBuilder::DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr) {
1362 LOperand* dividend = UseRegisterAtStart(instr->left());
1363 int32_t divisor = instr->right()->GetInteger32Constant();
1366 if ((instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) ||
1367 (instr->CheckFlag(HValue::kLeftCanBeMinInt) && divisor == -1)) {
1374 LInstruction* LChunkBuilder::DoFlooringDivByConstI(HMathFloorOfDiv* instr) {
1375 DCHECK(instr->representation().IsInteger32());
1376 DCHECK(instr->left()->representation().Equals(instr->representation()));
1377 DCHECK(instr->right()->representation().Equals(instr->representation()));
1378 LOperand* dividend = UseRegister(instr->left());
1379 int32_t divisor = instr->right()->GetInteger32Constant();
1381 ((divisor > 0 && !instr->CheckFlag(HValue::kLeftCanBeNegative)) ||
1382 (divisor < 0 && !instr->CheckFlag(HValue::kLeftCanBePositive))) ?
1387 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0)) {
1394 LInstruction* LChunkBuilder::DoFlooringDivI(HMathFloorOfDiv* instr) {
1395 DCHECK(instr->representation().IsSmiOrInteger32());
1396 DCHECK(instr->left()->representation().Equals(instr->representation()));
1397 DCHECK(instr->right()->representation().Equals(instr->representation()));
1398 LOperand* dividend = UseRegister(instr->left());
1399 LOperand* divisor = UseRegister(instr->right());
1407 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) {
1408 if (instr->RightIsPowerOf2()) {
1409 return DoFlooringDivByPowerOf2I(instr);
1410 } else if (instr->right()->IsConstant()) {
1411 return DoFlooringDivByConstI(instr);
1413 return DoFlooringDivI(instr);
1418 LInstruction* LChunkBuilder::DoModByPowerOf2I(HMod* instr) {
1419 DCHECK(instr->representation().IsSmiOrInteger32());
1420 DCHECK(instr->left()->representation().Equals(instr->representation()));
1421 DCHECK(instr->right()->representation().Equals(instr->representation()));
1422 LOperand* dividend = UseRegisterAtStart(instr->left());
1423 int32_t divisor = instr->right()->GetInteger32Constant();
1426 if (instr->CheckFlag(HValue::kLeftCanBeNegative) &&
1427 instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
1434 LInstruction* LChunkBuilder::DoModByConstI(HMod* instr) {
1435 DCHECK(instr->representation().IsSmiOrInteger32());
1436 DCHECK(instr->left()->representation().Equals(instr->representation()));
1437 DCHECK(instr->right()->representation().Equals(instr->representation()));
1438 LOperand* dividend = UseRegister(instr->left());
1439 int32_t divisor = instr->right()->GetInteger32Constant();
1442 if (divisor == 0 || instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
1449 LInstruction* LChunkBuilder::DoModI(HMod* instr) {
1450 DCHECK(instr->representation().IsSmiOrInteger32());
1451 DCHECK(instr->left()->representation().Equals(instr->representation()));
1452 DCHECK(instr->right()->representation().Equals(instr->representation()));
1453 LOperand* dividend = UseRegister(instr->left());
1454 LOperand* divisor = UseRegister(instr->right());
1461 if (instr->CheckFlag(HValue::kCanBeDivByZero) ||
1462 instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
1469 LInstruction* LChunkBuilder::DoMod(HMod* instr) {
1470 if (instr->representation().IsSmiOrInteger32()) {
1471 if (instr->RightIsPowerOf2()) {
1472 return DoModByPowerOf2I(instr);
1473 } else if (instr->right()->IsConstant()) {
1474 return DoModByConstI(instr);
1476 return DoModI(instr);
1478 } else if (instr->representation().IsDouble()) {
1479 return DoArithmeticD(Token::MOD, instr);
1481 return DoArithmeticT(Token::MOD, instr);
1486 LInstruction* LChunkBuilder::DoMul(HMul* instr) {
1487 if (instr->representation().IsSmiOrInteger32()) {
1488 DCHECK(instr->left()->representation().Equals(instr->representation()));
1489 DCHECK(instr->right()->representation().Equals(instr->representation()));
1490 HValue* left = instr->BetterLeftOperand();
1491 HValue* right = instr->BetterRightOperand();
1494 bool can_overflow = instr->CheckFlag(HValue::kCanOverflow);
1495 bool bailout_on_minus_zero = instr->CheckFlag(HValue::kBailoutOnMinusZero);
1527 } else if (instr->representation().IsDouble()) {
1528 if (instr->HasOneUse() && (instr->uses().value()->IsAdd() ||
1529 instr
1530 HBinaryOperation* use = HBinaryOperation::cast(instr->uses().value());
1532 if (use->IsAdd() && instr == use->left()) {
1537 if (instr == use->right() && use->IsAdd() && !use->left()->IsMul()) {
1542 if (instr == use->right() && use->IsSub()) {
1549 return DoArithmeticD(Token::MUL, instr);
1551 return DoArithmeticT(Token::MUL, instr);
1556 LInstruction* LChunkBuilder::DoSub(HSub* instr) {
1557 if (instr->representation().IsSmiOrInteger32()) {
1558 DCHECK(instr->left()->representation().Equals(instr->representation()));
1559 DCHECK(instr->right()->representation().Equals(instr->representation()));
1561 if (instr->left()->IsConstant()) {
1563 return DoRSub(instr);
1566 LOperand* left = UseRegisterAtStart(instr->left());
1567 LOperand* right = UseOrConstantAtStart(instr->right());
1570 if (instr->CheckFlag(HValue::kCanOverflow)) {
1574 } else if (instr->representation().IsDouble()) {
1575 if (instr->right()->IsMul() && instr->right()->HasOneUse()) {
1576 return DoMultiplySub(instr->left(), HMul::cast(instr->right()));
1579 return DoArithmeticD(Token::SUB, instr);
1581 return DoArithmeticT(Token::SUB, instr);
1586 LInstruction* LChunkBuilder::DoRSub(HSub* instr) {
1587 DCHECK(instr->representation().IsSmiOrInteger32());
1588 DCHECK(instr->left()->representation().Equals(instr->representation()));
1589 DCHECK(instr->right()->representation().Equals(instr->representation()));
1593 LOperand* left = UseRegisterAtStart(instr->right());
1594 LOperand* right = UseOrConstantAtStart(instr->left());
1597 if (instr->CheckFlag(HValue::kCanOverflow)) {
1624 LInstruction* LChunkBuilder::DoAdd(HAdd* instr) {
1625 if (instr->representation().IsSmiOrInteger32()) {
1626 DCHECK(instr->left()->representation().Equals(instr->representation()));
1627 DCHECK(instr->right()->representation().Equals(instr->representation()));
1628 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand());
1629 LOperand* right = UseOrConstantAtStart(instr->BetterRightOperand());
1632 if (instr->CheckFlag(HValue::kCanOverflow)) {
1636 } else if (instr->representation().IsExternal()) {
1637 DCHECK(instr->left()->representation().IsExternal());
1638 DCHECK(instr->right()->representation().IsInteger32());
1639 DCHECK(!instr->CheckFlag(HValue::kCanOverflow));
1640 LOperand* left = UseRegisterAtStart(instr->left());
1641 LOperand* right = UseOrConstantAtStart(instr->right());
1645 } else if (instr->representation().IsDouble()) {
1646 if (instr->left()->IsMul() && instr->left()->HasOneUse()) {
1647 return DoMultiplyAdd(HMul::cast(instr->left()), instr->right());
1650 if (instr->right()->IsMul() && instr->right()->HasOneUse()) {
1651 DCHECK(!instr->left()->IsMul() || !instr->left()->HasOneUse());
1652 return DoMultiplyAdd(HMul::cast(instr->right()), instr->left());
1655 return DoArithmeticD(Token::ADD, instr);
1657 return DoArithmeticT(Token::ADD, instr);
1662 LInstruction* LChunkBuilder::DoMathMinMax(HMathMinMax* instr) {
1665 if (instr->representation().IsSmiOrInteger32()) {
1666 DCHECK(instr->left()->representation().Equals(instr->representation()));
1667 DCHECK(instr->right()->representation().Equals(instr->representation()));
1668 left = UseRegisterAtStart(instr->BetterLeftOperand());
1669 right = UseOrConstantAtStart(instr->BetterRightOperand());
1671 DCHECK(instr->representation().IsDouble());
1672 DCHECK(instr->left()->representation().IsDouble());
1673 DCHECK(instr->right()->representation().IsDouble());
1674 left = UseRegisterAtStart(instr->left());
1675 right = UseRegisterAtStart(instr->right());
1681 LInstruction* LChunkBuilder::DoPower(HPower* instr) {
1682 DCHECK(instr->representation().IsDouble());
1685 Representation exponent_type = instr->right()->representation();
1686 DCHECK(instr->left()->representation().IsDouble());
1687 LOperand* left = UseFixedDouble(instr->left(), d0);
1690 ? UseFixedDouble(instr->right(), d1)
1691 : UseFixed(instr->right(), MathPowTaggedDescriptor::exponent());
1694 instr,
1699 LInstruction* LChunkBuilder::DoCompareGeneric(HCompareGeneric* instr) {
1700 DCHECK(instr->left()->representation().IsTagged());
1701 DCHECK(instr->right()->representation().IsTagged());
1702 LOperand* context = UseFixed(instr->context(), cp);
1703 LOperand* left = UseFixed(instr->left(), r1);
1704 LOperand* right = UseFixed(instr->right(), r0);
1706 return MarkAsCall(DefineFixed(result, r0), instr);
1711 HCompareNumericAndBranch* instr) {
1712 Representation r = instr->representation();
1714 DCHECK(instr->left()->representation().Equals(r));
1715 DCHECK(instr->right()->representation().Equals(r));
1716 LOperand* left = UseRegisterOrConstantAtStart(instr->left());
1717 LOperand* right = UseRegisterOrConstantAtStart(instr->right());
1721 DCHECK(instr->left()->representation().IsDouble());
1722 DCHECK(instr->right()->representation().IsDouble());
1723 LOperand* left = UseRegisterAtStart(instr->left());
1724 LOperand* right = UseRegisterAtStart(instr->right());
1731 HCompareObjectEqAndBranch* instr) {
1732 LOperand* left = UseRegisterAtStart(instr->left());
1733 LOperand* right = UseRegisterAtStart(instr->right());
1739 HCompareHoleAndBranch* instr) {
1740 LOperand* value = UseRegisterAtStart(instr->value());
1746 HCompareMinusZeroAndBranch* instr) {
1747 LOperand* value = UseRegister(instr->value());
1753 LInstruction* LChunkBuilder::DoIsObjectAndBranch(HIsObjectAndBranch* instr) {
1754 DCHECK(instr->value()->representation().IsTagged());
1755 LOperand* value = UseRegisterAtStart(instr->value());
1761 LInstruction* LChunkBuilder::DoIsStringAndBranch(HIsStringAndBranch* instr) {
1762 DCHECK(instr->value()->representation().IsTagged());
1763 LOperand* value = UseRegisterAtStart(instr->value());
1769 LInstruction* LChunkBuilder::DoIsSmiAndBranch(HIsSmiAndBranch* instr) {
1770 DCHECK(instr->value()->representation().IsTagged());
1771 return new(zone()) LIsSmiAndBranch(Use(instr->value()));
1776 HIsUndetectableAndBranch* instr) {
1777 DCHECK(instr->value()->representation().IsTagged());
1778 LOperand* value = UseRegisterAtStart(instr->value());
1784 HStringCompareAndBranch* instr) {
1785 DCHECK(instr->left()->representation().IsTagged());
1786 DCHECK(instr->right()->representation().IsTagged());
1787 LOperand* context = UseFixed(instr->context(), cp);
1788 LOperand* left = UseFixed(instr->left(), r1);
1789 LOperand* right = UseFixed(instr->right(), r0);
1792 return MarkAsCall(result, instr);
1797 HHasInstanceTypeAndBranch* instr) {
1798 DCHECK(instr->value()->representation().IsTagged());
1799 LOperand* value = UseRegisterAtStart(instr->value());
1805 HGetCachedArrayIndex* instr) {
1806 DCHECK(instr->value()->representation().IsTagged());
1807 LOperand* value = UseRegisterAtStart(instr->value());
1814 HHasCachedArrayIndexAndBranch* instr) {
1815 DCHECK(instr->value()->representation().IsTagged());
1817 UseRegisterAtStart(instr->value()));
1822 HClassOfTestAndBranch* instr) {
1823 DCHECK(instr->value()->representation().IsTagged());
1824 LOperand* value = UseRegister(instr->value());
1829 LInstruction* LChunkBuilder::DoMapEnumLength(HMapEnumLength* instr) {
1830 LOperand* map = UseRegisterAtStart(instr->value());
1835 LInstruction* LChunkBuilder::DoDateField(HDateField* instr) {
1836 LOperand* object = UseFixed(instr->value(), r0);
1838 new(zone()) LDateField(object, FixedTemp(r1), instr->index());
1839 return MarkAsCall(DefineFixed(result, r0), instr, CAN_DEOPTIMIZE_EAGERLY);
1843 LInstruction* LChunkBuilder::DoSeqStringGetChar(HSeqStringGetChar* instr) {
1844 LOperand* string = UseRegisterAtStart(instr->string());
1845 LOperand* index = UseRegisterOrConstantAtStart(instr->index());
1850 LInstruction* LChunkBuilder::DoSeqStringSetChar(HSeqStringSetChar* instr) {
1851 LOperand* string = UseRegisterAtStart(instr->string());
1853 ? UseRegisterAtStart(instr->index())
1854 : UseRegisterOrConstantAtStart(instr->index());
1855 LOperand* value = UseRegisterAtStart(instr->value());
1856 LOperand* context = FLAG_debug_code ? UseFixed(instr->context(), cp) : NULL;
1861 LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) {
1862 if (!FLAG_debug_code && instr->skip_check()) return NULL;
1863 LOperand* index = UseRegisterOrConstantAtStart(instr->index());
1865 ? UseRegisterOrConstantAtStart(instr->length())
1866 : UseRegisterAtStart(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();
1957 if (!instr->CanTruncateToInt32()) result = AssignEnvironment(result);
1963 if (!instr->CheckFlag(HValue::kCanOverflow)) {
1982 if (instr->CheckFlag(HValue::kCanOverflow)) {
2000 LInstruction* LChunkBuilder::DoCheckHeapObject(HCheckHeapObject* instr) {
2001 LOperand* value = UseRegisterAtStart(instr->value());
2003 if (!instr->value()->type().IsHeapObject()) {
2010 LInstruction* LChunkBuilder::DoCheckSmi(HCheckSmi* instr) {
2011 LOperand* value = UseRegisterAtStart(instr->value());
2016 LInstruction* LChunkBuilder::DoCheckInstanceType(HCheckInstanceType* instr) {
2017 LOperand* value = UseRegisterAtStart(instr->value());
2023 LInstruction* LChunkBuilder::DoCheckValue(HCheckValue* instr) {
2024 LOperand* value = UseRegisterAtStart(instr->value());
2029 LInstruction* LChunkBuilder::DoCheckMaps(HCheckMaps* instr) {
2030 if (instr->IsStabilityCheck()) return new(zone()) LCheckMaps;
2031 LOperand* value = UseRegisterAtStart(instr->value());
2033 if (instr->HasMigrationTarget()) {
2041 LInstruction* LChunkBuilder::DoClampToUint8(HClampToUint8* instr) {
2042 HValue* value = instr->value();
2060 LInstruction* LChunkBuilder::DoDoubleBits(HDoubleBits* instr) {
2061 HValue* value = instr->value();
2067 LInstruction* LChunkBuilder::DoConstructDouble(HConstructDouble* instr) {
2068 LOperand* lo = UseRegister(instr->lo());
2069 LOperand* hi = UseRegister(instr->hi());
2074 LInstruction* LChunkBuilder::DoReturn(HReturn* instr) {
2076 ? UseFixed(instr->context(), cp)
2078 LOperand* parameter_count = UseRegisterOrConstant(instr->parameter_count());
2079 return new(zone()) LReturn(UseFixed(instr->value(), r0), context,
2084 LInstruction* LChunkBuilder::DoConstant(HConstant* instr) {
2085 Representation r = instr->representation();
2103 LInstruction* LChunkBuilder::DoLoadGlobalCell(HLoadGlobalCell* instr) {
2105 return instr->RequiresHoleCheck()
2111 LInstruction* LChunkBuilder::DoLoadGlobalGeneric(HLoadGlobalGeneric* instr) {
2112 LOperand* context = UseFixed(instr->context(), cp);
2114 UseFixed(instr->global_object(), LoadDescriptor::ReceiverRegister());
2121 return MarkAsCall(DefineFixed(result, r0), instr);
2125 LInstruction* LChunkBuilder::DoStoreGlobalCell(HStoreGlobalCell* instr) {
2126 LOperand* value = UseRegister(instr->value());
2129 return instr->RequiresHoleCheck()
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 if (instr->NeedsWriteBarrier()) {
2150 context = UseTempRegister(instr->context());
2151 value = UseTempRegister(instr->value());
2153 context = UseRegister(instr->context());
2154 value = UseRegister(instr->value());
2157 if (instr->RequiresHoleCheck() && instr->DeoptimizesOnHole()) {
2164 LInstruction* LChunkBuilder::DoLoadNamedField(HLoadNamedField* instr) {
2165 LOperand* obj = UseRegisterAtStart(instr->object());
2170 LInstruction* LChunkBuilder::DoLoadNamedGeneric(HLoadNamedGeneric* instr) {
2171 LOperand* context = UseFixed(instr->context(), cp);
2173 UseFixed(instr->object(), LoadDescriptor::ReceiverRegister());
2181 return MarkAsCall(result, instr);
2186 HLoadFunctionPrototype* instr) {
2188 new(zone()) LLoadFunctionPrototype(UseRegister(instr->function()))));
2192 LInstruction* LChunkBuilder::DoLoadRoot(HLoadRoot* instr) {
2197 LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) {
2198 DCHECK(instr->key()->representation().IsSmiOrInteger32());
2199 ElementsKind elements_kind = instr->elements_kind();
2200 LOperand* key = UseRegisterOrConstantAtStart(instr->key());
2203 if (!instr->is_typed_elements()) {
2205 if (instr->representation().IsDouble()) {
2206 obj = UseRegister(instr->elements());
2208 DCHECK(instr->representation().IsSmiOrTagged());
2209 obj = UseRegisterAtStart(instr->elements());
2214 (instr->representation().IsInteger32() &&
2216 (instr->representation().IsDouble() &&
2218 LOperand* backing_store = UseRegister(instr->elements());
2222 if ((instr->is_external() || instr->is_fixed_typed_array()) ?
2226 !instr->CheckFlag(HInstruction::kUint32)) :
2229 instr->RequiresHoleCheck()) {
2236 LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) {
2237 LOperand* context = UseFixed(instr->context(), cp);
2239 UseFixed(instr->object(), LoadDescriptor::ReceiverRegister());
2240 LOperand* key = UseFixed(instr->key(), LoadDescriptor::NameRegister());
2249 return MarkAsCall(result, instr);
2253 LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) {
2254 if (!instr->is_typed_elements()) {
2255 DCHECK(instr->elements()->representation().IsTagged());
2256 bool needs_write_barrier = instr->NeedsWriteBarrier();
2261 if (instr->value()->representation().IsDouble()) {
2262 object = UseRegisterAtStart(instr->elements());
2263 val = UseRegister(instr->value());
2264 key = UseRegisterOrConstantAtStart(instr->key());
2266 DCHECK(instr->value()->representation().IsSmiOrTagged());
2268 object = UseTempRegister(instr->elements());
2269 val = UseTempRegister(instr->value());
2270 key = UseTempRegister(instr->key());
2272 object = UseRegisterAtStart(instr->elements());
2273 val = UseRegisterAtStart(instr->value());
2274 key = UseRegisterOrConstantAtStart(instr->key());
2282 (instr->value()->representation().IsInteger32() &&
2283 !IsDoubleOrFloatElementsKind(instr->elements_kind())) ||
2284 (instr->value()->representation().IsDouble() &&
2285 IsDoubleOrFloatElementsKind(instr->elements_kind())));
2286 DCHECK((instr->is_fixed_typed_array() &&
2287 instr->elements()->representation().IsTagged()) ||
2288 (instr->is_external() &&
2289 instr->elements()->representation().IsExternal()));
2290 LOperand* val = UseRegister(instr->value());
2291 LOperand* key = UseRegisterOrConstantAtStart(instr->key());
2292 LOperand* backing_store = UseRegister(instr->elements());
2297 LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) {
2298 LOperand* context = UseFixed(instr->context(), cp);
2300 UseFixed(instr->object(), StoreDescriptor::ReceiverRegister());
2301 LOperand* key = UseFixed(instr->key(), StoreDescriptor::NameRegister());
2302 LOperand* val = UseFixed(instr->value(), StoreDescriptor::ValueRegister());
2304 DCHECK(instr->object()->representation().IsTagged());
2305 DCHECK(instr->key()->representation().IsTagged());
2306 DCHECK(instr->value()->representation().IsTagged());
2309 new(zone()) LStoreKeyedGeneric(context, obj, key, val), instr);
2314 HTransitionElementsKind* instr) {
2315 if (IsSimpleMapChangeTransition(instr->from_kind(), instr->to_kind())) {
2316 LOperand* object = UseRegister(instr->object());
2322 LOperand* object = UseFixed(instr->object(), r0);
2323 LOperand* context = UseFixed(instr->context(), cp);
2326 return MarkAsCall(result, instr);
2332 HTrapAllocationMemento* instr) {
2333 LOperand* object = UseRegister(instr->object());
2341 LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) {
2342 bool is_in_object = instr->access().IsInobject();
2343 bool needs_write_barrier = instr->NeedsWriteBarrier();
2344 bool needs_write_barrier_for_map = instr->has_transition() &&
2345 instr->NeedsWriteBarrierForMap();
2350 ? UseRegister(instr->object())
2351 : UseTempRegister(instr->object());
2354 ? UseRegister(instr->object())
2355 : UseRegisterAtStart(instr->object());
2360 val = UseTempRegister(instr->value());
2361 } else if (instr->field_representation().IsDouble()) {
2362 val = UseRegisterAtStart(instr->value());
2364 val = UseRegister(instr->value());
2374 LInstruction* LChunkBuilder::DoStoreNamedGeneric(HStoreNamedGeneric* instr) {
2375 LOperand* context = UseFixed(instr->context(), cp);
2377 UseFixed(instr->object(), StoreDescriptor::ReceiverRegister());
2378 LOperand* val = UseFixed(instr->value(), StoreDescriptor::ValueRegister());
2381 return MarkAsCall(result, instr);
2385 LInstruction* LChunkBuilder::DoStringAdd(HStringAdd* instr) {
2386 LOperand* context = UseFixed(instr->context(), cp);
2387 LOperand* left = UseFixed(instr->left(), r1);
2388 LOperand* right = UseFixed(instr->right(), r0);
2391 instr);
2395 LInstruction* LChunkBuilder::DoStringCharCodeAt(HStringCharCodeAt* instr) {
2396 LOperand* string = UseTempRegister(instr->string());
2397 LOperand* index = UseTempRegister(instr->index());
2398 LOperand* context = UseAny(instr->context());
2405 LInstruction* LChunkBuilder::DoStringCharFromCode(HStringCharFromCode* instr) {
2406 LOperand* char_code = UseRegister(instr->value());
2407 LOperand* context = UseAny(instr->context());
2414 LInstruction* LChunkBuilder::DoAllocate(HAllocate* instr) {
2416 LOperand* context = UseAny(instr->context());
2417 LOperand* size = UseRegisterOrConstant(instr->size());
2425 LInstruction* LChunkBuilder::DoRegExpLiteral(HRegExpLiteral* instr) {
2426 LOperand* context = UseFixed(instr->context(), cp);
2428 DefineFixed(new(zone()) LRegExpLiteral(context), r0), instr);
2432 LInstruction* LChunkBuilder::DoFunctionLiteral(HFunctionLiteral* instr) {
2433 LOperand* context = UseFixed(instr->context(), cp);
2435 DefineFixed(new(zone()) LFunctionLiteral(context), r0), instr);
2439 LInstruction* LChunkBuilder::DoOsrEntry(HOsrEntry* instr) {
2442 current_block_->last_environment()->set_ast_id(instr->ast_id());
2447 LInstruction* LChunkBuilder::DoParameter(HParameter* instr) {
2449 if (instr->kind() == HParameter::STACK_PARAMETER) {
2450 int spill_index = chunk()->GetParameterStackSlot(instr->index());
2456 int index = static_cast<int>(instr->index());
2463 LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) {
2466 int env_index = instr->index();
2468 if (instr->environment()->is_parameter_index(env_index)) {
2471 spill_index = env_index - instr->environment()->first_local_index();
2481 LInstruction* LChunkBuilder::DoCallStub(HCallStub* instr) {
2482 LOperand* context = UseFixed(instr->context(), cp);
2483 return MarkAsCall(DefineFixed(new(zone()) LCallStub(context), r0), instr);
2487 LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) {
2496 LInstruction* LChunkBuilder::DoCapturedObject(HCapturedObject* instr) {
2497 instr->ReplayEnvironment(current_block_->last_environment());
2504 LInstruction* LChunkBuilder::DoAccessArgumentsAt(HAccessArgumentsAt* instr) {
2506 LOperand* args = UseRegister(instr->arguments());
2507 LOperand* length = UseRegisterOrConstantAtStart(instr->length());
2508 LOperand* index = UseRegisterOrConstantAtStart(instr->index());
2513 LInstruction* LChunkBuilder::DoToFastProperties(HToFastProperties* instr) {
2514 LOperand* object = UseFixed(instr->value(), r0);
2516 return MarkAsCall(DefineFixed(result, r0), instr);
2520 LInstruction* LChunkBuilder::DoTypeof(HTypeof* instr) {
2521 LOperand* context = UseFixed(instr->context(), cp);
2522 LTypeof* result = new(zone()) LTypeof(context, UseFixed(instr->value(), r0));
2523 return MarkAsCall(DefineFixed(result, r0), instr);
2527 LInstruction* LChunkBuilder::DoTypeofIsAndBranch(HTypeofIsAndBranch* instr) {
2528 return new(zone()) LTypeofIsAndBranch(UseRegister(instr->value()));
2533 HIsConstructCallAndBranch* instr) {
2538 LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) {
2539 instr->ReplayEnvironment(current_block_->last_environment());
2544 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) {
2545 if (instr->is_function_entry()) {
2546 LOperand* context = UseFixed(instr->context(), cp);
2547 return MarkAsCall(new(zone()) LStackCheck(context), instr);
2549 DCHECK(instr->is_backwards_branch());
2550 LOperand* context = UseAny(instr->context());
2557 LInstruction* LChunkBuilder::DoEnterInlined(HEnterInlined* instr) {
2559 outer->set_ast_id(instr->ReturnId());
2561 HEnvironment* inner = outer->CopyForInlining(instr->closure(),
2562 instr->arguments_count(),
2563 instr->function(),
2565 instr->inlining_kind());
2567 if (instr->arguments_var() != NULL && instr->arguments_object()->IsLinked()) {
2568 inner->Bind(instr->arguments_var(), instr->arguments_object());
2570 inner->BindContext(instr->closure_context());
2571 inner->set_entry(instr);
2573 chunk_->AddInlinedClosure(instr->closure());
2578 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) {
2586 DCHECK(instr->argument_delta() == -argument_count);
2597 LInstruction* LChunkBuilder::DoForInPrepareMap(HForInPrepareMap* instr) {
2598 LOperand* context = UseFixed(instr->context(), cp);
2599 LOperand* object = UseFixed(instr->enumerable(), r0);
2601 return MarkAsCall(DefineFixed(result, r0), instr, CAN_DEOPTIMIZE_EAGERLY);
2605 LInstruction* LChunkBuilder::DoForInCacheArray(HForInCacheArray* instr) {
2606 LOperand* map = UseRegister(instr->map());
2611 LInstruction* LChunkBuilder::DoCheckMapValue(HCheckMapValue* instr) {
2612 LOperand* value = UseRegisterAtStart(instr->value());
2613 LOperand* map = UseRegisterAtStart(instr->map());
2618 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) {
2619 LOperand* object = UseRegister(instr->object());
2620 LOperand* index = UseTempRegister(instr->index());
2627 LInstruction* LChunkBuilder::DoStoreFrameContext(HStoreFrameContext* instr) {
2628 LOperand* context = UseRegisterAtStart(instr->context());
2634 HAllocateBlockContext* instr) {
2635 LOperand* context = UseFixed(instr->context(), cp);
2636 LOperand* function = UseRegisterAtStart(instr->function());
2639 return MarkAsCall(DefineFixed(result, cp), instr);