OLD | NEW |
| (Empty) |
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. | |
4 | |
5 #include "src/mips64/lithium-mips64.h" | |
6 | |
7 #include <sstream> | |
8 | |
9 #if V8_TARGET_ARCH_MIPS64 | |
10 | |
11 #include "src/hydrogen-osr.h" | |
12 #include "src/lithium-inl.h" | |
13 #include "src/mips64/lithium-codegen-mips64.h" | |
14 | |
15 namespace v8 { | |
16 namespace internal { | |
17 | |
18 #define DEFINE_COMPILE(type) \ | |
19 void L##type::CompileToNative(LCodeGen* generator) { \ | |
20 generator->Do##type(this); \ | |
21 } | |
22 LITHIUM_CONCRETE_INSTRUCTION_LIST(DEFINE_COMPILE) | |
23 #undef DEFINE_COMPILE | |
24 | |
25 #ifdef DEBUG | |
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()); | |
38 } | |
39 for (TempIterator it(this); !it.Done(); it.Advance()) { | |
40 LUnallocated* operand = LUnallocated::cast(it.Current()); | |
41 DCHECK(operand->HasFixedPolicy() ||!operand->HasRegisterPolicy()); | |
42 } | |
43 } | |
44 #endif | |
45 | |
46 | |
47 void LInstruction::PrintTo(StringStream* stream) { | |
48 stream->Add("%s ", this->Mnemonic()); | |
49 | |
50 PrintOutputOperandTo(stream); | |
51 | |
52 PrintDataTo(stream); | |
53 | |
54 if (HasEnvironment()) { | |
55 stream->Add(" "); | |
56 environment()->PrintTo(stream); | |
57 } | |
58 | |
59 if (HasPointerMap()) { | |
60 stream->Add(" "); | |
61 pointer_map()->PrintTo(stream); | |
62 } | |
63 } | |
64 | |
65 | |
66 void LInstruction::PrintDataTo(StringStream* stream) { | |
67 stream->Add("= "); | |
68 for (int i = 0; i < InputCount(); i++) { | |
69 if (i > 0) stream->Add(" "); | |
70 if (InputAt(i) == NULL) { | |
71 stream->Add("NULL"); | |
72 } else { | |
73 InputAt(i)->PrintTo(stream); | |
74 } | |
75 } | |
76 } | |
77 | |
78 | |
79 void LInstruction::PrintOutputOperandTo(StringStream* stream) { | |
80 if (HasResult()) result()->PrintTo(stream); | |
81 } | |
82 | |
83 | |
84 void LLabel::PrintDataTo(StringStream* stream) { | |
85 LGap::PrintDataTo(stream); | |
86 LLabel* rep = replacement(); | |
87 if (rep != NULL) { | |
88 stream->Add(" Dead block replaced with B%d", rep->block_id()); | |
89 } | |
90 } | |
91 | |
92 | |
93 bool LGap::IsRedundant() const { | |
94 for (int i = 0; i < 4; i++) { | |
95 if (parallel_moves_[i] != NULL && !parallel_moves_[i]->IsRedundant()) { | |
96 return false; | |
97 } | |
98 } | |
99 | |
100 return true; | |
101 } | |
102 | |
103 | |
104 void LGap::PrintDataTo(StringStream* stream) { | |
105 for (int i = 0; i < 4; i++) { | |
106 stream->Add("("); | |
107 if (parallel_moves_[i] != NULL) { | |
108 parallel_moves_[i]->PrintDataTo(stream); | |
109 } | |
110 stream->Add(") "); | |
111 } | |
112 } | |
113 | |
114 | |
115 const char* LArithmeticD::Mnemonic() const { | |
116 switch (op()) { | |
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"; | |
122 default: | |
123 UNREACHABLE(); | |
124 return NULL; | |
125 } | |
126 } | |
127 | |
128 | |
129 const char* LArithmeticT::Mnemonic() const { | |
130 switch (op()) { | |
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"; | |
143 default: | |
144 UNREACHABLE(); | |
145 return NULL; | |
146 } | |
147 } | |
148 | |
149 | |
150 bool LGoto::HasInterestingComment(LCodeGen* gen) const { | |
151 return !gen->IsNextEmittedBlock(block_id()); | |
152 } | |
153 | |
154 | |
155 void LGoto::PrintDataTo(StringStream* stream) { | |
156 stream->Add("B%d", block_id()); | |
157 } | |
158 | |
159 | |
160 void LBranch::PrintDataTo(StringStream* stream) { | |
161 stream->Add("B%d | B%d on ", true_block_id(), false_block_id()); | |
162 value()->PrintTo(stream); | |
163 } | |
164 | |
165 | |
166 LInstruction* LChunkBuilder::DoDebugBreak(HDebugBreak* instr) { | |
167 return new(zone()) LDebugBreak(); | |
168 } | |
169 | |
170 | |
171 void LCompareNumericAndBranch::PrintDataTo(StringStream* stream) { | |
172 stream->Add("if "); | |
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()); | |
177 } | |
178 | |
179 | |
180 void LIsStringAndBranch::PrintDataTo(StringStream* stream) { | |
181 stream->Add("if is_string("); | |
182 value()->PrintTo(stream); | |
183 stream->Add(") then B%d else B%d", true_block_id(), false_block_id()); | |
184 } | |
185 | |
186 | |
187 void LIsSmiAndBranch::PrintDataTo(StringStream* stream) { | |
188 stream->Add("if is_smi("); | |
189 value()->PrintTo(stream); | |
190 stream->Add(") then B%d else B%d", true_block_id(), false_block_id()); | |
191 } | |
192 | |
193 | |
194 void LIsUndetectableAndBranch::PrintDataTo(StringStream* stream) { | |
195 stream->Add("if is_undetectable("); | |
196 value()->PrintTo(stream); | |
197 stream->Add(") then B%d else B%d", true_block_id(), false_block_id()); | |
198 } | |
199 | |
200 | |
201 void LStringCompareAndBranch::PrintDataTo(StringStream* stream) { | |
202 stream->Add("if string_compare("); | |
203 left()->PrintTo(stream); | |
204 right()->PrintTo(stream); | |
205 stream->Add(") then B%d else B%d", true_block_id(), false_block_id()); | |
206 } | |
207 | |
208 | |
209 void LHasInstanceTypeAndBranch::PrintDataTo(StringStream* stream) { | |
210 stream->Add("if has_instance_type("); | |
211 value()->PrintTo(stream); | |
212 stream->Add(") then B%d else B%d", true_block_id(), false_block_id()); | |
213 } | |
214 | |
215 | |
216 void LHasCachedArrayIndexAndBranch::PrintDataTo(StringStream* stream) { | |
217 stream->Add("if has_cached_array_index("); | |
218 value()->PrintTo(stream); | |
219 stream->Add(") then B%d else B%d", true_block_id(), false_block_id()); | |
220 } | |
221 | |
222 | |
223 void LClassOfTestAndBranch::PrintDataTo(StringStream* stream) { | |
224 stream->Add("if class_of_test("); | |
225 value()->PrintTo(stream); | |
226 stream->Add(", \"%o\") then B%d else B%d", | |
227 *hydrogen()->class_name(), | |
228 true_block_id(), | |
229 false_block_id()); | |
230 } | |
231 | |
232 | |
233 void LTypeofIsAndBranch::PrintDataTo(StringStream* stream) { | |
234 stream->Add("if typeof "); | |
235 value()->PrintTo(stream); | |
236 stream->Add(" == \"%s\" then B%d else B%d", | |
237 hydrogen()->type_literal()->ToCString().get(), | |
238 true_block_id(), false_block_id()); | |
239 } | |
240 | |
241 | |
242 void LStoreCodeEntry::PrintDataTo(StringStream* stream) { | |
243 stream->Add(" = "); | |
244 function()->PrintTo(stream); | |
245 stream->Add(".code_entry = "); | |
246 code_object()->PrintTo(stream); | |
247 } | |
248 | |
249 | |
250 void LInnerAllocatedObject::PrintDataTo(StringStream* stream) { | |
251 stream->Add(" = "); | |
252 base_object()->PrintTo(stream); | |
253 stream->Add(" + "); | |
254 offset()->PrintTo(stream); | |
255 } | |
256 | |
257 | |
258 void LCallFunction::PrintDataTo(StringStream* stream) { | |
259 context()->PrintTo(stream); | |
260 stream->Add(" "); | |
261 function()->PrintTo(stream); | |
262 if (hydrogen()->HasVectorAndSlot()) { | |
263 stream->Add(" (type-feedback-vector "); | |
264 temp_vector()->PrintTo(stream); | |
265 stream->Add(" "); | |
266 temp_slot()->PrintTo(stream); | |
267 stream->Add(")"); | |
268 } | |
269 } | |
270 | |
271 | |
272 void LCallJSFunction::PrintDataTo(StringStream* stream) { | |
273 stream->Add("= "); | |
274 function()->PrintTo(stream); | |
275 stream->Add("#%d / ", arity()); | |
276 } | |
277 | |
278 | |
279 void LCallWithDescriptor::PrintDataTo(StringStream* stream) { | |
280 for (int i = 0; i < InputCount(); i++) { | |
281 InputAt(i)->PrintTo(stream); | |
282 stream->Add(" "); | |
283 } | |
284 stream->Add("#%d / ", arity()); | |
285 } | |
286 | |
287 | |
288 void LLoadContextSlot::PrintDataTo(StringStream* stream) { | |
289 context()->PrintTo(stream); | |
290 stream->Add("[%d]", slot_index()); | |
291 } | |
292 | |
293 | |
294 void LStoreContextSlot::PrintDataTo(StringStream* stream) { | |
295 context()->PrintTo(stream); | |
296 stream->Add("[%d] <- ", slot_index()); | |
297 value()->PrintTo(stream); | |
298 } | |
299 | |
300 | |
301 void LInvokeFunction::PrintDataTo(StringStream* stream) { | |
302 stream->Add("= "); | |
303 function()->PrintTo(stream); | |
304 stream->Add(" #%d / ", arity()); | |
305 } | |
306 | |
307 | |
308 void LCallNew::PrintDataTo(StringStream* stream) { | |
309 stream->Add("= "); | |
310 constructor()->PrintTo(stream); | |
311 stream->Add(" #%d / ", arity()); | |
312 } | |
313 | |
314 | |
315 void LCallNewArray::PrintDataTo(StringStream* stream) { | |
316 stream->Add("= "); | |
317 constructor()->PrintTo(stream); | |
318 stream->Add(" #%d / ", arity()); | |
319 ElementsKind kind = hydrogen()->elements_kind(); | |
320 stream->Add(" (%s) ", ElementsKindToString(kind)); | |
321 } | |
322 | |
323 | |
324 void LAccessArgumentsAt::PrintDataTo(StringStream* stream) { | |
325 arguments()->PrintTo(stream); | |
326 stream->Add(" length "); | |
327 length()->PrintTo(stream); | |
328 stream->Add(" index "); | |
329 index()->PrintTo(stream); | |
330 } | |
331 | |
332 | |
333 void LLoadGlobalViaContext::PrintDataTo(StringStream* stream) { | |
334 stream->Add("depth:%d slot:%d", depth(), slot_index()); | |
335 } | |
336 | |
337 | |
338 void LStoreNamedField::PrintDataTo(StringStream* stream) { | |
339 object()->PrintTo(stream); | |
340 std::ostringstream os; | |
341 os << hydrogen()->access() << " <- "; | |
342 stream->Add(os.str().c_str()); | |
343 value()->PrintTo(stream); | |
344 } | |
345 | |
346 | |
347 void LStoreNamedGeneric::PrintDataTo(StringStream* stream) { | |
348 object()->PrintTo(stream); | |
349 stream->Add("."); | |
350 stream->Add(String::cast(*name())->ToCString().get()); | |
351 stream->Add(" <- "); | |
352 value()->PrintTo(stream); | |
353 } | |
354 | |
355 | |
356 void LStoreGlobalViaContext::PrintDataTo(StringStream* stream) { | |
357 stream->Add("depth:%d slot:%d <- ", depth(), slot_index()); | |
358 value()->PrintTo(stream); | |
359 } | |
360 | |
361 | |
362 void LLoadKeyed::PrintDataTo(StringStream* stream) { | |
363 elements()->PrintTo(stream); | |
364 stream->Add("["); | |
365 key()->PrintTo(stream); | |
366 if (hydrogen()->IsDehoisted()) { | |
367 stream->Add(" + %d]", base_offset()); | |
368 } else { | |
369 stream->Add("]"); | |
370 } | |
371 } | |
372 | |
373 | |
374 void LStoreKeyed::PrintDataTo(StringStream* stream) { | |
375 elements()->PrintTo(stream); | |
376 stream->Add("["); | |
377 key()->PrintTo(stream); | |
378 if (hydrogen()->IsDehoisted()) { | |
379 stream->Add(" + %d] <-", base_offset()); | |
380 } else { | |
381 stream->Add("] <- "); | |
382 } | |
383 | |
384 if (value() == NULL) { | |
385 DCHECK(hydrogen()->IsConstantHoleStore() && | |
386 hydrogen()->value()->representation().IsDouble()); | |
387 stream->Add("<the hole(nan)>"); | |
388 } else { | |
389 value()->PrintTo(stream); | |
390 } | |
391 } | |
392 | |
393 | |
394 void LStoreKeyedGeneric::PrintDataTo(StringStream* stream) { | |
395 object()->PrintTo(stream); | |
396 stream->Add("["); | |
397 key()->PrintTo(stream); | |
398 stream->Add("] <- "); | |
399 value()->PrintTo(stream); | |
400 } | |
401 | |
402 | |
403 void LTransitionElementsKind::PrintDataTo(StringStream* stream) { | |
404 object()->PrintTo(stream); | |
405 stream->Add(" %p -> %p", *original_map(), *transitioned_map()); | |
406 } | |
407 | |
408 | |
409 int LPlatformChunk::GetNextSpillIndex(RegisterKind kind) { | |
410 // Skip a slot if for a double-width slot. | |
411 if (kind == DOUBLE_REGISTERS) spill_slot_count_++; | |
412 return spill_slot_count_++; | |
413 } | |
414 | |
415 | |
416 LOperand* LPlatformChunk::GetNextSpillSlot(RegisterKind kind) { | |
417 int index = GetNextSpillIndex(kind); | |
418 if (kind == DOUBLE_REGISTERS) { | |
419 return LDoubleStackSlot::Create(index, zone()); | |
420 } else { | |
421 DCHECK(kind == GENERAL_REGISTERS); | |
422 return LStackSlot::Create(index, zone()); | |
423 } | |
424 } | |
425 | |
426 | |
427 LPlatformChunk* LChunkBuilder::Build() { | |
428 DCHECK(is_unused()); | |
429 chunk_ = new(zone()) LPlatformChunk(info(), graph()); | |
430 LPhase phase("L_Building chunk", chunk_); | |
431 status_ = BUILDING; | |
432 | |
433 // If compiling for OSR, reserve space for the unoptimized frame, | |
434 // which will be subsumed into this frame. | |
435 if (graph()->has_osr()) { | |
436 for (int i = graph()->osr()->UnoptimizedFrameSlots(); i > 0; i--) { | |
437 chunk_->GetNextSpillIndex(GENERAL_REGISTERS); | |
438 } | |
439 } | |
440 | |
441 const ZoneList<HBasicBlock*>* blocks = graph()->blocks(); | |
442 for (int i = 0; i < blocks->length(); i++) { | |
443 HBasicBlock* next = NULL; | |
444 if (i < blocks->length() - 1) next = blocks->at(i + 1); | |
445 DoBasicBlock(blocks->at(i), next); | |
446 if (is_aborted()) return NULL; | |
447 } | |
448 status_ = DONE; | |
449 return chunk_; | |
450 } | |
451 | |
452 | |
453 LUnallocated* LChunkBuilder::ToUnallocated(Register reg) { | |
454 return new (zone()) LUnallocated(LUnallocated::FIXED_REGISTER, reg.code()); | |
455 } | |
456 | |
457 | |
458 LUnallocated* LChunkBuilder::ToUnallocated(DoubleRegister reg) { | |
459 return new (zone()) | |
460 LUnallocated(LUnallocated::FIXED_DOUBLE_REGISTER, reg.code()); | |
461 } | |
462 | |
463 | |
464 LOperand* LChunkBuilder::UseFixed(HValue* value, Register fixed_register) { | |
465 return Use(value, ToUnallocated(fixed_register)); | |
466 } | |
467 | |
468 | |
469 LOperand* LChunkBuilder::UseFixedDouble(HValue* value, DoubleRegister reg) { | |
470 return Use(value, ToUnallocated(reg)); | |
471 } | |
472 | |
473 | |
474 LOperand* LChunkBuilder::UseRegister(HValue* value) { | |
475 return Use(value, new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER)); | |
476 } | |
477 | |
478 | |
479 LOperand* LChunkBuilder::UseRegisterAtStart(HValue* value) { | |
480 return Use(value, | |
481 new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER, | |
482 LUnallocated::USED_AT_START)); | |
483 } | |
484 | |
485 | |
486 LOperand* LChunkBuilder::UseTempRegister(HValue* value) { | |
487 return Use(value, new(zone()) LUnallocated(LUnallocated::WRITABLE_REGISTER)); | |
488 } | |
489 | |
490 | |
491 LOperand* LChunkBuilder::Use(HValue* value) { | |
492 return Use(value, new(zone()) LUnallocated(LUnallocated::NONE)); | |
493 } | |
494 | |
495 | |
496 LOperand* LChunkBuilder::UseAtStart(HValue* value) { | |
497 return Use(value, new(zone()) LUnallocated(LUnallocated::NONE, | |
498 LUnallocated::USED_AT_START)); | |
499 } | |
500 | |
501 | |
502 LOperand* LChunkBuilder::UseOrConstant(HValue* value) { | |
503 return value->IsConstant() | |
504 ? chunk_->DefineConstantOperand(HConstant::cast(value)) | |
505 : Use(value); | |
506 } | |
507 | |
508 | |
509 LOperand* LChunkBuilder::UseOrConstantAtStart(HValue* value) { | |
510 return value->IsConstant() | |
511 ? chunk_->DefineConstantOperand(HConstant::cast(value)) | |
512 : UseAtStart(value); | |
513 } | |
514 | |
515 | |
516 LOperand* LChunkBuilder::UseRegisterOrConstant(HValue* value) { | |
517 return value->IsConstant() | |
518 ? chunk_->DefineConstantOperand(HConstant::cast(value)) | |
519 : UseRegister(value); | |
520 } | |
521 | |
522 | |
523 LOperand* LChunkBuilder::UseRegisterOrConstantAtStart(HValue* value) { | |
524 return value->IsConstant() | |
525 ? chunk_->DefineConstantOperand(HConstant::cast(value)) | |
526 : UseRegisterAtStart(value); | |
527 } | |
528 | |
529 | |
530 LOperand* LChunkBuilder::UseConstant(HValue* value) { | |
531 return chunk_->DefineConstantOperand(HConstant::cast(value)); | |
532 } | |
533 | |
534 | |
535 LOperand* LChunkBuilder::UseAny(HValue* value) { | |
536 return value->IsConstant() | |
537 ? chunk_->DefineConstantOperand(HConstant::cast(value)) | |
538 : Use(value, new(zone()) LUnallocated(LUnallocated::ANY)); | |
539 } | |
540 | |
541 | |
542 LOperand* LChunkBuilder::Use(HValue* value, LUnallocated* operand) { | |
543 if (value->EmitAtUses()) { | |
544 HInstruction* instr = HInstruction::cast(value); | |
545 VisitInstruction(instr); | |
546 } | |
547 operand->set_virtual_register(value->id()); | |
548 return operand; | |
549 } | |
550 | |
551 | |
552 LInstruction* LChunkBuilder::Define(LTemplateResultInstruction<1>* instr, | |
553 LUnallocated* result) { | |
554 result->set_virtual_register(current_instruction_->id()); | |
555 instr->set_result(result); | |
556 return instr; | |
557 } | |
558 | |
559 | |
560 LInstruction* LChunkBuilder::DefineAsRegister( | |
561 LTemplateResultInstruction<1>* instr) { | |
562 return Define(instr, | |
563 new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER)); | |
564 } | |
565 | |
566 | |
567 LInstruction* LChunkBuilder::DefineAsSpilled( | |
568 LTemplateResultInstruction<1>* instr, int index) { | |
569 return Define(instr, | |
570 new(zone()) LUnallocated(LUnallocated::FIXED_SLOT, index)); | |
571 } | |
572 | |
573 | |
574 LInstruction* LChunkBuilder::DefineSameAsFirst( | |
575 LTemplateResultInstruction<1>* instr) { | |
576 return Define(instr, | |
577 new(zone()) LUnallocated(LUnallocated::SAME_AS_FIRST_INPUT)); | |
578 } | |
579 | |
580 | |
581 LInstruction* LChunkBuilder::DefineFixed( | |
582 LTemplateResultInstruction<1>* instr, Register reg) { | |
583 return Define(instr, ToUnallocated(reg)); | |
584 } | |
585 | |
586 | |
587 LInstruction* LChunkBuilder::DefineFixedDouble( | |
588 LTemplateResultInstruction<1>* instr, DoubleRegister reg) { | |
589 return Define(instr, ToUnallocated(reg)); | |
590 } | |
591 | |
592 | |
593 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { | |
594 HEnvironment* hydrogen_env = current_block_->last_environment(); | |
595 int argument_index_accumulator = 0; | |
596 ZoneList<HValue*> objects_to_materialize(0, zone()); | |
597 instr->set_environment(CreateEnvironment(hydrogen_env, | |
598 &argument_index_accumulator, | |
599 &objects_to_materialize)); | |
600 return instr; | |
601 } | |
602 | |
603 | |
604 LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr, | |
605 HInstruction* hinstr, | |
606 CanDeoptimize can_deoptimize) { | |
607 info()->MarkAsNonDeferredCalling(); | |
608 #ifdef DEBUG | |
609 instr->VerifyCall(); | |
610 #endif | |
611 instr->MarkAsCall(); | |
612 instr = AssignPointerMap(instr); | |
613 | |
614 // If instruction does not have side-effects lazy deoptimization | |
615 // after the call will try to deoptimize to the point before the call. | |
616 // Thus we still need to attach environment to this call even if | |
617 // call sequence can not deoptimize eagerly. | |
618 bool needs_environment = | |
619 (can_deoptimize == CAN_DEOPTIMIZE_EAGERLY) || | |
620 !hinstr->HasObservableSideEffects(); | |
621 if (needs_environment && !instr->HasEnvironment()) { | |
622 instr = AssignEnvironment(instr); | |
623 // We can't really figure out if the environment is needed or not. | |
624 instr->environment()->set_has_been_used(); | |
625 } | |
626 | |
627 return instr; | |
628 } | |
629 | |
630 | |
631 LInstruction* LChunkBuilder::AssignPointerMap(LInstruction* instr) { | |
632 DCHECK(!instr->HasPointerMap()); | |
633 instr->set_pointer_map(new(zone()) LPointerMap(zone())); | |
634 return instr; | |
635 } | |
636 | |
637 | |
638 LUnallocated* LChunkBuilder::TempRegister() { | |
639 LUnallocated* operand = | |
640 new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER); | |
641 int vreg = allocator_->GetVirtualRegister(); | |
642 if (!allocator_->AllocationOk()) { | |
643 Abort(kOutOfVirtualRegistersWhileTryingToAllocateTempRegister); | |
644 vreg = 0; | |
645 } | |
646 operand->set_virtual_register(vreg); | |
647 return operand; | |
648 } | |
649 | |
650 | |
651 LUnallocated* LChunkBuilder::TempDoubleRegister() { | |
652 LUnallocated* operand = | |
653 new(zone()) LUnallocated(LUnallocated::MUST_HAVE_DOUBLE_REGISTER); | |
654 int vreg = allocator_->GetVirtualRegister(); | |
655 if (!allocator_->AllocationOk()) { | |
656 Abort(kOutOfVirtualRegistersWhileTryingToAllocateTempRegister); | |
657 vreg = 0; | |
658 } | |
659 operand->set_virtual_register(vreg); | |
660 return operand; | |
661 } | |
662 | |
663 | |
664 LOperand* LChunkBuilder::FixedTemp(Register reg) { | |
665 LUnallocated* operand = ToUnallocated(reg); | |
666 DCHECK(operand->HasFixedPolicy()); | |
667 return operand; | |
668 } | |
669 | |
670 | |
671 LOperand* LChunkBuilder::FixedTemp(DoubleRegister reg) { | |
672 LUnallocated* operand = ToUnallocated(reg); | |
673 DCHECK(operand->HasFixedPolicy()); | |
674 return operand; | |
675 } | |
676 | |
677 | |
678 LInstruction* LChunkBuilder::DoBlockEntry(HBlockEntry* instr) { | |
679 return new(zone()) LLabel(instr->block()); | |
680 } | |
681 | |
682 | |
683 LInstruction* LChunkBuilder::DoDummyUse(HDummyUse* instr) { | |
684 return DefineAsRegister(new(zone()) LDummyUse(UseAny(instr->value()))); | |
685 } | |
686 | |
687 | |
688 LInstruction* LChunkBuilder::DoEnvironmentMarker(HEnvironmentMarker* instr) { | |
689 UNREACHABLE(); | |
690 return NULL; | |
691 } | |
692 | |
693 | |
694 LInstruction* LChunkBuilder::DoDeoptimize(HDeoptimize* instr) { | |
695 return AssignEnvironment(new(zone()) LDeoptimize); | |
696 } | |
697 | |
698 | |
699 LInstruction* LChunkBuilder::DoShift(Token::Value op, | |
700 HBitwiseBinaryOperation* instr) { | |
701 if (instr->representation().IsSmiOrInteger32()) { | |
702 DCHECK(instr->left()->representation().Equals(instr->representation())); | |
703 DCHECK(instr->right()->representation().Equals(instr->representation())); | |
704 LOperand* left = UseRegisterAtStart(instr->left()); | |
705 | |
706 HValue* right_value = instr->right(); | |
707 LOperand* right = NULL; | |
708 int constant_value = 0; | |
709 bool does_deopt = false; | |
710 if (right_value->IsConstant()) { | |
711 HConstant* constant = HConstant::cast(right_value); | |
712 right = chunk_->DefineConstantOperand(constant); | |
713 constant_value = constant->Integer32Value() & 0x1f; | |
714 // Left shifts can deoptimize if we shift by > 0 and the result cannot be | |
715 // truncated to smi. | |
716 if (instr->representation().IsSmi() && constant_value > 0) { | |
717 does_deopt = !instr->CheckUsesForFlag(HValue::kTruncatingToSmi); | |
718 } | |
719 } else { | |
720 right = UseRegisterAtStart(right_value); | |
721 } | |
722 | |
723 // Shift operations can only deoptimize if we do a logical shift | |
724 // by 0 and the result cannot be truncated to int32. | |
725 if (op == Token::SHR && constant_value == 0) { | |
726 does_deopt = !instr->CheckFlag(HInstruction::kUint32); | |
727 } | |
728 | |
729 LInstruction* result = | |
730 DefineAsRegister(new(zone()) LShiftI(op, left, right, does_deopt)); | |
731 return does_deopt ? AssignEnvironment(result) : result; | |
732 } else { | |
733 return DoArithmeticT(op, instr); | |
734 } | |
735 } | |
736 | |
737 | |
738 LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op, | |
739 HArithmeticBinaryOperation* instr) { | |
740 DCHECK(instr->representation().IsDouble()); | |
741 DCHECK(instr->left()->representation().IsDouble()); | |
742 DCHECK(instr->right()->representation().IsDouble()); | |
743 if (op == Token::MOD) { | |
744 LOperand* left = UseFixedDouble(instr->left(), f2); | |
745 LOperand* right = UseFixedDouble(instr->right(), f4); | |
746 LArithmeticD* result = new(zone()) LArithmeticD(op, left, right); | |
747 // We call a C function for double modulo. It can't trigger a GC. We need | |
748 // to use fixed result register for the call. | |
749 // TODO(fschneider): Allow any register as input registers. | |
750 return MarkAsCall(DefineFixedDouble(result, f2), instr); | |
751 } else { | |
752 LOperand* left = UseRegisterAtStart(instr->left()); | |
753 LOperand* right = UseRegisterAtStart(instr->right()); | |
754 LArithmeticD* result = new(zone()) LArithmeticD(op, left, right); | |
755 return DefineAsRegister(result); | |
756 } | |
757 } | |
758 | |
759 | |
760 LInstruction* LChunkBuilder::DoArithmeticT(Token::Value op, | |
761 HBinaryOperation* instr) { | |
762 HValue* left = instr->left(); | |
763 HValue* right = instr->right(); | |
764 DCHECK(left->representation().IsTagged()); | |
765 DCHECK(right->representation().IsTagged()); | |
766 LOperand* context = UseFixed(instr->context(), cp); | |
767 LOperand* left_operand = UseFixed(left, a1); | |
768 LOperand* right_operand = UseFixed(right, a0); | |
769 LArithmeticT* result = | |
770 new(zone()) LArithmeticT(op, context, left_operand, right_operand); | |
771 return MarkAsCall(DefineFixed(result, v0), instr); | |
772 } | |
773 | |
774 | |
775 void LChunkBuilder::DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block) { | |
776 DCHECK(is_building()); | |
777 current_block_ = block; | |
778 next_block_ = next_block; | |
779 if (block->IsStartBlock()) { | |
780 block->UpdateEnvironment(graph_->start_environment()); | |
781 argument_count_ = 0; | |
782 } else if (block->predecessors()->length() == 1) { | |
783 // We have a single predecessor => copy environment and outgoing | |
784 // argument count from the predecessor. | |
785 DCHECK(block->phis()->length() == 0); | |
786 HBasicBlock* pred = block->predecessors()->at(0); | |
787 HEnvironment* last_environment = pred->last_environment(); | |
788 DCHECK(last_environment != NULL); | |
789 // Only copy the environment, if it is later used again. | |
790 if (pred->end()->SecondSuccessor() == NULL) { | |
791 DCHECK(pred->end()->FirstSuccessor() == block); | |
792 } else { | |
793 if (pred->end()->FirstSuccessor()->block_id() > block->block_id() || | |
794 pred->end()->SecondSuccessor()->block_id() > block->block_id()) { | |
795 last_environment = last_environment->Copy(); | |
796 } | |
797 } | |
798 block->UpdateEnvironment(last_environment); | |
799 DCHECK(pred->argument_count() >= 0); | |
800 argument_count_ = pred->argument_count(); | |
801 } else { | |
802 // We are at a state join => process phis. | |
803 HBasicBlock* pred = block->predecessors()->at(0); | |
804 // No need to copy the environment, it cannot be used later. | |
805 HEnvironment* last_environment = pred->last_environment(); | |
806 for (int i = 0; i < block->phis()->length(); ++i) { | |
807 HPhi* phi = block->phis()->at(i); | |
808 if (phi->HasMergedIndex()) { | |
809 last_environment->SetValueAt(phi->merged_index(), phi); | |
810 } | |
811 } | |
812 for (int i = 0; i < block->deleted_phis()->length(); ++i) { | |
813 if (block->deleted_phis()->at(i) < last_environment->length()) { | |
814 last_environment->SetValueAt(block->deleted_phis()->at(i), | |
815 graph_->GetConstantUndefined()); | |
816 } | |
817 } | |
818 block->UpdateEnvironment(last_environment); | |
819 // Pick up the outgoing argument count of one of the predecessors. | |
820 argument_count_ = pred->argument_count(); | |
821 } | |
822 HInstruction* current = block->first(); | |
823 int start = chunk_->instructions()->length(); | |
824 while (current != NULL && !is_aborted()) { | |
825 // Code for constants in registers is generated lazily. | |
826 if (!current->EmitAtUses()) { | |
827 VisitInstruction(current); | |
828 } | |
829 current = current->next(); | |
830 } | |
831 int end = chunk_->instructions()->length() - 1; | |
832 if (end >= start) { | |
833 block->set_first_instruction_index(start); | |
834 block->set_last_instruction_index(end); | |
835 } | |
836 block->set_argument_count(argument_count_); | |
837 next_block_ = NULL; | |
838 current_block_ = NULL; | |
839 } | |
840 | |
841 | |
842 void LChunkBuilder::VisitInstruction(HInstruction* current) { | |
843 HInstruction* old_current = current_instruction_; | |
844 current_instruction_ = current; | |
845 | |
846 LInstruction* instr = NULL; | |
847 if (current->CanReplaceWithDummyUses()) { | |
848 if (current->OperandCount() == 0) { | |
849 instr = DefineAsRegister(new(zone()) LDummy()); | |
850 } else { | |
851 DCHECK(!current->OperandAt(0)->IsControlInstruction()); | |
852 instr = DefineAsRegister(new(zone()) | |
853 LDummyUse(UseAny(current->OperandAt(0)))); | |
854 } | |
855 for (int i = 1; i < current->OperandCount(); ++i) { | |
856 if (current->OperandAt(i)->IsControlInstruction()) continue; | |
857 LInstruction* dummy = | |
858 new(zone()) LDummyUse(UseAny(current->OperandAt(i))); | |
859 dummy->set_hydrogen_value(current); | |
860 chunk_->AddInstruction(dummy, current_block_); | |
861 } | |
862 } else { | |
863 HBasicBlock* successor; | |
864 if (current->IsControlInstruction() && | |
865 HControlInstruction::cast(current)->KnownSuccessorBlock(&successor) && | |
866 successor != NULL) { | |
867 instr = new(zone()) LGoto(successor); | |
868 } else { | |
869 instr = current->CompileToLithium(this); | |
870 } | |
871 } | |
872 | |
873 argument_count_ += current->argument_delta(); | |
874 DCHECK(argument_count_ >= 0); | |
875 | |
876 if (instr != NULL) { | |
877 AddInstruction(instr, current); | |
878 } | |
879 | |
880 current_instruction_ = old_current; | |
881 } | |
882 | |
883 | |
884 void LChunkBuilder::AddInstruction(LInstruction* instr, | |
885 HInstruction* hydrogen_val) { | |
886 // Associate the hydrogen instruction first, since we may need it for | |
887 // the ClobbersRegisters() or ClobbersDoubleRegisters() calls below. | |
888 instr->set_hydrogen_value(hydrogen_val); | |
889 | |
890 #if DEBUG | |
891 // Make sure that the lithium instruction has either no fixed register | |
892 // constraints in temps or the result OR no uses that are only used at | |
893 // start. If this invariant doesn't hold, the register allocator can decide | |
894 // to insert a split of a range immediately before the instruction due to an | |
895 // already allocated register needing to be used for the instruction's fixed | |
896 // register constraint. In this case, The register allocator won't see an | |
897 // interference between the split child and the use-at-start (it would if | |
898 // the it was just a plain use), so it is free to move the split child into | |
899 // the same register that is used for the use-at-start. | |
900 // See https://code.google.com/p/chromium/issues/detail?id=201590 | |
901 if (!(instr->ClobbersRegisters() && | |
902 instr->ClobbersDoubleRegisters(isolate()))) { | |
903 int fixed = 0; | |
904 int used_at_start = 0; | |
905 for (UseIterator it(instr); !it.Done(); it.Advance()) { | |
906 LUnallocated* operand = LUnallocated::cast(it.Current()); | |
907 if (operand->IsUsedAtStart()) ++used_at_start; | |
908 } | |
909 if (instr->Output() != NULL) { | |
910 if (LUnallocated::cast(instr->Output())->HasFixedPolicy()) ++fixed; | |
911 } | |
912 for (TempIterator it(instr); !it.Done(); it.Advance()) { | |
913 LUnallocated* operand = LUnallocated::cast(it.Current()); | |
914 if (operand->HasFixedPolicy()) ++fixed; | |
915 } | |
916 DCHECK(fixed == 0 || used_at_start == 0); | |
917 } | |
918 #endif | |
919 | |
920 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) { | |
921 instr = AssignPointerMap(instr); | |
922 } | |
923 if (FLAG_stress_environments && !instr->HasEnvironment()) { | |
924 instr = AssignEnvironment(instr); | |
925 } | |
926 chunk_->AddInstruction(instr, current_block_); | |
927 | |
928 if (instr->IsCall() || instr->IsPrologue()) { | |
929 HValue* hydrogen_value_for_lazy_bailout = hydrogen_val; | |
930 if (hydrogen_val->HasObservableSideEffects()) { | |
931 HSimulate* sim = HSimulate::cast(hydrogen_val->next()); | |
932 sim->ReplayEnvironment(current_block_->last_environment()); | |
933 hydrogen_value_for_lazy_bailout = sim; | |
934 } | |
935 LInstruction* bailout = AssignEnvironment(new(zone()) LLazyBailout()); | |
936 bailout->set_hydrogen_value(hydrogen_value_for_lazy_bailout); | |
937 chunk_->AddInstruction(bailout, current_block_); | |
938 } | |
939 } | |
940 | |
941 | |
942 LInstruction* LChunkBuilder::DoPrologue(HPrologue* instr) { | |
943 return new (zone()) LPrologue(); | |
944 } | |
945 | |
946 | |
947 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { | |
948 return new(zone()) LGoto(instr->FirstSuccessor()); | |
949 } | |
950 | |
951 | |
952 LInstruction* LChunkBuilder::DoBranch(HBranch* instr) { | |
953 HValue* value = instr->value(); | |
954 Representation r = value->representation(); | |
955 HType type = value->type(); | |
956 ToBooleanStub::Types expected = instr->expected_input_types(); | |
957 if (expected.IsEmpty()) expected = ToBooleanStub::Types::Generic(); | |
958 | |
959 bool easy_case = !r.IsTagged() || type.IsBoolean() || type.IsSmi() || | |
960 type.IsJSArray() || type.IsHeapNumber() || type.IsString(); | |
961 LInstruction* branch = new(zone()) LBranch(UseRegister(value)); | |
962 if (!easy_case && | |
963 ((!expected.Contains(ToBooleanStub::SMI) && expected.NeedsMap()) || | |
964 !expected.IsGeneric())) { | |
965 branch = AssignEnvironment(branch); | |
966 } | |
967 return branch; | |
968 } | |
969 | |
970 | |
971 LInstruction* LChunkBuilder::DoCompareMap(HCompareMap* instr) { | |
972 DCHECK(instr->value()->representation().IsTagged()); | |
973 LOperand* value = UseRegisterAtStart(instr->value()); | |
974 LOperand* temp = TempRegister(); | |
975 return new(zone()) LCmpMapAndBranch(value, temp); | |
976 } | |
977 | |
978 | |
979 LInstruction* LChunkBuilder::DoArgumentsLength(HArgumentsLength* length) { | |
980 info()->MarkAsRequiresFrame(); | |
981 return DefineAsRegister( | |
982 new(zone()) LArgumentsLength(UseRegister(length->value()))); | |
983 } | |
984 | |
985 | |
986 LInstruction* LChunkBuilder::DoArgumentsElements(HArgumentsElements* elems) { | |
987 info()->MarkAsRequiresFrame(); | |
988 return DefineAsRegister(new(zone()) LArgumentsElements); | |
989 } | |
990 | |
991 | |
992 LInstruction* LChunkBuilder::DoInstanceOf(HInstanceOf* instr) { | |
993 LOperand* left = | |
994 UseFixed(instr->left(), InstanceOfDescriptor::LeftRegister()); | |
995 LOperand* right = | |
996 UseFixed(instr->right(), InstanceOfDescriptor::RightRegister()); | |
997 LOperand* context = UseFixed(instr->context(), cp); | |
998 LInstanceOf* result = new (zone()) LInstanceOf(context, left, right); | |
999 return MarkAsCall(DefineFixed(result, v0), instr); | |
1000 } | |
1001 | |
1002 | |
1003 LInstruction* LChunkBuilder::DoHasInPrototypeChainAndBranch( | |
1004 HHasInPrototypeChainAndBranch* instr) { | |
1005 LOperand* object = UseRegister(instr->object()); | |
1006 LOperand* prototype = UseRegister(instr->prototype()); | |
1007 return new (zone()) LHasInPrototypeChainAndBranch(object, prototype); | |
1008 } | |
1009 | |
1010 | |
1011 LInstruction* LChunkBuilder::DoWrapReceiver(HWrapReceiver* instr) { | |
1012 LOperand* receiver = UseRegisterAtStart(instr->receiver()); | |
1013 LOperand* function = UseRegisterAtStart(instr->function()); | |
1014 LWrapReceiver* result = new(zone()) LWrapReceiver(receiver, function); | |
1015 return AssignEnvironment(DefineAsRegister(result)); | |
1016 } | |
1017 | |
1018 | |
1019 LInstruction* LChunkBuilder::DoApplyArguments(HApplyArguments* instr) { | |
1020 LOperand* function = UseFixed(instr->function(), a1); | |
1021 LOperand* receiver = UseFixed(instr->receiver(), a0); | |
1022 LOperand* length = UseFixed(instr->length(), a2); | |
1023 LOperand* elements = UseFixed(instr->elements(), a3); | |
1024 LApplyArguments* result = new(zone()) LApplyArguments(function, | |
1025 receiver, | |
1026 length, | |
1027 elements); | |
1028 return MarkAsCall(DefineFixed(result, v0), instr, CAN_DEOPTIMIZE_EAGERLY); | |
1029 } | |
1030 | |
1031 | |
1032 LInstruction* LChunkBuilder::DoPushArguments(HPushArguments* instr) { | |
1033 int argc = instr->OperandCount(); | |
1034 for (int i = 0; i < argc; ++i) { | |
1035 LOperand* argument = Use(instr->argument(i)); | |
1036 AddInstruction(new(zone()) LPushArgument(argument), instr); | |
1037 } | |
1038 return NULL; | |
1039 } | |
1040 | |
1041 | |
1042 LInstruction* LChunkBuilder::DoStoreCodeEntry( | |
1043 HStoreCodeEntry* store_code_entry) { | |
1044 LOperand* function = UseRegister(store_code_entry->function()); | |
1045 LOperand* code_object = UseTempRegister(store_code_entry->code_object()); | |
1046 return new(zone()) LStoreCodeEntry(function, code_object); | |
1047 } | |
1048 | |
1049 | |
1050 LInstruction* LChunkBuilder::DoInnerAllocatedObject( | |
1051 HInnerAllocatedObject* instr) { | |
1052 LOperand* base_object = UseRegisterAtStart(instr->base_object()); | |
1053 LOperand* offset = UseRegisterOrConstantAtStart(instr->offset()); | |
1054 return DefineAsRegister( | |
1055 new(zone()) LInnerAllocatedObject(base_object, offset)); | |
1056 } | |
1057 | |
1058 | |
1059 LInstruction* LChunkBuilder::DoThisFunction(HThisFunction* instr) { | |
1060 return instr->HasNoUses() | |
1061 ? NULL | |
1062 : DefineAsRegister(new(zone()) LThisFunction); | |
1063 } | |
1064 | |
1065 | |
1066 LInstruction* LChunkBuilder::DoContext(HContext* instr) { | |
1067 if (instr->HasNoUses()) return NULL; | |
1068 | |
1069 if (info()->IsStub()) { | |
1070 return DefineFixed(new(zone()) LContext, cp); | |
1071 } | |
1072 | |
1073 return DefineAsRegister(new(zone()) LContext); | |
1074 } | |
1075 | |
1076 | |
1077 LInstruction* LChunkBuilder::DoDeclareGlobals(HDeclareGlobals* instr) { | |
1078 LOperand* context = UseFixed(instr->context(), cp); | |
1079 return MarkAsCall(new(zone()) LDeclareGlobals(context), instr); | |
1080 } | |
1081 | |
1082 | |
1083 LInstruction* LChunkBuilder::DoCallJSFunction( | |
1084 HCallJSFunction* instr) { | |
1085 LOperand* function = UseFixed(instr->function(), a1); | |
1086 | |
1087 LCallJSFunction* result = new(zone()) LCallJSFunction(function); | |
1088 | |
1089 return MarkAsCall(DefineFixed(result, v0), instr); | |
1090 } | |
1091 | |
1092 | |
1093 LInstruction* LChunkBuilder::DoCallWithDescriptor( | |
1094 HCallWithDescriptor* instr) { | |
1095 CallInterfaceDescriptor descriptor = instr->descriptor(); | |
1096 | |
1097 LOperand* target = UseRegisterOrConstantAtStart(instr->target()); | |
1098 ZoneList<LOperand*> ops(instr->OperandCount(), zone()); | |
1099 // Target | |
1100 ops.Add(target, zone()); | |
1101 // Context | |
1102 LOperand* op = UseFixed(instr->OperandAt(1), cp); | |
1103 ops.Add(op, zone()); | |
1104 // Other register parameters | |
1105 for (int i = LCallWithDescriptor::kImplicitRegisterParameterCount; | |
1106 i < instr->OperandCount(); i++) { | |
1107 op = | |
1108 UseFixed(instr->OperandAt(i), | |
1109 descriptor.GetRegisterParameter( | |
1110 i - LCallWithDescriptor::kImplicitRegisterParameterCount)); | |
1111 ops.Add(op, zone()); | |
1112 } | |
1113 | |
1114 LCallWithDescriptor* result = new(zone()) LCallWithDescriptor( | |
1115 descriptor, ops, zone()); | |
1116 return MarkAsCall(DefineFixed(result, v0), instr); | |
1117 } | |
1118 | |
1119 | |
1120 LInstruction* LChunkBuilder::DoInvokeFunction(HInvokeFunction* instr) { | |
1121 LOperand* context = UseFixed(instr->context(), cp); | |
1122 LOperand* function = UseFixed(instr->function(), a1); | |
1123 LInvokeFunction* result = new(zone()) LInvokeFunction(context, function); | |
1124 return MarkAsCall(DefineFixed(result, v0), instr, CANNOT_DEOPTIMIZE_EAGERLY); | |
1125 } | |
1126 | |
1127 | |
1128 LInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) { | |
1129 switch (instr->op()) { | |
1130 case kMathFloor: | |
1131 return DoMathFloor(instr); | |
1132 case kMathRound: | |
1133 return DoMathRound(instr); | |
1134 case kMathFround: | |
1135 return DoMathFround(instr); | |
1136 case kMathAbs: | |
1137 return DoMathAbs(instr); | |
1138 case kMathLog: | |
1139 return DoMathLog(instr); | |
1140 case kMathExp: | |
1141 return DoMathExp(instr); | |
1142 case kMathSqrt: | |
1143 return DoMathSqrt(instr); | |
1144 case kMathPowHalf: | |
1145 return DoMathPowHalf(instr); | |
1146 case kMathClz32: | |
1147 return DoMathClz32(instr); | |
1148 default: | |
1149 UNREACHABLE(); | |
1150 return NULL; | |
1151 } | |
1152 } | |
1153 | |
1154 | |
1155 LInstruction* LChunkBuilder::DoMathLog(HUnaryMathOperation* instr) { | |
1156 DCHECK(instr->representation().IsDouble()); | |
1157 DCHECK(instr->value()->representation().IsDouble()); | |
1158 LOperand* input = UseFixedDouble(instr->value(), f4); | |
1159 return MarkAsCall(DefineFixedDouble(new(zone()) LMathLog(input), f4), instr); | |
1160 } | |
1161 | |
1162 | |
1163 LInstruction* LChunkBuilder::DoMathClz32(HUnaryMathOperation* instr) { | |
1164 LOperand* input = UseRegisterAtStart(instr->value()); | |
1165 LMathClz32* result = new(zone()) LMathClz32(input); | |
1166 return DefineAsRegister(result); | |
1167 } | |
1168 | |
1169 | |
1170 LInstruction* LChunkBuilder::DoMathExp(HUnaryMathOperation* instr) { | |
1171 DCHECK(instr->representation().IsDouble()); | |
1172 DCHECK(instr->value()->representation().IsDouble()); | |
1173 LOperand* input = UseRegister(instr->value()); | |
1174 LOperand* temp1 = TempRegister(); | |
1175 LOperand* temp2 = TempRegister(); | |
1176 LOperand* double_temp = TempDoubleRegister(); | |
1177 LMathExp* result = new(zone()) LMathExp(input, double_temp, temp1, temp2); | |
1178 return DefineAsRegister(result); | |
1179 } | |
1180 | |
1181 | |
1182 LInstruction* LChunkBuilder::DoMathPowHalf(HUnaryMathOperation* instr) { | |
1183 // Input cannot be the same as the result, see LCodeGen::DoMathPowHalf. | |
1184 LOperand* input = UseFixedDouble(instr->value(), f8); | |
1185 LOperand* temp = TempDoubleRegister(); | |
1186 LMathPowHalf* result = new(zone()) LMathPowHalf(input, temp); | |
1187 return DefineFixedDouble(result, f4); | |
1188 } | |
1189 | |
1190 | |
1191 LInstruction* LChunkBuilder::DoMathFround(HUnaryMathOperation* instr) { | |
1192 LOperand* input = UseRegister(instr->value()); | |
1193 LMathFround* result = new (zone()) LMathFround(input); | |
1194 return DefineAsRegister(result); | |
1195 } | |
1196 | |
1197 | |
1198 LInstruction* LChunkBuilder::DoMathAbs(HUnaryMathOperation* instr) { | |
1199 Representation r = instr->value()->representation(); | |
1200 LOperand* context = (r.IsDouble() || r.IsSmiOrInteger32()) | |
1201 ? NULL | |
1202 : UseFixed(instr->context(), cp); | |
1203 LOperand* input = UseRegister(instr->value()); | |
1204 LInstruction* result = | |
1205 DefineAsRegister(new(zone()) LMathAbs(context, input)); | |
1206 if (!r.IsDouble() && !r.IsSmiOrInteger32()) result = AssignPointerMap(result); | |
1207 if (!r.IsDouble()) result = AssignEnvironment(result); | |
1208 return result; | |
1209 } | |
1210 | |
1211 | |
1212 LInstruction* LChunkBuilder::DoMathFloor(HUnaryMathOperation* instr) { | |
1213 LOperand* input = UseRegister(instr->value()); | |
1214 LOperand* temp = TempRegister(); | |
1215 LMathFloor* result = new(zone()) LMathFloor(input, temp); | |
1216 return AssignEnvironment(AssignPointerMap(DefineAsRegister(result))); | |
1217 } | |
1218 | |
1219 | |
1220 LInstruction* LChunkBuilder::DoMathSqrt(HUnaryMathOperation* instr) { | |
1221 LOperand* input = UseRegister(instr->value()); | |
1222 LMathSqrt* result = new(zone()) LMathSqrt(input); | |
1223 return DefineAsRegister(result); | |
1224 } | |
1225 | |
1226 | |
1227 LInstruction* LChunkBuilder::DoMathRound(HUnaryMathOperation* instr) { | |
1228 LOperand* input = UseRegister(instr->value()); | |
1229 LOperand* temp = TempDoubleRegister(); | |
1230 LMathRound* result = new(zone()) LMathRound(input, temp); | |
1231 return AssignEnvironment(DefineAsRegister(result)); | |
1232 } | |
1233 | |
1234 | |
1235 LInstruction* LChunkBuilder::DoCallNew(HCallNew* instr) { | |
1236 LOperand* context = UseFixed(instr->context(), cp); | |
1237 LOperand* constructor = UseFixed(instr->constructor(), a1); | |
1238 LCallNew* result = new(zone()) LCallNew(context, constructor); | |
1239 return MarkAsCall(DefineFixed(result, v0), instr); | |
1240 } | |
1241 | |
1242 | |
1243 LInstruction* LChunkBuilder::DoCallNewArray(HCallNewArray* instr) { | |
1244 LOperand* context = UseFixed(instr->context(), cp); | |
1245 LOperand* constructor = UseFixed(instr->constructor(), a1); | |
1246 LCallNewArray* result = new(zone()) LCallNewArray(context, constructor); | |
1247 return MarkAsCall(DefineFixed(result, v0), instr); | |
1248 } | |
1249 | |
1250 | |
1251 LInstruction* LChunkBuilder::DoCallFunction(HCallFunction* instr) { | |
1252 LOperand* context = UseFixed(instr->context(), cp); | |
1253 LOperand* function = UseFixed(instr->function(), a1); | |
1254 LOperand* slot = NULL; | |
1255 LOperand* vector = NULL; | |
1256 if (instr->HasVectorAndSlot()) { | |
1257 slot = FixedTemp(a3); | |
1258 vector = FixedTemp(a2); | |
1259 } | |
1260 | |
1261 LCallFunction* call = | |
1262 new (zone()) LCallFunction(context, function, slot, vector); | |
1263 return MarkAsCall(DefineFixed(call, v0), instr); | |
1264 } | |
1265 | |
1266 | |
1267 LInstruction* LChunkBuilder::DoCallRuntime(HCallRuntime* instr) { | |
1268 LOperand* context = UseFixed(instr->context(), cp); | |
1269 return MarkAsCall(DefineFixed(new(zone()) LCallRuntime(context), v0), instr); | |
1270 } | |
1271 | |
1272 | |
1273 LInstruction* LChunkBuilder::DoRor(HRor* instr) { | |
1274 return DoShift(Token::ROR, instr); | |
1275 } | |
1276 | |
1277 | |
1278 LInstruction* LChunkBuilder::DoShr(HShr* instr) { | |
1279 return DoShift(Token::SHR, instr); | |
1280 } | |
1281 | |
1282 | |
1283 LInstruction* LChunkBuilder::DoSar(HSar* instr) { | |
1284 return DoShift(Token::SAR, instr); | |
1285 } | |
1286 | |
1287 | |
1288 LInstruction* LChunkBuilder::DoShl(HShl* instr) { | |
1289 return DoShift(Token::SHL, instr); | |
1290 } | |
1291 | |
1292 | |
1293 LInstruction* LChunkBuilder::DoBitwise(HBitwise* instr) { | |
1294 if (instr->representation().IsSmiOrInteger32()) { | |
1295 DCHECK(instr->left()->representation().Equals(instr->representation())); | |
1296 DCHECK(instr->right()->representation().Equals(instr->representation())); | |
1297 DCHECK(instr->CheckFlag(HValue::kTruncatingToInt32)); | |
1298 | |
1299 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); | |
1300 LOperand* right = UseOrConstantAtStart(instr->BetterRightOperand()); | |
1301 return DefineAsRegister(new(zone()) LBitI(left, right)); | |
1302 } else { | |
1303 return DoArithmeticT(instr->op(), instr); | |
1304 } | |
1305 } | |
1306 | |
1307 | |
1308 LInstruction* LChunkBuilder::DoDivByPowerOf2I(HDiv* instr) { | |
1309 DCHECK(instr->representation().IsSmiOrInteger32()); | |
1310 DCHECK(instr->left()->representation().Equals(instr->representation())); | |
1311 DCHECK(instr->right()->representation().Equals(instr->representation())); | |
1312 LOperand* dividend = UseRegister(instr->left()); | |
1313 int32_t divisor = instr->right()->GetInteger32Constant(); | |
1314 LInstruction* result = DefineAsRegister(new(zone()) LDivByPowerOf2I( | |
1315 dividend, divisor)); | |
1316 if ((instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) || | |
1317 (instr->CheckFlag(HValue::kCanOverflow) && divisor == -1) || | |
1318 (!instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32) && | |
1319 divisor != 1 && divisor != -1)) { | |
1320 result = AssignEnvironment(result); | |
1321 } | |
1322 return result; | |
1323 } | |
1324 | |
1325 | |
1326 LInstruction* LChunkBuilder::DoDivByConstI(HDiv* instr) { | |
1327 DCHECK(instr->representation().IsInteger32()); | |
1328 DCHECK(instr->left()->representation().Equals(instr->representation())); | |
1329 DCHECK(instr->right()->representation().Equals(instr->representation())); | |
1330 LOperand* dividend = UseRegister(instr->left()); | |
1331 int32_t divisor = instr->right()->GetInteger32Constant(); | |
1332 LInstruction* result = DefineAsRegister(new(zone()) LDivByConstI( | |
1333 dividend, divisor)); | |
1334 if (divisor == 0 || | |
1335 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) || | |
1336 !instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32)) { | |
1337 result = AssignEnvironment(result); | |
1338 } | |
1339 return result; | |
1340 } | |
1341 | |
1342 | |
1343 LInstruction* LChunkBuilder::DoDivI(HDiv* instr) { | |
1344 DCHECK(instr->representation().IsSmiOrInteger32()); | |
1345 DCHECK(instr->left()->representation().Equals(instr->representation())); | |
1346 DCHECK(instr->right()->representation().Equals(instr->representation())); | |
1347 LOperand* dividend = UseRegister(instr->left()); | |
1348 LOperand* divisor = UseRegister(instr->right()); | |
1349 LOperand* temp = instr->CheckFlag(HInstruction::kAllUsesTruncatingToInt32) | |
1350 ? NULL : TempRegister(); | |
1351 LInstruction* result = | |
1352 DefineAsRegister(new(zone()) LDivI(dividend, divisor, temp)); | |
1353 if (instr->CheckFlag(HValue::kCanBeDivByZero) || | |
1354 instr->CheckFlag(HValue::kBailoutOnMinusZero) || | |
1355 (instr->CheckFlag(HValue::kCanOverflow) && | |
1356 !instr->CheckFlag(HValue::kAllUsesTruncatingToInt32)) || | |
1357 (!instr->IsMathFloorOfDiv() && | |
1358 !instr->CheckFlag(HValue::kAllUsesTruncatingToInt32))) { | |
1359 result = AssignEnvironment(result); | |
1360 } | |
1361 return result; | |
1362 } | |
1363 | |
1364 | |
1365 LInstruction* LChunkBuilder::DoDiv(HDiv* instr) { | |
1366 if (instr->representation().IsSmiOrInteger32()) { | |
1367 if (instr->RightIsPowerOf2()) { | |
1368 return DoDivByPowerOf2I(instr); | |
1369 } else if (instr->right()->IsConstant()) { | |
1370 return DoDivByConstI(instr); | |
1371 } else { | |
1372 return DoDivI(instr); | |
1373 } | |
1374 } else if (instr->representation().IsDouble()) { | |
1375 return DoArithmeticD(Token::DIV, instr); | |
1376 } else { | |
1377 return DoArithmeticT(Token::DIV, instr); | |
1378 } | |
1379 } | |
1380 | |
1381 | |
1382 LInstruction* LChunkBuilder::DoFlooringDivByPowerOf2I(HMathFloorOfDiv* instr) { | |
1383 LOperand* dividend = UseRegisterAtStart(instr->left()); | |
1384 int32_t divisor = instr->right()->GetInteger32Constant(); | |
1385 LInstruction* result = DefineAsRegister(new(zone()) LFlooringDivByPowerOf2I( | |
1386 dividend, divisor)); | |
1387 if ((instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) || | |
1388 (instr->CheckFlag(HValue::kLeftCanBeMinInt) && divisor == -1)) { | |
1389 result = AssignEnvironment(result); | |
1390 } | |
1391 return result; | |
1392 } | |
1393 | |
1394 | |
1395 LInstruction* LChunkBuilder::DoFlooringDivByConstI(HMathFloorOfDiv* instr) { | |
1396 DCHECK(instr->representation().IsInteger32()); | |
1397 DCHECK(instr->left()->representation().Equals(instr->representation())); | |
1398 DCHECK(instr->right()->representation().Equals(instr->representation())); | |
1399 LOperand* dividend = UseRegister(instr->left()); | |
1400 int32_t divisor = instr->right()->GetInteger32Constant(); | |
1401 LOperand* temp = | |
1402 ((divisor > 0 && !instr->CheckFlag(HValue::kLeftCanBeNegative)) || | |
1403 (divisor < 0 && !instr->CheckFlag(HValue::kLeftCanBePositive))) ? | |
1404 NULL : TempRegister(); | |
1405 LInstruction* result = DefineAsRegister( | |
1406 new(zone()) LFlooringDivByConstI(dividend, divisor, temp)); | |
1407 if (divisor == 0 || | |
1408 (instr->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0)) { | |
1409 result = AssignEnvironment(result); | |
1410 } | |
1411 return result; | |
1412 } | |
1413 | |
1414 | |
1415 LInstruction* LChunkBuilder::DoFlooringDivI(HMathFloorOfDiv* instr) { | |
1416 DCHECK(instr->representation().IsSmiOrInteger32()); | |
1417 DCHECK(instr->left()->representation().Equals(instr->representation())); | |
1418 DCHECK(instr->right()->representation().Equals(instr->representation())); | |
1419 LOperand* dividend = UseRegister(instr->left()); | |
1420 LOperand* divisor = UseRegister(instr->right()); | |
1421 LInstruction* result = | |
1422 DefineAsRegister(new (zone()) LFlooringDivI(dividend, divisor)); | |
1423 if (instr->CheckFlag(HValue::kCanBeDivByZero) || | |
1424 instr->CheckFlag(HValue::kBailoutOnMinusZero) || | |
1425 (instr->CheckFlag(HValue::kCanOverflow))) { | |
1426 result = AssignEnvironment(result); | |
1427 } | |
1428 return result; | |
1429 } | |
1430 | |
1431 | |
1432 LInstruction* LChunkBuilder::DoMathFloorOfDiv(HMathFloorOfDiv* instr) { | |
1433 if (instr->RightIsPowerOf2()) { | |
1434 return DoFlooringDivByPowerOf2I(instr); | |
1435 } else if (instr->right()->IsConstant()) { | |
1436 return DoFlooringDivByConstI(instr); | |
1437 } else { | |
1438 return DoFlooringDivI(instr); | |
1439 } | |
1440 } | |
1441 | |
1442 | |
1443 LInstruction* LChunkBuilder::DoModByPowerOf2I(HMod* instr) { | |
1444 DCHECK(instr->representation().IsSmiOrInteger32()); | |
1445 DCHECK(instr->left()->representation().Equals(instr->representation())); | |
1446 DCHECK(instr->right()->representation().Equals(instr->representation())); | |
1447 LOperand* dividend = UseRegisterAtStart(instr->left()); | |
1448 int32_t divisor = instr->right()->GetInteger32Constant(); | |
1449 LInstruction* result = DefineSameAsFirst(new(zone()) LModByPowerOf2I( | |
1450 dividend, divisor)); | |
1451 if (instr->CheckFlag(HValue::kLeftCanBeNegative) && | |
1452 instr->CheckFlag(HValue::kBailoutOnMinusZero)) { | |
1453 result = AssignEnvironment(result); | |
1454 } | |
1455 return result; | |
1456 } | |
1457 | |
1458 | |
1459 LInstruction* LChunkBuilder::DoModByConstI(HMod* instr) { | |
1460 DCHECK(instr->representation().IsSmiOrInteger32()); | |
1461 DCHECK(instr->left()->representation().Equals(instr->representation())); | |
1462 DCHECK(instr->right()->representation().Equals(instr->representation())); | |
1463 LOperand* dividend = UseRegister(instr->left()); | |
1464 int32_t divisor = instr->right()->GetInteger32Constant(); | |
1465 LInstruction* result = DefineAsRegister(new(zone()) LModByConstI( | |
1466 dividend, divisor)); | |
1467 if (divisor == 0 || instr->CheckFlag(HValue::kBailoutOnMinusZero)) { | |
1468 result = AssignEnvironment(result); | |
1469 } | |
1470 return result; | |
1471 } | |
1472 | |
1473 | |
1474 LInstruction* LChunkBuilder::DoModI(HMod* instr) { | |
1475 DCHECK(instr->representation().IsSmiOrInteger32()); | |
1476 DCHECK(instr->left()->representation().Equals(instr->representation())); | |
1477 DCHECK(instr->right()->representation().Equals(instr->representation())); | |
1478 LOperand* dividend = UseRegister(instr->left()); | |
1479 LOperand* divisor = UseRegister(instr->right()); | |
1480 LInstruction* result = DefineAsRegister(new(zone()) LModI( | |
1481 dividend, divisor)); | |
1482 if (instr->CheckFlag(HValue::kCanBeDivByZero) || | |
1483 instr->CheckFlag(HValue::kBailoutOnMinusZero)) { | |
1484 result = AssignEnvironment(result); | |
1485 } | |
1486 return result; | |
1487 } | |
1488 | |
1489 | |
1490 LInstruction* LChunkBuilder::DoMod(HMod* instr) { | |
1491 if (instr->representation().IsSmiOrInteger32()) { | |
1492 return instr->RightIsPowerOf2() ? DoModByPowerOf2I(instr) : DoModI(instr); | |
1493 } else if (instr->representation().IsDouble()) { | |
1494 return DoArithmeticD(Token::MOD, instr); | |
1495 } else { | |
1496 return DoArithmeticT(Token::MOD, instr); | |
1497 } | |
1498 } | |
1499 | |
1500 | |
1501 LInstruction* LChunkBuilder::DoMul(HMul* instr) { | |
1502 if (instr->representation().IsSmiOrInteger32()) { | |
1503 DCHECK(instr->left()->representation().Equals(instr->representation())); | |
1504 DCHECK(instr->right()->representation().Equals(instr->representation())); | |
1505 HValue* left = instr->BetterLeftOperand(); | |
1506 HValue* right = instr->BetterRightOperand(); | |
1507 LOperand* left_op; | |
1508 LOperand* right_op; | |
1509 bool can_overflow = instr->CheckFlag(HValue::kCanOverflow); | |
1510 bool bailout_on_minus_zero = instr->CheckFlag(HValue::kBailoutOnMinusZero); | |
1511 | |
1512 int32_t constant_value = 0; | |
1513 if (right->IsConstant()) { | |
1514 HConstant* constant = HConstant::cast(right); | |
1515 constant_value = constant->Integer32Value(); | |
1516 // Constants -1, 0 and 1 can be optimized if the result can overflow. | |
1517 // For other constants, it can be optimized only without overflow. | |
1518 if (!can_overflow || ((constant_value >= -1) && (constant_value <= 1))) { | |
1519 left_op = UseRegisterAtStart(left); | |
1520 right_op = UseConstant(right); | |
1521 } else { | |
1522 if (bailout_on_minus_zero) { | |
1523 left_op = UseRegister(left); | |
1524 } else { | |
1525 left_op = UseRegisterAtStart(left); | |
1526 } | |
1527 right_op = UseRegister(right); | |
1528 } | |
1529 } else { | |
1530 if (bailout_on_minus_zero) { | |
1531 left_op = UseRegister(left); | |
1532 } else { | |
1533 left_op = UseRegisterAtStart(left); | |
1534 } | |
1535 right_op = UseRegister(right); | |
1536 } | |
1537 LInstruction* result = | |
1538 instr->representation().IsSmi() | |
1539 ? DefineAsRegister(new (zone()) LMulS(left_op, right_op)) | |
1540 : DefineAsRegister(new (zone()) LMulI(left_op, right_op)); | |
1541 if (right_op->IsConstantOperand() | |
1542 ? ((can_overflow && constant_value == -1) || | |
1543 (bailout_on_minus_zero && constant_value <= 0)) | |
1544 : (can_overflow || bailout_on_minus_zero)) { | |
1545 AssignEnvironment(result); | |
1546 } | |
1547 return result; | |
1548 | |
1549 } else if (instr->representation().IsDouble()) { | |
1550 if (kArchVariant == kMips64r2) { | |
1551 if (instr->HasOneUse() && instr->uses().value()->IsAdd()) { | |
1552 HAdd* add = HAdd::cast(instr->uses().value()); | |
1553 if (instr == add->left()) { | |
1554 // This mul is the lhs of an add. The add and mul will be folded | |
1555 // into a multiply-add. | |
1556 return NULL; | |
1557 } | |
1558 if (instr == add->right() && !add->left()->IsMul()) { | |
1559 // This mul is the rhs of an add, where the lhs is not another mul. | |
1560 // The add and mul will be folded into a multiply-add. | |
1561 return NULL; | |
1562 } | |
1563 } | |
1564 } | |
1565 return DoArithmeticD(Token::MUL, instr); | |
1566 } else { | |
1567 return DoArithmeticT(Token::MUL, instr); | |
1568 } | |
1569 } | |
1570 | |
1571 | |
1572 LInstruction* LChunkBuilder::DoSub(HSub* instr) { | |
1573 if (instr->representation().IsSmiOrInteger32()) { | |
1574 DCHECK(instr->left()->representation().Equals(instr->representation())); | |
1575 DCHECK(instr->right()->representation().Equals(instr->representation())); | |
1576 LOperand* left = UseRegisterAtStart(instr->left()); | |
1577 LOperand* right = UseRegisterOrConstantAtStart(instr->right()); | |
1578 LInstruction* result = | |
1579 instr->representation().IsSmi() | |
1580 ? DefineAsRegister(new (zone()) LSubS(left, right)) | |
1581 : DefineAsRegister(new (zone()) LSubI(left, right)); | |
1582 if (instr->CheckFlag(HValue::kCanOverflow)) { | |
1583 result = AssignEnvironment(result); | |
1584 } | |
1585 return result; | |
1586 } else if (instr->representation().IsDouble()) { | |
1587 return DoArithmeticD(Token::SUB, instr); | |
1588 } else { | |
1589 return DoArithmeticT(Token::SUB, instr); | |
1590 } | |
1591 } | |
1592 | |
1593 | |
1594 LInstruction* LChunkBuilder::DoMultiplyAdd(HMul* mul, HValue* addend) { | |
1595 LOperand* multiplier_op = UseRegisterAtStart(mul->left()); | |
1596 LOperand* multiplicand_op = UseRegisterAtStart(mul->right()); | |
1597 LOperand* addend_op = UseRegisterAtStart(addend); | |
1598 return DefineSameAsFirst(new(zone()) LMultiplyAddD(addend_op, multiplier_op, | |
1599 multiplicand_op)); | |
1600 } | |
1601 | |
1602 | |
1603 LInstruction* LChunkBuilder::DoAdd(HAdd* instr) { | |
1604 if (instr->representation().IsSmiOrInteger32()) { | |
1605 DCHECK(instr->left()->representation().Equals(instr->representation())); | |
1606 DCHECK(instr->right()->representation().Equals(instr->representation())); | |
1607 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); | |
1608 LOperand* right = UseRegisterOrConstantAtStart(instr->BetterRightOperand()); | |
1609 LInstruction* result = | |
1610 instr->representation().IsSmi() | |
1611 ? DefineAsRegister(new (zone()) LAddS(left, right)) | |
1612 : DefineAsRegister(new (zone()) LAddI(left, right)); | |
1613 if (instr->CheckFlag(HValue::kCanOverflow)) { | |
1614 result = AssignEnvironment(result); | |
1615 } | |
1616 return result; | |
1617 } else if (instr->representation().IsExternal()) { | |
1618 DCHECK(instr->IsConsistentExternalRepresentation()); | |
1619 DCHECK(!instr->CheckFlag(HValue::kCanOverflow)); | |
1620 LOperand* left = UseRegisterAtStart(instr->left()); | |
1621 LOperand* right = UseRegisterOrConstantAtStart(instr->right()); | |
1622 return DefineAsRegister(new (zone()) LAddE(left, right)); | |
1623 } else if (instr->representation().IsDouble()) { | |
1624 if (kArchVariant == kMips64r2) { | |
1625 if (instr->left()->IsMul()) | |
1626 return DoMultiplyAdd(HMul::cast(instr->left()), instr->right()); | |
1627 | |
1628 if (instr->right()->IsMul()) { | |
1629 DCHECK(!instr->left()->IsMul()); | |
1630 return DoMultiplyAdd(HMul::cast(instr->right()), instr->left()); | |
1631 } | |
1632 } | |
1633 return DoArithmeticD(Token::ADD, instr); | |
1634 } else { | |
1635 return DoArithmeticT(Token::ADD, instr); | |
1636 } | |
1637 } | |
1638 | |
1639 | |
1640 LInstruction* LChunkBuilder::DoMathMinMax(HMathMinMax* instr) { | |
1641 LOperand* left = NULL; | |
1642 LOperand* right = NULL; | |
1643 if (instr->representation().IsSmiOrInteger32()) { | |
1644 DCHECK(instr->left()->representation().Equals(instr->representation())); | |
1645 DCHECK(instr->right()->representation().Equals(instr->representation())); | |
1646 left = UseRegisterAtStart(instr->BetterLeftOperand()); | |
1647 right = UseOrConstantAtStart(instr->BetterRightOperand()); | |
1648 } else { | |
1649 DCHECK(instr->representation().IsDouble()); | |
1650 DCHECK(instr->left()->representation().IsDouble()); | |
1651 DCHECK(instr->right()->representation().IsDouble()); | |
1652 left = UseRegisterAtStart(instr->left()); | |
1653 right = UseRegisterAtStart(instr->right()); | |
1654 } | |
1655 return DefineAsRegister(new(zone()) LMathMinMax(left, right)); | |
1656 } | |
1657 | |
1658 | |
1659 LInstruction* LChunkBuilder::DoPower(HPower* instr) { | |
1660 DCHECK(instr->representation().IsDouble()); | |
1661 // We call a C function for double power. It can't trigger a GC. | |
1662 // We need to use fixed result register for the call. | |
1663 Representation exponent_type = instr->right()->representation(); | |
1664 DCHECK(instr->left()->representation().IsDouble()); | |
1665 LOperand* left = UseFixedDouble(instr->left(), f2); | |
1666 LOperand* right = | |
1667 exponent_type.IsDouble() | |
1668 ? UseFixedDouble(instr->right(), f4) | |
1669 : UseFixed(instr->right(), MathPowTaggedDescriptor::exponent()); | |
1670 LPower* result = new(zone()) LPower(left, right); | |
1671 return MarkAsCall(DefineFixedDouble(result, f0), | |
1672 instr, | |
1673 CAN_DEOPTIMIZE_EAGERLY); | |
1674 } | |
1675 | |
1676 | |
1677 LInstruction* LChunkBuilder::DoCompareGeneric(HCompareGeneric* instr) { | |
1678 DCHECK(instr->left()->representation().IsTagged()); | |
1679 DCHECK(instr->right()->representation().IsTagged()); | |
1680 LOperand* context = UseFixed(instr->context(), cp); | |
1681 LOperand* left = UseFixed(instr->left(), a1); | |
1682 LOperand* right = UseFixed(instr->right(), a0); | |
1683 LCmpT* result = new(zone()) LCmpT(context, left, right); | |
1684 return MarkAsCall(DefineFixed(result, v0), instr); | |
1685 } | |
1686 | |
1687 | |
1688 LInstruction* LChunkBuilder::DoCompareNumericAndBranch( | |
1689 HCompareNumericAndBranch* instr) { | |
1690 Representation r = instr->representation(); | |
1691 if (r.IsSmiOrInteger32()) { | |
1692 DCHECK(instr->left()->representation().Equals(r)); | |
1693 DCHECK(instr->right()->representation().Equals(r)); | |
1694 LOperand* left = UseRegisterOrConstantAtStart(instr->left()); | |
1695 LOperand* right = UseRegisterOrConstantAtStart(instr->right()); | |
1696 return new(zone()) LCompareNumericAndBranch(left, right); | |
1697 } else { | |
1698 DCHECK(r.IsDouble()); | |
1699 DCHECK(instr->left()->representation().IsDouble()); | |
1700 DCHECK(instr->right()->representation().IsDouble()); | |
1701 LOperand* left = UseRegisterAtStart(instr->left()); | |
1702 LOperand* right = UseRegisterAtStart(instr->right()); | |
1703 return new(zone()) LCompareNumericAndBranch(left, right); | |
1704 } | |
1705 } | |
1706 | |
1707 | |
1708 LInstruction* LChunkBuilder::DoCompareObjectEqAndBranch( | |
1709 HCompareObjectEqAndBranch* instr) { | |
1710 LOperand* left = UseRegisterAtStart(instr->left()); | |
1711 LOperand* right = UseRegisterAtStart(instr->right()); | |
1712 return new(zone()) LCmpObjectEqAndBranch(left, right); | |
1713 } | |
1714 | |
1715 | |
1716 LInstruction* LChunkBuilder::DoCompareHoleAndBranch( | |
1717 HCompareHoleAndBranch* instr) { | |
1718 LOperand* value = UseRegisterAtStart(instr->value()); | |
1719 return new(zone()) LCmpHoleAndBranch(value); | |
1720 } | |
1721 | |
1722 | |
1723 LInstruction* LChunkBuilder::DoCompareMinusZeroAndBranch( | |
1724 HCompareMinusZeroAndBranch* instr) { | |
1725 LOperand* value = UseRegister(instr->value()); | |
1726 LOperand* scratch = TempRegister(); | |
1727 return new(zone()) LCompareMinusZeroAndBranch(value, scratch); | |
1728 } | |
1729 | |
1730 | |
1731 LInstruction* LChunkBuilder::DoIsStringAndBranch(HIsStringAndBranch* instr) { | |
1732 DCHECK(instr->value()->representation().IsTagged()); | |
1733 LOperand* temp = TempRegister(); | |
1734 return new(zone()) LIsStringAndBranch(UseRegisterAtStart(instr->value()), | |
1735 temp); | |
1736 } | |
1737 | |
1738 | |
1739 LInstruction* LChunkBuilder::DoIsSmiAndBranch(HIsSmiAndBranch* instr) { | |
1740 DCHECK(instr->value()->representation().IsTagged()); | |
1741 return new(zone()) LIsSmiAndBranch(Use(instr->value())); | |
1742 } | |
1743 | |
1744 | |
1745 LInstruction* LChunkBuilder::DoIsUndetectableAndBranch( | |
1746 HIsUndetectableAndBranch* instr) { | |
1747 DCHECK(instr->value()->representation().IsTagged()); | |
1748 return new(zone()) LIsUndetectableAndBranch( | |
1749 UseRegisterAtStart(instr->value()), TempRegister()); | |
1750 } | |
1751 | |
1752 | |
1753 LInstruction* LChunkBuilder::DoStringCompareAndBranch( | |
1754 HStringCompareAndBranch* instr) { | |
1755 DCHECK(instr->left()->representation().IsTagged()); | |
1756 DCHECK(instr->right()->representation().IsTagged()); | |
1757 LOperand* context = UseFixed(instr->context(), cp); | |
1758 LOperand* left = UseFixed(instr->left(), a1); | |
1759 LOperand* right = UseFixed(instr->right(), a0); | |
1760 LStringCompareAndBranch* result = | |
1761 new(zone()) LStringCompareAndBranch(context, left, right); | |
1762 return MarkAsCall(result, instr); | |
1763 } | |
1764 | |
1765 | |
1766 LInstruction* LChunkBuilder::DoHasInstanceTypeAndBranch( | |
1767 HHasInstanceTypeAndBranch* instr) { | |
1768 DCHECK(instr->value()->representation().IsTagged()); | |
1769 LOperand* value = UseRegisterAtStart(instr->value()); | |
1770 return new(zone()) LHasInstanceTypeAndBranch(value); | |
1771 } | |
1772 | |
1773 | |
1774 LInstruction* LChunkBuilder::DoGetCachedArrayIndex( | |
1775 HGetCachedArrayIndex* instr) { | |
1776 DCHECK(instr->value()->representation().IsTagged()); | |
1777 LOperand* value = UseRegisterAtStart(instr->value()); | |
1778 | |
1779 return DefineAsRegister(new(zone()) LGetCachedArrayIndex(value)); | |
1780 } | |
1781 | |
1782 | |
1783 LInstruction* LChunkBuilder::DoHasCachedArrayIndexAndBranch( | |
1784 HHasCachedArrayIndexAndBranch* instr) { | |
1785 DCHECK(instr->value()->representation().IsTagged()); | |
1786 return new(zone()) LHasCachedArrayIndexAndBranch( | |
1787 UseRegisterAtStart(instr->value())); | |
1788 } | |
1789 | |
1790 | |
1791 LInstruction* LChunkBuilder::DoClassOfTestAndBranch( | |
1792 HClassOfTestAndBranch* instr) { | |
1793 DCHECK(instr->value()->representation().IsTagged()); | |
1794 return new(zone()) LClassOfTestAndBranch(UseRegister(instr->value()), | |
1795 TempRegister()); | |
1796 } | |
1797 | |
1798 | |
1799 LInstruction* LChunkBuilder::DoMapEnumLength(HMapEnumLength* instr) { | |
1800 LOperand* map = UseRegisterAtStart(instr->value()); | |
1801 return DefineAsRegister(new(zone()) LMapEnumLength(map)); | |
1802 } | |
1803 | |
1804 | |
1805 LInstruction* LChunkBuilder::DoDateField(HDateField* instr) { | |
1806 LOperand* object = UseFixed(instr->value(), a0); | |
1807 LDateField* result = | |
1808 new(zone()) LDateField(object, FixedTemp(a1), instr->index()); | |
1809 return MarkAsCall(DefineFixed(result, v0), instr, CANNOT_DEOPTIMIZE_EAGERLY); | |
1810 } | |
1811 | |
1812 | |
1813 LInstruction* LChunkBuilder::DoSeqStringGetChar(HSeqStringGetChar* instr) { | |
1814 LOperand* string = UseRegisterAtStart(instr->string()); | |
1815 LOperand* index = UseRegisterOrConstantAtStart(instr->index()); | |
1816 return DefineAsRegister(new(zone()) LSeqStringGetChar(string, index)); | |
1817 } | |
1818 | |
1819 | |
1820 LInstruction* LChunkBuilder::DoSeqStringSetChar(HSeqStringSetChar* instr) { | |
1821 LOperand* string = UseRegisterAtStart(instr->string()); | |
1822 LOperand* index = FLAG_debug_code | |
1823 ? UseRegisterAtStart(instr->index()) | |
1824 : UseRegisterOrConstantAtStart(instr->index()); | |
1825 LOperand* value = UseRegisterAtStart(instr->value()); | |
1826 LOperand* context = FLAG_debug_code ? UseFixed(instr->context(), cp) : NULL; | |
1827 return new(zone()) LSeqStringSetChar(context, string, index, value); | |
1828 } | |
1829 | |
1830 | |
1831 LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) { | |
1832 if (!FLAG_debug_code && instr->skip_check()) return NULL; | |
1833 LOperand* index = UseRegisterOrConstantAtStart(instr->index()); | |
1834 LOperand* length = !index->IsConstantOperand() | |
1835 ? UseRegisterOrConstantAtStart(instr->length()) | |
1836 : UseRegisterAtStart(instr->length()); | |
1837 LInstruction* result = new(zone()) LBoundsCheck(index, length); | |
1838 if (!FLAG_debug_code || !instr->skip_check()) { | |
1839 result = AssignEnvironment(result); | |
1840 } | |
1841 return result; | |
1842 } | |
1843 | |
1844 | |
1845 LInstruction* LChunkBuilder::DoBoundsCheckBaseIndexInformation( | |
1846 HBoundsCheckBaseIndexInformation* instr) { | |
1847 UNREACHABLE(); | |
1848 return NULL; | |
1849 } | |
1850 | |
1851 | |
1852 LInstruction* LChunkBuilder::DoAbnormalExit(HAbnormalExit* instr) { | |
1853 // The control instruction marking the end of a block that completed | |
1854 // abruptly (e.g., threw an exception). There is nothing specific to do. | |
1855 return NULL; | |
1856 } | |
1857 | |
1858 | |
1859 LInstruction* LChunkBuilder::DoUseConst(HUseConst* instr) { | |
1860 return NULL; | |
1861 } | |
1862 | |
1863 | |
1864 LInstruction* LChunkBuilder::DoForceRepresentation(HForceRepresentation* bad) { | |
1865 // All HForceRepresentation instructions should be eliminated in the | |
1866 // representation change phase of Hydrogen. | |
1867 UNREACHABLE(); | |
1868 return NULL; | |
1869 } | |
1870 | |
1871 | |
1872 LInstruction* LChunkBuilder::DoChange(HChange* instr) { | |
1873 Representation from = instr->from(); | |
1874 Representation to = instr->to(); | |
1875 HValue* val = instr->value(); | |
1876 if (from.IsSmi()) { | |
1877 if (to.IsTagged()) { | |
1878 LOperand* value = UseRegister(val); | |
1879 return DefineSameAsFirst(new(zone()) LDummyUse(value)); | |
1880 } | |
1881 from = Representation::Tagged(); | |
1882 } | |
1883 if (from.IsTagged()) { | |
1884 if (to.IsDouble()) { | |
1885 LOperand* value = UseRegister(val); | |
1886 LInstruction* result = DefineAsRegister(new(zone()) LNumberUntagD(value)); | |
1887 if (!val->representation().IsSmi()) result = AssignEnvironment(result); | |
1888 return result; | |
1889 } else if (to.IsSmi()) { | |
1890 LOperand* value = UseRegister(val); | |
1891 if (val->type().IsSmi()) { | |
1892 return DefineSameAsFirst(new(zone()) LDummyUse(value)); | |
1893 } | |
1894 return AssignEnvironment(DefineSameAsFirst(new(zone()) LCheckSmi(value))); | |
1895 } else { | |
1896 DCHECK(to.IsInteger32()); | |
1897 if (val->type().IsSmi() || val->representation().IsSmi()) { | |
1898 LOperand* value = UseRegisterAtStart(val); | |
1899 return DefineAsRegister(new(zone()) LSmiUntag(value, false)); | |
1900 } else { | |
1901 LOperand* value = UseRegister(val); | |
1902 LOperand* temp1 = TempRegister(); | |
1903 LOperand* temp2 = TempDoubleRegister(); | |
1904 LInstruction* result = | |
1905 DefineSameAsFirst(new(zone()) LTaggedToI(value, temp1, temp2)); | |
1906 if (!val->representation().IsSmi()) result = AssignEnvironment(result); | |
1907 return result; | |
1908 } | |
1909 } | |
1910 } else if (from.IsDouble()) { | |
1911 if (to.IsTagged()) { | |
1912 info()->MarkAsDeferredCalling(); | |
1913 LOperand* value = UseRegister(val); | |
1914 LOperand* temp1 = TempRegister(); | |
1915 LOperand* temp2 = TempRegister(); | |
1916 | |
1917 LUnallocated* result_temp = TempRegister(); | |
1918 LNumberTagD* result = new(zone()) LNumberTagD(value, temp1, temp2); | |
1919 return AssignPointerMap(Define(result, result_temp)); | |
1920 } else if (to.IsSmi()) { | |
1921 LOperand* value = UseRegister(val); | |
1922 return AssignEnvironment( | |
1923 DefineAsRegister(new(zone()) LDoubleToSmi(value))); | |
1924 } else { | |
1925 DCHECK(to.IsInteger32()); | |
1926 LOperand* value = UseRegister(val); | |
1927 LInstruction* result = DefineAsRegister(new(zone()) LDoubleToI(value)); | |
1928 if (!instr->CanTruncateToInt32()) result = AssignEnvironment(result); | |
1929 return result; | |
1930 } | |
1931 } else if (from.IsInteger32()) { | |
1932 info()->MarkAsDeferredCalling(); | |
1933 if (to.IsTagged()) { | |
1934 if (val->CheckFlag(HInstruction::kUint32)) { | |
1935 LOperand* value = UseRegisterAtStart(val); | |
1936 LOperand* temp1 = TempRegister(); | |
1937 LOperand* temp2 = TempRegister(); | |
1938 LNumberTagU* result = new(zone()) LNumberTagU(value, temp1, temp2); | |
1939 return AssignPointerMap(DefineAsRegister(result)); | |
1940 } else { | |
1941 STATIC_ASSERT((kMinInt == Smi::kMinValue) && | |
1942 (kMaxInt == Smi::kMaxValue)); | |
1943 LOperand* value = UseRegisterAtStart(val); | |
1944 return DefineAsRegister(new(zone()) LSmiTag(value)); | |
1945 } | |
1946 } else if (to.IsSmi()) { | |
1947 LOperand* value = UseRegister(val); | |
1948 LInstruction* result = DefineAsRegister(new(zone()) LSmiTag(value)); | |
1949 if (instr->CheckFlag(HValue::kCanOverflow)) { | |
1950 result = AssignEnvironment(result); | |
1951 } | |
1952 return result; | |
1953 } else { | |
1954 DCHECK(to.IsDouble()); | |
1955 if (val->CheckFlag(HInstruction::kUint32)) { | |
1956 return DefineAsRegister(new(zone()) LUint32ToDouble(UseRegister(val))); | |
1957 } else { | |
1958 return DefineAsRegister(new(zone()) LInteger32ToDouble(Use(val))); | |
1959 } | |
1960 } | |
1961 } | |
1962 UNREACHABLE(); | |
1963 return NULL; | |
1964 } | |
1965 | |
1966 | |
1967 LInstruction* LChunkBuilder::DoCheckHeapObject(HCheckHeapObject* instr) { | |
1968 LOperand* value = UseRegisterAtStart(instr->value()); | |
1969 LInstruction* result = new(zone()) LCheckNonSmi(value); | |
1970 if (!instr->value()->type().IsHeapObject()) { | |
1971 result = AssignEnvironment(result); | |
1972 } | |
1973 return result; | |
1974 } | |
1975 | |
1976 | |
1977 LInstruction* LChunkBuilder::DoCheckSmi(HCheckSmi* instr) { | |
1978 LOperand* value = UseRegisterAtStart(instr->value()); | |
1979 return AssignEnvironment(new(zone()) LCheckSmi(value)); | |
1980 } | |
1981 | |
1982 | |
1983 LInstruction* LChunkBuilder::DoCheckArrayBufferNotNeutered( | |
1984 HCheckArrayBufferNotNeutered* instr) { | |
1985 LOperand* view = UseRegisterAtStart(instr->value()); | |
1986 LCheckArrayBufferNotNeutered* result = | |
1987 new (zone()) LCheckArrayBufferNotNeutered(view); | |
1988 return AssignEnvironment(result); | |
1989 } | |
1990 | |
1991 | |
1992 LInstruction* LChunkBuilder::DoCheckInstanceType(HCheckInstanceType* instr) { | |
1993 LOperand* value = UseRegisterAtStart(instr->value()); | |
1994 LInstruction* result = new(zone()) LCheckInstanceType(value); | |
1995 return AssignEnvironment(result); | |
1996 } | |
1997 | |
1998 | |
1999 LInstruction* LChunkBuilder::DoCheckValue(HCheckValue* instr) { | |
2000 LOperand* value = UseRegisterAtStart(instr->value()); | |
2001 return AssignEnvironment(new(zone()) LCheckValue(value)); | |
2002 } | |
2003 | |
2004 | |
2005 LInstruction* LChunkBuilder::DoCheckMaps(HCheckMaps* instr) { | |
2006 if (instr->IsStabilityCheck()) return new(zone()) LCheckMaps; | |
2007 LOperand* value = UseRegisterAtStart(instr->value()); | |
2008 LInstruction* result = AssignEnvironment(new(zone()) LCheckMaps(value)); | |
2009 if (instr->HasMigrationTarget()) { | |
2010 info()->MarkAsDeferredCalling(); | |
2011 result = AssignPointerMap(result); | |
2012 } | |
2013 return result; | |
2014 } | |
2015 | |
2016 | |
2017 LInstruction* LChunkBuilder::DoClampToUint8(HClampToUint8* instr) { | |
2018 HValue* value = instr->value(); | |
2019 Representation input_rep = value->representation(); | |
2020 LOperand* reg = UseRegister(value); | |
2021 if (input_rep.IsDouble()) { | |
2022 // Revisit this decision, here and 8 lines below. | |
2023 return DefineAsRegister(new(zone()) LClampDToUint8(reg, | |
2024 TempDoubleRegister())); | |
2025 } else if (input_rep.IsInteger32()) { | |
2026 return DefineAsRegister(new(zone()) LClampIToUint8(reg)); | |
2027 } else { | |
2028 DCHECK(input_rep.IsSmiOrTagged()); | |
2029 LClampTToUint8* result = | |
2030 new(zone()) LClampTToUint8(reg, TempDoubleRegister()); | |
2031 return AssignEnvironment(DefineAsRegister(result)); | |
2032 } | |
2033 } | |
2034 | |
2035 | |
2036 LInstruction* LChunkBuilder::DoDoubleBits(HDoubleBits* instr) { | |
2037 HValue* value = instr->value(); | |
2038 DCHECK(value->representation().IsDouble()); | |
2039 return DefineAsRegister(new(zone()) LDoubleBits(UseRegister(value))); | |
2040 } | |
2041 | |
2042 | |
2043 LInstruction* LChunkBuilder::DoConstructDouble(HConstructDouble* instr) { | |
2044 LOperand* lo = UseRegister(instr->lo()); | |
2045 LOperand* hi = UseRegister(instr->hi()); | |
2046 return DefineAsRegister(new(zone()) LConstructDouble(hi, lo)); | |
2047 } | |
2048 | |
2049 | |
2050 LInstruction* LChunkBuilder::DoReturn(HReturn* instr) { | |
2051 LOperand* context = info()->IsStub() | |
2052 ? UseFixed(instr->context(), cp) | |
2053 : NULL; | |
2054 LOperand* parameter_count = UseRegisterOrConstant(instr->parameter_count()); | |
2055 return new(zone()) LReturn(UseFixed(instr->value(), v0), context, | |
2056 parameter_count); | |
2057 } | |
2058 | |
2059 | |
2060 LInstruction* LChunkBuilder::DoConstant(HConstant* instr) { | |
2061 Representation r = instr->representation(); | |
2062 if (r.IsSmi()) { | |
2063 return DefineAsRegister(new(zone()) LConstantS); | |
2064 } else if (r.IsInteger32()) { | |
2065 return DefineAsRegister(new(zone()) LConstantI); | |
2066 } else if (r.IsDouble()) { | |
2067 return DefineAsRegister(new(zone()) LConstantD); | |
2068 } else if (r.IsExternal()) { | |
2069 return DefineAsRegister(new(zone()) LConstantE); | |
2070 } else if (r.IsTagged()) { | |
2071 return DefineAsRegister(new(zone()) LConstantT); | |
2072 } else { | |
2073 UNREACHABLE(); | |
2074 return NULL; | |
2075 } | |
2076 } | |
2077 | |
2078 | |
2079 LInstruction* LChunkBuilder::DoLoadGlobalGeneric(HLoadGlobalGeneric* instr) { | |
2080 LOperand* context = UseFixed(instr->context(), cp); | |
2081 LOperand* global_object = | |
2082 UseFixed(instr->global_object(), LoadDescriptor::ReceiverRegister()); | |
2083 LOperand* vector = NULL; | |
2084 if (instr->HasVectorAndSlot()) { | |
2085 vector = FixedTemp(LoadWithVectorDescriptor::VectorRegister()); | |
2086 } | |
2087 LLoadGlobalGeneric* result = | |
2088 new(zone()) LLoadGlobalGeneric(context, global_object, vector); | |
2089 return MarkAsCall(DefineFixed(result, v0), instr); | |
2090 } | |
2091 | |
2092 | |
2093 LInstruction* LChunkBuilder::DoLoadGlobalViaContext( | |
2094 HLoadGlobalViaContext* instr) { | |
2095 LOperand* context = UseFixed(instr->context(), cp); | |
2096 DCHECK(instr->slot_index() > 0); | |
2097 LLoadGlobalViaContext* result = new (zone()) LLoadGlobalViaContext(context); | |
2098 return MarkAsCall(DefineFixed(result, v0), instr); | |
2099 } | |
2100 | |
2101 | |
2102 LInstruction* LChunkBuilder::DoLoadContextSlot(HLoadContextSlot* instr) { | |
2103 LOperand* context = UseRegisterAtStart(instr->value()); | |
2104 LInstruction* result = | |
2105 DefineAsRegister(new(zone()) LLoadContextSlot(context)); | |
2106 if (instr->RequiresHoleCheck() && instr->DeoptimizesOnHole()) { | |
2107 result = AssignEnvironment(result); | |
2108 } | |
2109 return result; | |
2110 } | |
2111 | |
2112 | |
2113 LInstruction* LChunkBuilder::DoStoreContextSlot(HStoreContextSlot* instr) { | |
2114 LOperand* context; | |
2115 LOperand* value; | |
2116 if (instr->NeedsWriteBarrier()) { | |
2117 context = UseTempRegister(instr->context()); | |
2118 value = UseTempRegister(instr->value()); | |
2119 } else { | |
2120 context = UseRegister(instr->context()); | |
2121 value = UseRegister(instr->value()); | |
2122 } | |
2123 LInstruction* result = new(zone()) LStoreContextSlot(context, value); | |
2124 if (instr->RequiresHoleCheck() && instr->DeoptimizesOnHole()) { | |
2125 result = AssignEnvironment(result); | |
2126 } | |
2127 return result; | |
2128 } | |
2129 | |
2130 | |
2131 LInstruction* LChunkBuilder::DoLoadNamedField(HLoadNamedField* instr) { | |
2132 LOperand* obj = UseRegisterAtStart(instr->object()); | |
2133 return DefineAsRegister(new(zone()) LLoadNamedField(obj)); | |
2134 } | |
2135 | |
2136 | |
2137 LInstruction* LChunkBuilder::DoLoadNamedGeneric(HLoadNamedGeneric* instr) { | |
2138 LOperand* context = UseFixed(instr->context(), cp); | |
2139 LOperand* object = | |
2140 UseFixed(instr->object(), LoadDescriptor::ReceiverRegister()); | |
2141 LOperand* vector = NULL; | |
2142 if (instr->HasVectorAndSlot()) { | |
2143 vector = FixedTemp(LoadWithVectorDescriptor::VectorRegister()); | |
2144 } | |
2145 | |
2146 LInstruction* result = | |
2147 DefineFixed(new(zone()) LLoadNamedGeneric(context, object, vector), v0); | |
2148 return MarkAsCall(result, instr); | |
2149 } | |
2150 | |
2151 | |
2152 LInstruction* LChunkBuilder::DoLoadFunctionPrototype( | |
2153 HLoadFunctionPrototype* instr) { | |
2154 return AssignEnvironment(DefineAsRegister( | |
2155 new(zone()) LLoadFunctionPrototype(UseRegister(instr->function())))); | |
2156 } | |
2157 | |
2158 | |
2159 LInstruction* LChunkBuilder::DoLoadRoot(HLoadRoot* instr) { | |
2160 return DefineAsRegister(new(zone()) LLoadRoot); | |
2161 } | |
2162 | |
2163 | |
2164 LInstruction* LChunkBuilder::DoLoadKeyed(HLoadKeyed* instr) { | |
2165 DCHECK(instr->key()->representation().IsSmiOrInteger32()); | |
2166 ElementsKind elements_kind = instr->elements_kind(); | |
2167 LOperand* key = UseRegisterOrConstantAtStart(instr->key()); | |
2168 LInstruction* result = NULL; | |
2169 | |
2170 if (!instr->is_fixed_typed_array()) { | |
2171 LOperand* obj = NULL; | |
2172 if (instr->representation().IsDouble()) { | |
2173 obj = UseRegister(instr->elements()); | |
2174 } else { | |
2175 DCHECK(instr->representation().IsSmiOrTagged() || | |
2176 instr->representation().IsInteger32()); | |
2177 obj = UseRegisterAtStart(instr->elements()); | |
2178 } | |
2179 result = DefineAsRegister(new(zone()) LLoadKeyed(obj, key)); | |
2180 } else { | |
2181 DCHECK( | |
2182 (instr->representation().IsInteger32() && | |
2183 !IsDoubleOrFloatElementsKind(elements_kind)) || | |
2184 (instr->representation().IsDouble() && | |
2185 IsDoubleOrFloatElementsKind(elements_kind))); | |
2186 LOperand* backing_store = UseRegister(instr->elements()); | |
2187 result = DefineAsRegister(new(zone()) LLoadKeyed(backing_store, key)); | |
2188 } | |
2189 | |
2190 bool needs_environment; | |
2191 if (instr->is_fixed_typed_array()) { | |
2192 // see LCodeGen::DoLoadKeyedExternalArray | |
2193 needs_environment = elements_kind == UINT32_ELEMENTS && | |
2194 !instr->CheckFlag(HInstruction::kUint32); | |
2195 } else { | |
2196 // see LCodeGen::DoLoadKeyedFixedDoubleArray and | |
2197 // LCodeGen::DoLoadKeyedFixedArray | |
2198 needs_environment = | |
2199 instr->RequiresHoleCheck() || | |
2200 (instr->hole_mode() == CONVERT_HOLE_TO_UNDEFINED && info()->IsStub()); | |
2201 } | |
2202 | |
2203 if (needs_environment) { | |
2204 result = AssignEnvironment(result); | |
2205 } | |
2206 return result; | |
2207 } | |
2208 | |
2209 | |
2210 LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) { | |
2211 LOperand* context = UseFixed(instr->context(), cp); | |
2212 LOperand* object = | |
2213 UseFixed(instr->object(), LoadDescriptor::ReceiverRegister()); | |
2214 LOperand* key = UseFixed(instr->key(), LoadDescriptor::NameRegister()); | |
2215 LOperand* vector = NULL; | |
2216 if (instr->HasVectorAndSlot()) { | |
2217 vector = FixedTemp(LoadWithVectorDescriptor::VectorRegister()); | |
2218 } | |
2219 | |
2220 LInstruction* result = | |
2221 DefineFixed(new(zone()) LLoadKeyedGeneric(context, object, key, vector), | |
2222 v0); | |
2223 return MarkAsCall(result, instr); | |
2224 } | |
2225 | |
2226 | |
2227 LInstruction* LChunkBuilder::DoStoreKeyed(HStoreKeyed* instr) { | |
2228 if (!instr->is_fixed_typed_array()) { | |
2229 DCHECK(instr->elements()->representation().IsTagged()); | |
2230 bool needs_write_barrier = instr->NeedsWriteBarrier(); | |
2231 LOperand* object = NULL; | |
2232 LOperand* val = NULL; | |
2233 LOperand* key = NULL; | |
2234 | |
2235 if (instr->value()->representation().IsDouble()) { | |
2236 object = UseRegisterAtStart(instr->elements()); | |
2237 key = UseRegisterOrConstantAtStart(instr->key()); | |
2238 val = UseRegister(instr->value()); | |
2239 } else { | |
2240 DCHECK(instr->value()->representation().IsSmiOrTagged() || | |
2241 instr->value()->representation().IsInteger32()); | |
2242 if (needs_write_barrier) { | |
2243 object = UseTempRegister(instr->elements()); | |
2244 val = UseTempRegister(instr->value()); | |
2245 key = UseTempRegister(instr->key()); | |
2246 } else { | |
2247 object = UseRegisterAtStart(instr->elements()); | |
2248 val = UseRegisterAtStart(instr->value()); | |
2249 key = UseRegisterOrConstantAtStart(instr->key()); | |
2250 } | |
2251 } | |
2252 | |
2253 return new(zone()) LStoreKeyed(object, key, val); | |
2254 } | |
2255 | |
2256 DCHECK( | |
2257 (instr->value()->representation().IsInteger32() && | |
2258 !IsDoubleOrFloatElementsKind(instr->elements_kind())) || | |
2259 (instr->value()->representation().IsDouble() && | |
2260 IsDoubleOrFloatElementsKind(instr->elements_kind()))); | |
2261 DCHECK(instr->elements()->representation().IsExternal()); | |
2262 LOperand* val = UseRegister(instr->value()); | |
2263 LOperand* key = UseRegisterOrConstantAtStart(instr->key()); | |
2264 LOperand* backing_store = UseRegister(instr->elements()); | |
2265 return new(zone()) LStoreKeyed(backing_store, key, val); | |
2266 } | |
2267 | |
2268 | |
2269 LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) { | |
2270 LOperand* context = UseFixed(instr->context(), cp); | |
2271 LOperand* obj = | |
2272 UseFixed(instr->object(), StoreDescriptor::ReceiverRegister()); | |
2273 LOperand* key = UseFixed(instr->key(), StoreDescriptor::NameRegister()); | |
2274 LOperand* val = UseFixed(instr->value(), StoreDescriptor::ValueRegister()); | |
2275 | |
2276 DCHECK(instr->object()->representation().IsTagged()); | |
2277 DCHECK(instr->key()->representation().IsTagged()); | |
2278 DCHECK(instr->value()->representation().IsTagged()); | |
2279 | |
2280 LOperand* slot = NULL; | |
2281 LOperand* vector = NULL; | |
2282 if (instr->HasVectorAndSlot()) { | |
2283 slot = FixedTemp(VectorStoreICDescriptor::SlotRegister()); | |
2284 vector = FixedTemp(VectorStoreICDescriptor::VectorRegister()); | |
2285 } | |
2286 | |
2287 LStoreKeyedGeneric* result = | |
2288 new (zone()) LStoreKeyedGeneric(context, obj, key, val, slot, vector); | |
2289 return MarkAsCall(result, instr); | |
2290 } | |
2291 | |
2292 | |
2293 LInstruction* LChunkBuilder::DoTransitionElementsKind( | |
2294 HTransitionElementsKind* instr) { | |
2295 if (IsSimpleMapChangeTransition(instr->from_kind(), instr->to_kind())) { | |
2296 LOperand* object = UseRegister(instr->object()); | |
2297 LOperand* new_map_reg = TempRegister(); | |
2298 LTransitionElementsKind* result = | |
2299 new(zone()) LTransitionElementsKind(object, NULL, new_map_reg); | |
2300 return result; | |
2301 } else { | |
2302 LOperand* object = UseFixed(instr->object(), a0); | |
2303 LOperand* context = UseFixed(instr->context(), cp); | |
2304 LTransitionElementsKind* result = | |
2305 new(zone()) LTransitionElementsKind(object, context, NULL); | |
2306 return MarkAsCall(result, instr); | |
2307 } | |
2308 } | |
2309 | |
2310 | |
2311 LInstruction* LChunkBuilder::DoTrapAllocationMemento( | |
2312 HTrapAllocationMemento* instr) { | |
2313 LOperand* object = UseRegister(instr->object()); | |
2314 LOperand* temp = TempRegister(); | |
2315 LTrapAllocationMemento* result = | |
2316 new(zone()) LTrapAllocationMemento(object, temp); | |
2317 return AssignEnvironment(result); | |
2318 } | |
2319 | |
2320 | |
2321 LInstruction* LChunkBuilder::DoMaybeGrowElements(HMaybeGrowElements* instr) { | |
2322 info()->MarkAsDeferredCalling(); | |
2323 LOperand* context = UseFixed(instr->context(), cp); | |
2324 LOperand* object = Use(instr->object()); | |
2325 LOperand* elements = Use(instr->elements()); | |
2326 LOperand* key = UseRegisterOrConstant(instr->key()); | |
2327 LOperand* current_capacity = UseRegisterOrConstant(instr->current_capacity()); | |
2328 | |
2329 LMaybeGrowElements* result = new (zone()) | |
2330 LMaybeGrowElements(context, object, elements, key, current_capacity); | |
2331 DefineFixed(result, v0); | |
2332 return AssignPointerMap(AssignEnvironment(result)); | |
2333 } | |
2334 | |
2335 | |
2336 LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) { | |
2337 bool is_in_object = instr->access().IsInobject(); | |
2338 bool needs_write_barrier = instr->NeedsWriteBarrier(); | |
2339 bool needs_write_barrier_for_map = instr->has_transition() && | |
2340 instr->NeedsWriteBarrierForMap(); | |
2341 | |
2342 LOperand* obj; | |
2343 if (needs_write_barrier) { | |
2344 obj = is_in_object | |
2345 ? UseRegister(instr->object()) | |
2346 : UseTempRegister(instr->object()); | |
2347 } else { | |
2348 obj = needs_write_barrier_for_map | |
2349 ? UseRegister(instr->object()) | |
2350 : UseRegisterAtStart(instr->object()); | |
2351 } | |
2352 | |
2353 LOperand* val; | |
2354 if (needs_write_barrier) { | |
2355 val = UseTempRegister(instr->value()); | |
2356 } else if (instr->field_representation().IsDouble()) { | |
2357 val = UseRegisterAtStart(instr->value()); | |
2358 } else { | |
2359 val = UseRegister(instr->value()); | |
2360 } | |
2361 | |
2362 // We need a temporary register for write barrier of the map field. | |
2363 LOperand* temp = needs_write_barrier_for_map ? TempRegister() : NULL; | |
2364 | |
2365 return new(zone()) LStoreNamedField(obj, val, temp); | |
2366 } | |
2367 | |
2368 | |
2369 LInstruction* LChunkBuilder::DoStoreNamedGeneric(HStoreNamedGeneric* instr) { | |
2370 LOperand* context = UseFixed(instr->context(), cp); | |
2371 LOperand* obj = | |
2372 UseFixed(instr->object(), StoreDescriptor::ReceiverRegister()); | |
2373 LOperand* val = UseFixed(instr->value(), StoreDescriptor::ValueRegister()); | |
2374 LOperand* slot = NULL; | |
2375 LOperand* vector = NULL; | |
2376 if (instr->HasVectorAndSlot()) { | |
2377 slot = FixedTemp(VectorStoreICDescriptor::SlotRegister()); | |
2378 vector = FixedTemp(VectorStoreICDescriptor::VectorRegister()); | |
2379 } | |
2380 | |
2381 LStoreNamedGeneric* result = | |
2382 new (zone()) LStoreNamedGeneric(context, obj, val, slot, vector); | |
2383 return MarkAsCall(result, instr); | |
2384 } | |
2385 | |
2386 | |
2387 LInstruction* LChunkBuilder::DoStoreGlobalViaContext( | |
2388 HStoreGlobalViaContext* instr) { | |
2389 LOperand* context = UseFixed(instr->context(), cp); | |
2390 LOperand* value = UseFixed(instr->value(), | |
2391 StoreGlobalViaContextDescriptor::ValueRegister()); | |
2392 DCHECK(instr->slot_index() > 0); | |
2393 | |
2394 LStoreGlobalViaContext* result = | |
2395 new (zone()) LStoreGlobalViaContext(context, value); | |
2396 return MarkAsCall(result, instr); | |
2397 } | |
2398 | |
2399 | |
2400 LInstruction* LChunkBuilder::DoStringAdd(HStringAdd* instr) { | |
2401 LOperand* context = UseFixed(instr->context(), cp); | |
2402 LOperand* left = UseFixed(instr->left(), a1); | |
2403 LOperand* right = UseFixed(instr->right(), a0); | |
2404 return MarkAsCall( | |
2405 DefineFixed(new(zone()) LStringAdd(context, left, right), v0), | |
2406 instr); | |
2407 } | |
2408 | |
2409 | |
2410 LInstruction* LChunkBuilder::DoStringCharCodeAt(HStringCharCodeAt* instr) { | |
2411 LOperand* string = UseTempRegister(instr->string()); | |
2412 LOperand* index = UseTempRegister(instr->index()); | |
2413 LOperand* context = UseAny(instr->context()); | |
2414 LStringCharCodeAt* result = | |
2415 new(zone()) LStringCharCodeAt(context, string, index); | |
2416 return AssignPointerMap(DefineAsRegister(result)); | |
2417 } | |
2418 | |
2419 | |
2420 LInstruction* LChunkBuilder::DoStringCharFromCode(HStringCharFromCode* instr) { | |
2421 LOperand* char_code = UseRegister(instr->value()); | |
2422 LOperand* context = UseAny(instr->context()); | |
2423 LStringCharFromCode* result = | |
2424 new(zone()) LStringCharFromCode(context, char_code); | |
2425 return AssignPointerMap(DefineAsRegister(result)); | |
2426 } | |
2427 | |
2428 | |
2429 LInstruction* LChunkBuilder::DoAllocate(HAllocate* instr) { | |
2430 info()->MarkAsDeferredCalling(); | |
2431 LOperand* context = UseAny(instr->context()); | |
2432 LOperand* size = UseRegisterOrConstant(instr->size()); | |
2433 LOperand* temp1 = TempRegister(); | |
2434 LOperand* temp2 = TempRegister(); | |
2435 LAllocate* result = new(zone()) LAllocate(context, size, temp1, temp2); | |
2436 return AssignPointerMap(DefineAsRegister(result)); | |
2437 } | |
2438 | |
2439 | |
2440 LInstruction* LChunkBuilder::DoRegExpLiteral(HRegExpLiteral* instr) { | |
2441 LOperand* context = UseFixed(instr->context(), cp); | |
2442 return MarkAsCall( | |
2443 DefineFixed(new(zone()) LRegExpLiteral(context), v0), instr); | |
2444 } | |
2445 | |
2446 | |
2447 LInstruction* LChunkBuilder::DoOsrEntry(HOsrEntry* instr) { | |
2448 DCHECK(argument_count_ == 0); | |
2449 allocator_->MarkAsOsrEntry(); | |
2450 current_block_->last_environment()->set_ast_id(instr->ast_id()); | |
2451 return AssignEnvironment(new(zone()) LOsrEntry); | |
2452 } | |
2453 | |
2454 | |
2455 LInstruction* LChunkBuilder::DoParameter(HParameter* instr) { | |
2456 LParameter* result = new(zone()) LParameter; | |
2457 if (instr->kind() == HParameter::STACK_PARAMETER) { | |
2458 int spill_index = chunk()->GetParameterStackSlot(instr->index()); | |
2459 return DefineAsSpilled(result, spill_index); | |
2460 } else { | |
2461 DCHECK(info()->IsStub()); | |
2462 CallInterfaceDescriptor descriptor = | |
2463 info()->code_stub()->GetCallInterfaceDescriptor(); | |
2464 int index = static_cast<int>(instr->index()); | |
2465 Register reg = descriptor.GetRegisterParameter(index); | |
2466 return DefineFixed(result, reg); | |
2467 } | |
2468 } | |
2469 | |
2470 | |
2471 LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) { | |
2472 // Use an index that corresponds to the location in the unoptimized frame, | |
2473 // which the optimized frame will subsume. | |
2474 int env_index = instr->index(); | |
2475 int spill_index = 0; | |
2476 if (instr->environment()->is_parameter_index(env_index)) { | |
2477 spill_index = chunk()->GetParameterStackSlot(env_index); | |
2478 } else { | |
2479 spill_index = env_index - instr->environment()->first_local_index(); | |
2480 if (spill_index > LUnallocated::kMaxFixedSlotIndex) { | |
2481 Retry(kTooManySpillSlotsNeededForOSR); | |
2482 spill_index = 0; | |
2483 } | |
2484 } | |
2485 return DefineAsSpilled(new(zone()) LUnknownOSRValue, spill_index); | |
2486 } | |
2487 | |
2488 | |
2489 LInstruction* LChunkBuilder::DoCallStub(HCallStub* instr) { | |
2490 LOperand* context = UseFixed(instr->context(), cp); | |
2491 return MarkAsCall(DefineFixed(new(zone()) LCallStub(context), v0), instr); | |
2492 } | |
2493 | |
2494 | |
2495 LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) { | |
2496 // There are no real uses of the arguments object. | |
2497 // arguments.length and element access are supported directly on | |
2498 // stack arguments, and any real arguments object use causes a bailout. | |
2499 // So this value is never used. | |
2500 return NULL; | |
2501 } | |
2502 | |
2503 | |
2504 LInstruction* LChunkBuilder::DoCapturedObject(HCapturedObject* instr) { | |
2505 instr->ReplayEnvironment(current_block_->last_environment()); | |
2506 | |
2507 // There are no real uses of a captured object. | |
2508 return NULL; | |
2509 } | |
2510 | |
2511 | |
2512 LInstruction* LChunkBuilder::DoAccessArgumentsAt(HAccessArgumentsAt* instr) { | |
2513 info()->MarkAsRequiresFrame(); | |
2514 LOperand* args = UseRegister(instr->arguments()); | |
2515 LOperand* length = UseRegisterOrConstantAtStart(instr->length()); | |
2516 LOperand* index = UseRegisterOrConstantAtStart(instr->index()); | |
2517 return DefineAsRegister(new(zone()) LAccessArgumentsAt(args, length, index)); | |
2518 } | |
2519 | |
2520 | |
2521 LInstruction* LChunkBuilder::DoToFastProperties(HToFastProperties* instr) { | |
2522 LOperand* object = UseFixed(instr->value(), a0); | |
2523 LToFastProperties* result = new(zone()) LToFastProperties(object); | |
2524 return MarkAsCall(DefineFixed(result, v0), instr); | |
2525 } | |
2526 | |
2527 | |
2528 LInstruction* LChunkBuilder::DoTypeof(HTypeof* instr) { | |
2529 LOperand* context = UseFixed(instr->context(), cp); | |
2530 LOperand* value = UseFixed(instr->value(), a3); | |
2531 LTypeof* result = new (zone()) LTypeof(context, value); | |
2532 return MarkAsCall(DefineFixed(result, v0), instr); | |
2533 } | |
2534 | |
2535 | |
2536 LInstruction* LChunkBuilder::DoTypeofIsAndBranch(HTypeofIsAndBranch* instr) { | |
2537 return new(zone()) LTypeofIsAndBranch(UseTempRegister(instr->value())); | |
2538 } | |
2539 | |
2540 | |
2541 LInstruction* LChunkBuilder::DoIsConstructCallAndBranch( | |
2542 HIsConstructCallAndBranch* instr) { | |
2543 return new(zone()) LIsConstructCallAndBranch(TempRegister()); | |
2544 } | |
2545 | |
2546 | |
2547 LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) { | |
2548 instr->ReplayEnvironment(current_block_->last_environment()); | |
2549 return NULL; | |
2550 } | |
2551 | |
2552 | |
2553 LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) { | |
2554 if (instr->is_function_entry()) { | |
2555 LOperand* context = UseFixed(instr->context(), cp); | |
2556 return MarkAsCall(new(zone()) LStackCheck(context), instr); | |
2557 } else { | |
2558 DCHECK(instr->is_backwards_branch()); | |
2559 LOperand* context = UseAny(instr->context()); | |
2560 return AssignEnvironment( | |
2561 AssignPointerMap(new(zone()) LStackCheck(context))); | |
2562 } | |
2563 } | |
2564 | |
2565 | |
2566 LInstruction* LChunkBuilder::DoEnterInlined(HEnterInlined* instr) { | |
2567 HEnvironment* outer = current_block_->last_environment(); | |
2568 outer->set_ast_id(instr->ReturnId()); | |
2569 HConstant* undefined = graph()->GetConstantUndefined(); | |
2570 HEnvironment* inner = outer->CopyForInlining(instr->closure(), | |
2571 instr->arguments_count(), | |
2572 instr->function(), | |
2573 undefined, | |
2574 instr->inlining_kind()); | |
2575 // Only replay binding of arguments object if it wasn't removed from graph. | |
2576 if (instr->arguments_var() != NULL && instr->arguments_object()->IsLinked()) { | |
2577 inner->Bind(instr->arguments_var(), instr->arguments_object()); | |
2578 } | |
2579 inner->BindContext(instr->closure_context()); | |
2580 inner->set_entry(instr); | |
2581 current_block_->UpdateEnvironment(inner); | |
2582 chunk_->AddInlinedFunction(instr->shared()); | |
2583 return NULL; | |
2584 } | |
2585 | |
2586 | |
2587 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) { | |
2588 LInstruction* pop = NULL; | |
2589 | |
2590 HEnvironment* env = current_block_->last_environment(); | |
2591 | |
2592 if (env->entry()->arguments_pushed()) { | |
2593 int argument_count = env->arguments_environment()->parameter_count(); | |
2594 pop = new(zone()) LDrop(argument_count); | |
2595 DCHECK(instr->argument_delta() == -argument_count); | |
2596 } | |
2597 | |
2598 HEnvironment* outer = current_block_->last_environment()-> | |
2599 DiscardInlined(false); | |
2600 current_block_->UpdateEnvironment(outer); | |
2601 | |
2602 return pop; | |
2603 } | |
2604 | |
2605 | |
2606 LInstruction* LChunkBuilder::DoForInPrepareMap(HForInPrepareMap* instr) { | |
2607 LOperand* context = UseFixed(instr->context(), cp); | |
2608 LOperand* object = UseFixed(instr->enumerable(), a0); | |
2609 LForInPrepareMap* result = new(zone()) LForInPrepareMap(context, object); | |
2610 return MarkAsCall(DefineFixed(result, v0), instr, CAN_DEOPTIMIZE_EAGERLY); | |
2611 } | |
2612 | |
2613 | |
2614 LInstruction* LChunkBuilder::DoForInCacheArray(HForInCacheArray* instr) { | |
2615 LOperand* map = UseRegister(instr->map()); | |
2616 return AssignEnvironment(DefineAsRegister(new(zone()) LForInCacheArray(map))); | |
2617 } | |
2618 | |
2619 | |
2620 LInstruction* LChunkBuilder::DoCheckMapValue(HCheckMapValue* instr) { | |
2621 LOperand* value = UseRegisterAtStart(instr->value()); | |
2622 LOperand* map = UseRegisterAtStart(instr->map()); | |
2623 return AssignEnvironment(new(zone()) LCheckMapValue(value, map)); | |
2624 } | |
2625 | |
2626 | |
2627 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | |
2628 LOperand* object = UseRegister(instr->object()); | |
2629 LOperand* index = UseTempRegister(instr->index()); | |
2630 LLoadFieldByIndex* load = new(zone()) LLoadFieldByIndex(object, index); | |
2631 LInstruction* result = DefineSameAsFirst(load); | |
2632 return AssignPointerMap(result); | |
2633 } | |
2634 | |
2635 | |
2636 LInstruction* LChunkBuilder::DoStoreFrameContext(HStoreFrameContext* instr) { | |
2637 LOperand* context = UseRegisterAtStart(instr->context()); | |
2638 return new(zone()) LStoreFrameContext(context); | |
2639 } | |
2640 | |
2641 | |
2642 LInstruction* LChunkBuilder::DoAllocateBlockContext( | |
2643 HAllocateBlockContext* instr) { | |
2644 LOperand* context = UseFixed(instr->context(), cp); | |
2645 LOperand* function = UseRegisterAtStart(instr->function()); | |
2646 LAllocateBlockContext* result = | |
2647 new(zone()) LAllocateBlockContext(context, function); | |
2648 return MarkAsCall(DefineFixed(result, cp), instr); | |
2649 } | |
2650 | |
2651 | |
2652 } // namespace internal | |
2653 } // namespace v8 | |
2654 | |
2655 #endif // V8_TARGET_ARCH_MIPS64 | |
OLD | NEW |