blob: b69afe292a9c33d4b1f0fab9b3d3da9029a6648f [file] [log] [blame]
erik.corry@gmail.comf2038fb2012-01-16 11:42:08 +00001// Copyright 2012 the V8 project authors. All rights reserved.
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002// Redistribution and use in source and binary forms, with or without
3// modification, are permitted provided that the following conditions are
4// met:
5//
6// * Redistributions of source code must retain the above copyright
7// notice, this list of conditions and the following disclaimer.
8// * Redistributions in binary form must reproduce the above
9// copyright notice, this list of conditions and the following
10// disclaimer in the documentation and/or other materials provided
11// with the distribution.
12// * Neither the name of Google Inc. nor the names of its
13// contributors may be used to endorse or promote products derived
14// from this software without specific prior written permission.
15//
16// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27
28#include "v8.h"
29
30#include "lithium-allocator-inl.h"
31#include "mips/lithium-mips.h"
32#include "mips/lithium-codegen-mips.h"
33
34namespace v8 {
35namespace internal {
36
37#define DEFINE_COMPILE(type) \
38 void L##type::CompileToNative(LCodeGen* generator) { \
39 generator->Do##type(this); \
40 }
41LITHIUM_CONCRETE_INSTRUCTION_LIST(DEFINE_COMPILE)
42#undef DEFINE_COMPILE
43
44LOsrEntry::LOsrEntry() {
45 for (int i = 0; i < Register::kNumAllocatableRegisters; ++i) {
46 register_spills_[i] = NULL;
47 }
48 for (int i = 0; i < DoubleRegister::kNumAllocatableRegisters; ++i) {
49 double_register_spills_[i] = NULL;
50 }
51}
52
53
54void LOsrEntry::MarkSpilledRegister(int allocation_index,
55 LOperand* spill_operand) {
56 ASSERT(spill_operand->IsStackSlot());
57 ASSERT(register_spills_[allocation_index] == NULL);
58 register_spills_[allocation_index] = spill_operand;
59}
60
61
62#ifdef DEBUG
63void LInstruction::VerifyCall() {
64 // Call instructions can use only fixed registers as temporaries and
65 // outputs because all registers are blocked by the calling convention.
66 // Inputs operands must use a fixed register or use-at-start policy or
67 // a non-register policy.
68 ASSERT(Output() == NULL ||
69 LUnallocated::cast(Output())->HasFixedPolicy() ||
70 !LUnallocated::cast(Output())->HasRegisterPolicy());
71 for (UseIterator it(this); !it.Done(); it.Advance()) {
72 LUnallocated* operand = LUnallocated::cast(it.Current());
73 ASSERT(operand->HasFixedPolicy() ||
74 operand->IsUsedAtStart());
75 }
76 for (TempIterator it(this); !it.Done(); it.Advance()) {
77 LUnallocated* operand = LUnallocated::cast(it.Current());
78 ASSERT(operand->HasFixedPolicy() ||!operand->HasRegisterPolicy());
79 }
80}
81#endif
82
83
84void LOsrEntry::MarkSpilledDoubleRegister(int allocation_index,
85 LOperand* spill_operand) {
86 ASSERT(spill_operand->IsDoubleStackSlot());
87 ASSERT(double_register_spills_[allocation_index] == NULL);
88 double_register_spills_[allocation_index] = spill_operand;
89}
90
91
92void LInstruction::PrintTo(StringStream* stream) {
93 stream->Add("%s ", this->Mnemonic());
94
95 PrintOutputOperandTo(stream);
96
97 PrintDataTo(stream);
98
99 if (HasEnvironment()) {
100 stream->Add(" ");
101 environment()->PrintTo(stream);
102 }
103
104 if (HasPointerMap()) {
105 stream->Add(" ");
106 pointer_map()->PrintTo(stream);
107 }
108}
109
110
mstarzinger@chromium.org88d326b2012-04-23 12:57:22 +0000111void LInstruction::PrintDataTo(StringStream* stream) {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000112 stream->Add("= ");
mstarzinger@chromium.org88d326b2012-04-23 12:57:22 +0000113 for (int i = 0; i < InputCount(); i++) {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000114 if (i > 0) stream->Add(" ");
mstarzinger@chromium.org88d326b2012-04-23 12:57:22 +0000115 InputAt(i)->PrintTo(stream);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000116 }
117}
118
119
mstarzinger@chromium.org88d326b2012-04-23 12:57:22 +0000120void LInstruction::PrintOutputOperandTo(StringStream* stream) {
121 if (HasResult()) result()->PrintTo(stream);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000122}
123
124
125void LLabel::PrintDataTo(StringStream* stream) {
126 LGap::PrintDataTo(stream);
127 LLabel* rep = replacement();
128 if (rep != NULL) {
129 stream->Add(" Dead block replaced with B%d", rep->block_id());
130 }
131}
132
133
134bool LGap::IsRedundant() const {
135 for (int i = 0; i < 4; i++) {
136 if (parallel_moves_[i] != NULL && !parallel_moves_[i]->IsRedundant()) {
137 return false;
138 }
139 }
140
141 return true;
142}
143
144
145void LGap::PrintDataTo(StringStream* stream) {
146 for (int i = 0; i < 4; i++) {
147 stream->Add("(");
148 if (parallel_moves_[i] != NULL) {
149 parallel_moves_[i]->PrintDataTo(stream);
150 }
151 stream->Add(") ");
152 }
153}
154
155
156const char* LArithmeticD::Mnemonic() const {
157 switch (op()) {
158 case Token::ADD: return "add-d";
159 case Token::SUB: return "sub-d";
160 case Token::MUL: return "mul-d";
161 case Token::DIV: return "div-d";
162 case Token::MOD: return "mod-d";
163 default:
164 UNREACHABLE();
165 return NULL;
166 }
167}
168
169
170const char* LArithmeticT::Mnemonic() const {
171 switch (op()) {
172 case Token::ADD: return "add-t";
173 case Token::SUB: return "sub-t";
174 case Token::MUL: return "mul-t";
175 case Token::MOD: return "mod-t";
176 case Token::DIV: return "div-t";
177 case Token::BIT_AND: return "bit-and-t";
178 case Token::BIT_OR: return "bit-or-t";
179 case Token::BIT_XOR: return "bit-xor-t";
180 case Token::SHL: return "sll-t";
181 case Token::SAR: return "sra-t";
182 case Token::SHR: return "srl-t";
183 default:
184 UNREACHABLE();
185 return NULL;
186 }
187}
188
189
190void LGoto::PrintDataTo(StringStream* stream) {
191 stream->Add("B%d", block_id());
192}
193
194
195void LBranch::PrintDataTo(StringStream* stream) {
196 stream->Add("B%d | B%d on ", true_block_id(), false_block_id());
197 InputAt(0)->PrintTo(stream);
198}
199
200
201void LCmpIDAndBranch::PrintDataTo(StringStream* stream) {
202 stream->Add("if ");
203 InputAt(0)->PrintTo(stream);
204 stream->Add(" %s ", Token::String(op()));
205 InputAt(1)->PrintTo(stream);
206 stream->Add(" then B%d else B%d", true_block_id(), false_block_id());
207}
208
209
210void LIsNilAndBranch::PrintDataTo(StringStream* stream) {
211 stream->Add("if ");
212 InputAt(0)->PrintTo(stream);
213 stream->Add(kind() == kStrictEquality ? " === " : " == ");
214 stream->Add(nil() == kNullValue ? "null" : "undefined");
215 stream->Add(" then B%d else B%d", true_block_id(), false_block_id());
216}
217
218
219void LIsObjectAndBranch::PrintDataTo(StringStream* stream) {
220 stream->Add("if is_object(");
221 InputAt(0)->PrintTo(stream);
222 stream->Add(") then B%d else B%d", true_block_id(), false_block_id());
223}
224
225
mstarzinger@chromium.orgf8c6bd52011-11-23 12:13:52 +0000226void LIsStringAndBranch::PrintDataTo(StringStream* stream) {
227 stream->Add("if is_string(");
228 InputAt(0)->PrintTo(stream);
229 stream->Add(") then B%d else B%d", true_block_id(), false_block_id());
230}
231
232
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000233void LIsSmiAndBranch::PrintDataTo(StringStream* stream) {
234 stream->Add("if is_smi(");
235 InputAt(0)->PrintTo(stream);
236 stream->Add(") then B%d else B%d", true_block_id(), false_block_id());
237}
238
239
240void LIsUndetectableAndBranch::PrintDataTo(StringStream* stream) {
241 stream->Add("if is_undetectable(");
242 InputAt(0)->PrintTo(stream);
243 stream->Add(") then B%d else B%d", true_block_id(), false_block_id());
244}
245
246
mstarzinger@chromium.orgf8c6bd52011-11-23 12:13:52 +0000247void LStringCompareAndBranch::PrintDataTo(StringStream* stream) {
248 stream->Add("if string_compare(");
249 InputAt(0)->PrintTo(stream);
250 InputAt(1)->PrintTo(stream);
251 stream->Add(") then B%d else B%d", true_block_id(), false_block_id());
252}
253
254
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000255void LHasInstanceTypeAndBranch::PrintDataTo(StringStream* stream) {
256 stream->Add("if has_instance_type(");
257 InputAt(0)->PrintTo(stream);
258 stream->Add(") then B%d else B%d", true_block_id(), false_block_id());
259}
260
261
262void LHasCachedArrayIndexAndBranch::PrintDataTo(StringStream* stream) {
263 stream->Add("if has_cached_array_index(");
264 InputAt(0)->PrintTo(stream);
265 stream->Add(") then B%d else B%d", true_block_id(), false_block_id());
266}
267
268
269void LClassOfTestAndBranch::PrintDataTo(StringStream* stream) {
270 stream->Add("if class_of_test(");
271 InputAt(0)->PrintTo(stream);
272 stream->Add(", \"%o\") then B%d else B%d",
273 *hydrogen()->class_name(),
274 true_block_id(),
275 false_block_id());
276}
277
278
279void LTypeofIsAndBranch::PrintDataTo(StringStream* stream) {
280 stream->Add("if typeof ");
281 InputAt(0)->PrintTo(stream);
282 stream->Add(" == \"%s\" then B%d else B%d",
283 *hydrogen()->type_literal()->ToCString(),
284 true_block_id(), false_block_id());
285}
286
287
288void LCallConstantFunction::PrintDataTo(StringStream* stream) {
289 stream->Add("#%d / ", arity());
290}
291
292
293void LUnaryMathOperation::PrintDataTo(StringStream* stream) {
294 stream->Add("/%s ", hydrogen()->OpName());
295 InputAt(0)->PrintTo(stream);
296}
297
298
299void LLoadContextSlot::PrintDataTo(StringStream* stream) {
300 InputAt(0)->PrintTo(stream);
301 stream->Add("[%d]", slot_index());
302}
303
304
305void LStoreContextSlot::PrintDataTo(StringStream* stream) {
306 InputAt(0)->PrintTo(stream);
307 stream->Add("[%d] <- ", slot_index());
308 InputAt(1)->PrintTo(stream);
309}
310
311
312void LInvokeFunction::PrintDataTo(StringStream* stream) {
313 stream->Add("= ");
314 InputAt(0)->PrintTo(stream);
315 stream->Add(" #%d / ", arity());
316}
317
318
319void LCallKeyed::PrintDataTo(StringStream* stream) {
320 stream->Add("[a2] #%d / ", arity());
321}
322
323
324void LCallNamed::PrintDataTo(StringStream* stream) {
325 SmartArrayPointer<char> name_string = name()->ToCString();
326 stream->Add("%s #%d / ", *name_string, arity());
327}
328
329
330void LCallGlobal::PrintDataTo(StringStream* stream) {
331 SmartArrayPointer<char> name_string = name()->ToCString();
332 stream->Add("%s #%d / ", *name_string, arity());
333}
334
335
336void LCallKnownGlobal::PrintDataTo(StringStream* stream) {
337 stream->Add("#%d / ", arity());
338}
339
340
341void LCallNew::PrintDataTo(StringStream* stream) {
342 stream->Add("= ");
343 InputAt(0)->PrintTo(stream);
344 stream->Add(" #%d / ", arity());
345}
346
347
348void LAccessArgumentsAt::PrintDataTo(StringStream* stream) {
349 arguments()->PrintTo(stream);
350
351 stream->Add(" length ");
352 length()->PrintTo(stream);
353
354 stream->Add(" index ");
355 index()->PrintTo(stream);
356}
357
358
359void LStoreNamedField::PrintDataTo(StringStream* stream) {
360 object()->PrintTo(stream);
361 stream->Add(".");
362 stream->Add(*String::cast(*name())->ToCString());
363 stream->Add(" <- ");
364 value()->PrintTo(stream);
365}
366
367
368void LStoreNamedGeneric::PrintDataTo(StringStream* stream) {
369 object()->PrintTo(stream);
370 stream->Add(".");
371 stream->Add(*String::cast(*name())->ToCString());
372 stream->Add(" <- ");
373 value()->PrintTo(stream);
374}
375
376
377void LStoreKeyedFastElement::PrintDataTo(StringStream* stream) {
378 object()->PrintTo(stream);
379 stream->Add("[");
380 key()->PrintTo(stream);
381 stream->Add("] <- ");
382 value()->PrintTo(stream);
383}
384
385
386void LStoreKeyedFastDoubleElement::PrintDataTo(StringStream* stream) {
387 elements()->PrintTo(stream);
388 stream->Add("[");
389 key()->PrintTo(stream);
390 stream->Add("] <- ");
391 value()->PrintTo(stream);
392}
393
394
395void LStoreKeyedGeneric::PrintDataTo(StringStream* stream) {
396 object()->PrintTo(stream);
397 stream->Add("[");
398 key()->PrintTo(stream);
399 stream->Add("] <- ");
400 value()->PrintTo(stream);
401}
402
403
404void LTransitionElementsKind::PrintDataTo(StringStream* stream) {
405 object()->PrintTo(stream);
406 stream->Add(" %p -> %p", *original_map(), *transitioned_map());
407}
408
409
410LChunk::LChunk(CompilationInfo* info, HGraph* graph)
411 : spill_slot_count_(0),
412 info_(info),
413 graph_(graph),
414 instructions_(32),
415 pointer_maps_(8),
416 inlined_closures_(1) {
417}
418
419
420int LChunk::GetNextSpillIndex(bool is_double) {
421 // Skip a slot if for a double-width slot.
422 if (is_double) spill_slot_count_++;
423 return spill_slot_count_++;
424}
425
426
427LOperand* LChunk::GetNextSpillSlot(bool is_double) {
428 int index = GetNextSpillIndex(is_double);
429 if (is_double) {
430 return LDoubleStackSlot::Create(index);
431 } else {
432 return LStackSlot::Create(index);
433 }
434}
435
436
437void LChunk::MarkEmptyBlocks() {
ulan@chromium.org9a21ec42012-03-06 08:42:24 +0000438 HPhase phase("L_Mark empty blocks", this);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000439 for (int i = 0; i < graph()->blocks()->length(); ++i) {
440 HBasicBlock* block = graph()->blocks()->at(i);
441 int first = block->first_instruction_index();
442 int last = block->last_instruction_index();
443 LInstruction* first_instr = instructions()->at(first);
444 LInstruction* last_instr = instructions()->at(last);
445
446 LLabel* label = LLabel::cast(first_instr);
447 if (last_instr->IsGoto()) {
448 LGoto* goto_instr = LGoto::cast(last_instr);
449 if (label->IsRedundant() &&
450 !label->is_loop_header()) {
451 bool can_eliminate = true;
452 for (int i = first + 1; i < last && can_eliminate; ++i) {
453 LInstruction* cur = instructions()->at(i);
454 if (cur->IsGap()) {
455 LGap* gap = LGap::cast(cur);
456 if (!gap->IsRedundant()) {
457 can_eliminate = false;
458 }
459 } else {
460 can_eliminate = false;
461 }
462 }
463
464 if (can_eliminate) {
465 label->set_replacement(GetLabel(goto_instr->block_id()));
466 }
467 }
468 }
469 }
470}
471
472
473void LChunk::AddInstruction(LInstruction* instr, HBasicBlock* block) {
ulan@chromium.org812308e2012-02-29 15:58:45 +0000474 LInstructionGap* gap = new(graph_->zone()) LInstructionGap(block);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000475 int index = -1;
476 if (instr->IsControl()) {
477 instructions_.Add(gap);
478 index = instructions_.length();
479 instructions_.Add(instr);
480 } else {
481 index = instructions_.length();
482 instructions_.Add(instr);
483 instructions_.Add(gap);
484 }
485 if (instr->HasPointerMap()) {
486 pointer_maps_.Add(instr->pointer_map());
487 instr->pointer_map()->set_lithium_position(index);
488 }
489}
490
491
492LConstantOperand* LChunk::DefineConstantOperand(HConstant* constant) {
493 return LConstantOperand::Create(constant->id());
494}
495
496
497int LChunk::GetParameterStackSlot(int index) const {
498 // The receiver is at index 0, the first parameter at index 1, so we
499 // shift all parameter indexes down by the number of parameters, and
500 // make sure they end up negative so they are distinguishable from
501 // spill slots.
502 int result = index - info()->scope()->num_parameters() - 1;
503 ASSERT(result < 0);
504 return result;
505}
506
507// A parameter relative to ebp in the arguments stub.
508int LChunk::ParameterAt(int index) {
509 ASSERT(-1 <= index); // -1 is the receiver.
510 return (1 + info()->scope()->num_parameters() - index) *
511 kPointerSize;
512}
513
514
515LGap* LChunk::GetGapAt(int index) const {
516 return LGap::cast(instructions_[index]);
517}
518
519
520bool LChunk::IsGapAt(int index) const {
521 return instructions_[index]->IsGap();
522}
523
524
525int LChunk::NearestGapPos(int index) const {
526 while (!IsGapAt(index)) index--;
527 return index;
528}
529
530
531void LChunk::AddGapMove(int index, LOperand* from, LOperand* to) {
532 GetGapAt(index)->GetOrCreateParallelMove(LGap::START)->AddMove(from, to);
533}
534
535
536Handle<Object> LChunk::LookupLiteral(LConstantOperand* operand) const {
537 return HConstant::cast(graph_->LookupValue(operand->index()))->handle();
538}
539
540
541Representation LChunk::LookupLiteralRepresentation(
542 LConstantOperand* operand) const {
543 return graph_->LookupValue(operand->index())->representation();
544}
545
546
547LChunk* LChunkBuilder::Build() {
548 ASSERT(is_unused());
ulan@chromium.org812308e2012-02-29 15:58:45 +0000549 chunk_ = new(zone()) LChunk(info(), graph());
ulan@chromium.org9a21ec42012-03-06 08:42:24 +0000550 HPhase phase("L_Building chunk", chunk_);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000551 status_ = BUILDING;
552 const ZoneList<HBasicBlock*>* blocks = graph()->blocks();
553 for (int i = 0; i < blocks->length(); i++) {
554 HBasicBlock* next = NULL;
555 if (i < blocks->length() - 1) next = blocks->at(i + 1);
556 DoBasicBlock(blocks->at(i), next);
557 if (is_aborted()) return NULL;
558 }
559 status_ = DONE;
560 return chunk_;
561}
562
563
564void LChunkBuilder::Abort(const char* format, ...) {
565 if (FLAG_trace_bailout) {
566 SmartArrayPointer<char> name(
567 info()->shared_info()->DebugName()->ToCString());
568 PrintF("Aborting LChunk building in @\"%s\": ", *name);
569 va_list arguments;
570 va_start(arguments, format);
571 OS::VPrint(format, arguments);
572 va_end(arguments);
573 PrintF("\n");
574 }
575 status_ = ABORTED;
576}
577
578
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000579LUnallocated* LChunkBuilder::ToUnallocated(Register reg) {
ulan@chromium.org812308e2012-02-29 15:58:45 +0000580 return new(zone()) LUnallocated(LUnallocated::FIXED_REGISTER,
581 Register::ToAllocationIndex(reg));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000582}
583
584
585LUnallocated* LChunkBuilder::ToUnallocated(DoubleRegister reg) {
ulan@chromium.org812308e2012-02-29 15:58:45 +0000586 return new(zone()) LUnallocated(LUnallocated::FIXED_DOUBLE_REGISTER,
587 DoubleRegister::ToAllocationIndex(reg));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000588}
589
590
591LOperand* LChunkBuilder::UseFixed(HValue* value, Register fixed_register) {
592 return Use(value, ToUnallocated(fixed_register));
593}
594
595
596LOperand* LChunkBuilder::UseFixedDouble(HValue* value, DoubleRegister reg) {
597 return Use(value, ToUnallocated(reg));
598}
599
600
601LOperand* LChunkBuilder::UseRegister(HValue* value) {
ulan@chromium.org812308e2012-02-29 15:58:45 +0000602 return Use(value, new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000603}
604
605
606LOperand* LChunkBuilder::UseRegisterAtStart(HValue* value) {
607 return Use(value,
ulan@chromium.org812308e2012-02-29 15:58:45 +0000608 new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER,
609 LUnallocated::USED_AT_START));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000610}
611
612
613LOperand* LChunkBuilder::UseTempRegister(HValue* value) {
ulan@chromium.org812308e2012-02-29 15:58:45 +0000614 return Use(value, new(zone()) LUnallocated(LUnallocated::WRITABLE_REGISTER));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000615}
616
617
618LOperand* LChunkBuilder::Use(HValue* value) {
ulan@chromium.org812308e2012-02-29 15:58:45 +0000619 return Use(value, new(zone()) LUnallocated(LUnallocated::NONE));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000620}
621
622
623LOperand* LChunkBuilder::UseAtStart(HValue* value) {
ulan@chromium.org812308e2012-02-29 15:58:45 +0000624 return Use(value, new(zone()) LUnallocated(LUnallocated::NONE,
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000625 LUnallocated::USED_AT_START));
626}
627
628
629LOperand* LChunkBuilder::UseOrConstant(HValue* value) {
630 return value->IsConstant()
631 ? chunk_->DefineConstantOperand(HConstant::cast(value))
632 : Use(value);
633}
634
635
636LOperand* LChunkBuilder::UseOrConstantAtStart(HValue* value) {
637 return value->IsConstant()
638 ? chunk_->DefineConstantOperand(HConstant::cast(value))
639 : UseAtStart(value);
640}
641
642
643LOperand* LChunkBuilder::UseRegisterOrConstant(HValue* value) {
644 return value->IsConstant()
645 ? chunk_->DefineConstantOperand(HConstant::cast(value))
646 : UseRegister(value);
647}
648
649
650LOperand* LChunkBuilder::UseRegisterOrConstantAtStart(HValue* value) {
651 return value->IsConstant()
652 ? chunk_->DefineConstantOperand(HConstant::cast(value))
653 : UseRegisterAtStart(value);
654}
655
656
657LOperand* LChunkBuilder::UseAny(HValue* value) {
658 return value->IsConstant()
659 ? chunk_->DefineConstantOperand(HConstant::cast(value))
ulan@chromium.org812308e2012-02-29 15:58:45 +0000660 : Use(value, new(zone()) LUnallocated(LUnallocated::ANY));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000661}
662
663
664LOperand* LChunkBuilder::Use(HValue* value, LUnallocated* operand) {
665 if (value->EmitAtUses()) {
666 HInstruction* instr = HInstruction::cast(value);
667 VisitInstruction(instr);
668 }
rossberg@chromium.org994edf62012-02-06 10:12:55 +0000669 operand->set_virtual_register(value->id());
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000670 return operand;
671}
672
673
674template<int I, int T>
675LInstruction* LChunkBuilder::Define(LTemplateInstruction<1, I, T>* instr,
676 LUnallocated* result) {
rossberg@chromium.org994edf62012-02-06 10:12:55 +0000677 result->set_virtual_register(current_instruction_->id());
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000678 instr->set_result(result);
679 return instr;
680}
681
682
683template<int I, int T>
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000684LInstruction* LChunkBuilder::DefineAsRegister(
685 LTemplateInstruction<1, I, T>* instr) {
ulan@chromium.org812308e2012-02-29 15:58:45 +0000686 return Define(instr,
687 new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000688}
689
690
691template<int I, int T>
692LInstruction* LChunkBuilder::DefineAsSpilled(
693 LTemplateInstruction<1, I, T>* instr, int index) {
ulan@chromium.org812308e2012-02-29 15:58:45 +0000694 return Define(instr,
695 new(zone()) LUnallocated(LUnallocated::FIXED_SLOT, index));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000696}
697
698
699template<int I, int T>
700LInstruction* LChunkBuilder::DefineSameAsFirst(
701 LTemplateInstruction<1, I, T>* instr) {
ulan@chromium.org812308e2012-02-29 15:58:45 +0000702 return Define(instr,
703 new(zone()) LUnallocated(LUnallocated::SAME_AS_FIRST_INPUT));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000704}
705
706
707template<int I, int T>
708LInstruction* LChunkBuilder::DefineFixed(
709 LTemplateInstruction<1, I, T>* instr, Register reg) {
710 return Define(instr, ToUnallocated(reg));
711}
712
713
714template<int I, int T>
715LInstruction* LChunkBuilder::DefineFixedDouble(
716 LTemplateInstruction<1, I, T>* instr, DoubleRegister reg) {
717 return Define(instr, ToUnallocated(reg));
718}
719
720
721LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) {
722 HEnvironment* hydrogen_env = current_block_->last_environment();
723 int argument_index_accumulator = 0;
724 instr->set_environment(CreateEnvironment(hydrogen_env,
725 &argument_index_accumulator));
726 return instr;
727}
728
729
730LInstruction* LChunkBuilder::SetInstructionPendingDeoptimizationEnvironment(
731 LInstruction* instr, int ast_id) {
732 ASSERT(instruction_pending_deoptimization_environment_ == NULL);
733 ASSERT(pending_deoptimization_ast_id_ == AstNode::kNoNumber);
734 instruction_pending_deoptimization_environment_ = instr;
735 pending_deoptimization_ast_id_ = ast_id;
736 return instr;
737}
738
739
740void LChunkBuilder::ClearInstructionPendingDeoptimizationEnvironment() {
741 instruction_pending_deoptimization_environment_ = NULL;
742 pending_deoptimization_ast_id_ = AstNode::kNoNumber;
743}
744
745
746LInstruction* LChunkBuilder::MarkAsCall(LInstruction* instr,
747 HInstruction* hinstr,
748 CanDeoptimize can_deoptimize) {
749#ifdef DEBUG
750 instr->VerifyCall();
751#endif
752 instr->MarkAsCall();
753 instr = AssignPointerMap(instr);
754
755 if (hinstr->HasObservableSideEffects()) {
756 ASSERT(hinstr->next()->IsSimulate());
757 HSimulate* sim = HSimulate::cast(hinstr->next());
758 instr = SetInstructionPendingDeoptimizationEnvironment(
759 instr, sim->ast_id());
760 }
761
762 // If instruction does not have side-effects lazy deoptimization
763 // after the call will try to deoptimize to the point before the call.
764 // Thus we still need to attach environment to this call even if
765 // call sequence can not deoptimize eagerly.
766 bool needs_environment =
767 (can_deoptimize == CAN_DEOPTIMIZE_EAGERLY) ||
768 !hinstr->HasObservableSideEffects();
769 if (needs_environment && !instr->HasEnvironment()) {
770 instr = AssignEnvironment(instr);
771 }
772
773 return instr;
774}
775
776
777LInstruction* LChunkBuilder::MarkAsSaveDoubles(LInstruction* instr) {
778 instr->MarkAsSaveDoubles();
779 return instr;
780}
781
782
783LInstruction* LChunkBuilder::AssignPointerMap(LInstruction* instr) {
784 ASSERT(!instr->HasPointerMap());
ulan@chromium.org812308e2012-02-29 15:58:45 +0000785 instr->set_pointer_map(new(zone()) LPointerMap(position_));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000786 return instr;
787}
788
789
790LUnallocated* LChunkBuilder::TempRegister() {
ulan@chromium.org812308e2012-02-29 15:58:45 +0000791 LUnallocated* operand =
792 new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER);
rossberg@chromium.org994edf62012-02-06 10:12:55 +0000793 operand->set_virtual_register(allocator_->GetVirtualRegister());
794 if (!allocator_->AllocationOk()) Abort("Not enough virtual registers.");
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000795 return operand;
796}
797
798
799LOperand* LChunkBuilder::FixedTemp(Register reg) {
800 LUnallocated* operand = ToUnallocated(reg);
rossberg@chromium.org994edf62012-02-06 10:12:55 +0000801 ASSERT(operand->HasFixedPolicy());
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000802 return operand;
803}
804
805
806LOperand* LChunkBuilder::FixedTemp(DoubleRegister reg) {
807 LUnallocated* operand = ToUnallocated(reg);
rossberg@chromium.org994edf62012-02-06 10:12:55 +0000808 ASSERT(operand->HasFixedPolicy());
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000809 return operand;
810}
811
812
813LInstruction* LChunkBuilder::DoBlockEntry(HBlockEntry* instr) {
ulan@chromium.org812308e2012-02-29 15:58:45 +0000814 return new(zone()) LLabel(instr->block());
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000815}
816
817
818LInstruction* LChunkBuilder::DoSoftDeoptimize(HSoftDeoptimize* instr) {
ulan@chromium.org812308e2012-02-29 15:58:45 +0000819 return AssignEnvironment(new(zone()) LDeoptimize);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000820}
821
822
823LInstruction* LChunkBuilder::DoDeoptimize(HDeoptimize* instr) {
ulan@chromium.org812308e2012-02-29 15:58:45 +0000824 return AssignEnvironment(new(zone()) LDeoptimize);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000825}
826
827
828LInstruction* LChunkBuilder::DoShift(Token::Value op,
829 HBitwiseBinaryOperation* instr) {
830 if (instr->representation().IsTagged()) {
831 ASSERT(instr->left()->representation().IsTagged());
832 ASSERT(instr->right()->representation().IsTagged());
833
834 LOperand* left = UseFixed(instr->left(), a1);
835 LOperand* right = UseFixed(instr->right(), a0);
ulan@chromium.org812308e2012-02-29 15:58:45 +0000836 LArithmeticT* result = new(zone()) LArithmeticT(op, left, right);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000837 return MarkAsCall(DefineFixed(result, v0), instr);
838 }
839
840 ASSERT(instr->representation().IsInteger32());
841 ASSERT(instr->left()->representation().IsInteger32());
842 ASSERT(instr->right()->representation().IsInteger32());
843 LOperand* left = UseRegisterAtStart(instr->left());
844
845 HValue* right_value = instr->right();
846 LOperand* right = NULL;
847 int constant_value = 0;
848 if (right_value->IsConstant()) {
849 HConstant* constant = HConstant::cast(right_value);
850 right = chunk_->DefineConstantOperand(constant);
851 constant_value = constant->Integer32Value() & 0x1f;
852 } else {
853 right = UseRegisterAtStart(right_value);
854 }
855
856 // Shift operations can only deoptimize if we do a logical shift
857 // by 0 and the result cannot be truncated to int32.
858 bool may_deopt = (op == Token::SHR && constant_value == 0);
859 bool does_deopt = false;
860 if (may_deopt) {
861 for (HUseIterator it(instr->uses()); !it.Done(); it.Advance()) {
862 if (!it.value()->CheckFlag(HValue::kTruncatingToInt32)) {
863 does_deopt = true;
864 break;
865 }
866 }
867 }
868
869 LInstruction* result =
ulan@chromium.org812308e2012-02-29 15:58:45 +0000870 DefineAsRegister(new(zone()) LShiftI(op, left, right, does_deopt));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000871 return does_deopt ? AssignEnvironment(result) : result;
872}
873
874
875LInstruction* LChunkBuilder::DoArithmeticD(Token::Value op,
876 HArithmeticBinaryOperation* instr) {
877 ASSERT(instr->representation().IsDouble());
878 ASSERT(instr->left()->representation().IsDouble());
879 ASSERT(instr->right()->representation().IsDouble());
880 ASSERT(op != Token::MOD);
881 LOperand* left = UseRegisterAtStart(instr->left());
882 LOperand* right = UseRegisterAtStart(instr->right());
ulan@chromium.org812308e2012-02-29 15:58:45 +0000883 LArithmeticD* result = new(zone()) LArithmeticD(op, left, right);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000884 return DefineAsRegister(result);
885}
886
887
888LInstruction* LChunkBuilder::DoArithmeticT(Token::Value op,
889 HArithmeticBinaryOperation* instr) {
890 ASSERT(op == Token::ADD ||
891 op == Token::DIV ||
892 op == Token::MOD ||
893 op == Token::MUL ||
894 op == Token::SUB);
895 HValue* left = instr->left();
896 HValue* right = instr->right();
897 ASSERT(left->representation().IsTagged());
898 ASSERT(right->representation().IsTagged());
899 LOperand* left_operand = UseFixed(left, a1);
900 LOperand* right_operand = UseFixed(right, a0);
ulan@chromium.org812308e2012-02-29 15:58:45 +0000901 LArithmeticT* result =
902 new(zone()) LArithmeticT(op, left_operand, right_operand);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +0000903 return MarkAsCall(DefineFixed(result, v0), instr);
904}
905
906
907void LChunkBuilder::DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block) {
908 ASSERT(is_building());
909 current_block_ = block;
910 next_block_ = next_block;
911 if (block->IsStartBlock()) {
912 block->UpdateEnvironment(graph_->start_environment());
913 argument_count_ = 0;
914 } else if (block->predecessors()->length() == 1) {
915 // We have a single predecessor => copy environment and outgoing
916 // argument count from the predecessor.
917 ASSERT(block->phis()->length() == 0);
918 HBasicBlock* pred = block->predecessors()->at(0);
919 HEnvironment* last_environment = pred->last_environment();
920 ASSERT(last_environment != NULL);
921 // Only copy the environment, if it is later used again.
922 if (pred->end()->SecondSuccessor() == NULL) {
923 ASSERT(pred->end()->FirstSuccessor() == block);
924 } else {
925 if (pred->end()->FirstSuccessor()->block_id() > block->block_id() ||
926 pred->end()->SecondSuccessor()->block_id() > block->block_id()) {
927 last_environment = last_environment->Copy();
928 }
929 }
930 block->UpdateEnvironment(last_environment);
931 ASSERT(pred->argument_count() >= 0);
932 argument_count_ = pred->argument_count();
933 } else {
934 // We are at a state join => process phis.
935 HBasicBlock* pred = block->predecessors()->at(0);
936 // No need to copy the environment, it cannot be used later.
937 HEnvironment* last_environment = pred->last_environment();
938 for (int i = 0; i < block->phis()->length(); ++i) {
939 HPhi* phi = block->phis()->at(i);
940 last_environment->SetValueAt(phi->merged_index(), phi);
941 }
942 for (int i = 0; i < block->deleted_phis()->length(); ++i) {
943 last_environment->SetValueAt(block->deleted_phis()->at(i),
944 graph_->GetConstantUndefined());
945 }
946 block->UpdateEnvironment(last_environment);
947 // Pick up the outgoing argument count of one of the predecessors.
948 argument_count_ = pred->argument_count();
949 }
950 HInstruction* current = block->first();
951 int start = chunk_->instructions()->length();
952 while (current != NULL && !is_aborted()) {
953 // Code for constants in registers is generated lazily.
954 if (!current->EmitAtUses()) {
955 VisitInstruction(current);
956 }
957 current = current->next();
958 }
959 int end = chunk_->instructions()->length() - 1;
960 if (end >= start) {
961 block->set_first_instruction_index(start);
962 block->set_last_instruction_index(end);
963 }
964 block->set_argument_count(argument_count_);
965 next_block_ = NULL;
966 current_block_ = NULL;
967}
968
969
970void LChunkBuilder::VisitInstruction(HInstruction* current) {
971 HInstruction* old_current = current_instruction_;
972 current_instruction_ = current;
973 if (current->has_position()) position_ = current->position();
974 LInstruction* instr = current->CompileToLithium(this);
975
976 if (instr != NULL) {
977 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) {
978 instr = AssignPointerMap(instr);
979 }
980 if (FLAG_stress_environments && !instr->HasEnvironment()) {
981 instr = AssignEnvironment(instr);
982 }
983 instr->set_hydrogen_value(current);
984 chunk_->AddInstruction(instr, current_block_);
985 }
986 current_instruction_ = old_current;
987}
988
989
990LEnvironment* LChunkBuilder::CreateEnvironment(
991 HEnvironment* hydrogen_env,
992 int* argument_index_accumulator) {
993 if (hydrogen_env == NULL) return NULL;
994
995 LEnvironment* outer =
996 CreateEnvironment(hydrogen_env->outer(), argument_index_accumulator);
997 int ast_id = hydrogen_env->ast_id();
ulan@chromium.org812308e2012-02-29 15:58:45 +0000998 ASSERT(ast_id != AstNode::kNoNumber ||
999 hydrogen_env->frame_type() != JS_FUNCTION);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001000 int value_count = hydrogen_env->length();
ulan@chromium.org812308e2012-02-29 15:58:45 +00001001 LEnvironment* result = new(zone()) LEnvironment(
1002 hydrogen_env->closure(),
1003 hydrogen_env->frame_type(),
1004 ast_id,
1005 hydrogen_env->parameter_count(),
1006 argument_count_,
1007 value_count,
1008 outer);
danno@chromium.orgfa458e42012-02-01 10:48:36 +00001009 int argument_index = *argument_index_accumulator;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001010 for (int i = 0; i < value_count; ++i) {
1011 if (hydrogen_env->is_special_index(i)) continue;
1012
1013 HValue* value = hydrogen_env->values()->at(i);
1014 LOperand* op = NULL;
1015 if (value->IsArgumentsObject()) {
1016 op = NULL;
1017 } else if (value->IsPushArgument()) {
ulan@chromium.org812308e2012-02-29 15:58:45 +00001018 op = new(zone()) LArgument(argument_index++);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001019 } else {
1020 op = UseAny(value);
1021 }
1022 result->AddValue(op, value->representation());
1023 }
1024
ulan@chromium.org812308e2012-02-29 15:58:45 +00001025 if (hydrogen_env->frame_type() == JS_FUNCTION) {
danno@chromium.orgfa458e42012-02-01 10:48:36 +00001026 *argument_index_accumulator = argument_index;
1027 }
1028
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001029 return result;
1030}
1031
1032
1033LInstruction* LChunkBuilder::DoGoto(HGoto* instr) {
ulan@chromium.org812308e2012-02-29 15:58:45 +00001034 return new(zone()) LGoto(instr->FirstSuccessor()->block_id());
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001035}
1036
1037
1038LInstruction* LChunkBuilder::DoBranch(HBranch* instr) {
erik.corry@gmail.comf2038fb2012-01-16 11:42:08 +00001039 HValue* value = instr->value();
1040 if (value->EmitAtUses()) {
1041 HBasicBlock* successor = HConstant::cast(value)->ToBoolean()
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001042 ? instr->FirstSuccessor()
1043 : instr->SecondSuccessor();
ulan@chromium.org812308e2012-02-29 15:58:45 +00001044 return new(zone()) LGoto(successor->block_id());
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001045 }
erik.corry@gmail.comf2038fb2012-01-16 11:42:08 +00001046
ulan@chromium.org812308e2012-02-29 15:58:45 +00001047 LBranch* result = new(zone()) LBranch(UseRegister(value));
erik.corry@gmail.comf2038fb2012-01-16 11:42:08 +00001048 // Tagged values that are not known smis or booleans require a
1049 // deoptimization environment.
1050 Representation rep = value->representation();
1051 HType type = value->type();
1052 if (rep.IsTagged() && !type.IsSmi() && !type.IsBoolean()) {
1053 return AssignEnvironment(result);
1054 }
1055 return result;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001056}
1057
1058
1059LInstruction* LChunkBuilder::DoCompareMap(HCompareMap* instr) {
1060 ASSERT(instr->value()->representation().IsTagged());
1061 LOperand* value = UseRegisterAtStart(instr->value());
1062 LOperand* temp = TempRegister();
ulan@chromium.org812308e2012-02-29 15:58:45 +00001063 return new(zone()) LCmpMapAndBranch(value, temp);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001064}
1065
1066
1067LInstruction* LChunkBuilder::DoArgumentsLength(HArgumentsLength* length) {
ulan@chromium.org812308e2012-02-29 15:58:45 +00001068 return DefineAsRegister(
1069 new(zone()) LArgumentsLength(UseRegister(length->value())));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001070}
1071
1072
1073LInstruction* LChunkBuilder::DoArgumentsElements(HArgumentsElements* elems) {
danno@chromium.orgb2a1c072012-03-23 15:47:56 +00001074 return DefineAsRegister(new(zone()) LArgumentsElements);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001075}
1076
1077
1078LInstruction* LChunkBuilder::DoInstanceOf(HInstanceOf* instr) {
1079 LInstanceOf* result =
ulan@chromium.org812308e2012-02-29 15:58:45 +00001080 new(zone()) LInstanceOf(UseFixed(instr->left(), a0),
1081 UseFixed(instr->right(), a1));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001082 return MarkAsCall(DefineFixed(result, v0), instr);
1083}
1084
1085
1086LInstruction* LChunkBuilder::DoInstanceOfKnownGlobal(
1087 HInstanceOfKnownGlobal* instr) {
1088 LInstanceOfKnownGlobal* result =
ulan@chromium.org812308e2012-02-29 15:58:45 +00001089 new(zone()) LInstanceOfKnownGlobal(UseFixed(instr->left(), a0),
1090 FixedTemp(t0));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001091 return MarkAsCall(DefineFixed(result, v0), instr);
1092}
1093
1094
rossberg@chromium.org2c067b12012-03-19 11:01:52 +00001095LInstruction* LChunkBuilder::DoWrapReceiver(HWrapReceiver* instr) {
1096 LOperand* receiver = UseRegisterAtStart(instr->receiver());
1097 LOperand* function = UseRegisterAtStart(instr->function());
1098 LWrapReceiver* result = new(zone()) LWrapReceiver(receiver, function);
1099 return AssignEnvironment(DefineSameAsFirst(result));
1100}
1101
1102
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001103LInstruction* LChunkBuilder::DoApplyArguments(HApplyArguments* instr) {
1104 LOperand* function = UseFixed(instr->function(), a1);
1105 LOperand* receiver = UseFixed(instr->receiver(), a0);
1106 LOperand* length = UseFixed(instr->length(), a2);
1107 LOperand* elements = UseFixed(instr->elements(), a3);
ulan@chromium.org812308e2012-02-29 15:58:45 +00001108 LApplyArguments* result = new(zone()) LApplyArguments(function,
1109 receiver,
1110 length,
1111 elements);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001112 return MarkAsCall(DefineFixed(result, v0), instr, CAN_DEOPTIMIZE_EAGERLY);
1113}
1114
1115
1116LInstruction* LChunkBuilder::DoPushArgument(HPushArgument* instr) {
1117 ++argument_count_;
1118 LOperand* argument = Use(instr->argument());
ulan@chromium.org812308e2012-02-29 15:58:45 +00001119 return new(zone()) LPushArgument(argument);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001120}
1121
1122
1123LInstruction* LChunkBuilder::DoThisFunction(HThisFunction* instr) {
ulan@chromium.org812308e2012-02-29 15:58:45 +00001124 return instr->HasNoUses()
1125 ? NULL
1126 : DefineAsRegister(new(zone()) LThisFunction);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001127}
1128
1129
1130LInstruction* LChunkBuilder::DoContext(HContext* instr) {
ulan@chromium.org812308e2012-02-29 15:58:45 +00001131 return instr->HasNoUses() ? NULL : DefineAsRegister(new(zone()) LContext);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001132}
1133
1134
1135LInstruction* LChunkBuilder::DoOuterContext(HOuterContext* instr) {
1136 LOperand* context = UseRegisterAtStart(instr->value());
ulan@chromium.org812308e2012-02-29 15:58:45 +00001137 return DefineAsRegister(new(zone()) LOuterContext(context));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001138}
1139
1140
jkummerow@chromium.orgf7a58842012-02-21 10:08:21 +00001141LInstruction* LChunkBuilder::DoDeclareGlobals(HDeclareGlobals* instr) {
ulan@chromium.org812308e2012-02-29 15:58:45 +00001142 return MarkAsCall(new(zone()) LDeclareGlobals, instr);
jkummerow@chromium.orgf7a58842012-02-21 10:08:21 +00001143}
1144
1145
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001146LInstruction* LChunkBuilder::DoGlobalObject(HGlobalObject* instr) {
1147 LOperand* context = UseRegisterAtStart(instr->value());
ulan@chromium.org812308e2012-02-29 15:58:45 +00001148 return DefineAsRegister(new(zone()) LGlobalObject(context));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001149}
1150
1151
1152LInstruction* LChunkBuilder::DoGlobalReceiver(HGlobalReceiver* instr) {
1153 LOperand* global_object = UseRegisterAtStart(instr->value());
ulan@chromium.org812308e2012-02-29 15:58:45 +00001154 return DefineAsRegister(new(zone()) LGlobalReceiver(global_object));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001155}
1156
1157
1158LInstruction* LChunkBuilder::DoCallConstantFunction(
1159 HCallConstantFunction* instr) {
1160 argument_count_ -= instr->argument_count();
ulan@chromium.org812308e2012-02-29 15:58:45 +00001161 return MarkAsCall(DefineFixed(new(zone()) LCallConstantFunction, v0), instr);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001162}
1163
1164
1165LInstruction* LChunkBuilder::DoInvokeFunction(HInvokeFunction* instr) {
1166 LOperand* function = UseFixed(instr->function(), a1);
1167 argument_count_ -= instr->argument_count();
ulan@chromium.org812308e2012-02-29 15:58:45 +00001168 LInvokeFunction* result = new(zone()) LInvokeFunction(function);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001169 return MarkAsCall(DefineFixed(result, v0), instr, CANNOT_DEOPTIMIZE_EAGERLY);
1170}
1171
1172
1173LInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) {
1174 BuiltinFunctionId op = instr->op();
ulan@chromium.org9a21ec42012-03-06 08:42:24 +00001175 if (op == kMathLog || op == kMathSin || op == kMathCos || op == kMathTan) {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001176 LOperand* input = UseFixedDouble(instr->value(), f4);
ulan@chromium.org812308e2012-02-29 15:58:45 +00001177 LUnaryMathOperation* result = new(zone()) LUnaryMathOperation(input, NULL);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001178 return MarkAsCall(DefineFixedDouble(result, f4), instr);
ricow@chromium.org64e3a4b2011-12-13 08:07:27 +00001179 } else if (op == kMathPowHalf) {
1180 // Input cannot be the same as the result.
1181 // See lithium-codegen-mips.cc::DoMathPowHalf.
1182 LOperand* input = UseFixedDouble(instr->value(), f8);
1183 LOperand* temp = FixedTemp(f6);
ulan@chromium.org812308e2012-02-29 15:58:45 +00001184 LUnaryMathOperation* result = new(zone()) LUnaryMathOperation(input, temp);
ricow@chromium.org64e3a4b2011-12-13 08:07:27 +00001185 return DefineFixedDouble(result, f4);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001186 } else {
1187 LOperand* input = UseRegisterAtStart(instr->value());
1188 LOperand* temp = (op == kMathFloor) ? TempRegister() : NULL;
ulan@chromium.org812308e2012-02-29 15:58:45 +00001189 LUnaryMathOperation* result = new(zone()) LUnaryMathOperation(input, temp);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001190 switch (op) {
1191 case kMathAbs:
1192 return AssignEnvironment(AssignPointerMap(DefineAsRegister(result)));
1193 case kMathFloor:
1194 return AssignEnvironment(AssignPointerMap(DefineAsRegister(result)));
1195 case kMathSqrt:
1196 return DefineAsRegister(result);
1197 case kMathRound:
1198 return AssignEnvironment(DefineAsRegister(result));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001199 default:
1200 UNREACHABLE();
1201 return NULL;
1202 }
1203 }
1204}
1205
1206
1207LInstruction* LChunkBuilder::DoCallKeyed(HCallKeyed* instr) {
1208 ASSERT(instr->key()->representation().IsTagged());
1209 argument_count_ -= instr->argument_count();
1210 LOperand* key = UseFixed(instr->key(), a2);
ulan@chromium.org812308e2012-02-29 15:58:45 +00001211 return MarkAsCall(DefineFixed(new(zone()) LCallKeyed(key), v0), instr);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001212}
1213
1214
1215LInstruction* LChunkBuilder::DoCallNamed(HCallNamed* instr) {
1216 argument_count_ -= instr->argument_count();
ulan@chromium.org812308e2012-02-29 15:58:45 +00001217 return MarkAsCall(DefineFixed(new(zone()) LCallNamed, v0), instr);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001218}
1219
1220
1221LInstruction* LChunkBuilder::DoCallGlobal(HCallGlobal* instr) {
1222 argument_count_ -= instr->argument_count();
ulan@chromium.org812308e2012-02-29 15:58:45 +00001223 return MarkAsCall(DefineFixed(new(zone()) LCallGlobal, v0), instr);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001224}
1225
1226
1227LInstruction* LChunkBuilder::DoCallKnownGlobal(HCallKnownGlobal* instr) {
1228 argument_count_ -= instr->argument_count();
ulan@chromium.org812308e2012-02-29 15:58:45 +00001229 return MarkAsCall(DefineFixed(new(zone()) LCallKnownGlobal, v0), instr);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001230}
1231
1232
1233LInstruction* LChunkBuilder::DoCallNew(HCallNew* instr) {
1234 LOperand* constructor = UseFixed(instr->constructor(), a1);
1235 argument_count_ -= instr->argument_count();
ulan@chromium.org812308e2012-02-29 15:58:45 +00001236 LCallNew* result = new(zone()) LCallNew(constructor);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001237 return MarkAsCall(DefineFixed(result, v0), instr);
1238}
1239
1240
1241LInstruction* LChunkBuilder::DoCallFunction(HCallFunction* instr) {
danno@chromium.orgc612e022011-11-10 11:38:15 +00001242 LOperand* function = UseFixed(instr->function(), a1);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001243 argument_count_ -= instr->argument_count();
ulan@chromium.org812308e2012-02-29 15:58:45 +00001244 return MarkAsCall(DefineFixed(new(zone()) LCallFunction(function), v0),
1245 instr);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001246}
1247
1248
1249LInstruction* LChunkBuilder::DoCallRuntime(HCallRuntime* instr) {
1250 argument_count_ -= instr->argument_count();
ulan@chromium.org812308e2012-02-29 15:58:45 +00001251 return MarkAsCall(DefineFixed(new(zone()) LCallRuntime, v0), instr);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001252}
1253
1254
1255LInstruction* LChunkBuilder::DoShr(HShr* instr) {
1256 return DoShift(Token::SHR, instr);
1257}
1258
1259
1260LInstruction* LChunkBuilder::DoSar(HSar* instr) {
1261 return DoShift(Token::SAR, instr);
1262}
1263
1264
1265LInstruction* LChunkBuilder::DoShl(HShl* instr) {
1266 return DoShift(Token::SHL, instr);
1267}
1268
1269
1270LInstruction* LChunkBuilder::DoBitwise(HBitwise* instr) {
1271 if (instr->representation().IsInteger32()) {
1272 ASSERT(instr->left()->representation().IsInteger32());
1273 ASSERT(instr->right()->representation().IsInteger32());
1274
1275 LOperand* left = UseRegisterAtStart(instr->LeastConstantOperand());
1276 LOperand* right = UseOrConstantAtStart(instr->MostConstantOperand());
ulan@chromium.org812308e2012-02-29 15:58:45 +00001277 return DefineAsRegister(new(zone()) LBitI(left, right));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001278 } else {
1279 ASSERT(instr->representation().IsTagged());
1280 ASSERT(instr->left()->representation().IsTagged());
1281 ASSERT(instr->right()->representation().IsTagged());
1282
1283 LOperand* left = UseFixed(instr->left(), a1);
1284 LOperand* right = UseFixed(instr->right(), a0);
ulan@chromium.org812308e2012-02-29 15:58:45 +00001285 LArithmeticT* result = new(zone()) LArithmeticT(instr->op(), left, right);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001286 return MarkAsCall(DefineFixed(result, v0), instr);
1287 }
1288}
1289
1290
1291LInstruction* LChunkBuilder::DoBitNot(HBitNot* instr) {
1292 ASSERT(instr->value()->representation().IsInteger32());
1293 ASSERT(instr->representation().IsInteger32());
mstarzinger@chromium.org88d326b2012-04-23 12:57:22 +00001294 if (instr->HasNoUses()) return NULL;
ulan@chromium.org812308e2012-02-29 15:58:45 +00001295 LOperand* value = UseRegisterAtStart(instr->value());
1296 return DefineAsRegister(new(zone()) LBitNotI(value));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001297}
1298
1299
1300LInstruction* LChunkBuilder::DoDiv(HDiv* instr) {
1301 if (instr->representation().IsDouble()) {
1302 return DoArithmeticD(Token::DIV, instr);
1303 } else if (instr->representation().IsInteger32()) {
1304 // TODO(1042) The fixed register allocation
1305 // is needed because we call TypeRecordingBinaryOpStub from
1306 // the generated code, which requires registers a0
1307 // and a1 to be used. We should remove that
1308 // when we provide a native implementation.
1309 LOperand* dividend = UseFixed(instr->left(), a0);
1310 LOperand* divisor = UseFixed(instr->right(), a1);
1311 return AssignEnvironment(AssignPointerMap(
ulan@chromium.org812308e2012-02-29 15:58:45 +00001312 DefineFixed(new(zone()) LDivI(dividend, divisor), v0)));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001313 } else {
1314 return DoArithmeticT(Token::DIV, instr);
1315 }
1316}
1317
1318
1319LInstruction* LChunkBuilder::DoMod(HMod* instr) {
1320 if (instr->representation().IsInteger32()) {
1321 ASSERT(instr->left()->representation().IsInteger32());
1322 ASSERT(instr->right()->representation().IsInteger32());
1323
1324 LModI* mod;
1325 if (instr->HasPowerOf2Divisor()) {
1326 ASSERT(!instr->CheckFlag(HValue::kCanBeDivByZero));
1327 LOperand* value = UseRegisterAtStart(instr->left());
ulan@chromium.org812308e2012-02-29 15:58:45 +00001328 mod = new(zone()) LModI(value, UseOrConstant(instr->right()));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001329 } else {
1330 LOperand* dividend = UseRegister(instr->left());
1331 LOperand* divisor = UseRegister(instr->right());
ulan@chromium.org812308e2012-02-29 15:58:45 +00001332 mod = new(zone()) LModI(dividend,
1333 divisor,
1334 TempRegister(),
1335 FixedTemp(f20),
1336 FixedTemp(f22));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001337 }
1338
1339 if (instr->CheckFlag(HValue::kBailoutOnMinusZero) ||
1340 instr->CheckFlag(HValue::kCanBeDivByZero)) {
1341 return AssignEnvironment(DefineAsRegister(mod));
1342 } else {
1343 return DefineAsRegister(mod);
1344 }
1345 } else if (instr->representation().IsTagged()) {
1346 return DoArithmeticT(Token::MOD, instr);
1347 } else {
1348 ASSERT(instr->representation().IsDouble());
1349 // We call a C function for double modulo. It can't trigger a GC.
1350 // We need to use fixed result register for the call.
1351 // TODO(fschneider): Allow any register as input registers.
1352 LOperand* left = UseFixedDouble(instr->left(), f2);
1353 LOperand* right = UseFixedDouble(instr->right(), f4);
ulan@chromium.org812308e2012-02-29 15:58:45 +00001354 LArithmeticD* result = new(zone()) LArithmeticD(Token::MOD, left, right);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001355 return MarkAsCall(DefineFixedDouble(result, f2), instr);
1356 }
1357}
1358
1359
1360LInstruction* LChunkBuilder::DoMul(HMul* instr) {
1361 if (instr->representation().IsInteger32()) {
1362 ASSERT(instr->left()->representation().IsInteger32());
1363 ASSERT(instr->right()->representation().IsInteger32());
1364 LOperand* left;
1365 LOperand* right = UseOrConstant(instr->MostConstantOperand());
1366 LOperand* temp = NULL;
1367 if (instr->CheckFlag(HValue::kBailoutOnMinusZero) &&
1368 (instr->CheckFlag(HValue::kCanOverflow) ||
1369 !right->IsConstantOperand())) {
1370 left = UseRegister(instr->LeastConstantOperand());
1371 temp = TempRegister();
1372 } else {
1373 left = UseRegisterAtStart(instr->LeastConstantOperand());
1374 }
ulan@chromium.org812308e2012-02-29 15:58:45 +00001375 LMulI* mul = new(zone()) LMulI(left, right, temp);
erik.corry@gmail.comf2038fb2012-01-16 11:42:08 +00001376 if (instr->CheckFlag(HValue::kCanOverflow) ||
1377 instr->CheckFlag(HValue::kBailoutOnMinusZero)) {
1378 AssignEnvironment(mul);
1379 }
1380 return DefineAsRegister(mul);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001381
1382 } else if (instr->representation().IsDouble()) {
1383 return DoArithmeticD(Token::MUL, instr);
1384
1385 } else {
1386 return DoArithmeticT(Token::MUL, instr);
1387 }
1388}
1389
1390
1391LInstruction* LChunkBuilder::DoSub(HSub* instr) {
1392 if (instr->representation().IsInteger32()) {
1393 ASSERT(instr->left()->representation().IsInteger32());
1394 ASSERT(instr->right()->representation().IsInteger32());
1395 LOperand* left = UseRegisterAtStart(instr->left());
1396 LOperand* right = UseOrConstantAtStart(instr->right());
ulan@chromium.org812308e2012-02-29 15:58:45 +00001397 LSubI* sub = new(zone()) LSubI(left, right);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001398 LInstruction* result = DefineAsRegister(sub);
1399 if (instr->CheckFlag(HValue::kCanOverflow)) {
1400 result = AssignEnvironment(result);
1401 }
1402 return result;
1403 } else if (instr->representation().IsDouble()) {
1404 return DoArithmeticD(Token::SUB, instr);
1405 } else {
1406 return DoArithmeticT(Token::SUB, instr);
1407 }
1408}
1409
1410
1411LInstruction* LChunkBuilder::DoAdd(HAdd* instr) {
1412 if (instr->representation().IsInteger32()) {
1413 ASSERT(instr->left()->representation().IsInteger32());
1414 ASSERT(instr->right()->representation().IsInteger32());
1415 LOperand* left = UseRegisterAtStart(instr->LeastConstantOperand());
1416 LOperand* right = UseOrConstantAtStart(instr->MostConstantOperand());
ulan@chromium.org812308e2012-02-29 15:58:45 +00001417 LAddI* add = new(zone()) LAddI(left, right);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001418 LInstruction* result = DefineAsRegister(add);
1419 if (instr->CheckFlag(HValue::kCanOverflow)) {
1420 result = AssignEnvironment(result);
1421 }
1422 return result;
1423 } else if (instr->representation().IsDouble()) {
1424 return DoArithmeticD(Token::ADD, instr);
1425 } else {
1426 ASSERT(instr->representation().IsTagged());
1427 return DoArithmeticT(Token::ADD, instr);
1428 }
1429}
1430
1431
1432LInstruction* LChunkBuilder::DoPower(HPower* instr) {
1433 ASSERT(instr->representation().IsDouble());
1434 // We call a C function for double power. It can't trigger a GC.
1435 // We need to use fixed result register for the call.
1436 Representation exponent_type = instr->right()->representation();
1437 ASSERT(instr->left()->representation().IsDouble());
1438 LOperand* left = UseFixedDouble(instr->left(), f2);
1439 LOperand* right = exponent_type.IsDouble() ?
1440 UseFixedDouble(instr->right(), f4) :
ricow@chromium.org64e3a4b2011-12-13 08:07:27 +00001441 UseFixed(instr->right(), a2);
ulan@chromium.org812308e2012-02-29 15:58:45 +00001442 LPower* result = new(zone()) LPower(left, right);
ricow@chromium.org64e3a4b2011-12-13 08:07:27 +00001443 return MarkAsCall(DefineFixedDouble(result, f0),
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001444 instr,
1445 CAN_DEOPTIMIZE_EAGERLY);
1446}
1447
1448
erik.corry@gmail.comf2038fb2012-01-16 11:42:08 +00001449LInstruction* LChunkBuilder::DoRandom(HRandom* instr) {
1450 ASSERT(instr->representation().IsDouble());
1451 ASSERT(instr->global_object()->representation().IsTagged());
1452 LOperand* global_object = UseFixed(instr->global_object(), a0);
ulan@chromium.org812308e2012-02-29 15:58:45 +00001453 LRandom* result = new(zone()) LRandom(global_object);
erik.corry@gmail.comf2038fb2012-01-16 11:42:08 +00001454 return MarkAsCall(DefineFixedDouble(result, f0), instr);
1455}
1456
1457
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001458LInstruction* LChunkBuilder::DoCompareGeneric(HCompareGeneric* instr) {
1459 Representation r = instr->GetInputRepresentation();
1460 ASSERT(instr->left()->representation().IsTagged());
1461 ASSERT(instr->right()->representation().IsTagged());
1462 LOperand* left = UseFixed(instr->left(), a1);
1463 LOperand* right = UseFixed(instr->right(), a0);
ulan@chromium.org812308e2012-02-29 15:58:45 +00001464 LCmpT* result = new(zone()) LCmpT(left, right);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001465 return MarkAsCall(DefineFixed(result, v0), instr);
1466}
1467
1468
1469LInstruction* LChunkBuilder::DoCompareIDAndBranch(
1470 HCompareIDAndBranch* instr) {
1471 Representation r = instr->GetInputRepresentation();
1472 if (r.IsInteger32()) {
1473 ASSERT(instr->left()->representation().IsInteger32());
1474 ASSERT(instr->right()->representation().IsInteger32());
1475 LOperand* left = UseRegisterOrConstantAtStart(instr->left());
1476 LOperand* right = UseRegisterOrConstantAtStart(instr->right());
ulan@chromium.org812308e2012-02-29 15:58:45 +00001477 return new(zone()) LCmpIDAndBranch(left, right);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001478 } else {
1479 ASSERT(r.IsDouble());
1480 ASSERT(instr->left()->representation().IsDouble());
1481 ASSERT(instr->right()->representation().IsDouble());
1482 LOperand* left = UseRegisterAtStart(instr->left());
1483 LOperand* right = UseRegisterAtStart(instr->right());
ulan@chromium.org812308e2012-02-29 15:58:45 +00001484 return new(zone()) LCmpIDAndBranch(left, right);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001485 }
1486}
1487
1488
1489LInstruction* LChunkBuilder::DoCompareObjectEqAndBranch(
1490 HCompareObjectEqAndBranch* instr) {
1491 LOperand* left = UseRegisterAtStart(instr->left());
1492 LOperand* right = UseRegisterAtStart(instr->right());
ulan@chromium.org812308e2012-02-29 15:58:45 +00001493 return new(zone()) LCmpObjectEqAndBranch(left, right);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001494}
1495
1496
1497LInstruction* LChunkBuilder::DoCompareConstantEqAndBranch(
1498 HCompareConstantEqAndBranch* instr) {
ulan@chromium.org812308e2012-02-29 15:58:45 +00001499 return new(zone()) LCmpConstantEqAndBranch(
1500 UseRegisterAtStart(instr->value()));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001501}
1502
1503
1504LInstruction* LChunkBuilder::DoIsNilAndBranch(HIsNilAndBranch* instr) {
1505 ASSERT(instr->value()->representation().IsTagged());
ulan@chromium.org812308e2012-02-29 15:58:45 +00001506 return new(zone()) LIsNilAndBranch(UseRegisterAtStart(instr->value()));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001507}
1508
1509
1510LInstruction* LChunkBuilder::DoIsObjectAndBranch(HIsObjectAndBranch* instr) {
1511 ASSERT(instr->value()->representation().IsTagged());
1512 LOperand* temp = TempRegister();
ulan@chromium.org812308e2012-02-29 15:58:45 +00001513 return new(zone()) LIsObjectAndBranch(UseRegisterAtStart(instr->value()),
1514 temp);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001515}
1516
1517
mstarzinger@chromium.orgf8c6bd52011-11-23 12:13:52 +00001518LInstruction* LChunkBuilder::DoIsStringAndBranch(HIsStringAndBranch* instr) {
1519 ASSERT(instr->value()->representation().IsTagged());
1520 LOperand* temp = TempRegister();
ulan@chromium.org812308e2012-02-29 15:58:45 +00001521 return new(zone()) LIsStringAndBranch(UseRegisterAtStart(instr->value()),
1522 temp);
mstarzinger@chromium.orgf8c6bd52011-11-23 12:13:52 +00001523}
1524
1525
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001526LInstruction* LChunkBuilder::DoIsSmiAndBranch(HIsSmiAndBranch* instr) {
1527 ASSERT(instr->value()->representation().IsTagged());
ulan@chromium.org812308e2012-02-29 15:58:45 +00001528 return new(zone()) LIsSmiAndBranch(Use(instr->value()));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001529}
1530
1531
1532LInstruction* LChunkBuilder::DoIsUndetectableAndBranch(
1533 HIsUndetectableAndBranch* instr) {
1534 ASSERT(instr->value()->representation().IsTagged());
ulan@chromium.org812308e2012-02-29 15:58:45 +00001535 return new(zone()) LIsUndetectableAndBranch(
1536 UseRegisterAtStart(instr->value()), TempRegister());
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001537}
1538
1539
mstarzinger@chromium.orgf8c6bd52011-11-23 12:13:52 +00001540LInstruction* LChunkBuilder::DoStringCompareAndBranch(
1541 HStringCompareAndBranch* instr) {
1542 ASSERT(instr->left()->representation().IsTagged());
1543 ASSERT(instr->right()->representation().IsTagged());
1544 LOperand* left = UseFixed(instr->left(), a1);
1545 LOperand* right = UseFixed(instr->right(), a0);
ulan@chromium.org812308e2012-02-29 15:58:45 +00001546 LStringCompareAndBranch* result =
1547 new(zone()) LStringCompareAndBranch(left, right);
mstarzinger@chromium.orgf8c6bd52011-11-23 12:13:52 +00001548 return MarkAsCall(result, instr);
1549}
1550
1551
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001552LInstruction* LChunkBuilder::DoHasInstanceTypeAndBranch(
1553 HHasInstanceTypeAndBranch* instr) {
1554 ASSERT(instr->value()->representation().IsTagged());
ulan@chromium.org812308e2012-02-29 15:58:45 +00001555 LOperand* value = UseRegisterAtStart(instr->value());
1556 return new(zone()) LHasInstanceTypeAndBranch(value);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001557}
1558
1559
1560LInstruction* LChunkBuilder::DoGetCachedArrayIndex(
1561 HGetCachedArrayIndex* instr) {
1562 ASSERT(instr->value()->representation().IsTagged());
1563 LOperand* value = UseRegisterAtStart(instr->value());
1564
ulan@chromium.org812308e2012-02-29 15:58:45 +00001565 return DefineAsRegister(new(zone()) LGetCachedArrayIndex(value));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001566}
1567
1568
1569LInstruction* LChunkBuilder::DoHasCachedArrayIndexAndBranch(
1570 HHasCachedArrayIndexAndBranch* instr) {
1571 ASSERT(instr->value()->representation().IsTagged());
ulan@chromium.org812308e2012-02-29 15:58:45 +00001572 return new(zone()) LHasCachedArrayIndexAndBranch(
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001573 UseRegisterAtStart(instr->value()));
1574}
1575
1576
1577LInstruction* LChunkBuilder::DoClassOfTestAndBranch(
1578 HClassOfTestAndBranch* instr) {
1579 ASSERT(instr->value()->representation().IsTagged());
ulan@chromium.org812308e2012-02-29 15:58:45 +00001580 return new(zone()) LClassOfTestAndBranch(UseRegister(instr->value()),
1581 TempRegister());
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001582}
1583
1584
1585LInstruction* LChunkBuilder::DoJSArrayLength(HJSArrayLength* instr) {
1586 LOperand* array = UseRegisterAtStart(instr->value());
ulan@chromium.org812308e2012-02-29 15:58:45 +00001587 return DefineAsRegister(new(zone()) LJSArrayLength(array));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001588}
1589
1590
1591LInstruction* LChunkBuilder::DoFixedArrayBaseLength(
1592 HFixedArrayBaseLength* instr) {
1593 LOperand* array = UseRegisterAtStart(instr->value());
ulan@chromium.org812308e2012-02-29 15:58:45 +00001594 return DefineAsRegister(new(zone()) LFixedArrayBaseLength(array));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001595}
1596
1597
1598LInstruction* LChunkBuilder::DoElementsKind(HElementsKind* instr) {
1599 LOperand* object = UseRegisterAtStart(instr->value());
ulan@chromium.org812308e2012-02-29 15:58:45 +00001600 return DefineAsRegister(new(zone()) LElementsKind(object));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001601}
1602
1603
1604LInstruction* LChunkBuilder::DoValueOf(HValueOf* instr) {
1605 LOperand* object = UseRegister(instr->value());
ulan@chromium.org812308e2012-02-29 15:58:45 +00001606 LValueOf* result = new(zone()) LValueOf(object, TempRegister());
erik.corry@gmail.comf2038fb2012-01-16 11:42:08 +00001607 return DefineAsRegister(result);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001608}
1609
1610
yangguo@chromium.org154ff992012-03-13 08:09:54 +00001611LInstruction* LChunkBuilder::DoDateField(HDateField* instr) {
1612 LOperand* object = UseFixed(instr->value(), a0);
1613 LDateField* result = new LDateField(object, FixedTemp(a1), instr->index());
1614 return MarkAsCall(DefineFixed(result, v0), instr);
1615}
1616
1617
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001618LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) {
ulan@chromium.org812308e2012-02-29 15:58:45 +00001619 LOperand* value = UseRegisterAtStart(instr->index());
1620 LOperand* length = UseRegister(instr->length());
1621 return AssignEnvironment(new(zone()) LBoundsCheck(value, length));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001622}
1623
1624
1625LInstruction* LChunkBuilder::DoAbnormalExit(HAbnormalExit* instr) {
1626 // The control instruction marking the end of a block that completed
1627 // abruptly (e.g., threw an exception). There is nothing specific to do.
1628 return NULL;
1629}
1630
1631
1632LInstruction* LChunkBuilder::DoThrow(HThrow* instr) {
1633 LOperand* value = UseFixed(instr->value(), a0);
ulan@chromium.org812308e2012-02-29 15:58:45 +00001634 return MarkAsCall(new(zone()) LThrow(value), instr);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001635}
1636
1637
1638LInstruction* LChunkBuilder::DoUseConst(HUseConst* instr) {
1639 return NULL;
1640}
1641
1642
1643LInstruction* LChunkBuilder::DoForceRepresentation(HForceRepresentation* bad) {
1644 // All HForceRepresentation instructions should be eliminated in the
1645 // representation change phase of Hydrogen.
1646 UNREACHABLE();
1647 return NULL;
1648}
1649
1650
1651LInstruction* LChunkBuilder::DoChange(HChange* instr) {
1652 Representation from = instr->from();
1653 Representation to = instr->to();
1654 if (from.IsTagged()) {
1655 if (to.IsDouble()) {
1656 LOperand* value = UseRegister(instr->value());
ulan@chromium.org812308e2012-02-29 15:58:45 +00001657 LNumberUntagD* res = new(zone()) LNumberUntagD(value);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001658 return AssignEnvironment(DefineAsRegister(res));
1659 } else {
1660 ASSERT(to.IsInteger32());
danno@chromium.orgfa458e42012-02-01 10:48:36 +00001661 LOperand* value = UseRegisterAtStart(instr->value());
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001662 bool needs_check = !instr->value()->type().IsSmi();
1663 LInstruction* res = NULL;
1664 if (!needs_check) {
ulan@chromium.org812308e2012-02-29 15:58:45 +00001665 res = DefineAsRegister(new(zone()) LSmiUntag(value, needs_check));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001666 } else {
1667 LOperand* temp1 = TempRegister();
1668 LOperand* temp2 = instr->CanTruncateToInt32() ? TempRegister()
1669 : NULL;
1670 LOperand* temp3 = instr->CanTruncateToInt32() ? FixedTemp(f22)
1671 : NULL;
ulan@chromium.org812308e2012-02-29 15:58:45 +00001672 res = DefineSameAsFirst(new(zone()) LTaggedToI(value,
1673 temp1,
1674 temp2,
1675 temp3));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001676 res = AssignEnvironment(res);
1677 }
1678 return res;
1679 }
1680 } else if (from.IsDouble()) {
1681 if (to.IsTagged()) {
1682 LOperand* value = UseRegister(instr->value());
1683 LOperand* temp1 = TempRegister();
1684 LOperand* temp2 = TempRegister();
1685
1686 // Make sure that the temp and result_temp registers are
1687 // different.
1688 LUnallocated* result_temp = TempRegister();
ulan@chromium.org812308e2012-02-29 15:58:45 +00001689 LNumberTagD* result = new(zone()) LNumberTagD(value, temp1, temp2);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001690 Define(result, result_temp);
1691 return AssignPointerMap(result);
1692 } else {
1693 ASSERT(to.IsInteger32());
1694 LOperand* value = UseRegister(instr->value());
ulan@chromium.org812308e2012-02-29 15:58:45 +00001695 LOperand* temp1 = TempRegister();
1696 LOperand* temp2 = instr->CanTruncateToInt32() ? TempRegister() : NULL;
1697 LDoubleToI* res = new(zone()) LDoubleToI(value, temp1, temp2);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001698 return AssignEnvironment(DefineAsRegister(res));
1699 }
1700 } else if (from.IsInteger32()) {
1701 if (to.IsTagged()) {
1702 HValue* val = instr->value();
danno@chromium.orgfa458e42012-02-01 10:48:36 +00001703 LOperand* value = UseRegisterAtStart(val);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001704 if (val->HasRange() && val->range()->IsInSmiRange()) {
ulan@chromium.org812308e2012-02-29 15:58:45 +00001705 return DefineAsRegister(new(zone()) LSmiTag(value));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001706 } else {
ulan@chromium.org812308e2012-02-29 15:58:45 +00001707 LNumberTagI* result = new(zone()) LNumberTagI(value);
danno@chromium.orgfa458e42012-02-01 10:48:36 +00001708 return AssignEnvironment(AssignPointerMap(DefineAsRegister(result)));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001709 }
1710 } else {
1711 ASSERT(to.IsDouble());
1712 LOperand* value = Use(instr->value());
ulan@chromium.org812308e2012-02-29 15:58:45 +00001713 return DefineAsRegister(new(zone()) LInteger32ToDouble(value));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001714 }
1715 }
1716 UNREACHABLE();
1717 return NULL;
1718}
1719
1720
1721LInstruction* LChunkBuilder::DoCheckNonSmi(HCheckNonSmi* instr) {
1722 LOperand* value = UseRegisterAtStart(instr->value());
ulan@chromium.org812308e2012-02-29 15:58:45 +00001723 return AssignEnvironment(new(zone()) LCheckNonSmi(value));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001724}
1725
1726
1727LInstruction* LChunkBuilder::DoCheckInstanceType(HCheckInstanceType* instr) {
1728 LOperand* value = UseRegisterAtStart(instr->value());
ulan@chromium.org812308e2012-02-29 15:58:45 +00001729 LInstruction* result = new(zone()) LCheckInstanceType(value);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001730 return AssignEnvironment(result);
1731}
1732
1733
1734LInstruction* LChunkBuilder::DoCheckPrototypeMaps(HCheckPrototypeMaps* instr) {
1735 LOperand* temp1 = TempRegister();
1736 LOperand* temp2 = TempRegister();
ulan@chromium.org812308e2012-02-29 15:58:45 +00001737 LInstruction* result = new(zone()) LCheckPrototypeMaps(temp1, temp2);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001738 return AssignEnvironment(result);
1739}
1740
1741
1742LInstruction* LChunkBuilder::DoCheckSmi(HCheckSmi* instr) {
1743 LOperand* value = UseRegisterAtStart(instr->value());
ulan@chromium.org812308e2012-02-29 15:58:45 +00001744 return AssignEnvironment(new(zone()) LCheckSmi(value));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001745}
1746
1747
1748LInstruction* LChunkBuilder::DoCheckFunction(HCheckFunction* instr) {
1749 LOperand* value = UseRegisterAtStart(instr->value());
ulan@chromium.org812308e2012-02-29 15:58:45 +00001750 return AssignEnvironment(new(zone()) LCheckFunction(value));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001751}
1752
1753
jkummerow@chromium.org1456e702012-03-30 08:38:13 +00001754LInstruction* LChunkBuilder::DoCheckMaps(HCheckMaps* instr) {
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001755 LOperand* value = UseRegisterAtStart(instr->value());
jkummerow@chromium.org1456e702012-03-30 08:38:13 +00001756 LInstruction* result = new(zone()) LCheckMaps(value);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001757 return AssignEnvironment(result);
1758}
1759
1760
1761LInstruction* LChunkBuilder::DoClampToUint8(HClampToUint8* instr) {
1762 HValue* value = instr->value();
1763 Representation input_rep = value->representation();
1764 LOperand* reg = UseRegister(value);
1765 if (input_rep.IsDouble()) {
1766 // Revisit this decision, here and 8 lines below.
ulan@chromium.org812308e2012-02-29 15:58:45 +00001767 return DefineAsRegister(new(zone()) LClampDToUint8(reg, FixedTemp(f22)));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001768 } else if (input_rep.IsInteger32()) {
ulan@chromium.org812308e2012-02-29 15:58:45 +00001769 return DefineAsRegister(new(zone()) LClampIToUint8(reg));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001770 } else {
1771 ASSERT(input_rep.IsTagged());
1772 // Register allocator doesn't (yet) support allocation of double
1773 // temps. Reserve f22 explicitly.
ulan@chromium.org812308e2012-02-29 15:58:45 +00001774 LClampTToUint8* result = new(zone()) LClampTToUint8(reg, FixedTemp(f22));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001775 return AssignEnvironment(DefineAsRegister(result));
1776 }
1777}
1778
1779
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001780LInstruction* LChunkBuilder::DoReturn(HReturn* instr) {
ulan@chromium.org812308e2012-02-29 15:58:45 +00001781 return new(zone()) LReturn(UseFixed(instr->value(), v0));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001782}
1783
1784
1785LInstruction* LChunkBuilder::DoConstant(HConstant* instr) {
1786 Representation r = instr->representation();
1787 if (r.IsInteger32()) {
ulan@chromium.org812308e2012-02-29 15:58:45 +00001788 return DefineAsRegister(new(zone()) LConstantI);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001789 } else if (r.IsDouble()) {
ulan@chromium.org812308e2012-02-29 15:58:45 +00001790 return DefineAsRegister(new(zone()) LConstantD);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001791 } else if (r.IsTagged()) {
ulan@chromium.org812308e2012-02-29 15:58:45 +00001792 return DefineAsRegister(new(zone()) LConstantT);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001793 } else {
1794 UNREACHABLE();
1795 return NULL;
1796 }
1797}
1798
1799
1800LInstruction* LChunkBuilder::DoLoadGlobalCell(HLoadGlobalCell* instr) {
ulan@chromium.org812308e2012-02-29 15:58:45 +00001801 LLoadGlobalCell* result = new(zone()) LLoadGlobalCell;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001802 return instr->RequiresHoleCheck()
1803 ? AssignEnvironment(DefineAsRegister(result))
1804 : DefineAsRegister(result);
1805}
1806
1807
1808LInstruction* LChunkBuilder::DoLoadGlobalGeneric(HLoadGlobalGeneric* instr) {
1809 LOperand* global_object = UseFixed(instr->global_object(), a0);
ulan@chromium.org812308e2012-02-29 15:58:45 +00001810 LLoadGlobalGeneric* result = new(zone()) LLoadGlobalGeneric(global_object);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001811 return MarkAsCall(DefineFixed(result, v0), instr);
1812}
1813
1814
1815LInstruction* LChunkBuilder::DoStoreGlobalCell(HStoreGlobalCell* instr) {
danno@chromium.orge78f9fc2011-12-21 08:29:34 +00001816 LOperand* value = UseRegister(instr->value());
1817 // Use a temp to check the value in the cell in the case where we perform
1818 // a hole check.
1819 return instr->RequiresHoleCheck()
ulan@chromium.org812308e2012-02-29 15:58:45 +00001820 ? AssignEnvironment(new(zone()) LStoreGlobalCell(value, TempRegister()))
1821 : new(zone()) LStoreGlobalCell(value, NULL);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001822}
1823
1824
1825LInstruction* LChunkBuilder::DoStoreGlobalGeneric(HStoreGlobalGeneric* instr) {
1826 LOperand* global_object = UseFixed(instr->global_object(), a1);
1827 LOperand* value = UseFixed(instr->value(), a0);
1828 LStoreGlobalGeneric* result =
ulan@chromium.org812308e2012-02-29 15:58:45 +00001829 new(zone()) LStoreGlobalGeneric(global_object, value);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001830 return MarkAsCall(result, instr);
1831}
1832
1833
1834LInstruction* LChunkBuilder::DoLoadContextSlot(HLoadContextSlot* instr) {
1835 LOperand* context = UseRegisterAtStart(instr->value());
ulan@chromium.org812308e2012-02-29 15:58:45 +00001836 LInstruction* result =
1837 DefineAsRegister(new(zone()) LLoadContextSlot(context));
ricow@chromium.org64e3a4b2011-12-13 08:07:27 +00001838 return instr->RequiresHoleCheck() ? AssignEnvironment(result) : result;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001839}
1840
1841
1842LInstruction* LChunkBuilder::DoStoreContextSlot(HStoreContextSlot* instr) {
1843 LOperand* context;
1844 LOperand* value;
1845 if (instr->NeedsWriteBarrier()) {
1846 context = UseTempRegister(instr->context());
1847 value = UseTempRegister(instr->value());
1848 } else {
1849 context = UseRegister(instr->context());
1850 value = UseRegister(instr->value());
1851 }
ulan@chromium.org812308e2012-02-29 15:58:45 +00001852 LInstruction* result = new(zone()) LStoreContextSlot(context, value);
ricow@chromium.org64e3a4b2011-12-13 08:07:27 +00001853 return instr->RequiresHoleCheck() ? AssignEnvironment(result) : result;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001854}
1855
1856
1857LInstruction* LChunkBuilder::DoLoadNamedField(HLoadNamedField* instr) {
1858 return DefineAsRegister(
ulan@chromium.org812308e2012-02-29 15:58:45 +00001859 new(zone()) LLoadNamedField(UseRegisterAtStart(instr->object())));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001860}
1861
1862
1863LInstruction* LChunkBuilder::DoLoadNamedFieldPolymorphic(
1864 HLoadNamedFieldPolymorphic* instr) {
1865 ASSERT(instr->representation().IsTagged());
1866 if (instr->need_generic()) {
1867 LOperand* obj = UseFixed(instr->object(), a0);
ulan@chromium.org812308e2012-02-29 15:58:45 +00001868 LLoadNamedFieldPolymorphic* result =
1869 new(zone()) LLoadNamedFieldPolymorphic(obj);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001870 return MarkAsCall(DefineFixed(result, v0), instr);
1871 } else {
1872 LOperand* obj = UseRegisterAtStart(instr->object());
ulan@chromium.org812308e2012-02-29 15:58:45 +00001873 LLoadNamedFieldPolymorphic* result =
1874 new(zone()) LLoadNamedFieldPolymorphic(obj);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001875 return AssignEnvironment(DefineAsRegister(result));
1876 }
1877}
1878
1879
1880LInstruction* LChunkBuilder::DoLoadNamedGeneric(HLoadNamedGeneric* instr) {
1881 LOperand* object = UseFixed(instr->object(), a0);
ulan@chromium.org812308e2012-02-29 15:58:45 +00001882 LInstruction* result = DefineFixed(new(zone()) LLoadNamedGeneric(object), v0);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001883 return MarkAsCall(result, instr);
1884}
1885
1886
1887LInstruction* LChunkBuilder::DoLoadFunctionPrototype(
1888 HLoadFunctionPrototype* instr) {
1889 return AssignEnvironment(DefineAsRegister(
ulan@chromium.org812308e2012-02-29 15:58:45 +00001890 new(zone()) LLoadFunctionPrototype(UseRegister(instr->function()))));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001891}
1892
1893
1894LInstruction* LChunkBuilder::DoLoadElements(HLoadElements* instr) {
1895 LOperand* input = UseRegisterAtStart(instr->value());
ulan@chromium.org812308e2012-02-29 15:58:45 +00001896 return DefineAsRegister(new(zone()) LLoadElements(input));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001897}
1898
1899
1900LInstruction* LChunkBuilder::DoLoadExternalArrayPointer(
1901 HLoadExternalArrayPointer* instr) {
1902 LOperand* input = UseRegisterAtStart(instr->value());
ulan@chromium.org812308e2012-02-29 15:58:45 +00001903 return DefineAsRegister(new(zone()) LLoadExternalArrayPointer(input));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001904}
1905
1906
1907LInstruction* LChunkBuilder::DoLoadKeyedFastElement(
1908 HLoadKeyedFastElement* instr) {
1909 ASSERT(instr->representation().IsTagged());
1910 ASSERT(instr->key()->representation().IsInteger32());
1911 LOperand* obj = UseRegisterAtStart(instr->object());
1912 LOperand* key = UseRegisterAtStart(instr->key());
ulan@chromium.org812308e2012-02-29 15:58:45 +00001913 LLoadKeyedFastElement* result = new(zone()) LLoadKeyedFastElement(obj, key);
erik.corry@gmail.comf2038fb2012-01-16 11:42:08 +00001914 if (instr->RequiresHoleCheck()) AssignEnvironment(result);
1915 return DefineAsRegister(result);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001916}
1917
1918
1919LInstruction* LChunkBuilder::DoLoadKeyedFastDoubleElement(
1920 HLoadKeyedFastDoubleElement* instr) {
1921 ASSERT(instr->representation().IsDouble());
1922 ASSERT(instr->key()->representation().IsInteger32());
1923 LOperand* elements = UseTempRegister(instr->elements());
1924 LOperand* key = UseRegisterOrConstantAtStart(instr->key());
1925 LLoadKeyedFastDoubleElement* result =
ulan@chromium.org812308e2012-02-29 15:58:45 +00001926 new(zone()) LLoadKeyedFastDoubleElement(elements, key);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001927 return AssignEnvironment(DefineAsRegister(result));
1928}
1929
1930
1931LInstruction* LChunkBuilder::DoLoadKeyedSpecializedArrayElement(
1932 HLoadKeyedSpecializedArrayElement* instr) {
1933 ElementsKind elements_kind = instr->elements_kind();
1934 Representation representation(instr->representation());
1935 ASSERT(
1936 (representation.IsInteger32() &&
1937 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) &&
1938 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) ||
1939 (representation.IsDouble() &&
1940 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) ||
1941 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS))));
1942 ASSERT(instr->key()->representation().IsInteger32());
1943 LOperand* external_pointer = UseRegister(instr->external_pointer());
1944 LOperand* key = UseRegisterOrConstant(instr->key());
1945 LLoadKeyedSpecializedArrayElement* result =
ulan@chromium.org812308e2012-02-29 15:58:45 +00001946 new(zone()) LLoadKeyedSpecializedArrayElement(external_pointer, key);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001947 LInstruction* load_instr = DefineAsRegister(result);
1948 // An unsigned int array load might overflow and cause a deopt, make sure it
1949 // has an environment.
1950 return (elements_kind == EXTERNAL_UNSIGNED_INT_ELEMENTS) ?
1951 AssignEnvironment(load_instr) : load_instr;
1952}
1953
1954
1955LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) {
1956 LOperand* object = UseFixed(instr->object(), a1);
1957 LOperand* key = UseFixed(instr->key(), a0);
1958
1959 LInstruction* result =
ulan@chromium.org812308e2012-02-29 15:58:45 +00001960 DefineFixed(new(zone()) LLoadKeyedGeneric(object, key), v0);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001961 return MarkAsCall(result, instr);
1962}
1963
1964
1965LInstruction* LChunkBuilder::DoStoreKeyedFastElement(
1966 HStoreKeyedFastElement* instr) {
1967 bool needs_write_barrier = instr->NeedsWriteBarrier();
1968 ASSERT(instr->value()->representation().IsTagged());
1969 ASSERT(instr->object()->representation().IsTagged());
1970 ASSERT(instr->key()->representation().IsInteger32());
1971
1972 LOperand* obj = UseTempRegister(instr->object());
1973 LOperand* val = needs_write_barrier
1974 ? UseTempRegister(instr->value())
1975 : UseRegisterAtStart(instr->value());
1976 LOperand* key = needs_write_barrier
1977 ? UseTempRegister(instr->key())
1978 : UseRegisterOrConstantAtStart(instr->key());
ulan@chromium.org812308e2012-02-29 15:58:45 +00001979 return new(zone()) LStoreKeyedFastElement(obj, key, val);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001980}
1981
1982
1983LInstruction* LChunkBuilder::DoStoreKeyedFastDoubleElement(
1984 HStoreKeyedFastDoubleElement* instr) {
1985 ASSERT(instr->value()->representation().IsDouble());
1986 ASSERT(instr->elements()->representation().IsTagged());
1987 ASSERT(instr->key()->representation().IsInteger32());
1988
1989 LOperand* elements = UseRegisterAtStart(instr->elements());
1990 LOperand* val = UseTempRegister(instr->value());
1991 LOperand* key = UseRegisterOrConstantAtStart(instr->key());
1992
ulan@chromium.org812308e2012-02-29 15:58:45 +00001993 return new(zone()) LStoreKeyedFastDoubleElement(elements, key, val);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00001994}
1995
1996
1997LInstruction* LChunkBuilder::DoStoreKeyedSpecializedArrayElement(
1998 HStoreKeyedSpecializedArrayElement* instr) {
1999 Representation representation(instr->value()->representation());
2000 ElementsKind elements_kind = instr->elements_kind();
2001 ASSERT(
2002 (representation.IsInteger32() &&
2003 (elements_kind != EXTERNAL_FLOAT_ELEMENTS) &&
2004 (elements_kind != EXTERNAL_DOUBLE_ELEMENTS)) ||
2005 (representation.IsDouble() &&
2006 ((elements_kind == EXTERNAL_FLOAT_ELEMENTS) ||
2007 (elements_kind == EXTERNAL_DOUBLE_ELEMENTS))));
2008 ASSERT(instr->external_pointer()->representation().IsExternal());
2009 ASSERT(instr->key()->representation().IsInteger32());
2010
2011 LOperand* external_pointer = UseRegister(instr->external_pointer());
2012 bool val_is_temp_register =
2013 elements_kind == EXTERNAL_PIXEL_ELEMENTS ||
2014 elements_kind == EXTERNAL_FLOAT_ELEMENTS;
2015 LOperand* val = val_is_temp_register
2016 ? UseTempRegister(instr->value())
2017 : UseRegister(instr->value());
2018 LOperand* key = UseRegisterOrConstant(instr->key());
2019
ulan@chromium.org812308e2012-02-29 15:58:45 +00002020 return new(zone()) LStoreKeyedSpecializedArrayElement(external_pointer,
2021 key,
2022 val);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002023}
2024
2025
2026LInstruction* LChunkBuilder::DoStoreKeyedGeneric(HStoreKeyedGeneric* instr) {
2027 LOperand* obj = UseFixed(instr->object(), a2);
2028 LOperand* key = UseFixed(instr->key(), a1);
2029 LOperand* val = UseFixed(instr->value(), a0);
2030
2031 ASSERT(instr->object()->representation().IsTagged());
2032 ASSERT(instr->key()->representation().IsTagged());
2033 ASSERT(instr->value()->representation().IsTagged());
2034
ulan@chromium.org812308e2012-02-29 15:58:45 +00002035 return MarkAsCall(new(zone()) LStoreKeyedGeneric(obj, key, val), instr);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002036}
2037
2038
2039LInstruction* LChunkBuilder::DoTransitionElementsKind(
2040 HTransitionElementsKind* instr) {
2041 if (instr->original_map()->elements_kind() == FAST_SMI_ONLY_ELEMENTS &&
2042 instr->transitioned_map()->elements_kind() == FAST_ELEMENTS) {
2043 LOperand* object = UseRegister(instr->object());
2044 LOperand* new_map_reg = TempRegister();
2045 LTransitionElementsKind* result =
ulan@chromium.org812308e2012-02-29 15:58:45 +00002046 new(zone()) LTransitionElementsKind(object, new_map_reg, NULL);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002047 return DefineSameAsFirst(result);
2048 } else {
2049 LOperand* object = UseFixed(instr->object(), a0);
2050 LOperand* fixed_object_reg = FixedTemp(a2);
2051 LOperand* new_map_reg = FixedTemp(a3);
2052 LTransitionElementsKind* result =
ulan@chromium.org812308e2012-02-29 15:58:45 +00002053 new(zone()) LTransitionElementsKind(object,
2054 new_map_reg,
2055 fixed_object_reg);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002056 return MarkAsCall(DefineFixed(result, v0), instr);
2057 }
2058}
2059
2060
2061LInstruction* LChunkBuilder::DoStoreNamedField(HStoreNamedField* instr) {
2062 bool needs_write_barrier = instr->NeedsWriteBarrier();
2063
2064 LOperand* obj = needs_write_barrier
2065 ? UseTempRegister(instr->object())
2066 : UseRegisterAtStart(instr->object());
2067
2068 LOperand* val = needs_write_barrier
2069 ? UseTempRegister(instr->value())
2070 : UseRegister(instr->value());
2071
ulan@chromium.org812308e2012-02-29 15:58:45 +00002072 return new(zone()) LStoreNamedField(obj, val);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002073}
2074
2075
2076LInstruction* LChunkBuilder::DoStoreNamedGeneric(HStoreNamedGeneric* instr) {
2077 LOperand* obj = UseFixed(instr->object(), a1);
2078 LOperand* val = UseFixed(instr->value(), a0);
2079
ulan@chromium.org812308e2012-02-29 15:58:45 +00002080 LInstruction* result = new(zone()) LStoreNamedGeneric(obj, val);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002081 return MarkAsCall(result, instr);
2082}
2083
2084
2085LInstruction* LChunkBuilder::DoStringAdd(HStringAdd* instr) {
2086 LOperand* left = UseRegisterAtStart(instr->left());
2087 LOperand* right = UseRegisterAtStart(instr->right());
ulan@chromium.org812308e2012-02-29 15:58:45 +00002088 return MarkAsCall(DefineFixed(new(zone()) LStringAdd(left, right), v0),
2089 instr);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002090}
2091
2092
2093LInstruction* LChunkBuilder::DoStringCharCodeAt(HStringCharCodeAt* instr) {
2094 LOperand* string = UseTempRegister(instr->string());
2095 LOperand* index = UseTempRegister(instr->index());
ulan@chromium.org812308e2012-02-29 15:58:45 +00002096 LStringCharCodeAt* result = new(zone()) LStringCharCodeAt(string, index);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002097 return AssignEnvironment(AssignPointerMap(DefineAsRegister(result)));
2098}
2099
2100
2101LInstruction* LChunkBuilder::DoStringCharFromCode(HStringCharFromCode* instr) {
2102 LOperand* char_code = UseRegister(instr->value());
ulan@chromium.org812308e2012-02-29 15:58:45 +00002103 LStringCharFromCode* result = new(zone()) LStringCharFromCode(char_code);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002104 return AssignPointerMap(DefineAsRegister(result));
2105}
2106
2107
2108LInstruction* LChunkBuilder::DoStringLength(HStringLength* instr) {
2109 LOperand* string = UseRegisterAtStart(instr->value());
ulan@chromium.org812308e2012-02-29 15:58:45 +00002110 return DefineAsRegister(new(zone()) LStringLength(string));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002111}
2112
2113
ulan@chromium.org967e2702012-02-28 09:49:15 +00002114LInstruction* LChunkBuilder::DoAllocateObject(HAllocateObject* instr) {
fschneider@chromium.org35814e52012-03-01 15:43:35 +00002115 LAllocateObject* result = new(zone()) LAllocateObject(
2116 TempRegister(), TempRegister());
ulan@chromium.org967e2702012-02-28 09:49:15 +00002117 return AssignPointerMap(DefineAsRegister(result));
2118}
2119
2120
jkummerow@chromium.orgf7a58842012-02-21 10:08:21 +00002121LInstruction* LChunkBuilder::DoFastLiteral(HFastLiteral* instr) {
ulan@chromium.org812308e2012-02-29 15:58:45 +00002122 return MarkAsCall(DefineFixed(new(zone()) LFastLiteral, v0), instr);
jkummerow@chromium.orgf7a58842012-02-21 10:08:21 +00002123}
2124
2125
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002126LInstruction* LChunkBuilder::DoArrayLiteral(HArrayLiteral* instr) {
ulan@chromium.org812308e2012-02-29 15:58:45 +00002127 return MarkAsCall(DefineFixed(new(zone()) LArrayLiteral, v0), instr);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002128}
2129
2130
jkummerow@chromium.orgf7a58842012-02-21 10:08:21 +00002131LInstruction* LChunkBuilder::DoObjectLiteral(HObjectLiteral* instr) {
ulan@chromium.org812308e2012-02-29 15:58:45 +00002132 return MarkAsCall(DefineFixed(new(zone()) LObjectLiteral, v0), instr);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002133}
2134
2135
2136LInstruction* LChunkBuilder::DoRegExpLiteral(HRegExpLiteral* instr) {
ulan@chromium.org812308e2012-02-29 15:58:45 +00002137 return MarkAsCall(DefineFixed(new(zone()) LRegExpLiteral, v0), instr);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002138}
2139
2140
2141LInstruction* LChunkBuilder::DoFunctionLiteral(HFunctionLiteral* instr) {
ulan@chromium.org812308e2012-02-29 15:58:45 +00002142 return MarkAsCall(DefineFixed(new(zone()) LFunctionLiteral, v0), instr);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002143}
2144
2145
2146LInstruction* LChunkBuilder::DoDeleteProperty(HDeleteProperty* instr) {
2147 LOperand* object = UseFixed(instr->object(), a0);
2148 LOperand* key = UseFixed(instr->key(), a1);
ulan@chromium.org812308e2012-02-29 15:58:45 +00002149 LDeleteProperty* result = new(zone()) LDeleteProperty(object, key);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002150 return MarkAsCall(DefineFixed(result, v0), instr);
2151}
2152
2153
2154LInstruction* LChunkBuilder::DoOsrEntry(HOsrEntry* instr) {
2155 allocator_->MarkAsOsrEntry();
2156 current_block_->last_environment()->set_ast_id(instr->ast_id());
ulan@chromium.org812308e2012-02-29 15:58:45 +00002157 return AssignEnvironment(new(zone()) LOsrEntry);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002158}
2159
2160
2161LInstruction* LChunkBuilder::DoParameter(HParameter* instr) {
2162 int spill_index = chunk()->GetParameterStackSlot(instr->index());
ulan@chromium.org812308e2012-02-29 15:58:45 +00002163 return DefineAsSpilled(new(zone()) LParameter, spill_index);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002164}
2165
2166
2167LInstruction* LChunkBuilder::DoUnknownOSRValue(HUnknownOSRValue* instr) {
2168 int spill_index = chunk()->GetNextSpillIndex(false); // Not double-width.
2169 if (spill_index > LUnallocated::kMaxFixedIndex) {
2170 Abort("Too many spill slots needed for OSR");
2171 spill_index = 0;
2172 }
ulan@chromium.org812308e2012-02-29 15:58:45 +00002173 return DefineAsSpilled(new(zone()) LUnknownOSRValue, spill_index);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002174}
2175
2176
2177LInstruction* LChunkBuilder::DoCallStub(HCallStub* instr) {
2178 argument_count_ -= instr->argument_count();
ulan@chromium.org812308e2012-02-29 15:58:45 +00002179 return MarkAsCall(DefineFixed(new(zone()) LCallStub, v0), instr);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002180}
2181
2182
2183LInstruction* LChunkBuilder::DoArgumentsObject(HArgumentsObject* instr) {
2184 // There are no real uses of the arguments object.
2185 // arguments.length and element access are supported directly on
2186 // stack arguments, and any real arguments object use causes a bailout.
2187 // So this value is never used.
2188 return NULL;
2189}
2190
2191
2192LInstruction* LChunkBuilder::DoAccessArgumentsAt(HAccessArgumentsAt* instr) {
2193 LOperand* arguments = UseRegister(instr->arguments());
2194 LOperand* length = UseTempRegister(instr->length());
2195 LOperand* index = UseRegister(instr->index());
ulan@chromium.org812308e2012-02-29 15:58:45 +00002196 LAccessArgumentsAt* result =
2197 new(zone()) LAccessArgumentsAt(arguments, length, index);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002198 return AssignEnvironment(DefineAsRegister(result));
2199}
2200
2201
2202LInstruction* LChunkBuilder::DoToFastProperties(HToFastProperties* instr) {
2203 LOperand* object = UseFixed(instr->value(), a0);
ulan@chromium.org812308e2012-02-29 15:58:45 +00002204 LToFastProperties* result = new(zone()) LToFastProperties(object);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002205 return MarkAsCall(DefineFixed(result, v0), instr);
2206}
2207
2208
2209LInstruction* LChunkBuilder::DoTypeof(HTypeof* instr) {
ulan@chromium.org812308e2012-02-29 15:58:45 +00002210 LTypeof* result = new(zone()) LTypeof(UseFixed(instr->value(), a0));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002211 return MarkAsCall(DefineFixed(result, v0), instr);
2212}
2213
2214
2215LInstruction* LChunkBuilder::DoTypeofIsAndBranch(HTypeofIsAndBranch* instr) {
ulan@chromium.org812308e2012-02-29 15:58:45 +00002216 return new(zone()) LTypeofIsAndBranch(UseTempRegister(instr->value()));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002217}
2218
2219
2220LInstruction* LChunkBuilder::DoIsConstructCallAndBranch(
2221 HIsConstructCallAndBranch* instr) {
ulan@chromium.org812308e2012-02-29 15:58:45 +00002222 return new(zone()) LIsConstructCallAndBranch(TempRegister());
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002223}
2224
2225
2226LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) {
2227 HEnvironment* env = current_block_->last_environment();
2228 ASSERT(env != NULL);
2229
2230 env->set_ast_id(instr->ast_id());
2231
2232 env->Drop(instr->pop_count());
2233 for (int i = 0; i < instr->values()->length(); ++i) {
2234 HValue* value = instr->values()->at(i);
2235 if (instr->HasAssignedIndexAt(i)) {
2236 env->Bind(instr->GetAssignedIndexAt(i), value);
2237 } else {
2238 env->Push(value);
2239 }
2240 }
2241
2242 // If there is an instruction pending deoptimization environment create a
2243 // lazy bailout instruction to capture the environment.
2244 if (pending_deoptimization_ast_id_ == instr->ast_id()) {
ulan@chromium.org812308e2012-02-29 15:58:45 +00002245 LInstruction* result = new(zone()) LLazyBailout;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002246 result = AssignEnvironment(result);
2247 instruction_pending_deoptimization_environment_->
2248 set_deoptimization_environment(result->environment());
2249 ClearInstructionPendingDeoptimizationEnvironment();
2250 return result;
2251 }
2252
2253 return NULL;
2254}
2255
2256
2257LInstruction* LChunkBuilder::DoStackCheck(HStackCheck* instr) {
2258 if (instr->is_function_entry()) {
ulan@chromium.org812308e2012-02-29 15:58:45 +00002259 return MarkAsCall(new(zone()) LStackCheck, instr);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002260 } else {
2261 ASSERT(instr->is_backwards_branch());
ulan@chromium.org812308e2012-02-29 15:58:45 +00002262 return AssignEnvironment(AssignPointerMap(new(zone()) LStackCheck));
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002263 }
2264}
2265
2266
2267LInstruction* LChunkBuilder::DoEnterInlined(HEnterInlined* instr) {
2268 HEnvironment* outer = current_block_->last_environment();
2269 HConstant* undefined = graph()->GetConstantUndefined();
2270 HEnvironment* inner = outer->CopyForInlining(instr->closure(),
danno@chromium.orgfa458e42012-02-01 10:48:36 +00002271 instr->arguments_count(),
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002272 instr->function(),
2273 undefined,
ulan@chromium.org812308e2012-02-29 15:58:45 +00002274 instr->call_kind(),
2275 instr->is_construct());
jkummerow@chromium.org28faa982012-04-13 09:58:30 +00002276 if (instr->arguments_var() != NULL) {
2277 inner->Bind(instr->arguments_var(), graph()->GetArgumentsObject());
danno@chromium.org8c0a43f2012-04-03 08:37:53 +00002278 }
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002279 current_block_->UpdateEnvironment(inner);
2280 chunk_->AddInlinedClosure(instr->closure());
2281 return NULL;
2282}
2283
2284
2285LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) {
jkummerow@chromium.org28faa982012-04-13 09:58:30 +00002286 LInstruction* pop = NULL;
2287
2288 HEnvironment* env = current_block_->last_environment();
2289
2290 if (instr->arguments_pushed()) {
2291 int argument_count = env->arguments_environment()->parameter_count();
2292 pop = new(zone()) LDrop(argument_count);
2293 argument_count_ -= argument_count;
2294 }
2295
danno@chromium.orgfa458e42012-02-01 10:48:36 +00002296 HEnvironment* outer = current_block_->last_environment()->
2297 DiscardInlined(false);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002298 current_block_->UpdateEnvironment(outer);
jkummerow@chromium.org28faa982012-04-13 09:58:30 +00002299
2300 return pop;
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002301}
2302
2303
2304LInstruction* LChunkBuilder::DoIn(HIn* instr) {
2305 LOperand* key = UseRegisterAtStart(instr->key());
2306 LOperand* object = UseRegisterAtStart(instr->object());
ulan@chromium.org812308e2012-02-29 15:58:45 +00002307 LIn* result = new(zone()) LIn(key, object);
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002308 return MarkAsCall(DefineFixed(result, v0), instr);
2309}
2310
2311
ulan@chromium.org812308e2012-02-29 15:58:45 +00002312LInstruction* LChunkBuilder::DoForInPrepareMap(HForInPrepareMap* instr) {
2313 LOperand* object = UseFixed(instr->enumerable(), a0);
fschneider@chromium.org35814e52012-03-01 15:43:35 +00002314 LForInPrepareMap* result = new(zone()) LForInPrepareMap(object);
ulan@chromium.org812308e2012-02-29 15:58:45 +00002315 return MarkAsCall(DefineFixed(result, v0), instr, CAN_DEOPTIMIZE_EAGERLY);
2316}
2317
2318
2319LInstruction* LChunkBuilder::DoForInCacheArray(HForInCacheArray* instr) {
2320 LOperand* map = UseRegister(instr->map());
2321 return AssignEnvironment(DefineAsRegister(
fschneider@chromium.org35814e52012-03-01 15:43:35 +00002322 new(zone()) LForInCacheArray(map)));
ulan@chromium.org812308e2012-02-29 15:58:45 +00002323}
2324
2325
2326LInstruction* LChunkBuilder::DoCheckMapValue(HCheckMapValue* instr) {
2327 LOperand* value = UseRegisterAtStart(instr->value());
2328 LOperand* map = UseRegisterAtStart(instr->map());
fschneider@chromium.org35814e52012-03-01 15:43:35 +00002329 return AssignEnvironment(new(zone()) LCheckMapValue(value, map));
ulan@chromium.org812308e2012-02-29 15:58:45 +00002330}
2331
2332
2333LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) {
2334 LOperand* object = UseRegister(instr->object());
2335 LOperand* index = UseRegister(instr->index());
fschneider@chromium.org35814e52012-03-01 15:43:35 +00002336 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index));
ulan@chromium.org812308e2012-02-29 15:58:45 +00002337}
2338
2339
jkummerow@chromium.orgc3b37122011-11-07 10:14:12 +00002340} } // namespace v8::internal