Lines Matching refs:instr
270 code->instr()->hydrogen_value()->id(),
271 code->instr()->Mnemonic());
680 LInstruction* instr) {
681 CallCodeGeneric(code, mode, instr, RECORD_SIMPLE_SAFEPOINT);
687 LInstruction* instr,
690 ASSERT(instr != NULL);
692 RecordSafepointWithLazyDeopt(instr, safepoint_mode);
698 LInstruction* instr,
700 ASSERT(instr != NULL);
704 RecordSafepointWithLazyDeopt(instr, RECORD_SIMPLE_SAFEPOINT);
725 LInstruction* instr,
730 instr->pointer_map(), argc, Safepoint::kNoLazyDeopt);
911 LInstruction* instr, SafepointMode safepoint_mode) {
913 RecordSafepoint(instr->pointer_map(), Safepoint::kLazyDeopt);
917 instr->pointer_map(), 0, Safepoint::kLazyDeopt);
1014 void LCodeGen::DoInstructionGap(LInstructionGap* instr) {
1015 DoGap(instr);
1019 void LCodeGen::DoParameter(LParameter* instr) {
1024 void LCodeGen::DoCallStub(LCallStub* instr) {
1025 ASSERT(ToRegister(instr->context()).is(cp));
1026 ASSERT(ToRegister(instr->result()).is(v0));
1027 switch (instr->hydrogen()->major_key()) {
1030 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
1035 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
1040 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
1045 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
1050 TranscendentalCacheStub stub(instr->transcendental_type(),
1052 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
1061 void LCodeGen::DoUnknownOSRValue(LUnknownOSRValue* instr) {
1066 void LCodeGen::DoModI(LModI* instr) {
1067 HMod* hmod = instr->hydrogen();
1071 const Register left_reg = ToRegister(instr->left());
1072 const Register result_reg = ToRegister(instr->result());
1084 DeoptimizeIf(eq, instr->environment(), result_reg, Operand(zero_reg));
1095 const Register left_reg = ToRegister(instr->left());
1096 const Register result_reg = ToRegister(instr->result());
1099 Register right_reg = EmitLoadRegister(instr->right(), scratch);
1106 DeoptimizeIf(eq, instr->environment(), right_reg, Operand(zero_reg));
1115 DeoptimizeIf(eq, instr->environment(), right_reg, Operand(-1));
1124 DeoptimizeIf(eq, instr->environment(), result_reg, Operand(zero_reg));
1233 void LCodeGen::DoDivI(LDivI* instr) {
1234 const Register left = ToRegister(instr->left());
1235 const Register right = ToRegister(instr->right());
1236 const Register result = ToRegister(instr->result());
1243 if (instr->hydrogen()->CheckFlag(HValue::kCanBeDivByZero)) {
1244 DeoptimizeIf(eq, instr->environment(), right, Operand(zero_reg));
1248 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
1251 DeoptimizeIf(lt, instr->environment(), right, Operand(zero_reg));
1256 if (instr->hydrogen()->CheckFlag(HValue::kCanOverflow)) {
1259 DeoptimizeIf(eq, instr->environment(), right, Operand(-1));
1263 if (!instr->hydrogen()->CheckFlag(HInstruction::kAllUsesTruncatingToInt32)) {
1265 DeoptimizeIf(ne, instr->environment(), result, Operand(zero_reg));
1271 void LCodeGen::DoMultiplyAddD(LMultiplyAddD* instr) {
1272 DoubleRegister addend = ToDoubleRegister(instr->addend());
1273 DoubleRegister multiplier = ToDoubleRegister(instr->multiplier());
1274 DoubleRegister multiplicand = ToDoubleRegister(instr->multiplicand());
1277 ASSERT(addend.is(ToDoubleRegister(instr->result())));
1283 void LCodeGen::DoMathFloorOfDiv(LMathFloorOfDiv* instr) {
1284 const Register result = ToRegister(instr->result());
1285 const Register left = ToRegister(instr->left());
1286 const Register remainder = ToRegister(instr->temp());
1289 if (instr->right()->IsConstantOperand()) {
1291 int32_t divisor = ToInteger32(LConstantOperand::cast(instr->right()));
1293 DeoptimizeIf(eq, instr->environment(), left, Operand(zero_reg));
1300 instr->environment());
1309 const Register right = ToRegister(instr->right());
1316 DeoptimizeIf(eq, instr->environment(), right, Operand(zero_reg));
1319 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
1322 DeoptimizeIf(lt, instr->environment(), right, Operand(zero_reg));
1327 if (instr->hydrogen()->CheckFlag(HValue::kCanOverflow)) {
1330 DeoptimizeIf(eq, instr->environment(), right, Operand(-1));
1347 void LCodeGen::DoMulI(LMulI* instr) {
1349 Register result = ToRegister(instr->result());
1351 Register left = ToRegister(instr->left());
1352 LOperand* right_op = instr->right();
1355 instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero);
1356 bool overflow = instr->hydrogen()->CheckFlag(HValue::kCanOverflow);
1364 DeoptimizeIf(eq, instr->environment(), left, Operand(zero_reg));
1371 DeoptimizeIf(lt, instr->environment(), scratch, Operand(zero_reg));
1380 DeoptimizeIf(lt, instr->environment(), left, Operand(zero_reg));
1425 if (instr->hydrogen()->representation().IsSmi()) {
1436 DeoptimizeIf(ne, instr->environment(), scratch, Operand(at));
1438 if (instr->hydrogen()->representation().IsSmi()) {
1452 instr->environment(),
1461 void LCodeGen::DoBitI(LBitI* instr) {
1462 LOperand* left_op = instr->left();
1463 LOperand* right_op = instr->right();
1466 Register result = ToRegister(instr->result());
1476 switch (instr->op()) {
1497 void LCodeGen::DoShiftI(LShiftI* instr) {
1500 LOperand* right_op = instr->right();
1501 Register left = ToRegister(instr->left());
1502 Register result = ToRegister(instr->result());
1508 switch (instr->op()) {
1517 if (instr->can_deopt()) {
1518 DeoptimizeIf(lt, instr->environment(), result, Operand(zero_reg));
1532 switch (instr->op()) {
1551 if (instr->can_deopt()) {
1553 DeoptimizeIf(ne, instr->environment(), at, Operand(zero_reg));
1560 if (instr->hydrogen_value()->representation().IsSmi() &&
1561 instr->can_deopt()) {
1568 DeoptimizeIf(lt, instr->environment(), scratch, Operand(zero_reg));
1584 void LCodeGen::DoSubI(LSubI* instr) {
1585 LOperand* left = instr->left();
1586 LOperand* right = instr->right();
1587 LOperand* result = instr->result();
1588 bool can_overflow = instr->hydrogen()->CheckFlag(HValue::kCanOverflow);
1618 DeoptimizeIf(lt, instr->environment(), overflow, Operand(zero_reg));
1623 void LCodeGen::DoConstantI(LConstantI* instr) {
1624 __ li(ToRegister(instr->result()), Operand(instr->value()));
1628 void LCodeGen::DoConstantS(LConstantS* instr) {
1629 __ li(ToRegister(instr->result()), Operand(instr->value()));
1633 void LCodeGen::DoConstantD(LConstantD* instr) {
1634 ASSERT(instr->result()->IsDoubleRegister());
1635 DoubleRegister result = ToDoubleRegister(instr->result());
1636 double v = instr->value();
1641 void LCodeGen::DoConstantE(LConstantE* instr) {
1642 __ li(ToRegister(instr->result()), Operand(instr->value()));
1646 void LCodeGen::DoConstantT(LConstantT* instr) {
1647 Handle<Object> value = instr->value(isolate());
1649 __ li(ToRegister(instr->result()), value);
1653 void LCodeGen::DoMapEnumLength(LMapEnumLength* instr) {
1654 Register result = ToRegister(instr->result());
1655 Register map = ToRegister(instr->value());
1660 void LCodeGen::DoElementsKind(LElementsKind* instr) {
1661 Register result = ToRegister(instr->result());
1662 Register input = ToRegister(instr->value());
1674 void LCodeGen::DoValueOf(LValueOf* instr) {
1675 Register input = ToRegister(instr->value());
1676 Register result = ToRegister(instr->result());
1677 Register map = ToRegister(instr->temp());
1680 if (!instr->hydrogen()->value()->IsHeapObject()) {
1695 void LCodeGen::DoDateField(LDateField* instr) {
1696 Register object = ToRegister(instr->date());
1697 Register result = ToRegister(instr->result());
1698 Register scratch = ToRegister(instr->temp());
1699 Smi* index = instr->index();
1707 DeoptimizeIf(eq, instr->environment(), at, Operand(zero_reg));
1709 DeoptimizeIf(ne, instr->environment(), scratch, Operand(JS_DATE_TYPE));
1758 void LCodeGen::DoSeqStringGetChar(LSeqStringGetChar* instr) {
1759 String::Encoding encoding = instr->hydrogen()->encoding();
1760 Register string = ToRegister(instr->string());
1761 Register result = ToRegister(instr->result());
1777 MemOperand operand = BuildSeqStringOperand(string, instr->index(), encoding);
1786 void LCodeGen::DoSeqStringSetChar(LSeqStringSetChar* instr) {
1787 String::Encoding encoding = instr->hydrogen()->encoding();
1788 Register string = ToRegister(instr->string());
1789 Register value = ToRegister(instr->value());
1793 Register index = ToRegister(instr->index());
1797 instr->hydrogen()->encoding() == String::ONE_BYTE_ENCODING
1802 MemOperand operand = BuildSeqStringOperand(string, instr->index(), encoding);
1811 void LCodeGen::DoThrow(LThrow* instr) {
1812 __ push(ToRegister(instr->value()));
1813 ASSERT(ToRegister(instr->context()).is(cp));
1814 CallRuntime(Runtime::kThrow, 1, instr);
1822 void LCodeGen::DoAddI(LAddI* instr) {
1823 LOperand* left = instr->left();
1824 LOperand* right = instr->right();
1825 LOperand* result = instr->result();
1826 bool can_overflow = instr->hydrogen()->CheckFlag(HValue::kCanOverflow);
1856 DeoptimizeIf(lt, instr->environment(), overflow, Operand(zero_reg));
1861 void LCodeGen::DoMathMinMax(LMathMinMax* instr) {
1862 LOperand* left = instr->left();
1863 LOperand* right = instr->right();
1864 HMathMinMax::Operation operation = instr->hydrogen()->operation();
1866 if (instr->hydrogen()->representation().IsSmiOrInteger32()) {
1871 Register result_reg = ToRegister(instr->result());
1883 ASSERT(instr->hydrogen()->representation().IsDouble());
1886 FPURegister result_reg = ToDoubleRegister(instr->result());
1923 void LCodeGen::DoArithmeticD(LArithmeticD* instr) {
1924 DoubleRegister left = ToDoubleRegister(instr->left());
1925 DoubleRegister right = ToDoubleRegister(instr->right());
1926 DoubleRegister result = ToDoubleRegister(instr->result());
1927 switch (instr->op()) {
1964 void LCodeGen::DoArithmeticT(LArithmeticT* instr) {
1965 ASSERT(ToRegister(instr->context()).is(cp));
1966 ASSERT(ToRegister(instr->left()).is(a1));
1967 ASSERT(ToRegister(instr->right()).is(a0));
1968 ASSERT(ToRegister(instr->result()).is(v0));
1970 BinaryOpICStub stub(instr->op(), NO_OVERWRITE);
1971 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
1979 void LCodeGen::EmitBranch(InstrType instr,
1983 int left_block = instr->TrueDestination(chunk_);
1984 int right_block = instr->FalseDestination(chunk_);
2002 void LCodeGen::EmitBranchF(InstrType instr,
2006 int right_block = instr->FalseDestination(chunk_);
2007 int left_block = instr->TrueDestination(chunk_);
2027 void LCodeGen::EmitFalseBranch(InstrType instr,
2031 int false_block = instr->FalseDestination(chunk_);
2037 void LCodeGen::EmitFalseBranchF(InstrType instr,
2041 int false_block = instr->FalseDestination(chunk_);
2047 void LCodeGen::DoDebugBreak(LDebugBreak* instr) {
2052 void LCodeGen::DoBranch(LBranch* instr) {
2053 Representation r = instr->hydrogen()->value()->representation();
2056 Register reg = ToRegister(instr->value());
2057 EmitBranch(instr, ne, reg, Operand(zero_reg));
2060 DoubleRegister reg = ToDoubleRegister(instr->value());
2062 EmitBranchF(instr, nue, reg, kDoubleRegZero);
2065 Register reg = ToRegister(instr->value());
2066 HType type = instr->hydrogen()->value()->type();
2070 EmitBranch(instr, eq, reg, Operand(at));
2073 EmitBranch(instr, ne, reg, Operand(zero_reg));
2076 EmitBranch(instr, al, zero_reg, Operand(zero_reg));
2082 EmitBranchF(instr, nue, dbl_scratch, kDoubleRegZero);
2086 EmitBranch(instr, ne, at, Operand(zero_reg));
2088 ToBooleanStub::Types expected = instr->hydrogen()->expected_input_types();
2095 __ Branch(instr->FalseLabel(chunk_), eq, reg, Operand(at));
2100 __ Branch(instr->TrueLabel(chunk_), eq, reg, Operand(at));
2102 __ Branch(instr->FalseLabel(chunk_), eq, reg, Operand(at));
2107 __ Branch(instr->FalseLabel(chunk_), eq, reg, Operand(at));
2112 __ Branch(instr->FalseLabel(chunk_), eq, reg, Operand(zero_reg));
2113 __ JumpIfSmi(reg, instr->TrueLabel(chunk_));
2117 DeoptimizeIf(eq, instr->environment(), at, Operand(zero_reg));
2127 __ Branch(instr->FalseLabel(chunk_), ne, at, Operand(zero_reg));
2134 __ Branch(instr->TrueLabel(chunk_),
2144 __ Branch(instr->TrueLabel(chunk_), ne, at, Operand(zero_reg));
2145 __ Branch(instr->FalseLabel(chunk_));
2153 __ Branch(instr->TrueLabel(chunk_), eq, scratch, Operand(SYMBOL_TYPE));
2163 __ BranchF(instr->TrueLabel(chunk_), instr->FalseLabel(chunk_),
2166 __ Branch(instr->FalseLabel(chunk_));
2173 DeoptimizeIf(al, instr->environment(), zero_reg, Operand(zero_reg));
2187 void LCodeGen::DoGoto(LGoto* instr) {
2188 EmitGoto(instr->block_id());
2224 void LCodeGen::DoCompareNumericAndBranch(LCompareNumericAndBranch* instr) {
2225 LOperand* left = instr->left();
2226 LOperand* right = instr->right();
2227 Condition cond = TokenToCondition(instr->op(), false);
2233 int next_block = EvalComparison(instr->op(), left_val, right_val) ?
2234 instr->TrueDestination(chunk_) : instr->FalseDestination(chunk_);
2237 if (instr->is_double()) {
2245 __ BranchF(NULL, instr->FalseLabel(chunk_), eq,
2248 EmitBranchF(instr, cond, left_reg, right_reg);
2255 if (instr->hydrogen_value()->representation().IsSmi()) {
2264 if (instr->hydrogen_value()->representation().IsSmi()) {
2278 EmitBranch(instr, cond, cmp_left, cmp_right);
2284 void LCodeGen::DoCmpObjectEqAndBranch(LCmpObjectEqAndBranch* instr) {
2285 Register left = ToRegister(instr->left());
2286 Register right = ToRegister(instr->right());
2288 EmitBranch(instr, eq, left, Operand(right));
2292 void LCodeGen::DoCmpHoleAndBranch(LCmpHoleAndBranch* instr) {
2293 if (instr->hydrogen()->representation().IsTagged()) {
2294 Register input_reg = ToRegister(instr->object());
2296 EmitBranch(instr, eq, input_reg, Operand(at));
2300 DoubleRegister input_reg = ToDoubleRegister(instr->object());
2301 EmitFalseBranchF(instr, eq, input_reg, input_reg);
2305 EmitBranch(instr, eq, scratch, Operand(kHoleNanUpper32));
2309 void LCodeGen::DoCompareMinusZeroAndBranch(LCompareMinusZeroAndBranch* instr) {
2310 Representation rep = instr->hydrogen()->value()->representation();
2312 Register scratch = ToRegister(instr->temp());
2315 DoubleRegister value = ToDoubleRegister(instr->value());
2316 EmitFalseBranchF(instr, ne, value, kDoubleRegZero);
2320 Register value = ToRegister(instr->value());
2324 instr->FalseLabel(chunk()),
2327 EmitFalseBranch(instr, ne, scratch, Operand(0x80000000));
2331 EmitBranch(instr, eq, scratch, Operand(at));
2361 void LCodeGen::DoIsObjectAndBranch(LIsObjectAndBranch* instr) {
2362 Register reg = ToRegister(instr->value());
2363 Register temp1 = ToRegister(instr->temp());
2368 instr->FalseLabel(chunk_), instr->TrueLabel(chunk_));
2370 EmitBranch(instr, true_cond, temp2,
2388 void LCodeGen::DoIsStringAndBranch(LIsStringAndBranch* instr) {
2389 Register reg = ToRegister(instr->value());
2390 Register temp1 = ToRegister(instr->temp());
2393 instr->hydrogen()->value()->IsHeapObject()
2396 EmitIsString(reg, temp1, instr->FalseLabel(chunk_), check_needed);
2398 EmitBranch(instr, true_cond, temp1,
2403 void LCodeGen::DoIsSmiAndBranch(LIsSmiAndBranch* instr) {
2404 Register input_reg = EmitLoadRegister(instr->value(), at);
2406 EmitBranch(instr, eq, at, Operand(zero_reg));
2410 instr) {
2411 Register input = ToRegister(instr->value());
2412 Register temp = ToRegister(instr->temp());
2414 if (!instr->hydrogen()->value()->IsHeapObject()) {
2415 __ JumpIfSmi(input, instr->FalseLabel(chunk_));
2420 EmitBranch(instr, ne, at, Operand(zero_reg));
2444 void LCodeGen::DoStringCompareAndBranch(LStringCompareAndBranch* instr) {
2445 ASSERT(ToRegister(instr->context()).is(cp));
2446 Token::Value op = instr->op();
2449 CallCode(ic, RelocInfo::CODE_TARGET, instr);
2453 EmitBranch(instr, condition, v0, Operand(zero_reg));
2457 static InstanceType TestType(HHasInstanceTypeAndBranch* instr) {
2458 InstanceType from = instr->from();
2459 InstanceType to = instr->to();
2466 static Condition BranchCondition(HHasInstanceTypeAndBranch* instr) {
2467 InstanceType from = instr->from();
2468 InstanceType to = instr->to();
2477 void LCodeGen::DoHasInstanceTypeAndBranch(LHasInstanceTypeAndBranch* instr) {
2479 Register input = ToRegister(instr->value());
2481 if (!instr->hydrogen()->value()->IsHeapObject()) {
2482 __ JumpIfSmi(input, instr->FalseLabel(chunk_));
2486 EmitBranch(instr,
2487 BranchCondition(instr->hydrogen()),
2489 Operand(TestType(instr->hydrogen())));
2493 void LCodeGen::DoGetCachedArrayIndex(LGetCachedArrayIndex* instr) {
2494 Register input = ToRegister(instr->value());
2495 Register result = ToRegister(instr->result());
2505 LHasCachedArrayIndexAndBranch* instr) {
2506 Register input = ToRegister(instr->value());
2512 EmitBranch(instr, eq, at, Operand(zero_reg));
2582 void LCodeGen::DoClassOfTestAndBranch(LClassOfTestAndBranch* instr) {
2583 Register input = ToRegister(instr->value());
2585 Register temp2 = ToRegister(instr->temp());
2586 Handle<String> class_name = instr->hydrogen()->class_name();
2588 EmitClassOfTest(instr->TrueLabel(chunk_), instr->FalseLabel(chunk_),
2591 EmitBranch(instr, eq, temp, Operand(class_name));
2595 void LCodeGen::DoCmpMapAndBranch(LCmpMapAndBranch* instr) {
2596 Register reg = ToRegister(instr->value());
2597 Register temp = ToRegister(instr->temp());
2600 EmitBranch(instr, eq, temp, Operand(instr->map()));
2604 void LCodeGen::DoInstanceOf(LInstanceOf* instr) {
2605 ASSERT(ToRegister(instr->context()).is(cp));
2607 ASSERT(ToRegister(instr->left()).is(a0)); // Object is in a0.
2608 ASSERT(ToRegister(instr->right()).is(a1)); // Function is in a1.
2609 Register result = ToRegister(instr->result());
2613 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
2624 void LCodeGen::DoInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr) {
2628 LInstanceOfKnownGlobal* instr)
2629 : LDeferredCode(codegen), instr_(instr) { }
2633 virtual LInstruction* instr() V8_OVERRIDE { return instr_; }
2642 deferred = new(zone()) DeferredInstanceOfKnownGlobal(this, instr);
2645 Register object = ToRegister(instr->value());
2646 Register temp = ToRegister(instr->temp());
2647 Register result = ToRegister(instr->result());
2701 void LCodeGen::DoDeferredInstanceOfKnownGlobal(LInstanceOfKnownGlobal* instr,
2703 Register result = ToRegister(instr->result());
2716 LoadContextFromDeferred(instr->context());
2721 Register temp = ToRegister(instr->temp());
2723 __ li(InstanceofStub::right(), instr->function());
2735 instr,
2737 LEnvironment* env = instr->GetDeferredLazyDeoptimizationEnvironment();
2745 void LCodeGen::DoCmpT(LCmpT* instr) {
2746 ASSERT(ToRegister(instr->context()).is(cp));
2747 Token::Value op = instr->op();
2750 CallCode(ic, RelocInfo::CODE_TARGET, instr);
2760 __ LoadRoot(ToRegister(instr->result()), Heap::kTrueValueRootIndex);
2762 __ LoadRoot(ToRegister(instr->result()), Heap::kFalseValueRootIndex);
2767 void LCodeGen::DoReturn(LReturn* instr) {
2786 if (instr->has_constant_parameter_count()) {
2787 int parameter_count = ToInteger32(instr->constant_parameter_count());
2793 Register reg = ToRegister(instr->parameter_count());
2808 void LCodeGen::DoLoadGlobalCell(LLoadGlobalCell* instr) {
2809 Register result = ToRegister(instr->result());
2810 __ li(at, Operand(Handle<Object>(instr->hydrogen()->cell().handle())));
2812 if (instr->hydrogen()->RequiresHoleCheck()) {
2814 DeoptimizeIf(eq, instr->environment(), result, Operand(at));
2819 void LCodeGen::DoLoadGlobalGeneric(LLoadGlobalGeneric* instr) {
2820 ASSERT(ToRegister(instr->context()).is(cp));
2821 ASSERT(ToRegister(instr->global_object()).is(a0));
2822 ASSERT(ToRegister(instr->result()).is(v0));
2824 __ li(a2, Operand(instr->name()));
2825 RelocInfo::Mode mode = instr->for_typeof() ? RelocInfo::CODE_TARGET
2828 CallCode(ic, mode, instr);
2832 void LCodeGen::DoStoreGlobalCell(LStoreGlobalCell* instr) {
2833 Register value = ToRegister(instr->value());
2837 __ li(cell, Operand(instr->hydrogen()->cell().handle()));
2843 if (instr->hydrogen()->RequiresHoleCheck()) {
2845 Register payload = ToRegister(instr->temp());
2848 DeoptimizeIf(eq, instr->environment(), payload, Operand(at));
2857 void LCodeGen::DoStoreGlobalGeneric(LStoreGlobalGeneric* instr) {
2858 ASSERT(ToRegister(instr->context()).is(cp));
2859 ASSERT(ToRegister(instr->global_object()).is(a1));
2860 ASSERT(ToRegister(instr->value()).is(a0));
2862 __ li(a2, Operand(instr->name()));
2863 Handle<Code> ic = (instr->strict_mode_flag() == kStrictMode)
2866 CallCode(ic, RelocInfo::CODE_TARGET_CONTEXT, instr);
2870 void LCodeGen::DoLoadContextSlot(LLoadContextSlot* instr) {
2871 Register context = ToRegister(instr->context());
2872 Register result = ToRegister(instr->result());
2874 __ lw(result, ContextOperand(context, instr->slot_index()));
2875 if (instr->hydrogen()->RequiresHoleCheck()) {
2878 if (instr->hydrogen()->DeoptimizesOnHole()) {
2879 DeoptimizeIf(eq, instr->environment(), result, Operand(at));
2890 void LCodeGen::DoStoreContextSlot(LStoreContextSlot* instr) {
2891 Register context = ToRegister(instr->context());
2892 Register value = ToRegister(instr->value());
2894 MemOperand target = ContextOperand(context, instr->slot_index());
2898 if (instr->hydrogen()->RequiresHoleCheck()) {
2902 if (instr->hydrogen()->DeoptimizesOnHole()) {
2903 DeoptimizeIf(eq, instr->environment(), scratch, Operand(at));
2910 if (instr->hydrogen()->NeedsWriteBarrier()) {
2912 instr->hydrogen()->value()->IsHeapObject()
2928 void LCodeGen::DoLoadNamedField(LLoadNamedField* instr) {
2929 HObjectAccess access = instr->hydrogen()->access();
2931 Register object = ToRegister(instr->object());
2934 Register result = ToRegister(instr->result());
2940 if (instr->hydrogen()->representation().IsDouble()) {
2941 DoubleRegister result = ToDoubleRegister(instr->result());
2946 Register result = ToRegister(instr->result());
2956 void LCodeGen::DoLoadNamedGeneric(LLoadNamedGeneric* instr) {
2957 ASSERT(ToRegister(instr->context()).is(cp));
2958 ASSERT(ToRegister(instr->object()).is(a0));
2959 ASSERT(ToRegister(instr->result()).is(v0));
2962 __ li(a2, Operand(instr->name()));
2964 CallCode(ic, RelocInfo::CODE_TARGET, instr);
2968 void LCodeGen::DoLoadFunctionPrototype(LLoadFunctionPrototype* instr) {
2970 Register function = ToRegister(instr->function());
2971 Register result = ToRegister(instr->result());
2976 DeoptimizeIf(ne, instr->environment(), scratch, Operand(JS_FUNCTION_TYPE));
2990 DeoptimizeIf(eq, instr->environment(), result, Operand(at));
3011 void LCodeGen::DoLoadRoot(LLoadRoot* instr) {
3012 Register result = ToRegister(instr->result());
3013 __ LoadRoot(result, instr->index());
3018 LLoadExternalArrayPointer* instr) {
3019 Register to_reg = ToRegister(instr->result());
3020 Register from_reg = ToRegister(instr->object());
3026 void LCodeGen::DoAccessArgumentsAt(LAccessArgumentsAt* instr) {
3027 Register arguments = ToRegister(instr->arguments());
3028 Register result = ToRegister(instr->result());
3031 if (instr->length()->IsConstantOperand()) {
3032 int const_length = ToInteger32(LConstantOperand::cast(instr->length()));
3033 if (instr->index()->IsConstantOperand()) {
3034 int const_index = ToInteger32(LConstantOperand::cast(instr->index()));
3038 Register index = ToRegister(instr->index());
3045 } else if (instr->index()->IsConstantOperand()) {
3046 Register length = ToRegister(instr->length());
3047 int const_index = ToInteger32(LConstantOperand::cast(instr->index()));
3060 Register length = ToRegister(instr->length());
3061 Register index = ToRegister(instr->index());
3071 void LCodeGen::DoLoadKeyedExternalArray(LLoadKeyed* instr) {
3072 Register external_pointer = ToRegister(instr->elements());
3074 ElementsKind elements_kind = instr->elements_kind();
3075 bool key_is_constant = instr->key()->IsConstantOperand();
3078 constant_key = ToInteger32(LConstantOperand::cast(instr->key()));
3083 key = ToRegister(instr->key());
3086 int shift_size = (instr->hydrogen()->key()->representation().IsSmi())
3088 int additional_offset = instr->additional_index() << element_size_shift;
3092 FPURegister result = ToDoubleRegister(instr->result());
3106 Register result = ToRegister(instr->result());
3110 instr->additional_index(), additional_offset);
3130 if (!instr->hydrogen()->CheckFlag(HInstruction::kUint32)) {
3131 DeoptimizeIf(Ugreater_equal, instr->environment(),
3152 void LCodeGen::DoLoadKeyedFixedDoubleArray(LLoadKeyed* instr) {
3153 Register elements = ToRegister(instr->elements());
3154 bool key_is_constant = instr->key()->IsConstantOperand();
3156 DoubleRegister result = ToDoubleRegister(instr->result());
3163 (instr->additional_index() << element_size_shift);
3165 int constant_key = ToInteger32(LConstantOperand::cast(instr->key()));
3174 key = ToRegister(instr->key());
3175 int shift_size = (instr->hydrogen()->key()->representation().IsSmi())
3183 if (instr->hydrogen()->RequiresHoleCheck()) {
3185 DeoptimizeIf(eq, instr->environment(), scratch, Operand(kHoleNanUpper32));
3190 void LCodeGen::DoLoadKeyedFixedArray(LLoadKeyed* instr) {
3191 Register elements = ToRegister(instr->elements());
3192 Register result = ToRegister(instr->result());
3197 if (instr->key()->IsConstantOperand()) {
3198 LConstantOperand* const_operand = LConstantOperand::cast(instr->key());
3200 instr->additional_index());
3203 Register key = ToRegister(instr->key());
3208 if (instr->hydrogen()->key()->representation().IsSmi()) {
3215 offset = FixedArray::OffsetOfElementAt(instr->additional_index());
3220 if (instr->hydrogen()->RequiresHoleCheck()) {
3221 if (IsFastSmiElementsKind(instr->hydrogen()->elements_kind())) {
3223 DeoptimizeIf(ne, instr->environment(), scratch, Operand(zero_reg));
3226 DeoptimizeIf(eq, instr->environment(), result, Operand(scratch));
3232 void LCodeGen::DoLoadKeyed(LLoadKeyed* instr) {
3233 if (instr->is_external()) {
3234 DoLoadKeyedExternalArray(instr);
3235 } else if (instr->hydrogen()->representation().IsDouble()) {
3236 DoLoadKeyedFixedDoubleArray(instr);
3238 DoLoadKeyedFixedArray(instr);
3287 void LCodeGen::DoLoadKeyedGeneric(LLoadKeyedGeneric* instr) {
3288 ASSERT(ToRegister(instr->context()).is(cp));
3289 ASSERT(ToRegister(instr->object()).is(a1));
3290 ASSERT(ToRegister(instr->key()).is(a0));
3293 CallCode(ic, RelocInfo::CODE_TARGET, instr);
3297 void LCodeGen::DoArgumentsElements(LArgumentsElements* instr) {
3300 Register result = ToRegister(instr->result());
3302 if (instr->hydrogen()->from_inlined()) {
3319 void LCodeGen::DoArgumentsLength(LArgumentsLength* instr) {
3320 Register elem = ToRegister(instr->elements());
3321 Register result = ToRegister(instr->result());
3340 void LCodeGen::DoWrapReceiver(LWrapReceiver* instr) {
3341 Register receiver = ToRegister(instr->receiver());
3342 Register function = ToRegister(instr->function());
3343 Register result = ToRegister(instr->result());
3373 DeoptimizeIf(eq, instr->environment(), scratch, Operand(zero_reg));
3376 DeoptimizeIf(lt, instr->environment(),
3398 void LCodeGen::DoApplyArguments(LApplyArguments* instr) {
3399 Register receiver = ToRegister(instr->receiver());
3400 Register function = ToRegister(instr->function());
3401 Register length = ToRegister(instr->length());
3402 Register elements = ToRegister(instr->elements());
3406 ASSERT(ToRegister(instr->result()).is(v0));
3411 DeoptimizeIf(hi, instr->environment(), length, Operand(kArgumentsLimit));
3435 ASSERT(instr->HasPointerMap());
3436 LPointerMap* pointers = instr->pointer_map();
3447 void LCodeGen::DoPushArgument(LPushArgument* instr) {
3448 LOperand* argument = instr->value();
3458 void LCodeGen::DoDrop(LDrop* instr) {
3459 __ Drop(instr->count());
3463 void LCodeGen::DoThisFunction(LThisFunction* instr) {
3464 Register result = ToRegister(instr->result());
3469 void LCodeGen::DoContext(LContext* instr) {
3471 Register result = ToRegister(instr->result());
3481 void LCodeGen::DoOuterContext(LOuterContext* instr) {
3482 Register context = ToRegister(instr->context());
3483 Register result = ToRegister(instr->result());
3489 void LCodeGen::DoDeclareGlobals(LDeclareGlobals* instr) {
3490 ASSERT(ToRegister(instr->context()).is(cp));
3491 __ li(scratch0(), instr->hydrogen()->pairs());
3492 __ li(scratch1(), Operand(Smi::FromInt(instr->hydrogen()->flags())));
3495 CallRuntime(Runtime::kDeclareGlobals, 3, instr);
3499 void LCodeGen::DoGlobalObject(LGlobalObject* instr) {
3500 Register context = ToRegister(instr->context());
3501 Register result = ToRegister(instr->result());
3506 void LCodeGen::DoGlobalReceiver(LGlobalReceiver* instr) {
3507 Register global = ToRegister(instr->global_object());
3508 Register result = ToRegister(instr->result());
3516 LInstruction* instr,
3524 LPointerMap* pointers = instr->pointer_map();
3546 RecordSafepointWithLazyDeopt(instr, RECORD_SIMPLE_SAFEPOINT);
3557 void LCodeGen::DoCallConstantFunction(LCallConstantFunction* instr) {
3558 ASSERT(ToRegister(instr->result()).is(v0));
3560 CallKnownFunction(instr->hydrogen()->function(),
3561 instr->hydrogen()->formal_parameter_count(),
3562 instr->arity(),
3563 instr,
3569 void LCodeGen::DoDeferredMathAbsTaggedHeapNumber(LMathAbs* instr) {
3570 ASSERT(instr->context() != NULL);
3571 ASSERT(ToRegister(instr->context()).is(cp));
3572 Register input = ToRegister(instr->value());
3573 Register result = ToRegister(instr->result());
3579 DeoptimizeIf(ne, instr->environment(), scratch, Operand(at));
3613 CallRuntimeFromDeferred(Runtime::kAllocateHeapNumber, 0, instr,
3614 instr->context());
3637 void LCodeGen::EmitIntegerMathAbs(LMathAbs* instr) {
3638 Register input = ToRegister(instr->value());
3639 Register result = ToRegister(instr->result());
3646 DeoptimizeIf(lt, instr->environment(), result, Operand(zero_reg));
3651 void LCodeGen::DoMathAbs(LMathAbs* instr) {
3655 DeferredMathAbsTaggedHeapNumber(LCodeGen* codegen, LMathAbs* instr)
3656 : LDeferredCode(codegen), instr_(instr) { }
3660 virtual LInstruction* instr() V8_OVERRIDE { return instr_; }
3665 Representation r = instr->hydrogen()->value()->representation();
3667 FPURegister input = ToDoubleRegister(instr->value());
3668 FPURegister result = ToDoubleRegister(instr->result());
3671 EmitIntegerMathAbs(instr);
3675 new(zone()) DeferredMathAbsTaggedHeapNumber(this, instr);
3676 Register input = ToRegister(instr->value());
3680 EmitIntegerMathAbs(instr);
3686 void LCodeGen::DoMathFloor(LMathFloor* instr) {
3687 DoubleRegister input = ToDoubleRegister(instr->value());
3688 Register result = ToRegister(instr->result());
3690 Register except_flag = ToRegister(instr->temp());
3700 DeoptimizeIf(ne, instr->environment(), except_flag, Operand(zero_reg));
3702 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
3708 DeoptimizeIf(ne, instr->environment(), scratch1, Operand(zero_reg));
3714 void LCodeGen::DoMathRound(LMathRound* instr) {
3715 DoubleRegister input = ToDoubleRegister(instr->value());
3716 Register result = ToRegister(instr->result());
3717 DoubleRegister double_scratch1 = ToDoubleRegister(instr->temp());
3732 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
3741 DeoptimizeIf(ge, instr->environment(), scratch,
3754 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
3756 DeoptimizeIf(lt, instr->environment(), result,
3776 DeoptimizeIf(ne, instr->environment(), except_flag, Operand(zero_reg));
3778 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
3784 DeoptimizeIf(ne, instr->environment(), scratch, Operand(zero_reg));
3790 void LCodeGen::DoMathSqrt(LMathSqrt* instr) {
3791 DoubleRegister input = ToDoubleRegister(instr->value());
3792 DoubleRegister result = ToDoubleRegister(instr->result());
3797 void LCodeGen::DoMathPowHalf(LMathPowHalf* instr) {
3798 DoubleRegister input = ToDoubleRegister(instr->value());
3799 DoubleRegister result = ToDoubleRegister(instr->result());
3800 DoubleRegister temp = ToDoubleRegister(instr->temp());
3821 void LCodeGen::DoPower(LPower* instr) {
3822 Representation exponent_type = instr->hydrogen()->right()->representation();
3825 ASSERT(!instr->right()->IsDoubleRegister() ||
3826 ToDoubleRegister(instr->right()).is(f4));
3827 ASSERT(!instr->right()->IsRegister() ||
3828 ToRegister(instr->right()).is(a2));
3829 ASSERT(ToDoubleRegister(instr->left()).is(f2));
3830 ASSERT(ToDoubleRegister(instr->result()).is(f0));
3839 DeoptimizeIf(ne, instr->environment(), t3, Operand(at));
3854 void LCodeGen::DoMathExp(LMathExp* instr) {
3855 DoubleRegister input = ToDoubleRegister(instr->value());
3856 DoubleRegister result = ToDoubleRegister(instr->result());
3857 DoubleRegister double_scratch1 = ToDoubleRegister(instr->double_temp());
3859 Register temp1 = ToRegister(instr->temp1());
3860 Register temp2 = ToRegister(instr->temp2());
3868 void LCodeGen::DoMathLog(LMathLog* instr) {
3869 ASSERT(ToDoubleRegister(instr->result()).is(f4));
3875 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
3879 void LCodeGen::DoMathTan(LMathTan* instr) {
3880 ASSERT(ToDoubleRegister(instr->result()).is(f4));
3886 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
3890 void LCodeGen::DoMathCos(LMathCos* instr) {
3891 ASSERT(ToDoubleRegister(instr->result()).is(f4));
3897 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
3901 void LCodeGen::DoMathSin(LMathSin* instr) {
3902 ASSERT(ToDoubleRegister(instr->result()).is(f4));
3908 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
3912 void LCodeGen::DoInvokeFunction(LInvokeFunction* instr) {
3913 ASSERT(ToRegister(instr->context()).is(cp));
3914 ASSERT(ToRegister(instr->function()).is(a1));
3915 ASSERT(instr->HasPointerMap());
3917 Handle<JSFunction> known_function = instr->hydrogen()->known_function();
3919 LPointerMap* pointers = instr->pointer_map();
3921 ParameterCount count(instr->arity());
3925 instr->hydrogen()->formal_parameter_count(),
3926 instr->arity(),
3927 instr,
3934 void LCodeGen::DoCallKeyed(LCallKeyed* instr) {
3935 ASSERT(ToRegister(instr->context()).is(cp));
3936 ASSERT(ToRegister(instr->result()).is(v0));
3938 int arity = instr->arity();
3941 CallCode(ic, RelocInfo::CODE_TARGET, instr);
3945 void LCodeGen::DoCallNamed(LCallNamed* instr) {
3946 ASSERT(ToRegister(instr->context()).is(cp));
3947 ASSERT(ToRegister(instr->result()).is(v0));
3949 int arity = instr->arity();
3953 __ li(a2, Operand(instr->name()));
3954 CallCode(ic, mode, instr);
3958 void LCodeGen::DoCallFunction(LCallFunction* instr) {
3959 ASSERT(ToRegister(instr->context()).is(cp));
3960 ASSERT(ToRegister(instr->function()).is(a1));
3961 ASSERT(ToRegister(instr->result()).is(v0));
3963 int arity = instr->arity();
3965 if (instr->hydrogen()->IsTailCall()) {
3969 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
3974 void LCodeGen::DoCallGlobal(LCallGlobal* instr) {
3975 ASSERT(ToRegister(instr->context()).is(cp));
3976 ASSERT(ToRegister(instr->result()).is(v0));
3978 int arity = instr->arity();
3982 __ li(a2, Operand(instr->name()));
3983 CallCode(ic, mode, instr);
3987 void LCodeGen::DoCallKnownGlobal(LCallKnownGlobal* instr) {
3988 ASSERT(ToRegister(instr->result()).is(v0));
3989 CallKnownFunction(instr->hydrogen()->target(),
3990 instr->hydrogen()->formal_parameter_count(),
3991 instr->arity(),
3992 instr,
3998 void LCodeGen::DoCallNew(LCallNew* instr) {
3999 ASSERT(ToRegister(instr->context()).is(cp));
4000 ASSERT(ToRegister(instr->constructor()).is(a1));
4001 ASSERT(ToRegister(instr->result()).is(v0));
4003 __ li(a0, Operand(instr->arity()));
4008 CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr);
4012 void LCodeGen::DoCallNewArray(LCallNewArray* instr) {
4013 ASSERT(ToRegister(instr->context()).is(cp));
4014 ASSERT(ToRegister(instr->constructor()).is(a1));
4015 ASSERT(ToRegister(instr->result()).is(v0));
4017 __ li(a0, Operand(instr->arity()));
4018 __ li(a2, Operand(instr->hydrogen()->property_cell()));
4019 ElementsKind kind = instr->hydrogen()->elements_kind();
4026 if (instr->arity() == 0) {
4028 CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr);
4029 } else if (instr->arity() == 1) {
4041 CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr);
4047 CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr);
4051 CallCode(stub.GetCode(isolate()), RelocInfo::CONSTRUCT_CALL, instr);
4056 void LCodeGen::DoCallRuntime(LCallRuntime* instr) {
4057 CallRuntime(instr->function(), instr->arity(), instr);
4061 void LCodeGen::DoStoreCodeEntry(LStoreCodeEntry* instr) {
4062 Register function = ToRegister(instr->function());
4063 Register code_object = ToRegister(instr->code_object());
4071 void LCodeGen::DoInnerAllocatedObject(LInnerAllocatedObject* instr) {
4072 Register result = ToRegister(instr->result());
4073 Register base = ToRegister(instr->base_object());
4074 if (instr->offset()->IsConstantOperand()) {
4075 LConstantOperand* offset = LConstantOperand::cast(instr->offset());
4078 Register offset = ToRegister(instr->offset());
4084 void LCodeGen::DoStoreNamedField(LStoreNamedField* instr) {
4085 Representation representation = instr->representation();
4087 Register object = ToRegister(instr->object());
4089 HObjectAccess access = instr->hydrogen()->access();
4093 Register value = ToRegister(instr->value());
4099 Handle<Map> transition = instr->transition();
4102 Register value = ToRegister(instr->value());
4103 if (!instr->hydrogen()->value()->type().IsHeapObject()) {
4105 DeoptimizeIf(eq, instr->environment(), scratch, Operand(zero_reg));
4110 ASSERT(!instr->hydrogen()->NeedsWriteBarrier());
4111 DoubleRegister value = ToDoubleRegister(instr->value());
4119 if (instr->hydrogen()->NeedsWriteBarrierForMap()) {
4120 Register temp = ToRegister(instr->temp());
4134 Register value = ToRegister(instr->value());
4137 instr->hydrogen()->value()->IsHeapObject()
4142 if (instr->hydrogen()->NeedsWriteBarrier()) {
4157 if (instr->hydrogen()->NeedsWriteBarrier()) {
4173 void LCodeGen::DoStoreNamedGeneric(LStoreNamedGeneric* instr) {
4174 ASSERT(ToRegister(instr->context()).is(cp));
4175 ASSERT(ToRegister(instr->object()).is(a1));
4176 ASSERT(ToRegister(instr->value()).is(a0));
4179 __ li(a2, Operand(instr->name()));
4180 Handle<Code> ic = (instr->strict_mode_flag() == kStrictMode)
4183 CallCode(ic, RelocInfo::CODE_TARGET, instr);
4202 void LCodeGen::DoBoundsCheck(LBoundsCheck* instr) {
4203 if (instr->hydrogen()->skip_check()) return;
4205 Condition condition = instr->hydrogen()->allow_equality() ? hi : hs;
4206 if (instr->index()->IsConstantOperand()) {
4208 ToInteger32(LConstantOperand::cast(instr->index()));
4209 if (instr->hydrogen()->length()->representation().IsSmi()) {
4215 instr,
4217 Operand(ToRegister(instr->length())));
4220 instr,
4221 ToRegister(instr->index()),
4222 Operand(ToRegister(instr->length())));
4227 void LCodeGen::DoStoreKeyedExternalArray(LStoreKeyed* instr) {
4228 Register external_pointer = ToRegister(instr->elements());
4230 ElementsKind elements_kind = instr->elements_kind();
4231 bool key_is_constant = instr->key()->IsConstantOperand();
4234 constant_key = ToInteger32(LConstantOperand::cast(instr->key()));
4239 key = ToRegister(instr->key());
4242 int shift_size = (instr->hydrogen()->key()->representation().IsSmi())
4244 int additional_offset = instr->additional_index() << element_size_shift;
4249 FPURegister value(ToDoubleRegister(instr->value()));
4269 Register value(ToRegister(instr->value()));
4273 instr->additional_index(), additional_offset);
4305 void LCodeGen::DoStoreKeyedFixedDoubleArray(LStoreKeyed* instr) {
4306 DoubleRegister value = ToDoubleRegister(instr->value());
4307 Register elements = ToRegister(instr->elements());
4310 bool key_is_constant = instr->key()->IsConstantOperand();
4317 int constant_key = ToInteger32(LConstantOperand::cast(instr->key()));
4325 int shift_size = (instr->hydrogen()->key()->representation().IsSmi())
4329 __ sll(at, ToRegister(instr->key()), shift_size);
4333 if (instr->NeedsCanonicalization()) {
4343 __ sdc1(double_scratch, MemOperand(scratch, instr->additional_index() <<
4349 __ sdc1(value, MemOperand(scratch, instr->additional_index() <<
4355 void LCodeGen::DoStoreKeyedFixedArray(LStoreKeyed* instr) {
4356 Register value = ToRegister(instr->value());
4357 Register elements = ToRegister(instr->elements());
4358 Register key = instr->key()->IsRegister() ? ToRegister(instr->key())
4365 if (instr->key()->IsConstantOperand()) {
4366 ASSERT(!instr->hydrogen()->NeedsWriteBarrier());
4367 LConstantOperand* const_operand = LConstantOperand::cast(instr->key());
4369 instr->additional_index());
4376 if (instr->hydrogen()->key()->representation().IsSmi()) {
4383 offset = FixedArray::OffsetOfElementAt(instr->additional_index());
4387 if (instr->hydrogen()->NeedsWriteBarrier()) {
4389 instr->hydrogen()->value()->IsHeapObject()
4404 void LCodeGen::DoStoreKeyed(LStoreKeyed* instr) {
4406 if (instr->is_external()) {
4407 DoStoreKeyedExternalArray(instr);
4408 } else if (instr->hydrogen()->value()->representation().IsDouble()) {
4409 DoStoreKeyedFixedDoubleArray(instr);
4411 DoStoreKeyedFixedArray(instr);
4416 void LCodeGen::DoStoreKeyedGeneric(LStoreKeyedGeneric* instr) {
4417 ASSERT(ToRegister(instr->context()).is(cp));
4418 ASSERT(ToRegister(instr->object()).is(a2));
4419 ASSERT(ToRegister(instr->key()).is(a1));
4420 ASSERT(ToRegister(instr->value()).is(a0));
4422 Handle<Code> ic = (instr->strict_mode_flag() == kStrictMode)
4425 CallCode(ic, RelocInfo::CODE_TARGET, instr);
4429 void LCodeGen::DoTransitionElementsKind(LTransitionElementsKind* instr) {
4430 Register object_reg = ToRegister(instr->object());
4433 Handle<Map> from_map = instr->original_map();
4434 Handle<Map> to_map = instr->transitioned_map();
4435 ElementsKind from_kind = instr->from_kind();
4436 ElementsKind to_kind = instr->to_kind();
4443 Register new_map_reg = ToRegister(instr->new_map_temp());
4450 ASSERT(ToRegister(instr->context()).is(cp));
4458 instr->pointer_map(), 0, Safepoint::kNoLazyDeopt);
4464 void LCodeGen::DoTrapAllocationMemento(LTrapAllocationMemento* instr) {
4465 Register object = ToRegister(instr->object());
4466 Register temp = ToRegister(instr->temp());
4470 DeoptimizeIf(al, instr->environment());
4475 void LCodeGen::DoStringAdd(LStringAdd* instr) {
4476 ASSERT(ToRegister(instr->context()).is(cp));
4478 ASSERT(ToRegister(instr->left()).is(a1));
4479 ASSERT(ToRegister(instr->right()).is(a0));
4480 NewStringAddStub stub(instr->hydrogen()->flags(),
4482 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
4484 __ push(ToRegister(instr->left()));
4485 __ push(ToRegister(instr->right()));
4486 StringAddStub stub(instr->hydrogen()->flags());
4487 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
4492 void LCodeGen::DoStringCharCodeAt(LStringCharCodeAt* instr) {
4495 DeferredStringCharCodeAt(LCodeGen* codegen, LStringCharCodeAt* instr)
4496 : LDeferredCode(codegen), instr_(instr) { }
4500 virtual LInstruction* instr() V8_OVERRIDE { return instr_; }
4506 new(zone()) DeferredStringCharCodeAt(this, instr);
4508 ToRegister(instr->string()),
4509 ToRegister(instr->index()),
4510 ToRegister(instr->result()),
4516 void LCodeGen::DoDeferredStringCharCodeAt(LStringCharCodeAt* instr) {
4517 Register string = ToRegister(instr->string());
4518 Register result = ToRegister(instr->result());
4530 if (instr->index()->IsConstantOperand()) {
4531 int const_index = ToInteger32(LConstantOperand::cast(instr->index()));
4535 Register index = ToRegister(instr->index());
4539 CallRuntimeFromDeferred(Runtime::kStringCharCodeAt, 2, instr,
4540 instr->context());
4547 void LCodeGen::DoStringCharFromCode(LStringCharFromCode* instr) {
4550 DeferredStringCharFromCode(LCodeGen* codegen, LStringCharFromCode* instr)
4551 : LDeferredCode(codegen), instr_(instr) { }
4555 virtual LInstruction* instr() V8_OVERRIDE { return instr_; }
4561 new(zone()) DeferredStringCharFromCode(this, instr);
4563 ASSERT(instr->hydrogen()->value()->representation().IsInteger32());
4564 Register char_code = ToRegister(instr->char_code());
4565 Register result = ToRegister(instr->result());
4581 void LCodeGen::DoDeferredStringCharFromCode(LStringCharFromCode* instr) {
4582 Register char_code = ToRegister(instr->char_code());
4583 Register result = ToRegister(instr->result());
4593 CallRuntimeFromDeferred(Runtime::kCharFromCode, 1, instr, instr->context());
4598 void LCodeGen::DoInteger32ToDouble(LInteger32ToDouble* instr) {
4599 LOperand* input = instr->value();
4601 LOperand* output = instr->result();
4615 void LCodeGen::DoInteger32ToSmi(LInteger32ToSmi* instr) {
4616 LOperand* input = instr->value();
4617 LOperand* output = instr->result();
4621 if (!instr->hydrogen()->value()->HasRange() ||
4622 !instr->hydrogen()->value()->range()->IsInSmiRange()) {
4624 DeoptimizeIf(lt, instr->environment(), scratch, Operand(zero_reg));
4631 void LCodeGen::DoUint32ToDouble(LUint32ToDouble* instr) {
4632 LOperand* input = instr->value();
4633 LOperand* output = instr->result();
4641 void LCodeGen::DoUint32ToSmi(LUint32ToSmi* instr) {
4642 LOperand* input = instr->value();
4643 LOperand* output = instr->result();
4644 if (!instr->hydrogen()->value()->HasRange() ||
4645 !instr->hydrogen()->value()->range()->IsInSmiRange()) {
4648 DeoptimizeIf(ne, instr->environment(), scratch, Operand(zero_reg));
4654 void LCodeGen::DoNumberTagI(LNumberTagI* instr) {
4657 DeferredNumberTagI(LCodeGen* codegen, LNumberTagI* instr)
4658 : LDeferredCode(codegen), instr_(instr) { }
4664 virtual LInstruction* instr() V8_OVERRIDE { return instr_; }
4669 Register src = ToRegister(instr->value());
4670 Register dst = ToRegister(instr->result());
4673 DeferredNumberTagI* deferred = new(zone()) DeferredNumberTagI(this, instr);
4680 void LCodeGen::DoNumberTagU(LNumberTagU* instr) {
4683 DeferredNumberTagU(LCodeGen* codegen, LNumberTagU* instr)
4684 : LDeferredCode(codegen), instr_(instr) { }
4690 virtual LInstruction* instr() V8_OVERRIDE { return instr_; }
4695 Register input = ToRegister(instr->value());
4696 Register result = ToRegister(instr->result());
4698 DeferredNumberTagU* deferred = new(zone()) DeferredNumberTagU(this, instr);
4705 void LCodeGen::DoDeferredNumberTagI(LInstruction* instr,
4710 Register dst = ToRegister(instr->result());
4754 instr->pointer_map(), 0, Safepoint::kNoLazyDeopt);
4767 void LCodeGen::DoNumberTagD(LNumberTagD* instr) {
4770 DeferredNumberTagD(LCodeGen* codegen, LNumberTagD* instr)
4771 : LDeferredCode(codegen), instr_(instr) { }
4775 virtual LInstruction* instr() V8_OVERRIDE { return instr_; }
4780 DoubleRegister input_reg = ToDoubleRegister(instr->value());
4782 Register reg = ToRegister(instr->result());
4783 Register temp1 = ToRegister(instr->temp());
4784 Register temp2 = ToRegister(instr->temp2());
4786 DeferredNumberTagD* deferred = new(zone()) DeferredNumberTagD(this, instr);
4802 void LCodeGen::DoDeferredNumberTagD(LNumberTagD* instr) {
4806 Register reg = ToRegister(instr->result());
4818 instr->pointer_map(), 0, Safepoint::kNoLazyDeopt);
4824 void LCodeGen::DoSmiTag(LSmiTag* instr) {
4825 ASSERT(!instr->hydrogen_value()->CheckFlag(HValue::kCanOverflow));
4826 __ SmiTag(ToRegister(instr->result()), ToRegister(instr->value()));
4830 void LCodeGen::DoSmiUntag(LSmiUntag* instr) {
4832 Register input = ToRegister(instr->value());
4833 Register result = ToRegister(instr->result());
4834 if (instr->needs_check()) {
4839 DeoptimizeIf(ne, instr->environment(), scratch, Operand(zero_reg));
4896 void LCodeGen::DoDeferredTaggedToI(LTaggedToI* instr) {
4897 Register input_reg = ToRegister(instr->value());
4899 Register scratch2 = ToRegister(instr->temp());
4901 DoubleRegister double_scratch2 = ToDoubleRegister(instr->temp2());
4915 if (instr->truncating()) {
4929 ASSERT(ToRegister(instr->result()).is(input_reg));
4941 DeoptimizeIf(ne, instr->environment(), scratch2, Operand(at));
4946 DeoptimizeIf(ne, instr->environment(), scratch1, Operand(at));
4962 DeoptimizeIf(ne, instr->environment(), except_flag, Operand(zero_reg));
4964 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
4969 DeoptimizeIf(ne, instr->environment(), scratch1, Operand(zero_reg));
4976 void LCodeGen::DoTaggedToI(LTaggedToI* instr) {
4979 DeferredTaggedToI(LCodeGen* codegen, LTaggedToI* instr)
4980 : LDeferredCode(codegen), instr_(instr) { }
4984 virtual LInstruction* instr() V8_OVERRIDE { return instr_; }
4989 LOperand* input = instr->value();
4991 ASSERT(input->Equals(instr->result()));
4995 if (instr->hydrogen()->value()->representation().IsSmi()) {
4998 DeferredTaggedToI* deferred = new(zone()) DeferredTaggedToI(this, instr);
5010 void LCodeGen::DoNumberUntagD(LNumberUntagD* instr) {
5011 LOperand* input = instr->value();
5013 LOperand* result = instr->result();
5019 HValue* value = instr->hydrogen()->value();
5024 instr->hydrogen()->can_convert_undefined_to_nan(),
5025 instr->hydrogen()->deoptimize_on_minus_zero(),
5026 instr->environment(),
5031 void LCodeGen::DoDoubleToI(LDoubleToI* instr) {
5032 Register result_reg = ToRegister(instr->result());
5034 DoubleRegister double_input = ToDoubleRegister(instr->value());
5036 if (instr->truncating()) {
5050 DeoptimizeIf(ne, instr->environment(), except_flag, Operand(zero_reg));
5052 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
5057 DeoptimizeIf(ne, instr->environment(), scratch1, Operand(zero_reg));
5064 void LCodeGen::DoDoubleToSmi(LDoubleToSmi* instr) {
5065 Register result_reg = ToRegister(instr->result());
5067 DoubleRegister double_input = ToDoubleRegister(instr->value());
5069 if (instr->truncating()) {
5083 DeoptimizeIf(ne, instr->environment(), except_flag, Operand(zero_reg));
5085 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) {
5090 DeoptimizeIf(ne, instr->environment(), scratch1, Operand(zero_reg));
5095 DeoptimizeIf(lt, instr->environment(), scratch1, Operand(zero_reg));
5099 void LCodeGen::DoCheckSmi(LCheckSmi* instr) {
5100 LOperand* input = instr->value();
5102 DeoptimizeIf(ne, instr->environment(), at, Operand(zero_reg));
5106 void LCodeGen::DoCheckNonSmi(LCheckNonSmi* instr) {
5107 if (!instr->hydrogen()->value()->IsHeapObject()) {
5108 LOperand* input = instr->value();
5110 DeoptimizeIf(eq, instr->environment(), at, Operand(zero_reg));
5115 void LCodeGen::DoCheckInstanceType(LCheckInstanceType* instr) {
5116 Register input = ToRegister(instr->value());
5121 if (instr->hydrogen()->is_interval_check()) {
5124 instr->hydrogen()->GetCheckInterval(&first, &last);
5128 DeoptimizeIf(ne, instr->environment(), scratch, Operand(first));
5130 DeoptimizeIf(lo, instr->environment(), scratch, Operand(first));
5133 DeoptimizeIf(hi, instr->environment(), scratch, Operand(last));
5139 instr->hydrogen()->GetCheckMaskAndTag(&mask, &tag);
5144 DeoptimizeIf(tag == 0 ? ne : eq, instr->environment(),
5148 DeoptimizeIf(ne, instr->environment(), scratch, Operand(tag));
5154 void LCodeGen::DoCheckValue(LCheckValue* instr) {
5155 Register reg = ToRegister(instr->value());
5156 Handle<HeapObject> object = instr->hydrogen()->object().handle();
5159 Register reg = ToRegister(instr->value());
5163 DeoptimizeIf(ne, instr->environment(), reg,
5166 DeoptimizeIf(ne, instr->environment(), reg,
5172 void LCodeGen::DoDeferredInstanceMigration(LCheckMaps* instr, Register object) {
5179 instr->pointer_map(), 1, Safepoint::kNoLazyDeopt);
5183 DeoptimizeIf(eq, instr
5187 void LCodeGen::DoCheckMaps(LCheckMaps* instr) {
5190 DeferredCheckMaps(LCodeGen* codegen, LCheckMaps* instr, Register object)
5191 : LDeferredCode(codegen), instr_(instr), object_(object) {
5198 virtual LInstruction* instr() V8_OVERRIDE { return instr_; }
5205 if (instr->hydrogen()->CanOmitMapChecks()) return;
5207 LOperand* input = instr->value();
5213 if (instr->hydrogen()->has_migration_target()) {
5214 deferred = new(zone()) DeferredCheckMaps(this, instr, reg);
5218 UniqueSet<Map> map_set = instr->hydrogen()->map_set();
5226 if (instr->hydrogen()->has_migration_target()) {
5229 DeoptimizeIf(ne, instr->environment(), map_reg, Operand(map));
5236 void LCodeGen::DoClampDToUint8(LClampDToUint8* instr) {
5237 DoubleRegister value_reg = ToDoubleRegister(instr->unclamped());
5238 Register result_reg = ToRegister(instr->result());
5239 DoubleRegister temp_reg = ToDoubleRegister(instr->temp());
5244 void LCodeGen::DoClampIToUint8(LClampIToUint8* instr) {
5245 Register unclamped_reg = ToRegister(instr->unclamped());
5246 Register result_reg = ToRegister(instr->result());
5251 void LCodeGen::DoClampTToUint8(LClampTToUint8* instr) {
5253 Register input_reg = ToRegister(instr->unclamped());
5254 Register result_reg = ToRegister(instr->result());
5255 DoubleRegister temp_reg = ToDoubleRegister(instr->temp());
5267 DeoptimizeIf(ne, instr->environment(), input_reg,
5286 void LCodeGen::DoAllocate(LAllocate* instr) {
5289 DeferredAllocate(LCodeGen* codegen, LAllocate* instr)
5290 : LDeferredCode(codegen), instr_(instr) { }
5294 virtual LInstruction* instr() V8_OVERRIDE { return instr_; }
5300 new(zone()) DeferredAllocate(this, instr);
5302 Register result = ToRegister(instr->result());
5303 Register scratch = ToRegister(instr->temp1());
5304 Register scratch2 = ToRegister(instr->temp2());
5308 if (instr->hydrogen()->MustAllocateDoubleAligned()) {
5311 if (instr->hydrogen()->IsOldPointerSpaceAllocation()) {
5312 ASSERT(!instr->hydrogen()->IsOldDataSpaceAllocation());
5313 ASSERT(!instr->hydrogen()->IsNewSpaceAllocation());
5315 } else if (instr->hydrogen()->IsOldDataSpaceAllocation()) {
5316 ASSERT(!instr->hydrogen()->IsNewSpaceAllocation());
5319 if (instr->size()->IsConstantOperand()) {
5320 int32_t size = ToInteger32(LConstantOperand::cast(instr->size()));
5327 Register size = ToRegister(instr->size());
5338 if (instr->hydrogen()->MustPrefillWithFiller()) {
5339 if (instr->size()->IsConstantOperand()) {
5340 int32_t size = ToInteger32(LConstantOperand::cast(instr->size()));
5343 scratch = ToRegister(instr->size());
5359 void LCodeGen::DoDeferredAllocate(LAllocate* instr) {
5360 Register result = ToRegister(instr->result());
5368 if (instr->size()->IsRegister()) {
5369 Register size = ToRegister(instr->size());
5374 int32_t size = ToInteger32(LConstantOperand::cast(instr->size()));
5379 instr->hydrogen()->MustAllocateDoubleAligned());
5380 if (instr->hydrogen()->IsOldPointerSpaceAllocation()) {
5381 ASSERT(!instr->hydrogen()->IsOldDataSpaceAllocation());
5382 ASSERT(!instr->hydrogen()->IsNewSpaceAllocation());
5384 } else if (instr->hydrogen()->IsOldDataSpaceAllocation()) {
5385 ASSERT(!instr->hydrogen()->IsNewSpaceAllocation());
5393 Runtime::kAllocateInTargetSpace, 2, instr, instr->context());
5398 void LCodeGen::DoToFastProperties(LToFastProperties* instr) {
5399 ASSERT(ToRegister(instr->value()).is(a0));
5400 ASSERT(ToRegister(instr->result()).is(v0));
5402 CallRuntime(Runtime::kToFastProperties, 1, instr);
5406 void LCodeGen::DoRegExpLiteral(LRegExpLiteral* instr) {
5407 ASSERT(ToRegister(instr->context()).is(cp));
5415 FixedArray::OffsetOfElementAt(instr->hydrogen()->literal_index());
5416 __ li(t3, instr->hydrogen()->literals());
5423 __ li(t2, Operand(Smi::FromInt(instr->hydrogen()->literal_index())));
5424 __ li(t1, Operand(instr->hydrogen()->pattern()));
5425 __ li(t0, Operand(instr->hydrogen()->flags()));
5427 CallRuntime(Runtime::kMaterializeRegExpLiteral, 4, instr);
5440 CallRuntime(Runtime::kAllocateInNewSpace, 1, instr);
5459 void LCodeGen::DoFunctionLiteral(LFunctionLiteral* instr) {
5460 ASSERT(ToRegister(instr->context()).is(cp));
5463 bool pretenure = instr->hydrogen()->pretenure();
5464 if (!pretenure && instr->hydrogen()->has_no_literals()) {
5465 FastNewClosureStub stub(instr->hydrogen()->language_mode(),
5466 instr->hydrogen()->is_generator());
5467 __ li(a2, Operand(instr->hydrogen()->shared_info()));
5468 CallCode(stub.GetCode(isolate()), RelocInfo::CODE_TARGET, instr);
5470 __ li(a2, Operand(instr->hydrogen()->shared_info()));
5474 CallRuntime(Runtime::kNewClosure, 3, instr);
5479 void LCodeGen::DoTypeof(LTypeof* instr) {
5480 ASSERT(ToRegister(instr->result()).is(v0));
5481 Register input = ToRegister(instr->value());
5483 CallRuntime(Runtime::kTypeof, 1, instr);
5487 void LCodeGen::DoTypeofIsAndBranch(LTypeofIsAndBranch* instr) {
5488 Register input = ToRegister(instr->value());
5493 Condition final_branch_condition = EmitTypeofIs(instr->TrueLabel(chunk_),
5494 instr->FalseLabel(chunk_),
5496 instr->type_literal(),
5504 EmitBranch(instr, final_branch_condition, cmp1, cmp2);
5615 void LCodeGen::DoIsConstructCallAndBranch(LIsConstructCallAndBranch* instr) {
5616 Register temp1 = ToRegister(instr->temp());
5620 EmitBranch(instr, eq, temp1,
5659 void LCodeGen::DoLazyBailout(LLazyBailout* instr) {
5662 ASSERT(instr->HasEnvironment());
5663 LEnvironment* env = instr->environment();
5669 void LCodeGen::DoDeoptimize(LDeoptimize* instr) {
5670 Deoptimizer::BailoutType type = instr->hydrogen()->type();
5679 Comment(";;; deoptimize: %s", instr->hydrogen()->reason());
5680 DeoptimizeIf(al, instr->environment(), type, zero_reg, Operand(zero_reg));
5684 void LCodeGen::DoDummy(LDummy* instr) {
5689 void LCodeGen::DoDummyUse(LDummyUse* instr) {
5694 void LCodeGen::DoDeferredStackCheck(LStackCheck* instr) {
5696 LoadContextFromDeferred(instr->context());
5699 instr, RECORD_SAFEPOINT_WITH_REGISTERS_AND_NO_ARGUMENTS);
5700 ASSERT(instr->HasEnvironment());
5701 LEnvironment* env = instr->environment();
5706 void LCodeGen::DoStackCheck(LStackCheck* instr) {
5709 DeferredStackCheck(LCodeGen* codegen, LStackCheck* instr)
5710 : LDeferredCode(codegen), instr_(instr) { }
5714 virtual LInstruction* instr() V8_OVERRIDE { return instr_; }
5719 ASSERT(instr->HasEnvironment());
5720 LEnvironment* env = instr->environment();
5723 if (instr->hydrogen()->is_function_entry()) {
5728 ASSERT(instr->context()->IsRegister());
5729 ASSERT(ToRegister(instr->context()).is(cp));
5732 instr);
5739 ASSERT(instr->hydrogen()->is_backwards_branch());
5742 new(zone()) DeferredStackCheck(this, instr);
5747 __ bind(instr->done_label());
5748 deferred_stack_check->SetExit(instr->done_label());
5757 void LCodeGen::DoOsrEntry(LOsrEntry* instr) {
5761 LEnvironment* environment = instr->environment();
5772 void LCodeGen::DoForInPrepareMap(LForInPrepareMap* instr) {
5773 Register result = ToRegister(instr->result());
5774 Register object = ToRegister(instr->object());
5776 DeoptimizeIf(eq, instr->environment(), object, Operand(at));
5780 DeoptimizeIf(eq, instr->environment(), object, Operand(null_value));
5783 DeoptimizeIf(eq, instr->environment(), at, Operand(zero_reg));
5787 DeoptimizeIf(le, instr->environment(), a1, Operand(LAST_JS_PROXY_TYPE));
5799 CallRuntime(Runtime::kGetPropertyNamesFast, 1, instr);
5804 DeoptimizeIf(ne, instr->environment(), a1, Operand(at));
5809 void LCodeGen::DoForInCacheArray(LForInCacheArray* instr) {
5810 Register map = ToRegister(instr->map());
5811 Register result = ToRegister(instr->result());
5823 FieldMemOperand(result, FixedArray::SizeFor(instr->idx())));
5824 DeoptimizeIf(eq, instr->environment(), result, Operand(zero_reg));
5830 void LCodeGen::DoCheckMapValue(LCheckMapValue* instr) {
5831 Register object = ToRegister(instr->value());
5832 Register map = ToRegister(instr->map());
5834 DeoptimizeIf(ne, instr->environment(), map, Operand(scratch0()));
5838 void LCodeGen::DoLoadFieldByIndex(LLoadFieldByIndex* instr) {
5839 Register object = ToRegister(instr->object());
5840 Register index = ToRegister(instr->index());
5841 Register result = ToRegister(instr->result());