Lines Matching refs:instr

371     HInstruction* instr = HInstruction::cast(value);
372 VisitInstruction(instr);
429 LInstruction* LChunkBuilder::Define(LTemplateResultInstruction<1>* instr,
432 instr->set_result(result);
433 return instr;
438 LTemplateResultInstruction<1>* instr) {
439 return Define(instr,
445 LTemplateResultInstruction<1>* instr, int index) {
446 return Define(instr,
452 LTemplateResultInstruction<1>* instr) {
453 return Define(instr,
459 LTemplateResultInstruction<1>* instr, Register reg) {
460 return Define(instr, ToUnallocated(reg));
465 LTemplateResultInstruction<1>* instr, DoubleRegister reg) {
466 return Define(instr, ToUnallocated(reg));
470 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr,
475 instr->VerifyCall();
477 instr->MarkAsCall();
478 instr = AssignPointerMap(instr);
487 if (needs_environment && !instr->HasEnvironment()) {
488 instr = AssignEnvironment(instr);
490 instr->environment()->set_has_been_used();
493 return instr;
497 LInstruction* LChunkBuilder::AssignPointerMap(LInstruction* instr) {
498 DCHECK(!instr->HasPointerMap());
499 instr->set_pointer_map(new(zone()) LPointerMap(zone()));
500 return instr;
659 LInstruction* instr = NULL;
662 instr = DefineAsRegister(new(zone()) LDummy());
665 instr = DefineAsRegister(new(zone())
680 instr = new(zone()) LGoto(successor);
682 instr = current->CompileToLithium(this);
689 if (instr != NULL) {
690 AddInstruction(instr, current);
697 void LChunkBuilder::AddInstruction(LInstruction* instr,
701 instr->set_hydrogen_value(hydrogen_val);
714 if (!(instr->ClobbersRegisters() &&
715 instr->ClobbersDoubleRegisters(isolate()))) {
718 for (UseIterator it(instr); !it.Done(); it.Advance()) {
722 if (instr->Output() != NULL) {
723 if (LUnallocated::cast(instr->Output())->HasFixedPolicy()) ++fixed;
725 for (TempIterator it(instr); !it.Done(); it.Advance()) {
733 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) {
734 instr = AssignPointerMap(instr);
736 if (FLAG_stress_environments && !instr->HasEnvironment()) {
737 instr = AssignEnvironment(instr);
739 chunk_->AddInstruction(instr, current_block_);
741 if (instr->IsCall()) {
746 instruction_needing_environment = instr;
763 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) {
767 instr->set_environment(CreateEnvironment(hydrogen_env,
770 return instr;
774 LInstruction* LChunkBuilder::DoAbnormalExit(HAbnormalExit* instr) {
782 HArithmeticBinaryOperation* instr) {
783 DCHECK(instr->representation().IsDouble());
784 DCHECK(instr->left()->representation().IsDouble());
785 DCHECK(instr->right()->representation().IsDouble());
788 LOperand* left = UseFixedDouble(instr->left(), d0);
789 LOperand* right = UseFixedDouble(instr->right(), d1);
791 return MarkAsCall(DefineFixedDouble(result, d0), instr);
793 LOperand* left = UseRegisterAtStart(instr->left());
794 LOperand* right = UseRegisterAtStart(instr->right());
802 HBinaryOperation* instr) {
808 HValue* left = instr->left();
809 HValue* right = instr->right();
813 DCHECK(instr->representation().IsSmiOrTagged());
817 LOperand* context = UseFixed(instr->context(), cp);
822 return MarkAsCall(DefineFixed(result, x0), instr);
827 HBoundsCheckBaseIndexInformation* instr) {
833 LInstruction* LChunkBuilder::DoAccessArgumentsAt(HAccessArgumentsAt* instr) {
839 if (instr->length()->IsConstant() && instr->index()->IsConstant()) {
840 args = UseRegisterAtStart(instr->arguments());
841 length = UseConstant(instr->length());
842 index = UseConstant(instr->index());
844 args = UseRegister(instr->arguments());
845 length = UseRegisterAtStart(instr->length());
846 index = UseRegisterOrConstantAtStart(instr->index());
853 LInstruction* LChunkBuilder::DoAdd(HAdd* instr) {
854 if (instr->representation().IsSmiOrInteger32()) {
855 DCHECK(instr->left()->representation().Equals(instr->representation()));
856 DCHECK(instr->right()->representation().Equals(instr->representation()));
858 LInstruction* shifted_operation = TryDoOpWithShiftedRightOperand(instr);
863 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand());
865 UseRegisterOrConstantAtStart(instr->BetterRightOperand());
866 LInstruction* result = instr->representation().IsSmi() ?
869 if (instr->CheckFlag(HValue::kCanOverflow)) {
873 } else if (instr->representation().IsExternal()) {
874 DCHECK(instr->left()->representation().IsExternal());
875 DCHECK(instr->right()->representation().IsInteger32());
876 DCHECK(!instr->CheckFlag(HValue::kCanOverflow));
877 LOperand* left = UseRegisterAtStart(instr->left());
878 LOperand* right = UseRegisterOrConstantAtStart(instr->right());
880 } else if (instr->representation().IsDouble()) {
881 return DoArithmeticD(Token::ADD, instr);
883 DCHECK(instr->representation().IsTagged());
884 return DoArithmeticT(Token::ADD, instr);
889 LInstruction* LChunkBuilder::DoAllocate(HAllocate* instr) {
891 LOperand* context = UseAny(instr->context());
892 LOperand* size = UseRegisterOrConstant(instr->size());
895 LOperand* temp3 = instr->MustPrefillWithFiller() ? TempRegister() : NULL;
901 LInstruction* LChunkBuilder::DoApplyArguments(HApplyArguments* instr) {
902 LOperand* function = UseFixed(instr->function(), x1);
903 LOperand* receiver = UseFixed(instr->receiver(), x0);
904 LOperand* length = UseFixed(instr->length(), x2);
905 LOperand* elements = UseFixed(instr->elements(), x3);
910 return MarkAsCall(DefineFixed(result, x0), instr, CAN_DEOPTIMIZE_EAGERLY);
914 LInstruction* LChunkBuilder::DoArgumentsElements(HArgumentsElements* instr) {
916 LOperand* temp = instr->from_inlined() ? NULL : TempRegister();
921 LInstruction* LChunkBuilder::DoArgumentsLength(HArgumentsLength* instr) {
923 LOperand* value = UseRegisterAtStart(instr->value());
928 LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) {
937 LInstruction* LChunkBuilder::DoBitwise(HBitwise* instr) {
938 if (instr->representation().IsSmiOrInteger32()) {
939 DCHECK(instr->left()->representation().Equals(instr->representation()));
940 DCHECK(instr->right()->representation().Equals(instr->representation()));
941 DCHECK(instr->CheckFlag(HValue::kTruncatingToInt32));
943 LInstruction* shifted_operation = TryDoOpWithShiftedRightOperand(instr);
948 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand());
950 UseRegisterOrConstantAtStart(instr->BetterRightOperand());
951 return instr->representation().IsSmi() ?
955 return DoArithmeticT(instr->op(), instr);
960 LInstruction* LChunkBuilder::DoBlockEntry(HBlockEntry* instr) {
964 return new(zone()) LLabel(instr->block());
968 LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) {
969 if (!FLAG_debug_code && instr->skip_check()) return NULL;
970 LOperand* index = UseRegisterOrConstantAtStart(instr->index());
972 ? UseRegisterOrConstantAtStart(instr->length())
973 : UseRegisterAtStart(instr->length());
975 if (!FLAG_debug_code || !instr->skip_check()) {
982 LInstruction* LChunkBuilder::DoBranch(HBranch* instr) {
983 HValue* value = instr->value();
1003 ToBooleanStub::Types expected = instr->expected_input_types();
1022 HCallJSFunction* instr) {
1023 LOperand* function = UseFixed(instr->function(), x1);
1027 return MarkAsCall(DefineFixed(result, x0), instr);
1032 HCallWithDescriptor* instr) {
1033 CallInterfaceDescriptor descriptor = instr->descriptor();
1035 LOperand* target = UseRegisterOrConstantAtStart(instr->target());
1036 ZoneList<LOperand*> ops(instr->OperandCount(), zone());
1038 for (int i = 1; i < instr->OperandCount(); i++) {
1040 UseFixed(instr->OperandAt(i), descriptor.GetParameterRegister(i - 1));
1047 return MarkAsCall(DefineFixed(result, x0), instr);
1051 LInstruction* LChunkBuilder::DoCallFunction(HCallFunction* instr) {
1052 LOperand* context = UseFixed(instr->context(), cp);
1053 LOperand* function = UseFixed(instr->function(), x1);
1055 return MarkAsCall(DefineFixed(call, x0), instr);
1059 LInstruction* LChunkBuilder::DoCallNew(HCallNew* instr) {
1060 LOperand* context = UseFixed(instr->context(), cp);
1062 LOperand* constructor = UseFixed(instr->constructor(), x1);
1064 return MarkAsCall(DefineFixed(result, x0), instr);
1068 LInstruction* LChunkBuilder::DoCallNewArray(HCallNewArray* instr) {
1069 LOperand* context = UseFixed(instr->context(), cp);
1071 LOperand* constructor = UseFixed(instr->constructor(), x1);
1073 return MarkAsCall(DefineFixed(result, x0), instr);
1077 LInstruction* LChunkBuilder::DoCallRuntime(HCallRuntime* instr) {
1078 LOperand* context = UseFixed(instr->context(), cp);
1079 return MarkAsCall(DefineFixed(new(zone()) LCallRuntime(context), x0), instr);
1083 LInstruction* LChunkBuilder::DoCallStub(HCallStub* instr) {
1084 LOperand* context = UseFixed(instr->context(), cp);
1085 return MarkAsCall(DefineFixed(new(zone()) LCallStub(context), x0), instr);
1089 LInstruction* LChunkBuilder::DoCapturedObject(HCapturedObject* instr) {
1090 instr->ReplayEnvironment(current_block_->last_environment());
1097 LInstruction* LChunkBuilder::DoChange(HChange* instr) {
1098 Representation from = instr->from();
1099 Representation to = instr->to();
1100 HValue* val = instr->value();
1130 LOperand* temp2 = instr->CanTruncateToInt32()
1148 if (instr->CanTruncateToInt32()) {
1194 LInstruction* LChunkBuilder::DoCheckValue(HCheckValue* instr) {
1195 LOperand* value = UseRegisterAtStart(instr->value());
1200 LInstruction* LChunkBuilder::DoCheckInstanceType(HCheckInstanceType* instr) {
1201 LOperand* value = UseRegisterAtStart(instr->value());
1208 LInstruction* LChunkBuilder::DoCheckMaps(HCheckMaps* instr) {
1209 if (instr->IsStabilityCheck()) return new(zone()) LCheckMaps;
1210 LOperand* value = UseRegisterAtStart(instr->value());
1213 if (instr->HasMigrationTarget()) {
1221 LInstruction* LChunkBuilder::DoCheckHeapObject(HCheckHeapObject* instr) {
1222 LOperand* value = UseRegisterAtStart(instr->value());
1224 if (!instr->value()->type().IsHeapObject()) {
1231 LInstruction* LChunkBuilder::DoCheckSmi(HCheckSmi* instr) {
1232 LOperand* value = UseRegisterAtStart(instr->value());
1237 LInstruction* LChunkBuilder::DoClampToUint8(HClampToUint8* instr) {
1238 HValue* value = instr->value();
1255 HClassOfTestAndBranch* instr) {
1256 DCHECK(instr->value()->representation().IsTagged());
1257 LOperand* value = UseRegisterAtStart(instr->value());
1265 HCompareNumericAndBranch* instr) {
1266 Representation r = instr->representation();
1268 DCHECK(instr->left()->representation().Equals(r));
1269 DCHECK(instr->right()->representation().Equals(r));
1270 LOperand* left = UseRegisterOrConstantAtStart(instr->left());
1271 LOperand* right = UseRegisterOrConstantAtStart(instr->right());
1275 DCHECK(instr->left()->representation().IsDouble());
1276 DCHECK(instr->right()->representation().IsDouble());
1277 if (instr->left()->IsConstant() && instr->right()->IsConstant()) {
1278 LOperand* left = UseConstant(instr->left());
1279 LOperand* right = UseConstant(instr->right());
1282 LOperand* left = UseRegisterAtStart(instr->left());
1283 LOperand* right = UseRegisterAtStart(instr->right());
1289 LInstruction* LChunkBuilder::DoCompareGeneric(HCompareGeneric* instr) {
1290 DCHECK(instr->left()->representation().IsTagged());
1291 DCHECK(instr->right()->representation().IsTagged());
1292 LOperand* context = UseFixed(instr->context(), cp);
1293 LOperand* left = UseFixed(instr->left(), x1);
1294 LOperand* right = UseFixed(instr->right(), x0);
1296 return MarkAsCall(DefineFixed(result, x0), instr);
1301 HCompareHoleAndBranch* instr) {
1302 LOperand* value = UseRegister(instr->value());
1303 if (instr->representation().IsTagged()) {
1313 HCompareObjectEqAndBranch* instr) {
1314 LOperand* left = UseRegisterAtStart(instr->left());
1315 LOperand* right = UseRegisterAtStart(instr->right());
1320 LInstruction* LChunkBuilder::DoCompareMap(HCompareMap* instr) {
1321 DCHECK(instr->value()->representation().IsTagged());
1322 LOperand* value = UseRegisterAtStart(instr->value());
1328 LInstruction* LChunkBuilder::DoConstant(HConstant* instr) {
1329 Representation r = instr->representation();
1347 LInstruction* LChunkBuilder::DoContext(HContext* instr) {
1348 if (instr->HasNoUses()) return NULL;
1358 LInstruction* LChunkBuilder::DoDateField(HDateField* instr) {
1359 LOperand* object = UseFixed(instr->value(), x0);
1360 LDateField* result = new(zone()) LDateField(object, instr->index());
1361 return MarkAsCall(DefineFixed(result, x0), instr, CAN_DEOPTIMIZE_EAGERLY);
1365 LInstruction* LChunkBuilder::DoDebugBreak(HDebugBreak* instr) {
1370 LInstruction* LChunkBuilder::DoDeclareGlobals(HDeclareGlobals* instr) {
1371 LOperand* context = UseFixed(instr->context(), cp);
1372 return MarkAsCall(new(zone()) LDeclareGlobals(context), instr);
1376 LInstruction* LChunkBuilder::DoDeoptimize(HDeoptimize* instr) {
1381 LInstruction* LChunkBuilder::DoDivByPowerOf2I(HDiv* instr) {
1382 DCHECK(instr->representation().IsInteger32());
1383 DCHECK(instr->left()->representation().Equals(instr->representation()));
1384 DCHECK(instr->right()->representation().Equals(instr->representation()));
1385 LOperand* dividend = UseRegister(instr->left());
1386 int32_t divisor = instr->right()->GetInteger32Constant();
1389 if ((instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) ||
1390 (instr->CheckFlag(HValue::kCanOverflow) && divisor == -1) ||
1391 (!instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32) &&
1399 LInstruction* LChunkBuilder::DoDivByConstI(HDiv* instr) {
1400 DCHECK(instr->representation().IsInteger32());
1401 DCHECK(instr->left()->representation().Equals(instr->representation()));
1402 DCHECK(instr->right()->representation().Equals(instr->representation()));
1403 LOperand* dividend = UseRegister(instr->left());
1404 int32_t divisor = instr->right()->GetInteger32Constant();
1405 LOperand* temp = instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32)
1410 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) ||
1411 !instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32)) {
1418 LInstruction* LChunkBuilder::DoDivI(HBinaryOperation* 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 = UseRegister(instr->left());
1423 LOperand* divisor = UseRegister(instr->right());
1424 LOperand* temp = instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32)
1428 if (!instr->CheckFlag(HValue::kAllUsesTruncatingToInt32)) {
1435 LInstruction* LChunkBuilder::DoDiv(HDiv* instr) {
1436 if (instr->representation().IsSmiOrInteger32()) {
1437 if (instr->RightIsPowerOf2()) {
1438 return DoDivByPowerOf2I(instr);
1439 } else if (instr->right()->IsConstant()) {
1440 return DoDivByConstI(instr);
1442 return DoDivI(instr);
1444 } else if (instr->representation().IsDouble()) {
1445 return DoArithmeticD(Token::DIV, instr);
1447 return DoArithmeticT(Token::DIV, instr);
1452 LInstruction* LChunkBuilder::DoDummyUse(HDummyUse* instr) {
1453 return DefineAsRegister(new(zone()) LDummyUse(UseAny(instr->value())));
1457 LInstruction* LChunkBuilder::DoEnterInlined(HEnterInlined* instr) {
1459 outer->set_ast_id(instr->ReturnId());
1461 HEnvironment* inner = outer->CopyForInlining(instr->closure(),
1462 instr->arguments_count(),
1463 instr->function(),
1465 instr->inlining_kind());
1467 if ((instr->arguments_var() != NULL) &&
1468 instr->arguments_object()->IsLinked()) {
1469 inner->Bind(instr->arguments_var(), instr->arguments_object());
1471 inner->BindContext(instr->closure_context());
1472 inner->set_entry(instr);
1474 chunk_->AddInlinedClosure(instr->closure());
1479 LInstruction* LChunkBuilder::DoEnvironmentMarker(HEnvironmentMarker* instr) {
1486 HForceRepresentation* instr) {
1494 LInstruction* LChunkBuilder::DoFunctionLiteral(HFunctionLiteral* instr) {
1495 LOperand* context = UseFixed(instr->context(), cp);
1497 DefineFixed(new(zone()) LFunctionLiteral(context), x0), instr);
1502 HGetCachedArrayIndex* instr) {
1503 DCHECK(instr->value()->representation().IsTagged());
1504 LOperand* value = UseRegisterAtStart(instr->value());
1509 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) {
1510 return new(zone()) LGoto(instr->FirstSuccessor());
1515 HHasCachedArrayIndexAndBranch* instr) {
1516 DCHECK(instr->value()->representation().IsTagged());
1518 UseRegisterAtStart(instr->value()), TempRegister());
1523 HHasInstanceTypeAndBranch* instr) {
1524 DCHECK(instr->value()->representation().IsTagged());
1525 LOperand* value = UseRegisterAtStart(instr->value());
1531 HInnerAllocatedObject* instr) {
1532 LOperand* base_object = UseRegisterAtStart(instr->base_object());
1533 LOperand* offset = UseRegisterOrConstantAtStart(instr->offset());
1539 LInstruction* LChunkBuilder::DoInstanceOf(HInstanceOf* instr) {
1540 LOperand* context = UseFixed(instr->context(), cp);
1543 UseFixed(instr->left(), InstanceofStub::left()),
1544 UseFixed(instr->right(), InstanceofStub::right()));
1545 return MarkAsCall(DefineFixed(result, x0), instr);
1550 HInstanceOfKnownGlobal* instr) {
1552 UseFixed(instr->context(), cp),
1553 UseFixed(instr->left(), InstanceofStub::left()));
1554 return MarkAsCall(DefineFixed(result, x0), instr);
1559 HTailCallThroughMegamorphicCache* instr) {
1560 LOperand* context = UseFixed(instr->context(), cp);
1562 UseFixed(instr->receiver(), LoadDescriptor::ReceiverRegister());
1564 UseFixed(instr->name(), LoadDescriptor::NameRegister());
1571 LInstruction* LChunkBuilder::DoInvokeFunction(HInvokeFunction* instr) {
1572 LOperand* context = UseFixed(instr->context(), cp);
1574 LOperand* function = UseFixed(instr->function(), x1);
1576 return MarkAsCall(DefineFixed(result, x0), instr, CANNOT_DEOPTIMIZE_EAGERLY);
1581 HIsConstructCallAndBranch* instr) {
1587 HCompareMinusZeroAndBranch* instr) {
1588 LOperand* value = UseRegister(instr->value());
1594 LInstruction* LChunkBuilder::DoIsObjectAndBranch(HIsObjectAndBranch* instr) {
1595 DCHECK(instr->value()->representation().IsTagged());
1596 LOperand* value = UseRegisterAtStart(instr->value());
1603 LInstruction* LChunkBuilder::DoIsStringAndBranch(HIsStringAndBranch* instr) {
1604 DCHECK(instr->value()->representation().IsTagged());
1605 LOperand* value = UseRegisterAtStart(instr->value());
1611 LInstruction* LChunkBuilder::DoIsSmiAndBranch(HIsSmiAndBranch* instr) {
1612 DCHECK(instr->value()->representation().IsTagged());
1613 return new(zone()) LIsSmiAndBranch(UseRegisterAtStart(instr->value()));
1618 HIsUndetectableAndBranch* instr) {
1619 DCHECK(instr->value()->representation().IsTagged());
1620 LOperand* value = UseRegisterAtStart(instr->value());
1625 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) {
1632 DCHECK(instr->argument_delta() == -argument_count);
1643 LInstruction* LChunkBuilder::DoLoadContextSlot(HLoadContextSlot* instr) {
1644 LOperand* context = UseRegisterAtStart(instr->value());
1647 if (instr->RequiresHoleCheck() && instr->DeoptimizesOnHole()) {
1655 HLoadFunctionPrototype* instr) {
1656 LOperand* function = UseRegister(instr->function());
1663 LInstruction* LChunkBuilder::DoLoadGlobalCell(HLoadGlobalCell* instr) {
1665 return instr->RequiresHoleCheck()
1671 LInstruction* LChunkBuilder::DoLoadGlobalGeneric(HLoadGlobalGeneric* instr) {
1672 LOperand* context = UseFixed(instr->context(), cp);
1674 UseFixed(instr->global_object(), LoadDescriptor::ReceiverRegister());
1682 return MarkAsCall(DefineFixed(result, x0), instr);
1686 LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) {
1687 DCHECK(instr->key()->representation().IsSmiOrInteger32());
1688 ElementsKind elements_kind = instr->elements_kind();
1689 LOperand* elements = UseRegister(instr->elements());
1690 LOperand* key = UseRegisterOrConstant(instr->key());
1692 if (!instr->is_typed_elements()) {
1693 if (instr->representation().IsDouble()) {
1694 LOperand* temp = (!instr->key()->IsConstant() ||
1695 instr->RequiresHoleCheck())
1701 return instr->RequiresHoleCheck()
1705 DCHECK(instr->representation().IsSmiOrTagged() ||
1706 instr->representation().IsInteger32());
1707 LOperand* temp = instr->key()->IsConstant() ? NULL : TempRegister();
1710 return instr->RequiresHoleCheck()
1715 DCHECK((instr->representation().IsInteger32() &&
1716 !IsDoubleOrFloatElementsKind(instr->elements_kind())) ||
1717 (instr->representation().IsDouble() &&
1718 IsDoubleOrFloatElementsKind(instr->elements_kind())));
1720 LOperand* temp = instr->key()->IsConstant() ? NULL : TempRegister();
1725 !instr->CheckFlag(HInstruction::kUint32)) {
1733 LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) {
1734 LOperand* context = UseFixed(instr->context(), cp);
1736 UseFixed(instr->object(), LoadDescriptor::ReceiverRegister());
1737 LOperand* key = UseFixed(instr->key(), LoadDescriptor::NameRegister());
1746 return MarkAsCall(result, instr);
1750 LInstruction* LChunkBuilder::DoLoadNamedField(HLoadNamedField* instr) {
1751 LOperand* object = UseRegisterAtStart(instr->object());
1756 LInstruction* LChunkBuilder::DoLoadNamedGeneric(HLoadNamedGeneric* instr) {
1757 LOperand* context = UseFixed(instr->context(), cp);
1759 UseFixed(instr->object(), LoadDescriptor::ReceiverRegister());
1767 return MarkAsCall(result, instr);
1771 LInstruction* LChunkBuilder::DoLoadRoot(HLoadRoot* instr) {
1776 LInstruction* LChunkBuilder::DoMapEnumLength(HMapEnumLength* instr) {
1777 LOperand* map = UseRegisterAtStart(instr->value());
1782 LInstruction* LChunkBuilder::DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr) {
1783 DCHECK(instr->representation().IsInteger32());
1784 DCHECK(instr->left()->representation().Equals(instr->representation()));
1785 DCHECK(instr->right()->representation().Equals(instr->representation()));
1786 LOperand* dividend = UseRegisterAtStart(instr->left());
1787 int32_t divisor = instr->right()->GetInteger32Constant();
1790 if ((instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) ||
1791 (instr->CheckFlag(HValue::kLeftCanBeMinInt) && divisor == -1)) {
1798 LInstruction* LChunkBuilder::DoFlooringDivByConstI(HMathFloorOfDiv* instr) {
1799 DCHECK(instr->representation().IsInteger32());
1800 DCHECK(instr->left()->representation().Equals(instr->representation()));
1801 DCHECK(instr->right()->representation().Equals(instr->representation()));
1802 LOperand* dividend = UseRegister(instr->left());
1803 int32_t divisor = instr->right()->GetInteger32Constant();
1805 ((divisor > 0 && !instr->CheckFlag(HValue::kLeftCanBeNegative)) ||
1806 (divisor < 0 && !instr->CheckFlag(HValue::kLeftCanBePositive))) ?
1811 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0)) {
1818 LInstruction* LChunkBuilder::DoFlooringDivI(HMathFloorOfDiv* instr) {
1819 LOperand* dividend = UseRegister(instr->left());
1820 LOperand* divisor = UseRegister(instr->right());
1828 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) {
1829 if (instr->RightIsPowerOf2()) {
1830 return DoFlooringDivByPowerOf2I(instr);
1831 } else if (instr->right()->IsConstant()) {
1832 return DoFlooringDivByConstI(instr);
1834 return DoFlooringDivI(instr);
1839 LInstruction* LChunkBuilder::DoMathMinMax(HMathMinMax* instr) {
1842 if (instr->representation().IsSmiOrInteger32()) {
1843 DCHECK(instr->left()->representation().Equals(instr->representation()));
1844 DCHECK(instr->right()->representation().Equals(instr->representation()));
1845 left = UseRegisterAtStart(instr->BetterLeftOperand());
1846 right = UseRegisterOrConstantAtStart(instr->BetterRightOperand());
1848 DCHECK(instr->representation().IsDouble());
1849 DCHECK(instr->left()->representation().IsDouble());
1850 DCHECK(instr->right()->representation().IsDouble());
1851 left = UseRegisterAtStart(instr->left());
1852 right = UseRegisterAtStart(instr->right());
1858 LInstruction* LChunkBuilder::DoModByPowerOf2I(HMod* instr) {
1859 DCHECK(instr->representation().IsInteger32());
1860 DCHECK(instr->left()->representation().Equals(instr->representation()));
1861 DCHECK(instr->right()->representation().Equals(instr->representation()));
1862 LOperand* dividend = UseRegisterAtStart(instr->left());
1863 int32_t divisor = instr->right()->GetInteger32Constant();
1866 if (instr->CheckFlag(HValue::kLeftCanBeNegative) &&
1867 instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
1874 LInstruction* LChunkBuilder::DoModByConstI(HMod* instr) {
1875 DCHECK(instr->representation().IsInteger32());
1876 DCHECK(instr->left()->representation().Equals(instr->representation()));
1877 DCHECK(instr->right()->representation().Equals(instr->representation()));
1878 LOperand* dividend = UseRegister(instr->left());
1879 int32_t divisor = instr->right()->GetInteger32Constant();
1883 if (divisor == 0 || instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
1890 LInstruction* LChunkBuilder::DoModI(HMod* instr) {
1891 DCHECK(instr->representation().IsSmiOrInteger32());
1892 DCHECK(instr->left()->representation().Equals(instr->representation()));
1893 DCHECK(instr->right()->representation().Equals(instr->representation()));
1894 LOperand* dividend = UseRegister(instr->left());
1895 LOperand* divisor = UseRegister(instr->right());
1897 if (instr->CheckFlag(HValue::kCanBeDivByZero) ||
1898 instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
1905 LInstruction* LChunkBuilder::DoMod(HMod* instr) {
1906 if (instr->representation().IsSmiOrInteger32()) {
1907 if (instr->RightIsPowerOf2()) {
1908 return DoModByPowerOf2I(instr);
1909 } else if (instr->right()->IsConstant()) {
1910 return DoModByConstI(instr);
1912 return DoModI(instr);
1914 } else if (instr->representation().IsDouble()) {
1915 return DoArithmeticD(Token::MOD, instr);
1917 return DoArithmeticT(Token::MOD, instr);
1922 LInstruction* LChunkBuilder::DoMul(HMul* instr) {
1923 if (instr->representation().IsSmiOrInteger32()) {
1924 DCHECK(instr->left()->representation().Equals(instr->representation()));
1925 DCHECK(instr->right()->representation().Equals(instr->representation()));
1927 bool can_overflow = instr->CheckFlag(HValue::kCanOverflow);
1928 bool bailout_on_minus_zero = instr->CheckFlag(HValue::kBailoutOnMinusZero);
1930 HValue* least_const = instr->BetterLeftOperand();
1931 HValue* most_const = instr->BetterRightOperand();
1967 LInstruction* result = instr->representation().IsSmi()
1974 } else if (instr->representation().IsDouble()) {
1975 return DoArithmeticD(Token::MUL, instr);
1977 return DoArithmeticT(Token::MUL, instr);
1982 LInstruction* LChunkBuilder::DoOsrEntry(HOsrEntry* instr) {
1985 current_block_->last_environment()->set_ast_id(instr->ast_id());
1990 LInstruction* LChunkBuilder::DoParameter(HParameter* instr) {
1992 if (instr->kind() == HParameter::STACK_PARAMETER) {
1993 int spill_index = chunk_->GetParameterStackSlot(instr->index());
1999 int index = static_cast<int>(instr->index());
2006 LInstruction* LChunkBuilder::DoPower(HPower* instr) {
2007 DCHECK(instr->representation().IsDouble());
2010 Representation exponent_type = instr->right()->representation();
2011 DCHECK(instr->left()->representation().IsDouble());
2012 LOperand* left = UseFixedDouble(instr->left(), d0);
2015 right = UseFixed(instr->right(), MathPowIntegerDescriptor::exponent());
2017 right = UseFixedDouble(instr->right(), d1);
2019 right = UseFixed(instr->right(), MathPowTaggedDescriptor::exponent());
2023 instr,
2028 LInstruction* LChunkBuilder::DoPushArguments(HPushArguments* instr) {
2029 int argc = instr->OperandCount();
2030 AddInstruction(new(zone()) LPreparePushArguments(argc), instr);
2036 AddInstruction(push_args, instr);
2039 push_args->AddArgument(UseRegister(instr->argument(i)));
2046 LInstruction* LChunkBuilder::DoRegExpLiteral(HRegExpLiteral* instr) {
2047 LOperand* context = UseFixed(instr->context(), cp);
2049 DefineFixed(new(zone()) LRegExpLiteral(context), x0), instr);
2053 LInstruction* LChunkBuilder::DoDoubleBits(HDoubleBits* instr) {
2054 HValue* value = instr->value();
2060 LInstruction* LChunkBuilder::DoConstructDouble(HConstructDouble* instr) {
2061 LOperand* lo = UseRegisterAndClobber(instr->lo());
2062 LOperand* hi = UseRegister(instr->hi());
2067 LInstruction* LChunkBuilder::DoReturn(HReturn* instr) {
2069 ? UseFixed(instr->context(), cp)
2071 LOperand* parameter_count = UseRegisterOrConstant(instr->parameter_count());
2072 return new(zone()) LReturn(UseFixed(instr->value(), x0), context,
2077 LInstruction* LChunkBuilder::DoSeqStringGetChar(HSeqStringGetChar* instr) {
2078 LOperand* string = UseRegisterAtStart(instr->string());
2079 LOperand* index = UseRegisterOrConstantAtStart(instr->index());
2087 LInstruction* LChunkBuilder::DoSeqStringSetChar(HSeqStringSetChar* instr) {
2088 LOperand* string = UseRegister(instr->string());
2090 ? UseRegister(instr->index())
2091 : UseRegisterOrConstant(instr->index());
2092 LOperand* value = UseRegister(instr->value());
2093 LOperand* context = FLAG_debug_code ? UseFixed(instr->context(), cp) : NULL;
2169 HBinaryOperation* instr) {
2171 HBitwiseBinaryOperation* shift = CanTransformToShiftedOp(instr, &left);
2174 return DoShiftedBinaryOp(instr, left, shift);
2213 HBitwiseBinaryOperation* instr) {
2214 if (instr->representation().IsTagged()) {
2215 return DoArithmeticT(op, instr);
2218 DCHECK(instr->representation().IsSmiOrInteger32());
2219 DCHECK(instr->left()->representation().Equals(instr->representation()));
2220 DCHECK(instr->right()->representation().Equals(instr->representation()));
2222 if (ShiftCanBeOptimizedAway(instr)) {
2226 LOperand* left = instr->representation().IsSmi()
2227 ? UseRegister(instr->left())
2228 : UseRegisterAtStart(instr->left());
2229 LOperand* right = UseRegisterOrConstantAtStart(instr->right());
2233 bool right_can_be_zero = !instr->right()->IsConstant() ||
2234 (JSShiftAmountFromHConstant(instr->right()) == 0);
2238 can_deopt = !instr->CheckFlag(HInstruction::kUint32);
2240 can_deopt = !instr->CheckUsesForFlag(HValue::kTruncatingToInt32);
2245 if (instr->representation().IsInteger32()) {
2248 DCHECK(instr->representation().IsSmi());
2256 LInstruction* LChunkBuilder::DoRor(HRor* instr) {
2257 return DoShift(Token::ROR, instr);
2261 LInstruction* LChunkBuilder::DoSar(HSar* instr) {
2262 return DoShift(Token::SAR, instr);
2266 LInstruction* LChunkBuilder::DoShl(HShl* instr) {
2267 return DoShift(Token::SHL, instr);
2271 LInstruction* LChunkBuilder::DoShr(HShr* instr) {
2272 return DoShift(Token::SHR, instr);
2276 LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) {
2277 instr->ReplayEnvironment(current_block_->last_environment());
2282 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) {
2283 if (instr->is_function_entry()) {
2284 LOperand* context = UseFixed(instr->context(), cp);
2285 return MarkAsCall(new(zone()) LStackCheck(context), instr);
2287 DCHECK(instr->is_backwards_branch());
2288 LOperand* context = UseAny(instr->context());
2295 LInstruction* LChunkBuilder::DoStoreCodeEntry(HStoreCodeEntry* instr) {
2296 LOperand* function = UseRegister(instr->function());
2297 LOperand* code_object = UseRegisterAtStart(instr->code_object());
2303 LInstruction* LChunkBuilder::DoStoreContextSlot(HStoreContextSlot* instr) {
2307 if (instr->NeedsWriteBarrier()) {
2310 context = UseRegisterAndClobber(instr->context());
2311 value = UseRegisterAndClobber(instr->value());
2313 context = UseRegister(instr->context());
2314 value = UseRegister(instr->value());
2317 if (instr->RequiresHoleCheck() && instr->DeoptimizesOnHole()) {
2324 LInstruction* LChunkBuilder::DoStoreGlobalCell(HStoreGlobalCell* instr) {
2325 LOperand* value = UseRegister(instr->value());
2326 if (instr->RequiresHoleCheck()) {
2336 LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) {
2337 LOperand* key = UseRegisterOrConstant(instr->key());
2342 if (!instr->is_typed_elements() &&
2343 instr->value()->representation().IsTagged() &&
2344 instr->NeedsWriteBarrier()) {
2346 elements = UseRegisterAndClobber(instr->elements());
2347 val = UseRegisterAndClobber(instr->value());
2350 elements = UseRegister(instr->elements());
2351 val = UseRegister(instr->value());
2352 temp = instr->key()->IsConstant() ? NULL : TempRegister();
2355 if (instr->is_typed_elements()) {
2356 DCHECK((instr->value()->representation().IsInteger32() &&
2357 !IsDoubleOrFloatElementsKind(instr->elements_kind())) ||
2358 (instr->value()->representation().IsDouble() &&
2359 IsDoubleOrFloatElementsKind(instr->elements_kind())));
2360 DCHECK((instr->is_fixed_typed_array() &&
2361 instr->elements()->representation().IsTagged()) ||
2362 (instr->is_external() &&
2363 instr->elements()->representation().IsExternal()));
2366 } else if (instr->value()->representation().IsDouble()) {
2367 DCHECK(instr->elements()->representation().IsTagged());
2371 DCHECK(instr->elements()->representation().IsTagged());
2372 DCHECK(instr->value()->representation().IsSmiOrTagged() ||
2373 instr->value()->representation().IsInteger32());
2379 LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) {
2380 LOperand* context = UseFixed(instr->context(), cp);
2382 UseFixed(instr->object(), StoreDescriptor::ReceiverRegister());
2383 LOperand* key = UseFixed(instr->key(), StoreDescriptor::NameRegister());
2384 LOperand* value = UseFixed(instr->value(), StoreDescriptor::ValueRegister());
2386 DCHECK(instr->object()->representation().IsTagged());
2387 DCHECK(instr->key()->representation().IsTagged());
2388 DCHECK(instr->value()->representation().IsTagged());
2391 new(zone()) LStoreKeyedGeneric(context, object, key, value), instr);
2395 LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) {
2399 LOperand* object = UseRegister(instr->object());
2404 if (instr->access().IsExternalMemory() ||
2405 instr->field_representation().IsDouble()) {
2406 value = UseRegister(instr->value());
2407 } else if (instr->NeedsWriteBarrier()) {
2408 value = UseRegisterAndClobber(instr->value());
2411 } else if (instr->NeedsWriteBarrierForMap()) {
2412 value = UseRegister(instr->value());
2416 value = UseRegister(instr->value());
2424 LInstruction* LChunkBuilder::DoStoreNamedGeneric(HStoreNamedGeneric* instr) {
2425 LOperand* context = UseFixed(instr->context(), cp);
2427 UseFixed(instr->object(), StoreDescriptor::ReceiverRegister());
2428 LOperand* value = UseFixed(instr->value(), StoreDescriptor::ValueRegister());
2431 return MarkAsCall(result, instr);
2435 LInstruction* LChunkBuilder::DoStringAdd(HStringAdd* instr) {
2436 LOperand* context = UseFixed(instr->context(), cp);
2437 LOperand* left = UseFixed(instr->left(), x1);
2438 LOperand* right = UseFixed(instr->right(), x0);
2441 return MarkAsCall(DefineFixed(result, x0), instr);
2445 LInstruction* LChunkBuilder::DoStringCharCodeAt(HStringCharCodeAt* instr) {
2446 LOperand* string = UseRegisterAndClobber(instr->string());
2447 LOperand* index = UseRegisterAndClobber(instr->index());
2448 LOperand* context = UseAny(instr->context());
2455 LInstruction* LChunkBuilder::DoStringCharFromCode(HStringCharFromCode* instr) {
2456 LOperand* char_code = UseRegister(instr->value());
2457 LOperand* context = UseAny(instr->context());
2465 HStringCompareAndBranch* instr) {
2466 DCHECK(instr->left()->representation().IsTagged());
2467 DCHECK(instr->right()->representation().IsTagged());
2468 LOperand* context = UseFixed(instr->context(), cp);
2469 LOperand* left = UseFixed(instr->left(), x1);
2470 LOperand* right = UseFixed(instr->right(), x0);
2473 return MarkAsCall(result, instr);
2477 LInstruction* LChunkBuilder::DoSub(HSub* instr) {
2478 if (instr->representation().IsSmiOrInteger32()) {
2479 DCHECK(instr->left()->representation().Equals(instr->representation()));
2480 DCHECK(instr->right()->representation().Equals(instr->representation()));
2482 LInstruction* shifted_operation = TryDoOpWithShiftedRightOperand(instr);
2488 if (instr->left()->IsConstant() &&
2489 (HConstant::cast(instr->left())->Integer32Value() == 0)) {
2490 left = UseConstant(instr->left());
2492 left = UseRegisterAtStart(instr->left());
2494 LOperand* right = UseRegisterOrConstantAtStart(instr->right());
2495 LInstruction* result = instr->representation().IsSmi() ?
2498 if (instr->CheckFlag(HValue::kCanOverflow)) {
2502 } else if (instr->representation().IsDouble()) {
2503 return DoArithmeticD(Token::SUB, instr);
2505 return DoArithmeticT(Token::SUB, instr);
2510 LInstruction* LChunkBuilder::DoThisFunction(HThisFunction* instr) {
2511 if (instr->HasNoUses()) {
2519 LInstruction* LChunkBuilder::DoToFastProperties(HToFastProperties* instr) {
2520 LOperand* object = UseFixed(instr->value(), x0);
2522 return MarkAsCall(DefineFixed(result, x0), instr);
2527 HTransitionElementsKind* instr) {
2528 if (IsSimpleMapChangeTransition(instr->from_kind(), instr->to_kind())) {
2529 LOperand* object = UseRegister(instr->object());
2535 LOperand* object = UseFixed(instr->object(), x0);
2536 LOperand* context = UseFixed(instr->context(), cp);
2539 return MarkAsCall(result, instr);
2545 HTrapAllocationMemento* instr) {
2546 LOperand* object = UseRegister(instr->object());
2555 LInstruction* LChunkBuilder::DoTypeof(HTypeof* instr) {
2556 LOperand* context = UseFixed(instr->context(), cp);
2562 new(zone()) LTypeof(context, UseRegisterAtStart(instr->value()));
2563 return MarkAsCall(DefineFixed(result, x0), instr);
2567 LInstruction* LChunkBuilder::DoTypeofIsAndBranch(HTypeofIsAndBranch* instr) {
2569 // instr->type_literal() handle to test that here.
2574 UseRegister(instr->value()), temp1, temp2);
2578 LInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) {
2579 switch (instr->op()) {
2581 Representation r = instr->representation();
2585 LOperand* context = UseFixed(instr->context(), cp);
2586 LOperand* input = UseRegister(instr->value());
2594 LOperand* input = UseRegisterAtStart(instr->value());
2601 DCHECK(instr->representation().IsDouble());
2602 DCHECK(instr->value()->representation().IsDouble());
2603 LOperand* input = UseRegister(instr->value());
2613 DCHECK(instr->value()->representation().IsDouble());
2614 LOperand* input = UseRegisterAtStart(instr->value());
2615 if (instr->representation().IsInteger32()) {
2619 DCHECK(instr->representation().IsDouble());
2625 DCHECK(instr->representation().IsDouble());
2626 DCHECK(instr->value()->representation().IsDouble());
2627 LOperand* input = UseFixedDouble(instr->value(), d0);
2629 return MarkAsCall(DefineFixedDouble(result, d0), instr);
2632 DCHECK(instr->representation().IsDouble());
2633 DCHECK(instr->value()->representation().IsDouble());
2634 LOperand* input = UseRegister(instr->value());
2638 DCHECK(instr->value()->representation().IsDouble());
2639 LOperand* input = UseRegister(instr->value());
2640 if (instr->representation().IsInteger32()) {
2645 DCHECK(instr->representation().IsDouble());
2651 DCHECK(instr->value()->representation().IsDouble());
2652 LOperand* input = UseRegister(instr->value());
2657 DCHECK(instr->representation().IsDouble());
2658 DCHECK(instr->value()->representation().IsDouble());
2659 LOperand* input = UseRegisterAtStart(instr->value());
2663 DCHECK(instr->representation().IsInteger32());
2664 DCHECK(instr->value()->representation().IsInteger32());
2665 LOperand* input = UseRegisterAtStart(instr->value());
2675 LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) {
2678 int env_index = instr->index();
2680 if (instr->environment()->is_parameter_index(env_index)) {
2683 spill_index = env_index - instr->environment()->first_local_index();
2693 LInstruction* LChunkBuilder::DoUseConst(HUseConst* instr) {
2698 LInstruction* LChunkBuilder::DoForInPrepareMap(HForInPrepareMap* instr) {
2699 LOperand* context = UseFixed(instr->context(), cp);
2702 LOperand* object = UseFixed(instr->enumerable(), x0);
2704 return MarkAsCall(DefineFixed(result, x0), instr, CAN_DEOPTIMIZE_EAGERLY);
2708 LInstruction* LChunkBuilder::DoForInCacheArray(HForInCacheArray* instr) {
2709 LOperand* map = UseRegister(instr->map());
2714 LInstruction* LChunkBuilder::DoCheckMapValue(HCheckMapValue* instr) {
2715 LOperand* value = UseRegisterAtStart(instr->value());
2716 LOperand* map = UseRegister(instr->map());
2722 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) {
2723 LOperand* object = UseRegisterAtStart(instr->object());
2724 LOperand* index = UseRegisterAndClobber(instr->index());
2731 LInstruction* LChunkBuilder::DoWrapReceiver(HWrapReceiver* instr) {
2732 LOperand* receiver = UseRegister(instr->receiver());
2733 LOperand* function = UseRegister(instr->function());
2739 LInstruction* LChunkBuilder::DoStoreFrameContext(HStoreFrameContext* instr) {
2740 LOperand* context = UseRegisterAtStart(instr->context());
2746 HAllocateBlockContext* instr) {
2747 LOperand* context = UseFixed(instr->context(), cp);
2748 LOperand* function = UseRegisterAtStart(instr->function());
2751 return MarkAsCall(DefineFixed(result, cp), instr);