1 // Copyright 2012 the V8 project authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file.
9 #if V8_TARGET_ARCH_MIPS64
11 #include "src/hydrogen-osr.h"
12 #include "src/lithium-inl.h"
13 #include "src/mips64/lithium-codegen-mips64.h"
18 #define DEFINE_COMPILE(type) \
19 void L##type::CompileToNative(LCodeGen* generator) { \
20 generator->Do##type(this); \
22 LITHIUM_CONCRETE_INSTRUCTION_LIST(DEFINE_COMPILE)
26 void LInstruction::VerifyCall() {
27 // Call instructions can use only fixed registers as temporaries and
28 // outputs because all registers are blocked by the calling convention.
29 // Inputs operands must use a fixed register or use-at-start policy or
30 // a non-register policy.
31 DCHECK(Output() == NULL ||
32 LUnallocated::cast(Output())->HasFixedPolicy() ||
33 !LUnallocated::cast(Output())->HasRegisterPolicy());
34 for (UseIterator it(this); !it.Done(); it.Advance()) {
35 LUnallocated* operand = LUnallocated::cast(it.Current());
36 DCHECK(operand->HasFixedPolicy() ||
37 operand->IsUsedAtStart());
39 for (TempIterator it(this); !it.Done(); it.Advance()) {
40 LUnallocated* operand = LUnallocated::cast(it.Current());
41 DCHECK(operand->HasFixedPolicy() ||!operand->HasRegisterPolicy());
47 void LInstruction::PrintTo(StringStream* stream) {
48 stream->Add("%s ", this->Mnemonic());
50 PrintOutputOperandTo(stream);
54 if (HasEnvironment()) {
56 environment()->PrintTo(stream);
59 if (HasPointerMap()) {
61 pointer_map()->PrintTo(stream);
66 void LInstruction::PrintDataTo(StringStream* stream) {
68 for (int i = 0; i < InputCount(); i++) {
69 if (i > 0) stream->Add(" ");
70 if (InputAt(i) == NULL) {
73 InputAt(i)->PrintTo(stream);
79 void LInstruction::PrintOutputOperandTo(StringStream* stream) {
80 if (HasResult()) result()->PrintTo(stream);
84 void LLabel::PrintDataTo(StringStream* stream) {
85 LGap::PrintDataTo(stream);
86 LLabel* rep = replacement();
88 stream->Add(" Dead block replaced with B%d", rep->block_id());
93 bool LGap::IsRedundant() const {
94 for (int i = 0; i < 4; i++) {
95 if (parallel_moves_[i] != NULL && !parallel_moves_[i]->IsRedundant()) {
104 void LGap::PrintDataTo(StringStream* stream) {
105 for (int i = 0; i < 4; i++) {
107 if (parallel_moves_[i] != NULL) {
108 parallel_moves_[i]->PrintDataTo(stream);
115 const char* LArithmeticD::Mnemonic() const {
117 case Token::ADD: return "add-d";
118 case Token::SUB: return "sub-d";
119 case Token::MUL: return "mul-d";
120 case Token::DIV: return "div-d";
121 case Token::MOD: return "mod-d";
129 const char* LArithmeticT::Mnemonic() const {
131 case Token::ADD: return "add-t";
132 case Token::SUB: return "sub-t";
133 case Token::MUL: return "mul-t";
134 case Token::MOD: return "mod-t";
135 case Token::DIV: return "div-t";
136 case Token::BIT_AND: return "bit-and-t";
137 case Token::BIT_OR: return "bit-or-t";
138 case Token::BIT_XOR: return "bit-xor-t";
139 case Token::ROR: return "ror-t";
140 case Token::SHL: return "sll-t";
141 case Token::SAR: return "sra-t";
142 case Token::SHR: return "srl-t";
150 bool LGoto::HasInterestingComment(LCodeGen* gen) const {
151 return !gen->IsNextEmittedBlock(block_id());
155 void LGoto::PrintDataTo(StringStream* stream) {
156 stream->Add("B%d", block_id());
160 void LBranch::PrintDataTo(StringStream* stream) {
161 stream->Add("B%d | B%d on ", true_block_id(), false_block_id());
162 value()->PrintTo(stream);
166 LInstruction* LChunkBuilder::DoDebugBreak(HDebugBreak* instr) {
167 return new(zone()) LDebugBreak();
171 void LCompareNumericAndBranch::PrintDataTo(StringStream* stream) {
173 left()->PrintTo(stream);
174 stream->Add(" %s ", Token::String(op()));
175 right()->PrintTo(stream);
176 stream->Add(" then B%d else B%d", true_block_id(), false_block_id());
180 void LIsObjectAndBranch::PrintDataTo(StringStream* stream) {
181 stream->Add("if is_object(");
182 value()->PrintTo(stream);
183 stream->Add(") then B%d else B%d", true_block_id(), false_block_id());
187 void LIsStringAndBranch::PrintDataTo(StringStream* stream) {
188 stream->Add("if is_string(");
189 value()->PrintTo(stream);
190 stream->Add(") then B%d else B%d", true_block_id(), false_block_id());
194 void LIsSmiAndBranch::PrintDataTo(StringStream* stream) {
195 stream->Add("if is_smi(");
196 value()->PrintTo(stream);
197 stream->Add(") then B%d else B%d", true_block_id(), false_block_id());
201 void LIsUndetectableAndBranch::PrintDataTo(StringStream* stream) {
202 stream->Add("if is_undetectable(");
203 value()->PrintTo(stream);
204 stream->Add(") then B%d else B%d", true_block_id(), false_block_id());
208 void LStringCompareAndBranch::PrintDataTo(StringStream* stream) {
209 stream->Add("if string_compare(");
210 left()->PrintTo(stream);
211 right()->PrintTo(stream);
212 stream->Add(") then B%d else B%d", true_block_id(), false_block_id());
216 void LHasInstanceTypeAndBranch::PrintDataTo(StringStream* stream) {
217 stream->Add("if has_instance_type(");
218 value()->PrintTo(stream);
219 stream->Add(") then B%d else B%d", true_block_id(), false_block_id());
223 void LHasCachedArrayIndexAndBranch::PrintDataTo(StringStream* stream) {
224 stream->Add("if has_cached_array_index(");
225 value()->PrintTo(stream);
226 stream->Add(") then B%d else B%d", true_block_id(), false_block_id());
230 void LClassOfTestAndBranch::PrintDataTo(StringStream* stream) {
231 stream->Add("if class_of_test(");
232 value()->PrintTo(stream);
233 stream->Add(", \"%o\") then B%d else B%d",
234 *hydrogen()->class_name(),
240 void LTypeofIsAndBranch::PrintDataTo(StringStream* stream) {
241 stream->Add("if typeof ");
242 value()->PrintTo(stream);
243 stream->Add(" == \"%s\" then B%d else B%d",
244 hydrogen()->type_literal()->ToCString().get(),
245 true_block_id(), false_block_id());
249 void LStoreCodeEntry::PrintDataTo(StringStream* stream) {
251 function()->PrintTo(stream);
252 stream->Add(".code_entry = ");
253 code_object()->PrintTo(stream);
257 void LInnerAllocatedObject::PrintDataTo(StringStream* stream) {
259 base_object()->PrintTo(stream);
261 offset()->PrintTo(stream);
265 void LCallFunction::PrintDataTo(StringStream* stream) {
266 context()->PrintTo(stream);
268 function()->PrintTo(stream);
269 if (hydrogen()->HasVectorAndSlot()) {
270 stream->Add(" (type-feedback-vector ");
271 temp_vector()->PrintTo(stream);
273 temp_slot()->PrintTo(stream);
279 void LCallJSFunction::PrintDataTo(StringStream* stream) {
281 function()->PrintTo(stream);
282 stream->Add("#%d / ", arity());
286 void LCallWithDescriptor::PrintDataTo(StringStream* stream) {
287 for (int i = 0; i < InputCount(); i++) {
288 InputAt(i)->PrintTo(stream);
291 stream->Add("#%d / ", arity());
295 void LLoadContextSlot::PrintDataTo(StringStream* stream) {
296 context()->PrintTo(stream);
297 stream->Add("[%d]", slot_index());
301 void LStoreContextSlot::PrintDataTo(StringStream* stream) {
302 context()->PrintTo(stream);
303 stream->Add("[%d] <- ", slot_index());
304 value()->PrintTo(stream);
308 void LInvokeFunction::PrintDataTo(StringStream* stream) {
310 function()->PrintTo(stream);
311 stream->Add(" #%d / ", arity());
315 void LCallNew::PrintDataTo(StringStream* stream) {
317 constructor()->PrintTo(stream);
318 stream->Add(" #%d / ", arity());
322 void LCallNewArray::PrintDataTo(StringStream* stream) {
324 constructor()->PrintTo(stream);
325 stream->Add(" #%d / ", arity());
326 ElementsKind kind = hydrogen()->elements_kind();
327 stream->Add(" (%s) ", ElementsKindToString(kind));
331 void LAccessArgumentsAt::PrintDataTo(StringStream* stream) {
332 arguments()->PrintTo(stream);
333 stream->Add(" length ");
334 length()->PrintTo(stream);
335 stream->Add(" index ");
336 index()->PrintTo(stream);
340 void LLoadGlobalViaContext::PrintDataTo(StringStream* stream) {
341 stream->Add("depth:%d slot:%d", depth(), slot_index());
345 void LStoreNamedField::PrintDataTo(StringStream* stream) {
346 object()->PrintTo(stream);
347 std::ostringstream os;
348 os << hydrogen()->access() << " <- ";
349 stream->Add(os.str().c_str());
350 value()->PrintTo(stream);
354 void LStoreNamedGeneric::PrintDataTo(StringStream* stream) {
355 object()->PrintTo(stream);
357 stream->Add(String::cast(*name())->ToCString().get());
359 value()->PrintTo(stream);
363 void LStoreGlobalViaContext::PrintDataTo(StringStream* stream) {
364 stream->Add("depth:%d slot:%d <- ", depth(), slot_index());
365 value()->PrintTo(stream);
369 void LLoadKeyed::PrintDataTo(StringStream* stream) {
370 elements()->PrintTo(stream);
372 key()->PrintTo(stream);
373 if (hydrogen()->IsDehoisted()) {
374 stream->Add(" + %d]", base_offset());
381 void LStoreKeyed::PrintDataTo(StringStream* stream) {
382 elements()->PrintTo(stream);
384 key()->PrintTo(stream);
385 if (hydrogen()->IsDehoisted()) {
386 stream->Add(" + %d] <-", base_offset());
388 stream->Add("] <- ");
391 if (value() == NULL) {
392 DCHECK(hydrogen()->IsConstantHoleStore() &&
393 hydrogen()->value()->representation().IsDouble());
394 stream->Add("<the hole(nan)>");
396 value()->PrintTo(stream);
401 void LStoreKeyedGeneric::PrintDataTo(StringStream* stream) {
402 object()->PrintTo(stream);
404 key()->PrintTo(stream);
405 stream->Add("] <- ");
406 value()->PrintTo(stream);
410 void LTransitionElementsKind::PrintDataTo(StringStream* stream) {
411 object()->PrintTo(stream);
412 stream->Add(" %p -> %p", *original_map(), *transitioned_map());
416 int LPlatformChunk::GetNextSpillIndex(RegisterKind kind) {
417 // Skip a slot if for a double-width slot.
418 if (kind == DOUBLE_REGISTERS) spill_slot_count_++;
419 return spill_slot_count_++;
423 LOperand* LPlatformChunk::GetNextSpillSlot(RegisterKind kind) {
424 int index = GetNextSpillIndex(kind);
425 if (kind == DOUBLE_REGISTERS) {
426 return LDoubleStackSlot::Create(index, zone());
428 DCHECK(kind == GENERAL_REGISTERS);
429 return LStackSlot::Create(index, zone());
434 LPlatformChunk* LChunkBuilder::Build() {
436 chunk_ = new(zone()) LPlatformChunk(info(), graph());
437 LPhase phase("L_Building chunk", chunk_);
440 // If compiling for OSR, reserve space for the unoptimized frame,
441 // which will be subsumed into this frame.
442 if (graph()->has_osr()) {
443 for (int i = graph()->osr()->UnoptimizedFrameSlots(); i > 0; i--) {
444 chunk_->GetNextSpillIndex(GENERAL_REGISTERS);
448 const ZoneList<HBasicBlock*>* blocks = graph()->blocks();
449 for (int i = 0; i < blocks->length(); i++) {
450 HBasicBlock* next = NULL;
451 if (i < blocks->length() - 1) next = blocks->at(i + 1);
452 DoBasicBlock(blocks->at(i), next);
453 if (is_aborted()) return NULL;
460 LUnallocated* LChunkBuilder::ToUnallocated(Register reg) {
461 return new(zone()) LUnallocated(LUnallocated::FIXED_REGISTER,
462 Register::ToAllocationIndex(reg));
466 LUnallocated* LChunkBuilder::ToUnallocated(DoubleRegister reg) {
467 return new(zone()) LUnallocated(LUnallocated::FIXED_DOUBLE_REGISTER,
468 DoubleRegister::ToAllocationIndex(reg));
472 LOperand* LChunkBuilder::UseFixed(HValue* value, Register fixed_register) {
473 return Use(value, ToUnallocated(fixed_register));
477 LOperand* LChunkBuilder::UseFixedDouble(HValue* value, DoubleRegister reg) {
478 return Use(value, ToUnallocated(reg));
482 LOperand* LChunkBuilder::UseRegister(HValue* value) {
483 return Use(value, new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER));
487 LOperand* LChunkBuilder::UseRegisterAtStart(HValue* value) {
489 new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER,
490 LUnallocated::USED_AT_START));
494 LOperand* LChunkBuilder::UseTempRegister(HValue* value) {
495 return Use(value, new(zone()) LUnallocated(LUnallocated::WRITABLE_REGISTER));
499 LOperand* LChunkBuilder::Use(HValue* value) {
500 return Use(value, new(zone()) LUnallocated(LUnallocated::NONE));
504 LOperand* LChunkBuilder::UseAtStart(HValue* value) {
505 return Use(value, new(zone()) LUnallocated(LUnallocated::NONE,
506 LUnallocated::USED_AT_START));
510 LOperand* LChunkBuilder::UseOrConstant(HValue* value) {
511 return value->IsConstant()
512 ? chunk_->DefineConstantOperand(HConstant::cast(value))
517 LOperand* LChunkBuilder::UseOrConstantAtStart(HValue* value) {
518 return value->IsConstant()
519 ? chunk_->DefineConstantOperand(HConstant::cast(value))
524 LOperand* LChunkBuilder::UseRegisterOrConstant(HValue* value) {
525 return value->IsConstant()
526 ? chunk_->DefineConstantOperand(HConstant::cast(value))
527 : UseRegister(value);
531 LOperand* LChunkBuilder::UseRegisterOrConstantAtStart(HValue* value) {
532 return value->IsConstant()
533 ? chunk_->DefineConstantOperand(HConstant::cast(value))
534 : UseRegisterAtStart(value);
538 LOperand* LChunkBuilder::UseConstant(HValue* value) {
539 return chunk_->DefineConstantOperand(HConstant::cast(value));
543 LOperand* LChunkBuilder::UseAny(HValue* value) {
544 return value->IsConstant()
545 ? chunk_->DefineConstantOperand(HConstant::cast(value))
546 : Use(value, new(zone()) LUnallocated(LUnallocated::ANY));
550 LOperand* LChunkBuilder::Use(HValue* value, LUnallocated* operand) {
551 if (value->EmitAtUses()) {
552 HInstruction* instr = HInstruction::cast(value);
553 VisitInstruction(instr);
555 operand->set_virtual_register(value->id());
560 LInstruction* LChunkBuilder::Define(LTemplateResultInstruction<1>* instr,
561 LUnallocated* result) {
562 result->set_virtual_register(current_instruction_->id());
563 instr->set_result(result);
568 LInstruction* LChunkBuilder::DefineAsRegister(
569 LTemplateResultInstruction<1>* instr) {
571 new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER));
575 LInstruction* LChunkBuilder::DefineAsSpilled(
576 LTemplateResultInstruction<1>* instr, int index) {
578 new(zone()) LUnallocated(LUnallocated::FIXED_SLOT, index));
582 LInstruction* LChunkBuilder::DefineSameAsFirst(
583 LTemplateResultInstruction<1>* instr) {
585 new(zone()) LUnallocated(LUnallocated::SAME_AS_FIRST_INPUT));
589 LInstruction* LChunkBuilder::DefineFixed(
590 LTemplateResultInstruction<1>* instr, Register reg) {
591 return Define(instr, ToUnallocated(reg));
595 LInstruction* LChunkBuilder::DefineFixedDouble(
596 LTemplateResultInstruction<1>* instr, DoubleRegister reg) {
597 return Define(instr, ToUnallocated(reg));
601 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) {
602 HEnvironment* hydrogen_env = current_block_->last_environment();
603 int argument_index_accumulator = 0;
604 ZoneList<HValue*> objects_to_materialize(0, zone());
605 instr->set_environment(CreateEnvironment(hydrogen_env,
606 &argument_index_accumulator,
607 &objects_to_materialize));
612 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr,
613 HInstruction* hinstr,
614 CanDeoptimize can_deoptimize) {
615 info()->MarkAsNonDeferredCalling();
620 instr = AssignPointerMap(instr);
622 // If instruction does not have side-effects lazy deoptimization
623 // after the call will try to deoptimize to the point before the call.
624 // Thus we still need to attach environment to this call even if
625 // call sequence can not deoptimize eagerly.
626 bool needs_environment =
627 (can_deoptimize == CAN_DEOPTIMIZE_EAGERLY) ||
628 !hinstr->HasObservableSideEffects();
629 if (needs_environment && !instr->HasEnvironment()) {
630 instr = AssignEnvironment(instr);
631 // We can't really figure out if the environment is needed or not.
632 instr->environment()->set_has_been_used();
639 LInstruction* LChunkBuilder::AssignPointerMap(LInstruction* instr) {
640 DCHECK(!instr->HasPointerMap());
641 instr->set_pointer_map(new(zone()) LPointerMap(zone()));
646 LUnallocated* LChunkBuilder::TempRegister() {
647 LUnallocated* operand =
648 new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER);
649 int vreg = allocator_->GetVirtualRegister();
650 if (!allocator_->AllocationOk()) {
651 Abort(kOutOfVirtualRegistersWhileTryingToAllocateTempRegister);
654 operand->set_virtual_register(vreg);
659 LUnallocated* LChunkBuilder::TempDoubleRegister() {
660 LUnallocated* operand =
661 new(zone()) LUnallocated(LUnallocated::MUST_HAVE_DOUBLE_REGISTER);
662 int vreg = allocator_->GetVirtualRegister();
663 if (!allocator_->AllocationOk()) {
664 Abort(kOutOfVirtualRegistersWhileTryingToAllocateTempRegister);
667 operand->set_virtual_register(vreg);
672 LOperand* LChunkBuilder::FixedTemp(Register reg) {
673 LUnallocated* operand = ToUnallocated(reg);
674 DCHECK(operand->HasFixedPolicy());
679 LOperand* LChunkBuilder::FixedTemp(DoubleRegister reg) {
680 LUnallocated* operand = ToUnallocated(reg);
681 DCHECK(operand->HasFixedPolicy());
686 LInstruction* LChunkBuilder::DoBlockEntry(HBlockEntry* instr) {
687 return new(zone()) LLabel(instr->block());
691 LInstruction* LChunkBuilder::DoDummyUse(HDummyUse* instr) {
692 return DefineAsRegister(new(zone()) LDummyUse(UseAny(instr->value())));
696 LInstruction* LChunkBuilder::DoEnvironmentMarker(HEnvironmentMarker* instr) {
702 LInstruction* LChunkBuilder::DoDeoptimize(HDeoptimize* instr) {
703 return AssignEnvironment(new(zone()) LDeoptimize);
707 LInstruction* LChunkBuilder::DoShift(Token::Value op,
708 HBitwiseBinaryOperation* instr) {
709 if (instr->representation().IsSmiOrInteger32()) {
710 DCHECK(instr->left()->representation().Equals(instr->representation()));
711 DCHECK(instr->right()->representation().Equals(instr->representation()));
712 LOperand* left = UseRegisterAtStart(instr->left());
714 HValue* right_value = instr->right();
715 LOperand* right = NULL;
716 int constant_value = 0;
717 bool does_deopt = false;
718 if (right_value->IsConstant()) {
719 HConstant* constant = HConstant::cast(right_value);
720 right = chunk_->DefineConstantOperand(constant);
721 constant_value = constant->Integer32Value() & 0x1f;
722 // Left shifts can deoptimize if we shift by > 0 and the result cannot be
724 if (instr->representation().IsSmi() && constant_value > 0) {
725 does_deopt = !instr->CheckUsesForFlag(HValue::kTruncatingToSmi);
728 right = UseRegisterAtStart(right_value);
731 // Shift operations can only deoptimize if we do a logical shift
732 // by 0 and the result cannot be truncated to int32.
733 if (op == Token::SHR && constant_value == 0) {
734 does_deopt = !instr->CheckFlag(HInstruction::kUint32);
737 LInstruction* result =
738 DefineAsRegister(new(zone()) LShiftI(op, left, right, does_deopt));
739 return does_deopt ? AssignEnvironment(result) : result;
741 return DoArithmeticT(op, instr);
746 LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op,
747 HArithmeticBinaryOperation* instr) {
748 DCHECK(instr->representation().IsDouble());
749 DCHECK(instr->left()->representation().IsDouble());
750 DCHECK(instr->right()->representation().IsDouble());
751 if (op == Token::MOD) {
752 LOperand* left = UseFixedDouble(instr->left(), f2);
753 LOperand* right = UseFixedDouble(instr->right(), f4);
754 LArithmeticD* result = new(zone()) LArithmeticD(op, left, right);
755 // We call a C function for double modulo. It can't trigger a GC. We need
756 // to use fixed result register for the call.
757 // TODO(fschneider): Allow any register as input registers.
758 return MarkAsCall(DefineFixedDouble(result, f2), instr);
760 LOperand* left = UseRegisterAtStart(instr->left());
761 LOperand* right = UseRegisterAtStart(instr->right());
762 LArithmeticD* result = new(zone()) LArithmeticD(op, left, right);
763 return DefineAsRegister(result);
768 LInstruction* LChunkBuilder::DoArithmeticT(Token::Value op,
769 HBinaryOperation* instr) {
770 HValue* left = instr->left();
771 HValue* right = instr->right();
772 DCHECK(left->representation().IsTagged());
773 DCHECK(right->representation().IsTagged());
774 LOperand* context = UseFixed(instr->context(), cp);
775 LOperand* left_operand = UseFixed(left, a1);
776 LOperand* right_operand = UseFixed(right, a0);
777 LArithmeticT* result =
778 new(zone()) LArithmeticT(op, context, left_operand, right_operand);
779 return MarkAsCall(DefineFixed(result, v0), instr);
783 void LChunkBuilder::DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block) {
784 DCHECK(is_building());
785 current_block_ = block;
786 next_block_ = next_block;
787 if (block->IsStartBlock()) {
788 block->UpdateEnvironment(graph_->start_environment());
790 } else if (block->predecessors()->length() == 1) {
791 // We have a single predecessor => copy environment and outgoing
792 // argument count from the predecessor.
793 DCHECK(block->phis()->length() == 0);
794 HBasicBlock* pred = block->predecessors()->at(0);
795 HEnvironment* last_environment = pred->last_environment();
796 DCHECK(last_environment != NULL);
797 // Only copy the environment, if it is later used again.
798 if (pred->end()->SecondSuccessor() == NULL) {
799 DCHECK(pred->end()->FirstSuccessor() == block);
801 if (pred->end()->FirstSuccessor()->block_id() > block->block_id() ||
802 pred->end()->SecondSuccessor()->block_id() > block->block_id()) {
803 last_environment = last_environment->Copy();
806 block->UpdateEnvironment(last_environment);
807 DCHECK(pred->argument_count() >= 0);
808 argument_count_ = pred->argument_count();
810 // We are at a state join => process phis.
811 HBasicBlock* pred = block->predecessors()->at(0);
812 // No need to copy the environment, it cannot be used later.
813 HEnvironment* last_environment = pred->last_environment();
814 for (int i = 0; i < block->phis()->length(); ++i) {
815 HPhi* phi = block->phis()->at(i);
816 if (phi->HasMergedIndex()) {
817 last_environment->SetValueAt(phi->merged_index(), phi);
820 for (int i = 0; i < block->deleted_phis()->length(); ++i) {
821 if (block->deleted_phis()->at(i) < last_environment->length()) {
822 last_environment->SetValueAt(block->deleted_phis()->at(i),
823 graph_->GetConstantUndefined());
826 block->UpdateEnvironment(last_environment);
827 // Pick up the outgoing argument count of one of the predecessors.
828 argument_count_ = pred->argument_count();
830 HInstruction* current = block->first();
831 int start = chunk_->instructions()->length();
832 while (current != NULL && !is_aborted()) {
833 // Code for constants in registers is generated lazily.
834 if (!current->EmitAtUses()) {
835 VisitInstruction(current);
837 current = current->next();
839 int end = chunk_->instructions()->length() - 1;
841 block->set_first_instruction_index(start);
842 block->set_last_instruction_index(end);
844 block->set_argument_count(argument_count_);
846 current_block_ = NULL;
850 void LChunkBuilder::VisitInstruction(HInstruction* current) {
851 HInstruction* old_current = current_instruction_;
852 current_instruction_ = current;
854 LInstruction* instr = NULL;
855 if (current->CanReplaceWithDummyUses()) {
856 if (current->OperandCount() == 0) {
857 instr = DefineAsRegister(new(zone()) LDummy());
859 DCHECK(!current->OperandAt(0)->IsControlInstruction());
860 instr = DefineAsRegister(new(zone())
861 LDummyUse(UseAny(current->OperandAt(0))));
863 for (int i = 1; i < current->OperandCount(); ++i) {
864 if (current->OperandAt(i)->IsControlInstruction()) continue;
865 LInstruction* dummy =
866 new(zone()) LDummyUse(UseAny(current->OperandAt(i)));
867 dummy->set_hydrogen_value(current);
868 chunk_->AddInstruction(dummy, current_block_);
871 HBasicBlock* successor;
872 if (current->IsControlInstruction() &&
873 HControlInstruction::cast(current)->KnownSuccessorBlock(&successor) &&
875 instr = new(zone()) LGoto(successor);
877 instr = current->CompileToLithium(this);
881 argument_count_ += current->argument_delta();
882 DCHECK(argument_count_ >= 0);
885 AddInstruction(instr, current);
888 current_instruction_ = old_current;
892 void LChunkBuilder::AddInstruction(LInstruction* instr,
893 HInstruction* hydrogen_val) {
894 // Associate the hydrogen instruction first, since we may need it for
895 // the ClobbersRegisters() or ClobbersDoubleRegisters() calls below.
896 instr->set_hydrogen_value(hydrogen_val);
899 // Make sure that the lithium instruction has either no fixed register
900 // constraints in temps or the result OR no uses that are only used at
901 // start. If this invariant doesn't hold, the register allocator can decide
902 // to insert a split of a range immediately before the instruction due to an
903 // already allocated register needing to be used for the instruction's fixed
904 // register constraint. In this case, The register allocator won't see an
905 // interference between the split child and the use-at-start (it would if
906 // the it was just a plain use), so it is free to move the split child into
907 // the same register that is used for the use-at-start.
908 // See https://code.google.com/p/chromium/issues/detail?id=201590
909 if (!(instr->ClobbersRegisters() &&
910 instr->ClobbersDoubleRegisters(isolate()))) {
912 int used_at_start = 0;
913 for (UseIterator it(instr); !it.Done(); it.Advance()) {
914 LUnallocated* operand = LUnallocated::cast(it.Current());
915 if (operand->IsUsedAtStart()) ++used_at_start;
917 if (instr->Output() != NULL) {
918 if (LUnallocated::cast(instr->Output())->HasFixedPolicy()) ++fixed;
920 for (TempIterator it(instr); !it.Done(); it.Advance()) {
921 LUnallocated* operand = LUnallocated::cast(it.Current());
922 if (operand->HasFixedPolicy()) ++fixed;
924 DCHECK(fixed == 0 || used_at_start == 0);
928 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) {
929 instr = AssignPointerMap(instr);
931 if (FLAG_stress_environments && !instr->HasEnvironment()) {
932 instr = AssignEnvironment(instr);
934 chunk_->AddInstruction(instr, current_block_);
936 if (instr->IsCall()) {
937 HValue* hydrogen_value_for_lazy_bailout = hydrogen_val;
938 LInstruction* instruction_needing_environment = NULL;
939 if (hydrogen_val->HasObservableSideEffects()) {
940 HSimulate* sim = HSimulate::cast(hydrogen_val->next());
941 instruction_needing_environment = instr;
942 sim->ReplayEnvironment(current_block_->last_environment());
943 hydrogen_value_for_lazy_bailout = sim;
945 LInstruction* bailout = AssignEnvironment(new(zone()) LLazyBailout());
946 bailout->set_hydrogen_value(hydrogen_value_for_lazy_bailout);
947 chunk_->AddInstruction(bailout, current_block_);
948 if (instruction_needing_environment != NULL) {
949 // Store the lazy deopt environment with the instruction if needed.
950 // Right now it is only used for LInstanceOfKnownGlobal.
951 instruction_needing_environment->
952 SetDeferredLazyDeoptimizationEnvironment(bailout->environment());
958 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) {
959 return new(zone()) LGoto(instr->FirstSuccessor());
963 LInstruction* LChunkBuilder::DoBranch(HBranch* instr) {
964 HValue* value = instr->value();
965 Representation r = value->representation();
966 HType type = value->type();
967 ToBooleanStub::Types expected = instr->expected_input_types();
968 if (expected.IsEmpty()) expected = ToBooleanStub::Types::Generic();
970 bool easy_case = !r.IsTagged() || type.IsBoolean() || type.IsSmi() ||
971 type.IsJSArray() || type.IsHeapNumber() || type.IsString();
972 LInstruction* branch = new(zone()) LBranch(UseRegister(value));
974 ((!expected.Contains(ToBooleanStub::SMI) && expected.NeedsMap()) ||
975 !expected.IsGeneric())) {
976 branch = AssignEnvironment(branch);
982 LInstruction* LChunkBuilder::DoCompareMap(HCompareMap* instr) {
983 DCHECK(instr->value()->representation().IsTagged());
984 LOperand* value = UseRegisterAtStart(instr->value());
985 LOperand* temp = TempRegister();
986 return new(zone()) LCmpMapAndBranch(value, temp);
990 LInstruction* LChunkBuilder::DoArgumentsLength(HArgumentsLength* length) {
991 info()->MarkAsRequiresFrame();
992 return DefineAsRegister(
993 new(zone()) LArgumentsLength(UseRegister(length->value())));
997 LInstruction* LChunkBuilder::DoArgumentsElements(HArgumentsElements* elems) {
998 info()->MarkAsRequiresFrame();
999 return DefineAsRegister(new(zone()) LArgumentsElements);
1003 LInstruction* LChunkBuilder::DoInstanceOf(HInstanceOf* instr) {
1004 LOperand* context = UseFixed(instr->context(), cp);
1005 LInstanceOf* result =
1006 new(zone()) LInstanceOf(context, UseFixed(instr->left(), a0),
1007 UseFixed(instr->right(), a1));
1008 return MarkAsCall(DefineFixed(result, v0), instr);
1012 LInstruction* LChunkBuilder::DoInstanceOfKnownGlobal(
1013 HInstanceOfKnownGlobal* instr) {
1014 LInstanceOfKnownGlobal* result =
1015 new(zone()) LInstanceOfKnownGlobal(
1016 UseFixed(instr->context(), cp),
1017 UseFixed(instr->left(), a0),
1019 return MarkAsCall(DefineFixed(result, v0), instr);
1023 LInstruction* LChunkBuilder::DoWrapReceiver(HWrapReceiver* instr) {
1024 LOperand* receiver = UseRegisterAtStart(instr->receiver());
1025 LOperand* function = UseRegisterAtStart(instr->function());
1026 LWrapReceiver* result = new(zone()) LWrapReceiver(receiver, function);
1027 return AssignEnvironment(DefineAsRegister(result));
1031 LInstruction* LChunkBuilder::DoApplyArguments(HApplyArguments* instr) {
1032 LOperand* function = UseFixed(instr->function(), a1);
1033 LOperand* receiver = UseFixed(instr->receiver(), a0);
1034 LOperand* length = UseFixed(instr->length(), a2);
1035 LOperand* elements = UseFixed(instr->elements(), a3);
1036 LApplyArguments* result = new(zone()) LApplyArguments(function,
1040 return MarkAsCall(DefineFixed(result, v0), instr, CAN_DEOPTIMIZE_EAGERLY);
1044 LInstruction* LChunkBuilder::DoPushArguments(HPushArguments* instr) {
1045 int argc = instr->OperandCount();
1046 for (int i = 0; i < argc; ++i) {
1047 LOperand* argument = Use(instr->argument(i));
1048 AddInstruction(new(zone()) LPushArgument(argument), instr);
1054 LInstruction* LChunkBuilder::DoStoreCodeEntry(
1055 HStoreCodeEntry* store_code_entry) {
1056 LOperand* function = UseRegister(store_code_entry->function());
1057 LOperand* code_object = UseTempRegister(store_code_entry->code_object());
1058 return new(zone()) LStoreCodeEntry(function, code_object);
1062 LInstruction* LChunkBuilder::DoInnerAllocatedObject(
1063 HInnerAllocatedObject* instr) {
1064 LOperand* base_object = UseRegisterAtStart(instr->base_object());
1065 LOperand* offset = UseRegisterOrConstantAtStart(instr->offset());
1066 return DefineAsRegister(
1067 new(zone()) LInnerAllocatedObject(base_object, offset));
1071 LInstruction* LChunkBuilder::DoThisFunction(HThisFunction* instr) {
1072 return instr->HasNoUses()
1074 : DefineAsRegister(new(zone()) LThisFunction);
1078 LInstruction* LChunkBuilder::DoContext(HContext* instr) {
1079 if (instr->HasNoUses()) return NULL;
1081 if (info()->IsStub()) {
1082 return DefineFixed(new(zone()) LContext, cp);
1085 return DefineAsRegister(new(zone()) LContext);
1089 LInstruction* LChunkBuilder::DoDeclareGlobals(HDeclareGlobals* instr) {
1090 LOperand* context = UseFixed(instr->context(), cp);
1091 return MarkAsCall(new(zone()) LDeclareGlobals(context), instr);
1095 LInstruction* LChunkBuilder::DoCallJSFunction(
1096 HCallJSFunction* instr) {
1097 LOperand* function = UseFixed(instr->function(), a1);
1099 LCallJSFunction* result = new(zone()) LCallJSFunction(function);
1101 return MarkAsCall(DefineFixed(result, v0), instr);
1105 LInstruction* LChunkBuilder::DoCallWithDescriptor(
1106 HCallWithDescriptor* instr) {
1107 CallInterfaceDescriptor descriptor = instr->descriptor();
1109 LOperand* target = UseRegisterOrConstantAtStart(instr->target());
1110 ZoneList<LOperand*> ops(instr->OperandCount(), zone());
1112 ops.Add(target, zone());
1114 LOperand* op = UseFixed(instr->OperandAt(1), cp);
1115 ops.Add(op, zone());
1116 // Other register parameters
1117 for (int i = LCallWithDescriptor::kImplicitRegisterParameterCount;
1118 i < instr->OperandCount(); i++) {
1120 UseFixed(instr->OperandAt(i),
1121 descriptor.GetRegisterParameter(
1122 i - LCallWithDescriptor::kImplicitRegisterParameterCount));
1123 ops.Add(op, zone());
1126 LCallWithDescriptor* result = new(zone()) LCallWithDescriptor(
1127 descriptor, ops, zone());
1128 return MarkAsCall(DefineFixed(result, v0), instr);
1132 LInstruction* LChunkBuilder::DoInvokeFunction(HInvokeFunction* instr) {
1133 LOperand* context = UseFixed(instr->context(), cp);
1134 LOperand* function = UseFixed(instr->function(), a1);
1135 LInvokeFunction* result = new(zone()) LInvokeFunction(context, function);
1136 return MarkAsCall(DefineFixed(result, v0), instr, CANNOT_DEOPTIMIZE_EAGERLY);
1140 LInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) {
1141 switch (instr->op()) {
1143 return DoMathFloor(instr);
1145 return DoMathRound(instr);
1147 return DoMathFround(instr);
1149 return DoMathAbs(instr);
1151 return DoMathLog(instr);
1153 return DoMathExp(instr);
1155 return DoMathSqrt(instr);
1157 return DoMathPowHalf(instr);
1159 return DoMathClz32(instr);
1167 LInstruction* LChunkBuilder::DoMathLog(HUnaryMathOperation* instr) {
1168 DCHECK(instr->representation().IsDouble());
1169 DCHECK(instr->value()->representation().IsDouble());
1170 LOperand* input = UseFixedDouble(instr->value(), f4);
1171 return MarkAsCall(DefineFixedDouble(new(zone()) LMathLog(input), f4), instr);
1175 LInstruction* LChunkBuilder::DoMathClz32(HUnaryMathOperation* instr) {
1176 LOperand* input = UseRegisterAtStart(instr->value());
1177 LMathClz32* result = new(zone()) LMathClz32(input);
1178 return DefineAsRegister(result);
1182 LInstruction* LChunkBuilder::DoMathExp(HUnaryMathOperation* instr) {
1183 DCHECK(instr->representation().IsDouble());
1184 DCHECK(instr->value()->representation().IsDouble());
1185 LOperand* input = UseRegister(instr->value());
1186 LOperand* temp1 = TempRegister();
1187 LOperand* temp2 = TempRegister();
1188 LOperand* double_temp = TempDoubleRegister();
1189 LMathExp* result = new(zone()) LMathExp(input, double_temp, temp1, temp2);
1190 return DefineAsRegister(result);
1194 LInstruction* LChunkBuilder::DoMathPowHalf(HUnaryMathOperation* instr) {
1195 // Input cannot be the same as the result, see LCodeGen::DoMathPowHalf.
1196 LOperand* input = UseFixedDouble(instr->value(), f8);
1197 LOperand* temp = TempDoubleRegister();
1198 LMathPowHalf* result = new(zone()) LMathPowHalf(input, temp);
1199 return DefineFixedDouble(result, f4);
1203 LInstruction* LChunkBuilder::DoMathFround(HUnaryMathOperation* instr) {
1204 LOperand* input = UseRegister(instr->value());
1205 LMathFround* result = new (zone()) LMathFround(input);
1206 return DefineAsRegister(result);
1210 LInstruction* LChunkBuilder::DoMathAbs(HUnaryMathOperation* instr) {
1211 Representation r = instr->value()->representation();
1212 LOperand* context = (r.IsDouble() || r.IsSmiOrInteger32())
1214 : UseFixed(instr->context(), cp);
1215 LOperand* input = UseRegister(instr->value());
1216 LInstruction* result =
1217 DefineAsRegister(new(zone()) LMathAbs(context, input));
1218 if (!r.IsDouble() && !r.IsSmiOrInteger32()) result = AssignPointerMap(result);
1219 if (!r.IsDouble()) result = AssignEnvironment(result);
1224 LInstruction* LChunkBuilder::DoMathFloor(HUnaryMathOperation* instr) {
1225 LOperand* input = UseRegister(instr->value());
1226 LOperand* temp = TempRegister();
1227 LMathFloor* result = new(zone()) LMathFloor(input, temp);
1228 return AssignEnvironment(AssignPointerMap(DefineAsRegister(result)));
1232 LInstruction* LChunkBuilder::DoMathSqrt(HUnaryMathOperation* instr) {
1233 LOperand* input = UseRegister(instr->value());
1234 LMathSqrt* result = new(zone()) LMathSqrt(input);
1235 return DefineAsRegister(result);
1239 LInstruction* LChunkBuilder::DoMathRound(HUnaryMathOperation* instr) {
1240 LOperand* input = UseRegister(instr->value());
1241 LOperand* temp = TempDoubleRegister();
1242 LMathRound* result = new(zone()) LMathRound(input, temp);
1243 return AssignEnvironment(DefineAsRegister(result));
1247 LInstruction* LChunkBuilder::DoCallNew(HCallNew* instr) {
1248 LOperand* context = UseFixed(instr->context(), cp);
1249 LOperand* constructor = UseFixed(instr->constructor(), a1);
1250 LCallNew* result = new(zone()) LCallNew(context, constructor);
1251 return MarkAsCall(DefineFixed(result, v0), instr);
1255 LInstruction* LChunkBuilder::DoCallNewArray(HCallNewArray* instr) {
1256 LOperand* context = UseFixed(instr->context(), cp);
1257 LOperand* constructor = UseFixed(instr->constructor(), a1);
1258 LCallNewArray* result = new(zone()) LCallNewArray(context, constructor);
1259 return MarkAsCall(DefineFixed(result, v0), instr);
1263 LInstruction* LChunkBuilder::DoCallFunction(HCallFunction* instr) {
1264 LOperand* context = UseFixed(instr->context(), cp);
1265 LOperand* function = UseFixed(instr->function(), a1);
1266 LOperand* slot = NULL;
1267 LOperand* vector = NULL;
1268 if (instr->HasVectorAndSlot()) {
1269 slot = FixedTemp(a3);
1270 vector = FixedTemp(a2);
1273 LCallFunction* call =
1274 new (zone()) LCallFunction(context, function, slot, vector);
1275 return MarkAsCall(DefineFixed(call, v0), instr);
1279 LInstruction* LChunkBuilder::DoCallRuntime(HCallRuntime* instr) {
1280 LOperand* context = UseFixed(instr->context(), cp);
1281 return MarkAsCall(DefineFixed(new(zone()) LCallRuntime(context), v0), instr);
1285 LInstruction* LChunkBuilder::DoRor(HRor* instr) {
1286 return DoShift(Token::ROR, instr);
1290 LInstruction* LChunkBuilder::DoShr(HShr* instr) {
1291 return DoShift(Token::SHR, instr);
1295 LInstruction* LChunkBuilder::DoSar(HSar* instr) {
1296 return DoShift(Token::SAR, instr);
1300 LInstruction* LChunkBuilder::DoShl(HShl* instr) {
1301 return DoShift(Token::SHL, instr);
1305 LInstruction* LChunkBuilder::DoBitwise(HBitwise* instr) {
1306 if (instr->representation().IsSmiOrInteger32()) {
1307 DCHECK(instr->left()->representation().Equals(instr->representation()));
1308 DCHECK(instr->right()->representation().Equals(instr->representation()));
1309 DCHECK(instr->CheckFlag(HValue::kTruncatingToInt32));
1311 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand());
1312 LOperand* right = UseOrConstantAtStart(instr->BetterRightOperand());
1313 return DefineAsRegister(new(zone()) LBitI(left, right));
1315 return DoArithmeticT(instr->op(), instr);
1320 LInstruction* LChunkBuilder::DoDivByPowerOf2I(HDiv* instr) {
1321 DCHECK(instr->representation().IsSmiOrInteger32());
1322 DCHECK(instr->left()->representation().Equals(instr->representation()));
1323 DCHECK(instr->right()->representation().Equals(instr->representation()));
1324 LOperand* dividend = UseRegister(instr->left());
1325 int32_t divisor = instr->right()->GetInteger32Constant();
1326 LInstruction* result = DefineAsRegister(new(zone()) LDivByPowerOf2I(
1327 dividend, divisor));
1328 if ((instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) ||
1329 (instr->CheckFlag(HValue::kCanOverflow) && divisor == -1) ||
1330 (!instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32) &&
1331 divisor != 1 && divisor != -1)) {
1332 result = AssignEnvironment(result);
1338 LInstruction* LChunkBuilder::DoDivByConstI(HDiv* instr) {
1339 DCHECK(instr->representation().IsInteger32());
1340 DCHECK(instr->left()->representation().Equals(instr->representation()));
1341 DCHECK(instr->right()->representation().Equals(instr->representation()));
1342 LOperand* dividend = UseRegister(instr->left());
1343 int32_t divisor = instr->right()->GetInteger32Constant();
1344 LInstruction* result = DefineAsRegister(new(zone()) LDivByConstI(
1345 dividend, divisor));
1347 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) ||
1348 !instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32)) {
1349 result = AssignEnvironment(result);
1355 LInstruction* LChunkBuilder::DoDivI(HDiv* instr) {
1356 DCHECK(instr->representation().IsSmiOrInteger32());
1357 DCHECK(instr->left()->representation().Equals(instr->representation()));
1358 DCHECK(instr->right()->representation().Equals(instr->representation()));
1359 LOperand* dividend = UseRegister(instr->left());
1360 LOperand* divisor = UseRegister(instr->right());
1361 LOperand* temp = instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32)
1362 ? NULL : TempRegister();
1363 LInstruction* result =
1364 DefineAsRegister(new(zone()) LDivI(dividend, divisor, temp));
1365 if (instr->CheckFlag(HValue::kCanBeDivByZero) ||
1366 instr->CheckFlag(HValue::kBailoutOnMinusZero) ||
1367 (instr->CheckFlag(HValue::kCanOverflow) &&
1368 !instr->CheckFlag(HValue::kAllUsesTruncatingToInt32)) ||
1369 (!instr->IsMathFloorOfDiv() &&
1370 !instr->CheckFlag(HValue::kAllUsesTruncatingToInt32))) {
1371 result = AssignEnvironment(result);
1377 LInstruction* LChunkBuilder::DoDiv(HDiv* instr) {
1378 if (instr->representation().IsSmiOrInteger32()) {
1379 if (instr->RightIsPowerOf2()) {
1380 return DoDivByPowerOf2I(instr);
1381 } else if (instr->right()->IsConstant()) {
1382 return DoDivByConstI(instr);
1384 return DoDivI(instr);
1386 } else if (instr->representation().IsDouble()) {
1387 return DoArithmeticD(Token::DIV, instr);
1389 return DoArithmeticT(Token::DIV, instr);
1394 LInstruction* LChunkBuilder::DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr) {
1395 LOperand* dividend = UseRegisterAtStart(instr->left());
1396 int32_t divisor = instr->right()->GetInteger32Constant();
1397 LInstruction* result = DefineAsRegister(new(zone()) LFlooringDivByPowerOf2I(
1398 dividend, divisor));
1399 if ((instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) ||
1400 (instr->CheckFlag(HValue::kLeftCanBeMinInt) && divisor == -1)) {
1401 result = AssignEnvironment(result);
1407 LInstruction* LChunkBuilder::DoFlooringDivByConstI(HMathFloorOfDiv* instr) {
1408 DCHECK(instr->representation().IsInteger32());
1409 DCHECK(instr->left()->representation().Equals(instr->representation()));
1410 DCHECK(instr->right()->representation().Equals(instr->representation()));
1411 LOperand* dividend = UseRegister(instr->left());
1412 int32_t divisor = instr->right()->GetInteger32Constant();
1414 ((divisor > 0 && !instr->CheckFlag(HValue::kLeftCanBeNegative)) ||
1415 (divisor < 0 && !instr->CheckFlag(HValue::kLeftCanBePositive))) ?
1416 NULL : TempRegister();
1417 LInstruction* result = DefineAsRegister(
1418 new(zone()) LFlooringDivByConstI(dividend, divisor, temp));
1420 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0)) {
1421 result = AssignEnvironment(result);
1427 LInstruction* LChunkBuilder::DoFlooringDivI(HMathFloorOfDiv* instr) {
1428 DCHECK(instr->representation().IsSmiOrInteger32());
1429 DCHECK(instr->left()->representation().Equals(instr->representation()));
1430 DCHECK(instr->right()->representation().Equals(instr->representation()));
1431 LOperand* dividend = UseRegister(instr->left());
1432 LOperand* divisor = UseRegister(instr->right());
1433 LInstruction* result =
1434 DefineAsRegister(new (zone()) LFlooringDivI(dividend, divisor));
1435 if (instr->CheckFlag(HValue::kCanBeDivByZero) ||
1436 instr->CheckFlag(HValue::kBailoutOnMinusZero) ||
1437 (instr->CheckFlag(HValue::kCanOverflow))) {
1438 result = AssignEnvironment(result);
1444 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) {
1445 if (instr->RightIsPowerOf2()) {
1446 return DoFlooringDivByPowerOf2I(instr);
1447 } else if (instr->right()->IsConstant()) {
1448 return DoFlooringDivByConstI(instr);
1450 return DoFlooringDivI(instr);
1455 LInstruction* LChunkBuilder::DoModByPowerOf2I(HMod* instr) {
1456 DCHECK(instr->representation().IsSmiOrInteger32());
1457 DCHECK(instr->left()->representation().Equals(instr->representation()));
1458 DCHECK(instr->right()->representation().Equals(instr->representation()));
1459 LOperand* dividend = UseRegisterAtStart(instr->left());
1460 int32_t divisor = instr->right()->GetInteger32Constant();
1461 LInstruction* result = DefineSameAsFirst(new(zone()) LModByPowerOf2I(
1462 dividend, divisor));
1463 if (instr->CheckFlag(HValue::kLeftCanBeNegative) &&
1464 instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
1465 result = AssignEnvironment(result);
1471 LInstruction* LChunkBuilder::DoModByConstI(HMod* instr) {
1472 DCHECK(instr->representation().IsSmiOrInteger32());
1473 DCHECK(instr->left()->representation().Equals(instr->representation()));
1474 DCHECK(instr->right()->representation().Equals(instr->representation()));
1475 LOperand* dividend = UseRegister(instr->left());
1476 int32_t divisor = instr->right()->GetInteger32Constant();
1477 LInstruction* result = DefineAsRegister(new(zone()) LModByConstI(
1478 dividend, divisor));
1479 if (divisor == 0 || instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
1480 result = AssignEnvironment(result);
1486 LInstruction* LChunkBuilder::DoModI(HMod* instr) {
1487 DCHECK(instr->representation().IsSmiOrInteger32());
1488 DCHECK(instr->left()->representation().Equals(instr->representation()));
1489 DCHECK(instr->right()->representation().Equals(instr->representation()));
1490 LOperand* dividend = UseRegister(instr->left());
1491 LOperand* divisor = UseRegister(instr->right());
1492 LInstruction* result = DefineAsRegister(new(zone()) LModI(
1493 dividend, divisor));
1494 if (instr->CheckFlag(HValue::kCanBeDivByZero) ||
1495 instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
1496 result = AssignEnvironment(result);
1502 LInstruction* LChunkBuilder::DoMod(HMod* instr) {
1503 if (instr->representation().IsSmiOrInteger32()) {
1504 return instr->RightIsPowerOf2() ? DoModByPowerOf2I(instr) : DoModI(instr);
1505 } else if (instr->representation().IsDouble()) {
1506 return DoArithmeticD(Token::MOD, instr);
1508 return DoArithmeticT(Token::MOD, instr);
1513 LInstruction* LChunkBuilder::DoMul(HMul* instr) {
1514 if (instr->representation().IsSmiOrInteger32()) {
1515 DCHECK(instr->left()->representation().Equals(instr->representation()));
1516 DCHECK(instr->right()->representation().Equals(instr->representation()));
1517 HValue* left = instr->BetterLeftOperand();
1518 HValue* right = instr->BetterRightOperand();
1521 bool can_overflow = instr->CheckFlag(HValue::kCanOverflow);
1522 bool bailout_on_minus_zero = instr->CheckFlag(HValue::kBailoutOnMinusZero);
1524 int32_t constant_value = 0;
1525 if (right->IsConstant()) {
1526 HConstant* constant = HConstant::cast(right);
1527 constant_value = constant->Integer32Value();
1528 // Constants -1, 0 and 1 can be optimized if the result can overflow.
1529 // For other constants, it can be optimized only without overflow.
1530 if (!can_overflow || ((constant_value >= -1) && (constant_value <= 1))) {
1531 left_op = UseRegisterAtStart(left);
1532 right_op = UseConstant(right);
1534 if (bailout_on_minus_zero) {
1535 left_op = UseRegister(left);
1537 left_op = UseRegisterAtStart(left);
1539 right_op = UseRegister(right);
1542 if (bailout_on_minus_zero) {
1543 left_op = UseRegister(left);
1545 left_op = UseRegisterAtStart(left);
1547 right_op = UseRegister(right);
1549 LInstruction* result =
1550 instr->representation().IsSmi()
1551 ? DefineAsRegister(new (zone()) LMulS(left_op, right_op))
1552 : DefineAsRegister(new (zone()) LMulI(left_op, right_op));
1553 if (right_op->IsConstantOperand()
1554 ? ((can_overflow && constant_value == -1) ||
1555 (bailout_on_minus_zero && constant_value <= 0))
1556 : (can_overflow || bailout_on_minus_zero)) {
1557 AssignEnvironment(result);
1561 } else if (instr->representation().IsDouble()) {
1562 if (kArchVariant == kMips64r2) {
1563 if (instr->HasOneUse() && instr->uses().value()->IsAdd()) {
1564 HAdd* add = HAdd::cast(instr->uses().value());
1565 if (instr == add->left()) {
1566 // This mul is the lhs of an add. The add and mul will be folded
1567 // into a multiply-add.
1570 if (instr == add->right() && !add->left()->IsMul()) {
1571 // This mul is the rhs of an add, where the lhs is not another mul.
1572 // The add and mul will be folded into a multiply-add.
1577 return DoArithmeticD(Token::MUL, instr);
1579 return DoArithmeticT(Token::MUL, instr);
1584 LInstruction* LChunkBuilder::DoSub(HSub* instr) {
1585 if (instr->representation().IsSmiOrInteger32()) {
1586 DCHECK(instr->left()->representation().Equals(instr->representation()));
1587 DCHECK(instr->right()->representation().Equals(instr->representation()));
1588 LOperand* left = UseRegisterAtStart(instr->left());
1589 LOperand* right = UseRegisterOrConstantAtStart(instr->right());
1590 LInstruction* result =
1591 instr->representation().IsSmi()
1592 ? DefineAsRegister(new (zone()) LSubS(left, right))
1593 : DefineAsRegister(new (zone()) LSubI(left, right));
1594 if (instr->CheckFlag(HValue::kCanOverflow)) {
1595 result = AssignEnvironment(result);
1598 } else if (instr->representation().IsDouble()) {
1599 return DoArithmeticD(Token::SUB, instr);
1601 return DoArithmeticT(Token::SUB, instr);
1606 LInstruction* LChunkBuilder::DoMultiplyAdd(HMul* mul, HValue* addend) {
1607 LOperand* multiplier_op = UseRegisterAtStart(mul->left());
1608 LOperand* multiplicand_op = UseRegisterAtStart(mul->right());
1609 LOperand* addend_op = UseRegisterAtStart(addend);
1610 return DefineSameAsFirst(new(zone()) LMultiplyAddD(addend_op, multiplier_op,
1615 LInstruction* LChunkBuilder::DoAdd(HAdd* instr) {
1616 if (instr->representation().IsSmiOrInteger32()) {
1617 DCHECK(instr->left()->representation().Equals(instr->representation()));
1618 DCHECK(instr->right()->representation().Equals(instr->representation()));
1619 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand());
1620 LOperand* right = UseRegisterOrConstantAtStart(instr->BetterRightOperand());
1621 LInstruction* result =
1622 instr->representation().IsSmi()
1623 ? DefineAsRegister(new (zone()) LAddS(left, right))
1624 : DefineAsRegister(new (zone()) LAddI(left, right));
1625 if (instr->CheckFlag(HValue::kCanOverflow)) {
1626 result = AssignEnvironment(result);
1629 } else if (instr->representation().IsExternal()) {
1630 DCHECK(instr->IsConsistentExternalRepresentation());
1631 DCHECK(!instr->CheckFlag(HValue::kCanOverflow));
1632 LOperand* left = UseRegisterAtStart(instr->left());
1633 LOperand* right = UseRegisterOrConstantAtStart(instr->right());
1634 return DefineAsRegister(new (zone()) LAddE(left, right));
1635 } else if (instr->representation().IsDouble()) {
1636 if (kArchVariant == kMips64r2) {
1637 if (instr->left()->IsMul())
1638 return DoMultiplyAdd(HMul::cast(instr->left()), instr->right());
1640 if (instr->right()->IsMul()) {
1641 DCHECK(!instr->left()->IsMul());
1642 return DoMultiplyAdd(HMul::cast(instr->right()), instr->left());
1645 return DoArithmeticD(Token::ADD, instr);
1647 return DoArithmeticT(Token::ADD, instr);
1652 LInstruction* LChunkBuilder::DoMathMinMax(HMathMinMax* instr) {
1653 LOperand* left = NULL;
1654 LOperand* right = NULL;
1655 if (instr->representation().IsSmiOrInteger32()) {
1656 DCHECK(instr->left()->representation().Equals(instr->representation()));
1657 DCHECK(instr->right()->representation().Equals(instr->representation()));
1658 left = UseRegisterAtStart(instr->BetterLeftOperand());
1659 right = UseOrConstantAtStart(instr->BetterRightOperand());
1661 DCHECK(instr->representation().IsDouble());
1662 DCHECK(instr->left()->representation().IsDouble());
1663 DCHECK(instr->right()->representation().IsDouble());
1664 left = UseRegisterAtStart(instr->left());
1665 right = UseRegisterAtStart(instr->right());
1667 return DefineAsRegister(new(zone()) LMathMinMax(left, right));
1671 LInstruction* LChunkBuilder::DoPower(HPower* instr) {
1672 DCHECK(instr->representation().IsDouble());
1673 // We call a C function for double power. It can't trigger a GC.
1674 // We need to use fixed result register for the call.
1675 Representation exponent_type = instr->right()->representation();
1676 DCHECK(instr->left()->representation().IsDouble());
1677 LOperand* left = UseFixedDouble(instr->left(), f2);
1679 exponent_type.IsDouble()
1680 ? UseFixedDouble(instr->right(), f4)
1681 : UseFixed(instr->right(), MathPowTaggedDescriptor::exponent());
1682 LPower* result = new(zone()) LPower(left, right);
1683 return MarkAsCall(DefineFixedDouble(result, f0),
1685 CAN_DEOPTIMIZE_EAGERLY);
1689 LInstruction* LChunkBuilder::DoCompareGeneric(HCompareGeneric* instr) {
1690 DCHECK(instr->left()->representation().IsTagged());
1691 DCHECK(instr->right()->representation().IsTagged());
1692 LOperand* context = UseFixed(instr->context(), cp);
1693 LOperand* left = UseFixed(instr->left(), a1);
1694 LOperand* right = UseFixed(instr->right(), a0);
1695 LCmpT* result = new(zone()) LCmpT(context, left, right);
1696 return MarkAsCall(DefineFixed(result, v0), instr);
1700 LInstruction* LChunkBuilder::DoCompareNumericAndBranch(
1701 HCompareNumericAndBranch* instr) {
1702 Representation r = instr->representation();
1703 if (r.IsSmiOrInteger32()) {
1704 DCHECK(instr->left()->representation().Equals(r));
1705 DCHECK(instr->right()->representation().Equals(r));
1706 LOperand* left = UseRegisterOrConstantAtStart(instr->left());
1707 LOperand* right = UseRegisterOrConstantAtStart(instr->right());
1708 return new(zone()) LCompareNumericAndBranch(left, right);
1710 DCHECK(r.IsDouble());
1711 DCHECK(instr->left()->representation().IsDouble());
1712 DCHECK(instr->right()->representation().IsDouble());
1713 LOperand* left = UseRegisterAtStart(instr->left());
1714 LOperand* right = UseRegisterAtStart(instr->right());
1715 return new(zone()) LCompareNumericAndBranch(left, right);
1720 LInstruction* LChunkBuilder::DoCompareObjectEqAndBranch(
1721 HCompareObjectEqAndBranch* instr) {
1722 LOperand* left = UseRegisterAtStart(instr->left());
1723 LOperand* right = UseRegisterAtStart(instr->right());
1724 return new(zone()) LCmpObjectEqAndBranch(left, right);
1728 LInstruction* LChunkBuilder::DoCompareHoleAndBranch(
1729 HCompareHoleAndBranch* instr) {
1730 LOperand* value = UseRegisterAtStart(instr->value());
1731 return new(zone()) LCmpHoleAndBranch(value);
1735 LInstruction* LChunkBuilder::DoCompareMinusZeroAndBranch(
1736 HCompareMinusZeroAndBranch* instr) {
1737 LOperand* value = UseRegister(instr->value());
1738 LOperand* scratch = TempRegister();
1739 return new(zone()) LCompareMinusZeroAndBranch(value, scratch);
1743 LInstruction* LChunkBuilder::DoIsObjectAndBranch(HIsObjectAndBranch* instr) {
1744 DCHECK(instr->value()->representation().IsTagged());
1745 LOperand* temp = TempRegister();
1746 return new(zone()) LIsObjectAndBranch(UseRegisterAtStart(instr->value()),
1751 LInstruction* LChunkBuilder::DoIsStringAndBranch(HIsStringAndBranch* instr) {
1752 DCHECK(instr->value()->representation().IsTagged());
1753 LOperand* temp = TempRegister();
1754 return new(zone()) LIsStringAndBranch(UseRegisterAtStart(instr->value()),
1759 LInstruction* LChunkBuilder::DoIsSmiAndBranch(HIsSmiAndBranch* instr) {
1760 DCHECK(instr->value()->representation().IsTagged());
1761 return new(zone()) LIsSmiAndBranch(Use(instr->value()));
1765 LInstruction* LChunkBuilder::DoIsUndetectableAndBranch(
1766 HIsUndetectableAndBranch* instr) {
1767 DCHECK(instr->value()->representation().IsTagged());
1768 return new(zone()) LIsUndetectableAndBranch(
1769 UseRegisterAtStart(instr->value()), TempRegister());
1773 LInstruction* LChunkBuilder::DoStringCompareAndBranch(
1774 HStringCompareAndBranch* instr) {
1775 DCHECK(instr->left()->representation().IsTagged());
1776 DCHECK(instr->right()->representation().IsTagged());
1777 LOperand* context = UseFixed(instr->context(), cp);
1778 LOperand* left = UseFixed(instr->left(), a1);
1779 LOperand* right = UseFixed(instr->right(), a0);
1780 LStringCompareAndBranch* result =
1781 new(zone()) LStringCompareAndBranch(context, left, right);
1782 return MarkAsCall(result, instr);
1786 LInstruction* LChunkBuilder::DoHasInstanceTypeAndBranch(
1787 HHasInstanceTypeAndBranch* instr) {
1788 DCHECK(instr->value()->representation().IsTagged());
1789 LOperand* value = UseRegisterAtStart(instr->value());
1790 return new(zone()) LHasInstanceTypeAndBranch(value);
1794 LInstruction* LChunkBuilder::DoGetCachedArrayIndex(
1795 HGetCachedArrayIndex* instr) {
1796 DCHECK(instr->value()->representation().IsTagged());
1797 LOperand* value = UseRegisterAtStart(instr->value());
1799 return DefineAsRegister(new(zone()) LGetCachedArrayIndex(value));
1803 LInstruction* LChunkBuilder::DoHasCachedArrayIndexAndBranch(
1804 HHasCachedArrayIndexAndBranch* instr) {
1805 DCHECK(instr->value()->representation().IsTagged());
1806 return new(zone()) LHasCachedArrayIndexAndBranch(
1807 UseRegisterAtStart(instr->value()));
1811 LInstruction* LChunkBuilder::DoClassOfTestAndBranch(
1812 HClassOfTestAndBranch* instr) {
1813 DCHECK(instr->value()->representation().IsTagged());
1814 return new(zone()) LClassOfTestAndBranch(UseRegister(instr->value()),
1819 LInstruction* LChunkBuilder::DoMapEnumLength(HMapEnumLength* instr) {
1820 LOperand* map = UseRegisterAtStart(instr->value());
1821 return DefineAsRegister(new(zone()) LMapEnumLength(map));
1825 LInstruction* LChunkBuilder::DoDateField(HDateField* instr) {
1826 LOperand* object = UseFixed(instr->value(), a0);
1827 LDateField* result =
1828 new(zone()) LDateField(object, FixedTemp(a1), instr->index());
1829 return MarkAsCall(DefineFixed(result, v0), instr, CANNOT_DEOPTIMIZE_EAGERLY);
1833 LInstruction* LChunkBuilder::DoSeqStringGetChar(HSeqStringGetChar* instr) {
1834 LOperand* string = UseRegisterAtStart(instr->string());
1835 LOperand* index = UseRegisterOrConstantAtStart(instr->index());
1836 return DefineAsRegister(new(zone()) LSeqStringGetChar(string, index));
1840 LInstruction* LChunkBuilder::DoSeqStringSetChar(HSeqStringSetChar* instr) {
1841 LOperand* string = UseRegisterAtStart(instr->string());
1842 LOperand* index = FLAG_debug_code
1843 ? UseRegisterAtStart(instr->index())
1844 : UseRegisterOrConstantAtStart(instr->index());
1845 LOperand* value = UseRegisterAtStart(instr->value());
1846 LOperand* context = FLAG_debug_code ? UseFixed(instr->context(), cp) : NULL;
1847 return new(zone()) LSeqStringSetChar(context, string, index, value);
1851 LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) {
1852 if (!FLAG_debug_code && instr->skip_check()) return NULL;
1853 LOperand* index = UseRegisterOrConstantAtStart(instr->index());
1854 LOperand* length = !index->IsConstantOperand()
1855 ? UseRegisterOrConstantAtStart(instr->length())
1856 : UseRegisterAtStart(instr->length());
1857 LInstruction* result = new(zone()) LBoundsCheck(index, length);
1858 if (!FLAG_debug_code || !instr->skip_check()) {
1859 result = AssignEnvironment(result);
1865 LInstruction* LChunkBuilder::DoBoundsCheckBaseIndexInformation(
1866 HBoundsCheckBaseIndexInformation* instr) {
1872 LInstruction* LChunkBuilder::DoAbnormalExit(HAbnormalExit* instr) {
1873 // The control instruction marking the end of a block that completed
1874 // abruptly (e.g., threw an exception). There is nothing specific to do.
1879 LInstruction* LChunkBuilder::DoUseConst(HUseConst* instr) {
1884 LInstruction* LChunkBuilder::DoForceRepresentation(HForceRepresentation* bad) {
1885 // All HForceRepresentation instructions should be eliminated in the
1886 // representation change phase of Hydrogen.
1892 LInstruction* LChunkBuilder::DoChange(HChange* instr) {
1893 Representation from = instr->from();
1894 Representation to = instr->to();
1895 HValue* val = instr->value();
1897 if (to.IsTagged()) {
1898 LOperand* value = UseRegister(val);
1899 return DefineSameAsFirst(new(zone()) LDummyUse(value));
1901 from = Representation::Tagged();
1903 if (from.IsTagged()) {
1904 if (to.IsDouble()) {
1905 LOperand* value = UseRegister(val);
1906 LInstruction* result = DefineAsRegister(new(zone()) LNumberUntagD(value));
1907 if (!val->representation().IsSmi()) result = AssignEnvironment(result);
1909 } else if (to.IsSmi()) {
1910 LOperand* value = UseRegister(val);
1911 if (val->type().IsSmi()) {
1912 return DefineSameAsFirst(new(zone()) LDummyUse(value));
1914 return AssignEnvironment(DefineSameAsFirst(new(zone()) LCheckSmi(value)));
1916 DCHECK(to.IsInteger32());
1917 if (val->type().IsSmi() || val->representation().IsSmi()) {
1918 LOperand* value = UseRegisterAtStart(val);
1919 return DefineAsRegister(new(zone()) LSmiUntag(value, false));
1921 LOperand* value = UseRegister(val);
1922 LOperand* temp1 = TempRegister();
1923 LOperand* temp2 = TempDoubleRegister();
1924 LInstruction* result =
1925 DefineSameAsFirst(new(zone()) LTaggedToI(value, temp1, temp2));
1926 if (!val->representation().IsSmi()) result = AssignEnvironment(result);
1930 } else if (from.IsDouble()) {
1931 if (to.IsTagged()) {
1932 info()->MarkAsDeferredCalling();
1933 LOperand* value = UseRegister(val);
1934 LOperand* temp1 = TempRegister();
1935 LOperand* temp2 = TempRegister();
1937 LUnallocated* result_temp = TempRegister();
1938 LNumberTagD* result = new(zone()) LNumberTagD(value, temp1, temp2);
1939 return AssignPointerMap(Define(result, result_temp));
1940 } else if (to.IsSmi()) {
1941 LOperand* value = UseRegister(val);
1942 return AssignEnvironment(
1943 DefineAsRegister(new(zone()) LDoubleToSmi(value)));
1945 DCHECK(to.IsInteger32());
1946 LOperand* value = UseRegister(val);
1947 LInstruction* result = DefineAsRegister(new(zone()) LDoubleToI(value));
1948 if (!instr->CanTruncateToInt32()) result = AssignEnvironment(result);
1951 } else if (from.IsInteger32()) {
1952 info()->MarkAsDeferredCalling();
1953 if (to.IsTagged()) {
1954 if (val->CheckFlag(HInstruction::kUint32)) {
1955 LOperand* value = UseRegisterAtStart(val);
1956 LOperand* temp1 = TempRegister();
1957 LOperand* temp2 = TempRegister();
1958 LNumberTagU* result = new(zone()) LNumberTagU(value, temp1, temp2);
1959 return AssignPointerMap(DefineAsRegister(result));
1961 STATIC_ASSERT((kMinInt == Smi::kMinValue) &&
1962 (kMaxInt == Smi::kMaxValue));
1963 LOperand* value = UseRegisterAtStart(val);
1964 return DefineAsRegister(new(zone()) LSmiTag(value));
1966 } else if (to.IsSmi()) {
1967 LOperand* value = UseRegister(val);
1968 LInstruction* result = DefineAsRegister(new(zone()) LSmiTag(value));
1969 if (instr->CheckFlag(HValue::kCanOverflow)) {
1970 result = AssignEnvironment(result);
1974 DCHECK(to.IsDouble());
1975 if (val->CheckFlag(HInstruction::kUint32)) {
1976 return DefineAsRegister(new(zone()) LUint32ToDouble(UseRegister(val)));
1978 return DefineAsRegister(new(zone()) LInteger32ToDouble(Use(val)));
1987 LInstruction* LChunkBuilder::DoCheckHeapObject(HCheckHeapObject* instr) {
1988 LOperand* value = UseRegisterAtStart(instr->value());
1989 LInstruction* result = new(zone()) LCheckNonSmi(value);
1990 if (!instr->value()->type().IsHeapObject()) {
1991 result = AssignEnvironment(result);
1997 LInstruction* LChunkBuilder::DoCheckSmi(HCheckSmi* instr) {
1998 LOperand* value = UseRegisterAtStart(instr->value());
1999 return AssignEnvironment(new(zone()) LCheckSmi(value));
2003 LInstruction* LChunkBuilder::DoCheckArrayBufferNotNeutered(
2004 HCheckArrayBufferNotNeutered* instr) {
2005 LOperand* view = UseRegisterAtStart(instr->value());
2006 LCheckArrayBufferNotNeutered* result =
2007 new (zone()) LCheckArrayBufferNotNeutered(view);
2008 return AssignEnvironment(result);
2012 LInstruction* LChunkBuilder::DoCheckInstanceType(HCheckInstanceType* instr) {
2013 LOperand* value = UseRegisterAtStart(instr->value());
2014 LInstruction* result = new(zone()) LCheckInstanceType(value);
2015 return AssignEnvironment(result);
2019 LInstruction* LChunkBuilder::DoCheckValue(HCheckValue* instr) {
2020 LOperand* value = UseRegisterAtStart(instr->value());
2021 return AssignEnvironment(new(zone()) LCheckValue(value));
2025 LInstruction* LChunkBuilder::DoCheckMaps(HCheckMaps* instr) {
2026 if (instr->IsStabilityCheck()) return new(zone()) LCheckMaps;
2027 LOperand* value = UseRegisterAtStart(instr->value());
2028 LInstruction* result = AssignEnvironment(new(zone()) LCheckMaps(value));
2029 if (instr->HasMigrationTarget()) {
2030 info()->MarkAsDeferredCalling();
2031 result = AssignPointerMap(result);
2037 LInstruction* LChunkBuilder::DoClampToUint8(HClampToUint8* instr) {
2038 HValue* value = instr->value();
2039 Representation input_rep = value->representation();
2040 LOperand* reg = UseRegister(value);
2041 if (input_rep.IsDouble()) {
2042 // Revisit this decision, here and 8 lines below.
2043 return DefineAsRegister(new(zone()) LClampDToUint8(reg,
2044 TempDoubleRegister()));
2045 } else if (input_rep.IsInteger32()) {
2046 return DefineAsRegister(new(zone()) LClampIToUint8(reg));
2048 DCHECK(input_rep.IsSmiOrTagged());
2049 LClampTToUint8* result =
2050 new(zone()) LClampTToUint8(reg, TempDoubleRegister());
2051 return AssignEnvironment(DefineAsRegister(result));
2056 LInstruction* LChunkBuilder::DoDoubleBits(HDoubleBits* instr) {
2057 HValue* value = instr->value();
2058 DCHECK(value->representation().IsDouble());
2059 return DefineAsRegister(new(zone()) LDoubleBits(UseRegister(value)));
2063 LInstruction* LChunkBuilder::DoConstructDouble(HConstructDouble* instr) {
2064 LOperand* lo = UseRegister(instr->lo());
2065 LOperand* hi = UseRegister(instr->hi());
2066 return DefineAsRegister(new(zone()) LConstructDouble(hi, lo));
2070 LInstruction* LChunkBuilder::DoReturn(HReturn* instr) {
2071 LOperand* context = info()->IsStub()
2072 ? UseFixed(instr->context(), cp)
2074 LOperand* parameter_count = UseRegisterOrConstant(instr->parameter_count());
2075 return new(zone()) LReturn(UseFixed(instr->value(), v0), context,
2080 LInstruction* LChunkBuilder::DoConstant(HConstant* instr) {
2081 Representation r = instr->representation();
2083 return DefineAsRegister(new(zone()) LConstantS);
2084 } else if (r.IsInteger32()) {
2085 return DefineAsRegister(new(zone()) LConstantI);
2086 } else if (r.IsDouble()) {
2087 return DefineAsRegister(new(zone()) LConstantD);
2088 } else if (r.IsExternal()) {
2089 return DefineAsRegister(new(zone()) LConstantE);
2090 } else if (r.IsTagged()) {
2091 return DefineAsRegister(new(zone()) LConstantT);
2099 LInstruction* LChunkBuilder::DoLoadGlobalGeneric(HLoadGlobalGeneric* instr) {
2100 LOperand* context = UseFixed(instr->context(), cp);
2101 LOperand* global_object =
2102 UseFixed(instr->global_object(), LoadDescriptor::ReceiverRegister());
2103 LOperand* vector = NULL;
2104 if (instr->HasVectorAndSlot()) {
2105 vector = FixedTemp(LoadWithVectorDescriptor::VectorRegister());
2107 LLoadGlobalGeneric* result =
2108 new(zone()) LLoadGlobalGeneric(context, global_object, vector);
2109 return MarkAsCall(DefineFixed(result, v0), instr);
2113 LInstruction* LChunkBuilder::DoLoadGlobalViaContext(
2114 HLoadGlobalViaContext* instr) {
2115 LOperand* context = UseFixed(instr->context(), cp);
2116 DCHECK(instr->slot_index() > 0);
2117 LLoadGlobalViaContext* result = new (zone()) LLoadGlobalViaContext(context);
2118 return MarkAsCall(DefineFixed(result, v0), instr);
2122 LInstruction* LChunkBuilder::DoLoadContextSlot(HLoadContextSlot* instr) {
2123 LOperand* context = UseRegisterAtStart(instr->value());
2124 LInstruction* result =
2125 DefineAsRegister(new(zone()) LLoadContextSlot(context));
2126 if (instr->RequiresHoleCheck() && instr->DeoptimizesOnHole()) {
2127 result = AssignEnvironment(result);
2133 LInstruction* LChunkBuilder::DoStoreContextSlot(HStoreContextSlot* instr) {
2136 if (instr->NeedsWriteBarrier()) {
2137 context = UseTempRegister(instr->context());
2138 value = UseTempRegister(instr->value());
2140 context = UseRegister(instr->context());
2141 value = UseRegister(instr->value());
2143 LInstruction* result = new(zone()) LStoreContextSlot(context, value);
2144 if (instr->RequiresHoleCheck() && instr->DeoptimizesOnHole()) {
2145 result = AssignEnvironment(result);
2151 LInstruction* LChunkBuilder::DoLoadNamedField(HLoadNamedField* instr) {
2152 LOperand* obj = UseRegisterAtStart(instr->object());
2153 return DefineAsRegister(new(zone()) LLoadNamedField(obj));
2157 LInstruction* LChunkBuilder::DoLoadNamedGeneric(HLoadNamedGeneric* instr) {
2158 LOperand* context = UseFixed(instr->context(), cp);
2160 UseFixed(instr->object(), LoadDescriptor::ReceiverRegister());
2161 LOperand* vector = NULL;
2162 if (instr->HasVectorAndSlot()) {
2163 vector = FixedTemp(LoadWithVectorDescriptor::VectorRegister());
2166 LInstruction* result =
2167 DefineFixed(new(zone()) LLoadNamedGeneric(context, object, vector), v0);
2168 return MarkAsCall(result, instr);
2172 LInstruction* LChunkBuilder::DoLoadFunctionPrototype(
2173 HLoadFunctionPrototype* instr) {
2174 return AssignEnvironment(DefineAsRegister(
2175 new(zone()) LLoadFunctionPrototype(UseRegister(instr->function()))));
2179 LInstruction* LChunkBuilder::DoLoadRoot(HLoadRoot* instr) {
2180 return DefineAsRegister(new(zone()) LLoadRoot);
2184 LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) {
2185 DCHECK(instr->key()->representation().IsSmiOrInteger32());
2186 ElementsKind elements_kind = instr->elements_kind();
2187 LOperand* key = UseRegisterOrConstantAtStart(instr->key());
2188 LInstruction* result = NULL;
2190 if (!instr->is_typed_elements()) {
2191 LOperand* obj = NULL;
2192 if (instr->representation().IsDouble()) {
2193 obj = UseRegister(instr->elements());
2195 DCHECK(instr->representation().IsSmiOrTagged() ||
2196 instr->representation().IsInteger32());
2197 obj = UseRegisterAtStart(instr->elements());
2199 result = DefineAsRegister(new(zone()) LLoadKeyed(obj, key));
2202 (instr->representation().IsInteger32() &&
2203 !IsDoubleOrFloatElementsKind(elements_kind)) ||
2204 (instr->representation().IsDouble() &&
2205 IsDoubleOrFloatElementsKind(elements_kind)));
2206 LOperand* backing_store = UseRegister(instr->elements());
2207 result = DefineAsRegister(new(zone()) LLoadKeyed(backing_store, key));
2210 bool needs_environment;
2211 if (instr->is_external() || instr->is_fixed_typed_array()) {
2212 // see LCodeGen::DoLoadKeyedExternalArray
2213 needs_environment = (elements_kind == EXTERNAL_UINT32_ELEMENTS ||
2214 elements_kind == UINT32_ELEMENTS) &&
2215 !instr->CheckFlag(HInstruction::kUint32);
2217 // see LCodeGen::DoLoadKeyedFixedDoubleArray and
2218 // LCodeGen::DoLoadKeyedFixedArray
2220 instr->RequiresHoleCheck() ||
2221 (instr->hole_mode() == CONVERT_HOLE_TO_UNDEFINED && info()->IsStub());
2224 if (needs_environment) {
2225 result = AssignEnvironment(result);
2231 LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) {
2232 LOperand* context = UseFixed(instr->context(), cp);
2234 UseFixed(instr->object(), LoadDescriptor::ReceiverRegister());
2235 LOperand* key = UseFixed(instr->key(), LoadDescriptor::NameRegister());
2236 LOperand* vector = NULL;
2237 if (instr->HasVectorAndSlot()) {
2238 vector = FixedTemp(LoadWithVectorDescriptor::VectorRegister());
2241 LInstruction* result =
2242 DefineFixed(new(zone()) LLoadKeyedGeneric(context, object, key, vector),
2244 return MarkAsCall(result, instr);
2248 LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) {
2249 if (!instr->is_typed_elements()) {
2250 DCHECK(instr->elements()->representation().IsTagged());
2251 bool needs_write_barrier = instr->NeedsWriteBarrier();
2252 LOperand* object = NULL;
2253 LOperand* val = NULL;
2254 LOperand* key = NULL;
2256 if (instr->value()->representation().IsDouble()) {
2257 object = UseRegisterAtStart(instr->elements());
2258 key = UseRegisterOrConstantAtStart(instr->key());
2259 val = UseRegister(instr->value());
2261 DCHECK(instr->value()->representation().IsSmiOrTagged() ||
2262 instr->value()->representation().IsInteger32());
2263 if (needs_write_barrier) {
2264 object = UseTempRegister(instr->elements());
2265 val = UseTempRegister(instr->value());
2266 key = UseTempRegister(instr->key());
2268 object = UseRegisterAtStart(instr->elements());
2269 val = UseRegisterAtStart(instr->value());
2270 key = UseRegisterOrConstantAtStart(instr->key());
2274 return new(zone()) LStoreKeyed(object, key, val);
2278 (instr->value()->representation().IsInteger32() &&
2279 !IsDoubleOrFloatElementsKind(instr->elements_kind())) ||
2280 (instr->value()->representation().IsDouble() &&
2281 IsDoubleOrFloatElementsKind(instr->elements_kind())));
2282 DCHECK(instr->elements()->representation().IsExternal());
2283 LOperand* val = UseRegister(instr->value());
2284 LOperand* key = UseRegisterOrConstantAtStart(instr->key());
2285 LOperand* backing_store = UseRegister(instr->elements());
2286 return new(zone()) LStoreKeyed(backing_store, key, val);
2290 LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) {
2291 LOperand* context = UseFixed(instr->context(), cp);
2293 UseFixed(instr->object(), StoreDescriptor::ReceiverRegister());
2294 LOperand* key = UseFixed(instr->key(), StoreDescriptor::NameRegister());
2295 LOperand* val = UseFixed(instr->value(), StoreDescriptor::ValueRegister());
2297 DCHECK(instr->object()->representation().IsTagged());
2298 DCHECK(instr->key()->representation().IsTagged());
2299 DCHECK(instr->value()->representation().IsTagged());
2301 LOperand* slot = NULL;
2302 LOperand* vector = NULL;
2303 if (instr->HasVectorAndSlot()) {
2304 slot = FixedTemp(VectorStoreICDescriptor::SlotRegister());
2305 vector = FixedTemp(VectorStoreICDescriptor::VectorRegister());
2308 LStoreKeyedGeneric* result =
2309 new (zone()) LStoreKeyedGeneric(context, obj, key, val, slot, vector);
2310 return MarkAsCall(result, instr);
2314 LInstruction* LChunkBuilder::DoTransitionElementsKind(
2315 HTransitionElementsKind* instr) {
2316 if (IsSimpleMapChangeTransition(instr->from_kind(), instr->to_kind())) {
2317 LOperand* object = UseRegister(instr->object());
2318 LOperand* new_map_reg = TempRegister();
2319 LTransitionElementsKind* result =
2320 new(zone()) LTransitionElementsKind(object, NULL, new_map_reg);
2323 LOperand* object = UseFixed(instr->object(), a0);
2324 LOperand* context = UseFixed(instr->context(), cp);
2325 LTransitionElementsKind* result =
2326 new(zone()) LTransitionElementsKind(object, context, NULL);
2327 return MarkAsCall(result, instr);
2332 LInstruction* LChunkBuilder::DoTrapAllocationMemento(
2333 HTrapAllocationMemento* instr) {
2334 LOperand* object = UseRegister(instr->object());
2335 LOperand* temp = TempRegister();
2336 LTrapAllocationMemento* result =
2337 new(zone()) LTrapAllocationMemento(object, temp);
2338 return AssignEnvironment(result);
2342 LInstruction* LChunkBuilder::DoMaybeGrowElements(HMaybeGrowElements* instr) {
2343 info()->MarkAsDeferredCalling();
2344 LOperand* context = UseFixed(instr->context(), cp);
2345 LOperand* object = Use(instr->object());
2346 LOperand* elements = Use(instr->elements());
2347 LOperand* key = UseRegisterOrConstant(instr->key());
2348 LOperand* current_capacity = UseRegisterOrConstant(instr->current_capacity());
2350 LMaybeGrowElements* result = new (zone())
2351 LMaybeGrowElements(context, object, elements, key, current_capacity);
2352 DefineFixed(result, v0);
2353 return AssignPointerMap(AssignEnvironment(result));
2357 LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) {
2358 bool is_in_object = instr->access().IsInobject();
2359 bool needs_write_barrier = instr->NeedsWriteBarrier();
2360 bool needs_write_barrier_for_map = instr->has_transition() &&
2361 instr->NeedsWriteBarrierForMap();
2364 if (needs_write_barrier) {
2366 ? UseRegister(instr->object())
2367 : UseTempRegister(instr->object());
2369 obj = needs_write_barrier_for_map
2370 ? UseRegister(instr->object())
2371 : UseRegisterAtStart(instr->object());
2375 if (needs_write_barrier) {
2376 val = UseTempRegister(instr->value());
2377 } else if (instr->field_representation().IsDouble()) {
2378 val = UseRegisterAtStart(instr->value());
2380 val = UseRegister(instr->value());
2383 // We need a temporary register for write barrier of the map field.
2384 LOperand* temp = needs_write_barrier_for_map ? TempRegister() : NULL;
2386 return new(zone()) LStoreNamedField(obj, val, temp);
2390 LInstruction* LChunkBuilder::DoStoreNamedGeneric(HStoreNamedGeneric* instr) {
2391 LOperand* context = UseFixed(instr->context(), cp);
2393 UseFixed(instr->object(), StoreDescriptor::ReceiverRegister());
2394 LOperand* val = UseFixed(instr->value(), StoreDescriptor::ValueRegister());
2395 LOperand* slot = NULL;
2396 LOperand* vector = NULL;
2397 if (instr->HasVectorAndSlot()) {
2398 slot = FixedTemp(VectorStoreICDescriptor::SlotRegister());
2399 vector = FixedTemp(VectorStoreICDescriptor::VectorRegister());
2402 LStoreNamedGeneric* result =
2403 new (zone()) LStoreNamedGeneric(context, obj, val, slot, vector);
2404 return MarkAsCall(result, instr);
2408 LInstruction* LChunkBuilder::DoStoreGlobalViaContext(
2409 HStoreGlobalViaContext* instr) {
2410 LOperand* context = UseFixed(instr->context(), cp);
2411 LOperand* value = UseFixed(instr->value(),
2412 StoreGlobalViaContextDescriptor::ValueRegister());
2413 DCHECK(instr->slot_index() > 0);
2415 LStoreGlobalViaContext* result =
2416 new (zone()) LStoreGlobalViaContext(context, value);
2417 return MarkAsCall(result, instr);
2421 LInstruction* LChunkBuilder::DoStringAdd(HStringAdd* instr) {
2422 LOperand* context = UseFixed(instr->context(), cp);
2423 LOperand* left = UseFixed(instr->left(), a1);
2424 LOperand* right = UseFixed(instr->right(), a0);
2426 DefineFixed(new(zone()) LStringAdd(context, left, right), v0),
2431 LInstruction* LChunkBuilder::DoStringCharCodeAt(HStringCharCodeAt* instr) {
2432 LOperand* string = UseTempRegister(instr->string());
2433 LOperand* index = UseTempRegister(instr->index());
2434 LOperand* context = UseAny(instr->context());
2435 LStringCharCodeAt* result =
2436 new(zone()) LStringCharCodeAt(context, string, index);
2437 return AssignPointerMap(DefineAsRegister(result));
2441 LInstruction* LChunkBuilder::DoStringCharFromCode(HStringCharFromCode* instr) {
2442 LOperand* char_code = UseRegister(instr->value());
2443 LOperand* context = UseAny(instr->context());
2444 LStringCharFromCode* result =
2445 new(zone()) LStringCharFromCode(context, char_code);
2446 return AssignPointerMap(DefineAsRegister(result));
2450 LInstruction* LChunkBuilder::DoAllocate(HAllocate* instr) {
2451 info()->MarkAsDeferredCalling();
2452 LOperand* context = UseAny(instr->context());
2453 LOperand* size = UseRegisterOrConstant(instr->size());
2454 LOperand* temp1 = TempRegister();
2455 LOperand* temp2 = TempRegister();
2456 LAllocate* result = new(zone()) LAllocate(context, size, temp1, temp2);
2457 return AssignPointerMap(DefineAsRegister(result));
2461 LInstruction* LChunkBuilder::DoRegExpLiteral(HRegExpLiteral* instr) {
2462 LOperand* context = UseFixed(instr->context(), cp);
2464 DefineFixed(new(zone()) LRegExpLiteral(context), v0), instr);
2468 LInstruction* LChunkBuilder::DoFunctionLiteral(HFunctionLiteral* instr) {
2469 LOperand* context = UseFixed(instr->context(), cp);
2471 DefineFixed(new(zone()) LFunctionLiteral(context), v0), instr);
2475 LInstruction* LChunkBuilder::DoOsrEntry(HOsrEntry* instr) {
2476 DCHECK(argument_count_ == 0);
2477 allocator_->MarkAsOsrEntry();
2478 current_block_->last_environment()->set_ast_id(instr->ast_id());
2479 return AssignEnvironment(new(zone()) LOsrEntry);
2483 LInstruction* LChunkBuilder::DoParameter(HParameter* instr) {
2484 LParameter* result = new(zone()) LParameter;
2485 if (instr->kind() == HParameter::STACK_PARAMETER) {
2486 int spill_index = chunk()->GetParameterStackSlot(instr->index());
2487 return DefineAsSpilled(result, spill_index);
2489 DCHECK(info()->IsStub());
2490 CallInterfaceDescriptor descriptor =
2491 info()->code_stub()->GetCallInterfaceDescriptor();
2492 int index = static_cast<int>(instr->index());
2493 Register reg = descriptor.GetRegisterParameter(index);
2494 return DefineFixed(result, reg);
2499 LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) {
2500 // Use an index that corresponds to the location in the unoptimized frame,
2501 // which the optimized frame will subsume.
2502 int env_index = instr->index();
2503 int spill_index = 0;
2504 if (instr->environment()->is_parameter_index(env_index)) {
2505 spill_index = chunk()->GetParameterStackSlot(env_index);
2507 spill_index = env_index - instr->environment()->first_local_index();
2508 if (spill_index > LUnallocated::kMaxFixedSlotIndex) {
2509 Retry(kTooManySpillSlotsNeededForOSR);
2513 return DefineAsSpilled(new(zone()) LUnknownOSRValue, spill_index);
2517 LInstruction* LChunkBuilder::DoCallStub(HCallStub* instr) {
2518 LOperand* context = UseFixed(instr->context(), cp);
2519 return MarkAsCall(DefineFixed(new(zone()) LCallStub(context), v0), instr);
2523 LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) {
2524 // There are no real uses of the arguments object.
2525 // arguments.length and element access are supported directly on
2526 // stack arguments, and any real arguments object use causes a bailout.
2527 // So this value is never used.
2532 LInstruction* LChunkBuilder::DoCapturedObject(HCapturedObject* instr) {
2533 instr->ReplayEnvironment(current_block_->last_environment());
2535 // There are no real uses of a captured object.
2540 LInstruction* LChunkBuilder::DoAccessArgumentsAt(HAccessArgumentsAt* instr) {
2541 info()->MarkAsRequiresFrame();
2542 LOperand* args = UseRegister(instr->arguments());
2543 LOperand* length = UseRegisterOrConstantAtStart(instr->length());
2544 LOperand* index = UseRegisterOrConstantAtStart(instr->index());
2545 return DefineAsRegister(new(zone()) LAccessArgumentsAt(args, length, index));
2549 LInstruction* LChunkBuilder::DoToFastProperties(HToFastProperties* instr) {
2550 LOperand* object = UseFixed(instr->value(), a0);
2551 LToFastProperties* result = new(zone()) LToFastProperties(object);
2552 return MarkAsCall(DefineFixed(result, v0), instr);
2556 LInstruction* LChunkBuilder::DoTypeof(HTypeof* instr) {
2557 LOperand* context = UseFixed(instr->context(), cp);
2558 LOperand* value = UseFixed(instr->value(), a3);
2559 LTypeof* result = new (zone()) LTypeof(context, value);
2560 return MarkAsCall(DefineFixed(result, v0), instr);
2564 LInstruction* LChunkBuilder::DoTypeofIsAndBranch(HTypeofIsAndBranch* instr) {
2565 return new(zone()) LTypeofIsAndBranch(UseTempRegister(instr->value()));
2569 LInstruction* LChunkBuilder::DoIsConstructCallAndBranch(
2570 HIsConstructCallAndBranch* instr) {
2571 return new(zone()) LIsConstructCallAndBranch(TempRegister());
2575 LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) {
2576 instr->ReplayEnvironment(current_block_->last_environment());
2581 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) {
2582 if (instr->is_function_entry()) {
2583 LOperand* context = UseFixed(instr->context(), cp);
2584 return MarkAsCall(new(zone()) LStackCheck(context), instr);
2586 DCHECK(instr->is_backwards_branch());
2587 LOperand* context = UseAny(instr->context());
2588 return AssignEnvironment(
2589 AssignPointerMap(new(zone()) LStackCheck(context)));
2594 LInstruction* LChunkBuilder::DoEnterInlined(HEnterInlined* instr) {
2595 HEnvironment* outer = current_block_->last_environment();
2596 outer->set_ast_id(instr->ReturnId());
2597 HConstant* undefined = graph()->GetConstantUndefined();
2598 HEnvironment* inner = outer->CopyForInlining(instr->closure(),
2599 instr->arguments_count(),
2602 instr->inlining_kind());
2603 // Only replay binding of arguments object if it wasn't removed from graph.
2604 if (instr->arguments_var() != NULL && instr->arguments_object()->IsLinked()) {
2605 inner->Bind(instr->arguments_var(), instr->arguments_object());
2607 inner->BindContext(instr->closure_context());
2608 inner->set_entry(instr);
2609 current_block_->UpdateEnvironment(inner);
2610 chunk_->AddInlinedFunction(instr->shared());
2615 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) {
2616 LInstruction* pop = NULL;
2618 HEnvironment* env = current_block_->last_environment();
2620 if (env->entry()->arguments_pushed()) {
2621 int argument_count = env->arguments_environment()->parameter_count();
2622 pop = new(zone()) LDrop(argument_count);
2623 DCHECK(instr->argument_delta() == -argument_count);
2626 HEnvironment* outer = current_block_->last_environment()->
2627 DiscardInlined(false);
2628 current_block_->UpdateEnvironment(outer);
2634 LInstruction* LChunkBuilder::DoForInPrepareMap(HForInPrepareMap* instr) {
2635 LOperand* context = UseFixed(instr->context(), cp);
2636 LOperand* object = UseFixed(instr->enumerable(), a0);
2637 LForInPrepareMap* result = new(zone()) LForInPrepareMap(context, object);
2638 return MarkAsCall(DefineFixed(result, v0), instr, CAN_DEOPTIMIZE_EAGERLY);
2642 LInstruction* LChunkBuilder::DoForInCacheArray(HForInCacheArray* instr) {
2643 LOperand* map = UseRegister(instr->map());
2644 return AssignEnvironment(DefineAsRegister(new(zone()) LForInCacheArray(map)));
2648 LInstruction* LChunkBuilder::DoCheckMapValue(HCheckMapValue* instr) {
2649 LOperand* value = UseRegisterAtStart(instr->value());
2650 LOperand* map = UseRegisterAtStart(instr->map());
2651 return AssignEnvironment(new(zone()) LCheckMapValue(value, map));
2655 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) {
2656 LOperand* object = UseRegister(instr->object());
2657 LOperand* index = UseTempRegister(instr->index());
2658 LLoadFieldByIndex* load = new(zone()) LLoadFieldByIndex(object, index);
2659 LInstruction* result = DefineSameAsFirst(load);
2660 return AssignPointerMap(result);
2664 LInstruction* LChunkBuilder::DoStoreFrameContext(HStoreFrameContext* instr) {
2665 LOperand* context = UseRegisterAtStart(instr->context());
2666 return new(zone()) LStoreFrameContext(context);
2670 LInstruction* LChunkBuilder::DoAllocateBlockContext(
2671 HAllocateBlockContext* instr) {
2672 LOperand* context = UseFixed(instr->context(), cp);
2673 LOperand* function = UseRegisterAtStart(instr->function());
2674 LAllocateBlockContext* result =
2675 new(zone()) LAllocateBlockContext(context, function);
2676 return MarkAsCall(DefineFixed(result, cp), instr);
2680 } // namespace internal
2683 #endif // V8_TARGET_ARCH_MIPS64