Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(73)

Side by Side Diff: src/arm/lithium-arm.cc

Issue 6250027: Port lithium template classes to ARM.... (Closed) Base URL: http://v8.googlecode.com/svn/branches/bleeding_edge/
Patch Set: '' Created 9 years, 11 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
« no previous file with comments | « src/arm/lithium-arm.h ('k') | src/arm/lithium-codegen-arm.h » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2011 the V8 project authors. All rights reserved. 1 // Copyright 2011 the V8 project authors. All rights reserved.
2 // Redistribution and use in source and binary forms, with or without 2 // Redistribution and use in source and binary forms, with or without
3 // modification, are permitted provided that the following conditions are 3 // modification, are permitted provided that the following conditions are
4 // met: 4 // met:
5 // 5 //
6 // * Redistributions of source code must retain the above copyright 6 // * Redistributions of source code must retain the above copyright
7 // notice, this list of conditions and the following disclaimer. 7 // notice, this list of conditions and the following disclaimer.
8 // * Redistributions in binary form must reproduce the above 8 // * Redistributions in binary form must reproduce the above
9 // copyright notice, this list of conditions and the following 9 // copyright notice, this list of conditions and the following
10 // disclaimer in the documentation and/or other materials provided 10 // disclaimer in the documentation and/or other materials provided
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
57 57
58 58
59 void LOsrEntry::MarkSpilledDoubleRegister(int allocation_index, 59 void LOsrEntry::MarkSpilledDoubleRegister(int allocation_index,
60 LOperand* spill_operand) { 60 LOperand* spill_operand) {
61 ASSERT(spill_operand->IsDoubleStackSlot()); 61 ASSERT(spill_operand->IsDoubleStackSlot());
62 ASSERT(double_register_spills_[allocation_index] == NULL); 62 ASSERT(double_register_spills_[allocation_index] == NULL);
63 double_register_spills_[allocation_index] = spill_operand; 63 double_register_spills_[allocation_index] = spill_operand;
64 } 64 }
65 65
66 66
67 void LInstruction::PrintTo(StringStream* stream) const { 67 void LInstruction::PrintTo(StringStream* stream) {
68 stream->Add("%s ", this->Mnemonic()); 68 stream->Add("%s ", this->Mnemonic());
69 if (HasResult()) { 69 if (HasResult()) {
70 result()->PrintTo(stream); 70 PrintOutputOperandTo(stream);
71 stream->Add(" ");
72 } 71 }
72
73 PrintDataTo(stream); 73 PrintDataTo(stream);
74 74
75 if (HasEnvironment()) { 75 if (HasEnvironment()) {
76 stream->Add(" "); 76 stream->Add(" ");
77 environment()->PrintTo(stream); 77 environment()->PrintTo(stream);
78 } 78 }
79 79
80 if (HasPointerMap()) { 80 if (HasPointerMap()) {
81 stream->Add(" "); 81 stream->Add(" ");
82 pointer_map()->PrintTo(stream); 82 pointer_map()->PrintTo(stream);
83 } 83 }
84 } 84 }
85 85
86 86
87 void LLabel::PrintDataTo(StringStream* stream) const { 87 template<int R, int I, int T>
88 void LTemplateInstruction<R, I, T>::PrintDataTo(StringStream* stream) {
89 stream->Add("= ");
90 inputs_.PrintOperandsTo(stream);
91 }
92
93
94 template<int R, int I, int T>
95 void LTemplateInstruction<R, I, T>::PrintOutputOperandTo(StringStream* stream) {
96 results_.PrintOperandsTo(stream);
97 }
98
99
100 template<typename T, int N>
101 void OperandContainer<T, N>::PrintOperandsTo(StringStream* stream) {
102 for (int i = 0; i < N; i++) {
103 if (i > 0) stream->Add(" ");
104 elems_[i]->PrintTo(stream);
105 }
106 }
107
108
109 void LLabel::PrintDataTo(StringStream* stream) {
88 LGap::PrintDataTo(stream); 110 LGap::PrintDataTo(stream);
89 LLabel* rep = replacement(); 111 LLabel* rep = replacement();
90 if (rep != NULL) { 112 if (rep != NULL) {
91 stream->Add(" Dead block replaced with B%d", rep->block_id()); 113 stream->Add(" Dead block replaced with B%d", rep->block_id());
92 } 114 }
93 } 115 }
94 116
95 117
96 bool LGap::IsRedundant() const { 118 bool LGap::IsRedundant() const {
97 for (int i = 0; i < 4; i++) { 119 for (int i = 0; i < 4; i++) {
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
136 case Token::MUL: return "mul-t"; 158 case Token::MUL: return "mul-t";
137 case Token::MOD: return "mod-t"; 159 case Token::MOD: return "mod-t";
138 case Token::DIV: return "div-t"; 160 case Token::DIV: return "div-t";
139 default: 161 default:
140 UNREACHABLE(); 162 UNREACHABLE();
141 return NULL; 163 return NULL;
142 } 164 }
143 } 165 }
144 166
145 167
146 168 void LGoto::PrintDataTo(StringStream* stream) {
147 void LBinaryOperation::PrintDataTo(StringStream* stream) const {
148 stream->Add("= ");
149 left()->PrintTo(stream);
150 stream->Add(" ");
151 right()->PrintTo(stream);
152 }
153
154
155 void LGoto::PrintDataTo(StringStream* stream) const {
156 stream->Add("B%d", block_id()); 169 stream->Add("B%d", block_id());
157 } 170 }
158 171
159 172
160 void LBranch::PrintDataTo(StringStream* stream) const { 173 void LBranch::PrintDataTo(StringStream* stream) {
161 stream->Add("B%d | B%d on ", true_block_id(), false_block_id()); 174 stream->Add("B%d | B%d on ", true_block_id(), false_block_id());
162 input()->PrintTo(stream); 175 InputAt(0)->PrintTo(stream);
163 } 176 }
164 177
165 178
166 void LCmpIDAndBranch::PrintDataTo(StringStream* stream) const { 179 void LCmpIDAndBranch::PrintDataTo(StringStream* stream) {
167 stream->Add("if "); 180 stream->Add("if ");
168 left()->PrintTo(stream); 181 InputAt(0)->PrintTo(stream);
169 stream->Add(" %s ", Token::String(op())); 182 stream->Add(" %s ", Token::String(op()));
170 right()->PrintTo(stream); 183 InputAt(1)->PrintTo(stream);
171 stream->Add(" then B%d else B%d", true_block_id(), false_block_id()); 184 stream->Add(" then B%d else B%d", true_block_id(), false_block_id());
172 } 185 }
173 186
174 187
175 void LIsNullAndBranch::PrintDataTo(StringStream* stream) const { 188 void LIsNullAndBranch::PrintDataTo(StringStream* stream) {
176 stream->Add("if "); 189 stream->Add("if ");
177 input()->PrintTo(stream); 190 InputAt(0)->PrintTo(stream);
178 stream->Add(is_strict() ? " === null" : " == null"); 191 stream->Add(is_strict() ? " === null" : " == null");
179 stream->Add(" then B%d else B%d", true_block_id(), false_block_id()); 192 stream->Add(" then B%d else B%d", true_block_id(), false_block_id());
180 } 193 }
181 194
182 195
183 void LIsObjectAndBranch::PrintDataTo(StringStream* stream) const { 196 void LIsObjectAndBranch::PrintDataTo(StringStream* stream) {
184 stream->Add("if is_object("); 197 stream->Add("if is_object(");
185 input()->PrintTo(stream); 198 InputAt(0)->PrintTo(stream);
186 stream->Add(") then B%d else B%d", true_block_id(), false_block_id()); 199 stream->Add(") then B%d else B%d", true_block_id(), false_block_id());
187 } 200 }
188 201
189 202
190 void LIsSmiAndBranch::PrintDataTo(StringStream* stream) const { 203 void LIsSmiAndBranch::PrintDataTo(StringStream* stream) {
191 stream->Add("if is_smi("); 204 stream->Add("if is_smi(");
192 input()->PrintTo(stream); 205 InputAt(0)->PrintTo(stream);
193 stream->Add(") then B%d else B%d", true_block_id(), false_block_id()); 206 stream->Add(") then B%d else B%d", true_block_id(), false_block_id());
194 } 207 }
195 208
196 209
197 void LHasInstanceTypeAndBranch::PrintDataTo(StringStream* stream) const { 210 void LHasInstanceTypeAndBranch::PrintDataTo(StringStream* stream) {
198 stream->Add("if has_instance_type("); 211 stream->Add("if has_instance_type(");
199 input()->PrintTo(stream); 212 InputAt(0)->PrintTo(stream);
200 stream->Add(") then B%d else B%d", true_block_id(), false_block_id()); 213 stream->Add(") then B%d else B%d", true_block_id(), false_block_id());
201 } 214 }
202 215
203 216
204 void LHasCachedArrayIndexAndBranch::PrintDataTo(StringStream* stream) const { 217 void LHasCachedArrayIndexAndBranch::PrintDataTo(StringStream* stream) {
205 stream->Add("if has_cached_array_index("); 218 stream->Add("if has_cached_array_index(");
206 input()->PrintTo(stream); 219 InputAt(0)->PrintTo(stream);
207 stream->Add(") then B%d else B%d", true_block_id(), false_block_id()); 220 stream->Add(") then B%d else B%d", true_block_id(), false_block_id());
208 } 221 }
209 222
210 223
211 void LClassOfTestAndBranch::PrintDataTo(StringStream* stream) const { 224 void LClassOfTestAndBranch::PrintDataTo(StringStream* stream) {
212 stream->Add("if class_of_test("); 225 stream->Add("if class_of_test(");
213 input()->PrintTo(stream); 226 InputAt(0)->PrintTo(stream);
214 stream->Add(", \"%o\") then B%d else B%d", 227 stream->Add(", \"%o\") then B%d else B%d",
215 *hydrogen()->class_name(), 228 *hydrogen()->class_name(),
216 true_block_id(), 229 true_block_id(),
217 false_block_id()); 230 false_block_id());
218 } 231 }
219 232
220 233
221 void LTypeofIs::PrintDataTo(StringStream* stream) const { 234 void LTypeofIs::PrintDataTo(StringStream* stream) {
222 input()->PrintTo(stream); 235 InputAt(0)->PrintTo(stream);
223 stream->Add(" == \"%s\"", *hydrogen()->type_literal()->ToCString()); 236 stream->Add(" == \"%s\"", *hydrogen()->type_literal()->ToCString());
224 } 237 }
225 238
226 239
227 void LTypeofIsAndBranch::PrintDataTo(StringStream* stream) const { 240 void LTypeofIsAndBranch::PrintDataTo(StringStream* stream) {
228 stream->Add("if typeof "); 241 stream->Add("if typeof ");
229 input()->PrintTo(stream); 242 InputAt(0)->PrintTo(stream);
230 stream->Add(" == \"%s\" then B%d else B%d", 243 stream->Add(" == \"%s\" then B%d else B%d",
231 *hydrogen()->type_literal()->ToCString(), 244 *hydrogen()->type_literal()->ToCString(),
232 true_block_id(), false_block_id()); 245 true_block_id(), false_block_id());
233 } 246 }
234 247
235 248
236 void LCallConstantFunction::PrintDataTo(StringStream* stream) const { 249 void LCallConstantFunction::PrintDataTo(StringStream* stream) {
237 stream->Add("#%d / ", arity()); 250 stream->Add("#%d / ", arity());
238 } 251 }
239 252
240 253
241 void LUnaryMathOperation::PrintDataTo(StringStream* stream) const { 254 void LUnaryMathOperation::PrintDataTo(StringStream* stream) {
242 stream->Add("/%s ", hydrogen()->OpName()); 255 stream->Add("/%s ", hydrogen()->OpName());
243 input()->PrintTo(stream); 256 InputAt(0)->PrintTo(stream);
244 } 257 }
245 258
246 259
247 void LLoadContextSlot::PrintDataTo(StringStream* stream) { 260 void LLoadContextSlot::PrintDataTo(StringStream* stream) {
248 stream->Add("(%d, %d)", context_chain_length(), slot_index()); 261 stream->Add("(%d, %d)", context_chain_length(), slot_index());
249 } 262 }
250 263
251 264
252 void LCallKeyed::PrintDataTo(StringStream* stream) const { 265 void LCallKeyed::PrintDataTo(StringStream* stream) {
253 stream->Add("[r2] #%d / ", arity()); 266 stream->Add("[r2] #%d / ", arity());
254 } 267 }
255 268
256 269
257 void LCallNamed::PrintDataTo(StringStream* stream) const { 270 void LCallNamed::PrintDataTo(StringStream* stream) {
258 SmartPointer<char> name_string = name()->ToCString(); 271 SmartPointer<char> name_string = name()->ToCString();
259 stream->Add("%s #%d / ", *name_string, arity()); 272 stream->Add("%s #%d / ", *name_string, arity());
260 } 273 }
261 274
262 275
263 void LCallGlobal::PrintDataTo(StringStream* stream) const { 276 void LCallGlobal::PrintDataTo(StringStream* stream) {
264 SmartPointer<char> name_string = name()->ToCString(); 277 SmartPointer<char> name_string = name()->ToCString();
265 stream->Add("%s #%d / ", *name_string, arity()); 278 stream->Add("%s #%d / ", *name_string, arity());
266 } 279 }
267 280
268 281
269 void LCallKnownGlobal::PrintDataTo(StringStream* stream) const { 282 void LCallKnownGlobal::PrintDataTo(StringStream* stream) {
270 stream->Add("#%d / ", arity()); 283 stream->Add("#%d / ", arity());
271 } 284 }
272 285
273 286
274 void LCallNew::PrintDataTo(StringStream* stream) const { 287 void LCallNew::PrintDataTo(StringStream* stream) {
275 LUnaryOperation::PrintDataTo(stream); 288 stream->Add("= ");
289 InputAt(0)->PrintTo(stream);
276 stream->Add(" #%d / ", arity()); 290 stream->Add(" #%d / ", arity());
277 } 291 }
278 292
279 293
280 void LClassOfTest::PrintDataTo(StringStream* stream) const { 294 void LClassOfTest::PrintDataTo(StringStream* stream) {
281 stream->Add("= class_of_test("); 295 stream->Add("= class_of_test(");
282 input()->PrintTo(stream); 296 InputAt(0)->PrintTo(stream);
283 stream->Add(", \"%o\")", *hydrogen()->class_name()); 297 stream->Add(", \"%o\")", *hydrogen()->class_name());
284 } 298 }
285 299
286 300
287 void LUnaryOperation::PrintDataTo(StringStream* stream) const { 301 void LAccessArgumentsAt::PrintDataTo(StringStream* stream) {
288 stream->Add("= ");
289 input()->PrintTo(stream);
290 }
291
292
293 void LAccessArgumentsAt::PrintDataTo(StringStream* stream) const {
294 arguments()->PrintTo(stream); 302 arguments()->PrintTo(stream);
295 303
296 stream->Add(" length "); 304 stream->Add(" length ");
297 length()->PrintTo(stream); 305 length()->PrintTo(stream);
298 306
299 stream->Add(" index "); 307 stream->Add(" index ");
300 index()->PrintTo(stream); 308 index()->PrintTo(stream);
301 } 309 }
302 310
303 311
312 void LStoreNamed::PrintDataTo(StringStream* stream) {
313 object()->PrintTo(stream);
314 stream->Add(".");
315 stream->Add(*String::cast(*name())->ToCString());
316 stream->Add(" <- ");
317 value()->PrintTo(stream);
318 }
319
320
321 void LStoreKeyed::PrintDataTo(StringStream* stream) {
322 object()->PrintTo(stream);
323 stream->Add("[");
324 key()->PrintTo(stream);
325 stream->Add("] <- ");
326 value()->PrintTo(stream);
327 }
328
329
304 LChunk::LChunk(HGraph* graph) 330 LChunk::LChunk(HGraph* graph)
305 : spill_slot_count_(0), 331 : spill_slot_count_(0),
306 graph_(graph), 332 graph_(graph),
307 instructions_(32), 333 instructions_(32),
308 pointer_maps_(8), 334 pointer_maps_(8),
309 inlined_closures_(1) { 335 inlined_closures_(1) {
310 } 336 }
311 337
312 338
313 void LChunk::Verify() const {
314 // TODO(twuerthinger): Implement verification for chunk.
315 }
316
317
318 int LChunk::GetNextSpillIndex(bool is_double) { 339 int LChunk::GetNextSpillIndex(bool is_double) {
319 // Skip a slot if for a double-width slot. 340 // Skip a slot if for a double-width slot.
320 if (is_double) spill_slot_count_++; 341 if (is_double) spill_slot_count_++;
321 return spill_slot_count_++; 342 return spill_slot_count_++;
322 } 343 }
323 344
324 345
325 LOperand* LChunk::GetNextSpillSlot(bool is_double) { 346 LOperand* LChunk::GetNextSpillSlot(bool is_double) {
326 int index = GetNextSpillIndex(is_double); 347 int index = GetNextSpillIndex(is_double);
327 if (is_double) { 348 if (is_double) {
(...skipping 34 matching lines...) Expand 10 before | Expand all | Expand 10 after
362 383
363 if (can_eliminate) { 384 if (can_eliminate) {
364 label->set_replacement(GetLabel(goto_instr->block_id())); 385 label->set_replacement(GetLabel(goto_instr->block_id()));
365 } 386 }
366 } 387 }
367 } 388 }
368 } 389 }
369 } 390 }
370 391
371 392
372 void LStoreNamed::PrintDataTo(StringStream* stream) const {
373 object()->PrintTo(stream);
374 stream->Add(".");
375 stream->Add(*String::cast(*name())->ToCString());
376 stream->Add(" <- ");
377 value()->PrintTo(stream);
378 }
379
380
381 void LStoreKeyed::PrintDataTo(StringStream* stream) const {
382 object()->PrintTo(stream);
383 stream->Add("[");
384 key()->PrintTo(stream);
385 stream->Add("] <- ");
386 value()->PrintTo(stream);
387 }
388
389
390 int LChunk::AddInstruction(LInstruction* instr, HBasicBlock* block) { 393 int LChunk::AddInstruction(LInstruction* instr, HBasicBlock* block) {
391 LGap* gap = new LGap(block); 394 LGap* gap = new LGap(block);
392 int index = -1; 395 int index = -1;
393 if (instr->IsControl()) { 396 if (instr->IsControl()) {
394 instructions_.Add(gap); 397 instructions_.Add(gap);
395 index = instructions_.length(); 398 index = instructions_.length();
396 instructions_.Add(instr); 399 instructions_.Add(instr);
397 } else { 400 } else {
398 index = instructions_.length(); 401 index = instructions_.length();
399 instructions_.Add(instr); 402 instructions_.Add(instr);
(...skipping 186 matching lines...) Expand 10 before | Expand all | Expand 10 after
586 LOperand* LChunkBuilder::Use(HValue* value, LUnallocated* operand) { 589 LOperand* LChunkBuilder::Use(HValue* value, LUnallocated* operand) {
587 if (value->EmitAtUses()) { 590 if (value->EmitAtUses()) {
588 HInstruction* instr = HInstruction::cast(value); 591 HInstruction* instr = HInstruction::cast(value);
589 VisitInstruction(instr); 592 VisitInstruction(instr);
590 } 593 }
591 allocator_->RecordUse(value, operand); 594 allocator_->RecordUse(value, operand);
592 return operand; 595 return operand;
593 } 596 }
594 597
595 598
596 LInstruction* LChunkBuilder::Define(LInstruction* instr) { 599 template<int I, int T>
600 LInstruction* LChunkBuilder::Define(LTemplateInstruction<1, I, T>* instr,
601 LUnallocated* result) {
602 allocator_->RecordDefinition(current_instruction_, result);
603 instr->set_result(result);
604 return instr;
605 }
606
607
608 template<int I, int T>
609 LInstruction* LChunkBuilder::Define(LTemplateInstruction<1, I, T>* instr) {
597 return Define(instr, new LUnallocated(LUnallocated::NONE)); 610 return Define(instr, new LUnallocated(LUnallocated::NONE));
598 } 611 }
599 612
600 613
601 LInstruction* LChunkBuilder::DefineAsRegister(LInstruction* instr) { 614 template<int I, int T>
615 LInstruction* LChunkBuilder::DefineAsRegister(
616 LTemplateInstruction<1, I, T>* instr) {
602 return Define(instr, new LUnallocated(LUnallocated::MUST_HAVE_REGISTER)); 617 return Define(instr, new LUnallocated(LUnallocated::MUST_HAVE_REGISTER));
603 } 618 }
604 619
605 620
606 LInstruction* LChunkBuilder::DefineAsSpilled(LInstruction* instr, int index) { 621 template<int I, int T>
622 LInstruction* LChunkBuilder::DefineAsSpilled(
623 LTemplateInstruction<1, I, T>* instr, int index) {
607 return Define(instr, new LUnallocated(LUnallocated::FIXED_SLOT, index)); 624 return Define(instr, new LUnallocated(LUnallocated::FIXED_SLOT, index));
608 } 625 }
609 626
610 627
611 LInstruction* LChunkBuilder::DefineSameAsFirst(LInstruction* instr) { 628 template<int I, int T>
629 LInstruction* LChunkBuilder::DefineSameAsFirst(
630 LTemplateInstruction<1, I, T>* instr) {
612 return Define(instr, new LUnallocated(LUnallocated::SAME_AS_FIRST_INPUT)); 631 return Define(instr, new LUnallocated(LUnallocated::SAME_AS_FIRST_INPUT));
613 } 632 }
614 633
615 634
616 LInstruction* LChunkBuilder::DefineFixed(LInstruction* instr, Register reg) { 635 template<int I, int T>
636 LInstruction* LChunkBuilder::DefineFixed(
637 LTemplateInstruction<1, I, T>* instr, Register reg) {
617 return Define(instr, ToUnallocated(reg)); 638 return Define(instr, ToUnallocated(reg));
618 } 639 }
619 640
620 641
621 LInstruction* LChunkBuilder::DefineFixedDouble(LInstruction* instr, 642 template<int I, int T>
622 DoubleRegister reg) { 643 LInstruction* LChunkBuilder::DefineFixedDouble(
644 LTemplateInstruction<1, I, T>* instr, DoubleRegister reg) {
623 return Define(instr, ToUnallocated(reg)); 645 return Define(instr, ToUnallocated(reg));
624 } 646 }
625 647
626 648
627 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) { 649 LInstruction* LChunkBuilder::AssignEnvironment(LInstruction* instr) {
628 HEnvironment* hydrogen_env = current_block_->last_environment(); 650 HEnvironment* hydrogen_env = current_block_->last_environment();
629 instr->set_environment(CreateEnvironment(hydrogen_env)); 651 instr->set_environment(CreateEnvironment(hydrogen_env));
630 return instr; 652 return instr;
631 } 653 }
632 654
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
680 } 702 }
681 703
682 704
683 LInstruction* LChunkBuilder::AssignPointerMap(LInstruction* instr) { 705 LInstruction* LChunkBuilder::AssignPointerMap(LInstruction* instr) {
684 ASSERT(!instr->HasPointerMap()); 706 ASSERT(!instr->HasPointerMap());
685 instr->set_pointer_map(new LPointerMap(position_)); 707 instr->set_pointer_map(new LPointerMap(position_));
686 return instr; 708 return instr;
687 } 709 }
688 710
689 711
690 LInstruction* LChunkBuilder::Define(LInstruction* instr, LUnallocated* result) {
691 allocator_->RecordDefinition(current_instruction_, result);
692 instr->set_result(result);
693 return instr;
694 }
695
696
697 LUnallocated* LChunkBuilder::TempRegister() { 712 LUnallocated* LChunkBuilder::TempRegister() {
698 LUnallocated* operand = new LUnallocated(LUnallocated::MUST_HAVE_REGISTER); 713 LUnallocated* operand = new LUnallocated(LUnallocated::MUST_HAVE_REGISTER);
699 allocator_->RecordTemporary(operand); 714 allocator_->RecordTemporary(operand);
700 return operand; 715 return operand;
701 } 716 }
702 717
703 718
704 LOperand* LChunkBuilder::FixedTemp(Register reg) { 719 LOperand* LChunkBuilder::FixedTemp(Register reg) {
705 LUnallocated* operand = ToUnallocated(reg); 720 LUnallocated* operand = ToUnallocated(reg);
706 allocator_->RecordTemporary(operand); 721 allocator_->RecordTemporary(operand);
(...skipping 87 matching lines...) Expand 10 before | Expand all | Expand 10 after
794 op == Token::DIV || 809 op == Token::DIV ||
795 op == Token::MOD || 810 op == Token::MOD ||
796 op == Token::MUL || 811 op == Token::MUL ||
797 op == Token::SUB); 812 op == Token::SUB);
798 HValue* left = instr->left(); 813 HValue* left = instr->left();
799 HValue* right = instr->right(); 814 HValue* right = instr->right();
800 ASSERT(left->representation().IsTagged()); 815 ASSERT(left->representation().IsTagged());
801 ASSERT(right->representation().IsTagged()); 816 ASSERT(right->representation().IsTagged());
802 LOperand* left_operand = UseFixed(left, r1); 817 LOperand* left_operand = UseFixed(left, r1);
803 LOperand* right_operand = UseFixed(right, r0); 818 LOperand* right_operand = UseFixed(right, r0);
804 LInstruction* result = new LArithmeticT(op, left_operand, right_operand); 819 LArithmeticT* result = new LArithmeticT(op, left_operand, right_operand);
805 return MarkAsCall(DefineFixed(result, r0), instr); 820 return MarkAsCall(DefineFixed(result, r0), instr);
806 } 821 }
807 822
808 void LChunkBuilder::DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block) { 823 void LChunkBuilder::DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block) {
809 ASSERT(is_building()); 824 ASSERT(is_building());
810 current_block_ = block; 825 current_block_ = block;
811 next_block_ = next_block; 826 next_block_ = next_block;
812 if (block->IsStartBlock()) { 827 if (block->IsStartBlock()) {
813 block->UpdateEnvironment(graph_->start_environment()); 828 block->UpdateEnvironment(graph_->start_environment());
814 argument_count_ = 0; 829 argument_count_ = 0;
(...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after
875 if (current->has_position()) position_ = current->position(); 890 if (current->has_position()) position_ = current->position();
876 LInstruction* instr = current->CompileToLithium(this); 891 LInstruction* instr = current->CompileToLithium(this);
877 892
878 if (instr != NULL) { 893 if (instr != NULL) {
879 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) { 894 if (FLAG_stress_pointer_maps && !instr->HasPointerMap()) {
880 instr = AssignPointerMap(instr); 895 instr = AssignPointerMap(instr);
881 } 896 }
882 if (FLAG_stress_environments && !instr->HasEnvironment()) { 897 if (FLAG_stress_environments && !instr->HasEnvironment()) {
883 instr = AssignEnvironment(instr); 898 instr = AssignEnvironment(instr);
884 } 899 }
885 if (current->IsTest()) { 900 if (current->IsTest() && !instr->IsGoto()) {
886 instr->set_hydrogen_value(HTest::cast(current)->value()); 901 ASSERT(instr->IsControl());
902 HTest* test = HTest::cast(current);
903 instr->set_hydrogen_value(test->value());
904 HBasicBlock* first = test->FirstSuccessor();
905 HBasicBlock* second = test->SecondSuccessor();
906 ASSERT(first != NULL && second != NULL);
907 instr->SetBranchTargets(first->block_id(), second->block_id());
887 } else { 908 } else {
888 instr->set_hydrogen_value(current); 909 instr->set_hydrogen_value(current);
889 } 910 }
890 911
891 int index = chunk_->AddInstruction(instr, current_block_); 912 int index = chunk_->AddInstruction(instr, current_block_);
892 allocator_->SummarizeInstruction(index); 913 allocator_->SummarizeInstruction(index);
893 } else { 914 } else {
894 // This instruction should be omitted. 915 // This instruction should be omitted.
895 allocator_->OmitInstruction(); 916 allocator_->OmitInstruction();
896 } 917 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { 953 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) {
933 LInstruction* result = new LGoto(instr->FirstSuccessor()->block_id(), 954 LInstruction* result = new LGoto(instr->FirstSuccessor()->block_id(),
934 instr->include_stack_check()); 955 instr->include_stack_check());
935 if (instr->include_stack_check()) result = AssignPointerMap(result); 956 if (instr->include_stack_check()) result = AssignPointerMap(result);
936 return result; 957 return result;
937 } 958 }
938 959
939 960
940 LInstruction* LChunkBuilder::DoTest(HTest* instr) { 961 LInstruction* LChunkBuilder::DoTest(HTest* instr) {
941 HValue* v = instr->value(); 962 HValue* v = instr->value();
942 HBasicBlock* first = instr->FirstSuccessor();
943 HBasicBlock* second = instr->SecondSuccessor();
944 ASSERT(first != NULL && second != NULL);
945 int first_id = first->block_id();
946 int second_id = second->block_id();
947
948 if (v->EmitAtUses()) { 963 if (v->EmitAtUses()) {
949 if (v->IsClassOfTest()) { 964 if (v->IsClassOfTest()) {
950 HClassOfTest* compare = HClassOfTest::cast(v); 965 HClassOfTest* compare = HClassOfTest::cast(v);
951 ASSERT(compare->value()->representation().IsTagged()); 966 ASSERT(compare->value()->representation().IsTagged());
952 967
953 return new LClassOfTestAndBranch(UseTempRegister(compare->value()), 968 return new LClassOfTestAndBranch(UseTempRegister(compare->value()),
954 TempRegister(), 969 TempRegister());
955 first_id,
956 second_id);
957 } else if (v->IsCompare()) { 970 } else if (v->IsCompare()) {
958 HCompare* compare = HCompare::cast(v); 971 HCompare* compare = HCompare::cast(v);
959 Token::Value op = compare->token(); 972 Token::Value op = compare->token();
960 HValue* left = compare->left(); 973 HValue* left = compare->left();
961 HValue* right = compare->right(); 974 HValue* right = compare->right();
962 Representation r = compare->GetInputRepresentation(); 975 Representation r = compare->GetInputRepresentation();
963 if (r.IsInteger32()) { 976 if (r.IsInteger32()) {
964 ASSERT(left->representation().IsInteger32()); 977 ASSERT(left->representation().IsInteger32());
965 ASSERT(right->representation().IsInteger32()); 978 ASSERT(right->representation().IsInteger32());
966 return new LCmpIDAndBranch(UseRegisterAtStart(left), 979 return new LCmpIDAndBranch(UseRegisterAtStart(left),
967 UseOrConstantAtStart(right), 980 UseOrConstantAtStart(right));
968 first_id,
969 second_id);
970 } else if (r.IsDouble()) { 981 } else if (r.IsDouble()) {
971 ASSERT(left->representation().IsDouble()); 982 ASSERT(left->representation().IsDouble());
972 ASSERT(right->representation().IsDouble()); 983 ASSERT(right->representation().IsDouble());
973 return new LCmpIDAndBranch(UseRegisterAtStart(left), 984 return new LCmpIDAndBranch(UseRegisterAtStart(left),
974 UseRegisterAtStart(right), 985 UseRegisterAtStart(right));
975 first_id,
976 second_id);
977 } else { 986 } else {
978 ASSERT(left->representation().IsTagged()); 987 ASSERT(left->representation().IsTagged());
979 ASSERT(right->representation().IsTagged()); 988 ASSERT(right->representation().IsTagged());
980 bool reversed = op == Token::GT || op == Token::LTE; 989 bool reversed = op == Token::GT || op == Token::LTE;
981 LOperand* left_operand = UseFixed(left, reversed ? r0 : r1); 990 LOperand* left_operand = UseFixed(left, reversed ? r0 : r1);
982 LOperand* right_operand = UseFixed(right, reversed ? r1 : r0); 991 LOperand* right_operand = UseFixed(right, reversed ? r1 : r0);
983 LInstruction* result = new LCmpTAndBranch(left_operand, 992 LInstruction* result = new LCmpTAndBranch(left_operand,
984 right_operand, 993 right_operand);
985 first_id,
986 second_id);
987 return MarkAsCall(result, instr); 994 return MarkAsCall(result, instr);
988 } 995 }
989 } else if (v->IsIsSmi()) { 996 } else if (v->IsIsSmi()) {
990 HIsSmi* compare = HIsSmi::cast(v); 997 HIsSmi* compare = HIsSmi::cast(v);
991 ASSERT(compare->value()->representation().IsTagged()); 998 ASSERT(compare->value()->representation().IsTagged());
992 999
993 return new LIsSmiAndBranch(Use(compare->value()), 1000 return new LIsSmiAndBranch(Use(compare->value()));
994 first_id,
995 second_id);
996 } else if (v->IsHasInstanceType()) { 1001 } else if (v->IsHasInstanceType()) {
997 HHasInstanceType* compare = HHasInstanceType::cast(v); 1002 HHasInstanceType* compare = HHasInstanceType::cast(v);
998 ASSERT(compare->value()->representation().IsTagged()); 1003 ASSERT(compare->value()->representation().IsTagged());
999 1004 return new LHasInstanceTypeAndBranch(
1000 return new LHasInstanceTypeAndBranch(UseRegisterAtStart(compare->value()), 1005 UseRegisterAtStart(compare->value()));
1001 first_id,
1002 second_id);
1003 } else if (v->IsHasCachedArrayIndex()) { 1006 } else if (v->IsHasCachedArrayIndex()) {
1004 HHasCachedArrayIndex* compare = HHasCachedArrayIndex::cast(v); 1007 HHasCachedArrayIndex* compare = HHasCachedArrayIndex::cast(v);
1005 ASSERT(compare->value()->representation().IsTagged()); 1008 ASSERT(compare->value()->representation().IsTagged());
1006 1009
1007 return new LHasCachedArrayIndexAndBranch( 1010 return new LHasCachedArrayIndexAndBranch(
1008 UseRegisterAtStart(compare->value()), first_id, second_id); 1011 UseRegisterAtStart(compare->value()));
1009 } else if (v->IsIsNull()) { 1012 } else if (v->IsIsNull()) {
1010 HIsNull* compare = HIsNull::cast(v); 1013 HIsNull* compare = HIsNull::cast(v);
1011 ASSERT(compare->value()->representation().IsTagged()); 1014 ASSERT(compare->value()->representation().IsTagged());
1012 1015
1013 return new LIsNullAndBranch(UseRegisterAtStart(compare->value()), 1016 return new LIsNullAndBranch(UseRegisterAtStart(compare->value()));
1014 first_id,
1015 second_id);
1016 } else if (v->IsIsObject()) { 1017 } else if (v->IsIsObject()) {
1017 HIsObject* compare = HIsObject::cast(v); 1018 HIsObject* compare = HIsObject::cast(v);
1018 ASSERT(compare->value()->representation().IsTagged()); 1019 ASSERT(compare->value()->representation().IsTagged());
1019 1020
1020 LOperand* temp1 = TempRegister(); 1021 LOperand* temp1 = TempRegister();
1021 LOperand* temp2 = TempRegister(); 1022 LOperand* temp2 = TempRegister();
1022 return new LIsObjectAndBranch(UseRegisterAtStart(compare->value()), 1023 return new LIsObjectAndBranch(UseRegisterAtStart(compare->value()),
1023 temp1, 1024 temp1,
1024 temp2, 1025 temp2);
1025 first_id,
1026 second_id);
1027 } else if (v->IsCompareJSObjectEq()) { 1026 } else if (v->IsCompareJSObjectEq()) {
1028 HCompareJSObjectEq* compare = HCompareJSObjectEq::cast(v); 1027 HCompareJSObjectEq* compare = HCompareJSObjectEq::cast(v);
1029 return new LCmpJSObjectEqAndBranch(UseRegisterAtStart(compare->left()), 1028 return new LCmpJSObjectEqAndBranch(UseRegisterAtStart(compare->left()),
1030 UseRegisterAtStart(compare->right()), 1029 UseRegisterAtStart(compare->right()));
1031 first_id,
1032 second_id);
1033 } else if (v->IsInstanceOf()) { 1030 } else if (v->IsInstanceOf()) {
1034 HInstanceOf* instance_of = HInstanceOf::cast(v); 1031 HInstanceOf* instance_of = HInstanceOf::cast(v);
1035 LInstruction* result = 1032 LInstruction* result =
1036 new LInstanceOfAndBranch(Use(instance_of->left()), 1033 new LInstanceOfAndBranch(Use(instance_of->left()),
1037 Use(instance_of->right()), 1034 Use(instance_of->right()));
1038 first_id,
1039 second_id);
1040 return MarkAsCall(result, instr); 1035 return MarkAsCall(result, instr);
1041 } else if (v->IsTypeofIs()) { 1036 } else if (v->IsTypeofIs()) {
1042 HTypeofIs* typeof_is = HTypeofIs::cast(v); 1037 HTypeofIs* typeof_is = HTypeofIs::cast(v);
1043 return new LTypeofIsAndBranch(UseTempRegister(typeof_is->value()), 1038 return new LTypeofIsAndBranch(UseTempRegister(typeof_is->value()));
1044 first_id,
1045 second_id);
1046 } else { 1039 } else {
1047 if (v->IsConstant()) { 1040 if (v->IsConstant()) {
1048 if (HConstant::cast(v)->handle()->IsTrue()) { 1041 if (HConstant::cast(v)->handle()->IsTrue()) {
1049 return new LGoto(first_id); 1042 return new LGoto(instr->FirstSuccessor()->block_id());
1050 } else if (HConstant::cast(v)->handle()->IsFalse()) { 1043 } else if (HConstant::cast(v)->handle()->IsFalse()) {
1051 return new LGoto(second_id); 1044 return new LGoto(instr->SecondSuccessor()->block_id());
1052 } 1045 }
1053 } 1046 }
1054 Abort("Undefined compare before branch"); 1047 Abort("Undefined compare before branch");
1055 return NULL; 1048 return NULL;
1056 } 1049 }
1057 } 1050 }
1058 return new LBranch(UseRegisterAtStart(v), first_id, second_id); 1051 return new LBranch(UseRegisterAtStart(v));
1059 } 1052 }
1060 1053
1061 1054
1062 LInstruction* LChunkBuilder::DoCompareMap(HCompareMap* instr) { 1055 LInstruction* LChunkBuilder::DoCompareMap(HCompareMap* instr) {
1063 ASSERT(instr->value()->representation().IsTagged()); 1056 ASSERT(instr->value()->representation().IsTagged());
1064 LOperand* value = UseRegisterAtStart(instr->value()); 1057 LOperand* value = UseRegisterAtStart(instr->value());
1065 LOperand* temp = TempRegister(); 1058 LOperand* temp = TempRegister();
1066 return new LCmpMapAndBranch(value, temp); 1059 return new LCmpMapAndBranch(value, temp);
1067 } 1060 }
1068 1061
1069 1062
1070 LInstruction* LChunkBuilder::DoArgumentsLength(HArgumentsLength* length) { 1063 LInstruction* LChunkBuilder::DoArgumentsLength(HArgumentsLength* length) {
1071 return DefineAsRegister(new LArgumentsLength(UseRegister(length->value()))); 1064 return DefineAsRegister(new LArgumentsLength(UseRegister(length->value())));
1072 } 1065 }
1073 1066
1074 1067
1075 LInstruction* LChunkBuilder::DoArgumentsElements(HArgumentsElements* elems) { 1068 LInstruction* LChunkBuilder::DoArgumentsElements(HArgumentsElements* elems) {
1076 return DefineAsRegister(new LArgumentsElements); 1069 return DefineAsRegister(new LArgumentsElements);
1077 } 1070 }
1078 1071
1079 1072
1080 LInstruction* LChunkBuilder::DoInstanceOf(HInstanceOf* instr) { 1073 LInstruction* LChunkBuilder::DoInstanceOf(HInstanceOf* instr) {
1081 LInstruction* result = 1074 LInstanceOf* result =
1082 new LInstanceOf(UseFixed(instr->left(), r0), 1075 new LInstanceOf(UseFixed(instr->left(), r0),
1083 UseFixed(instr->right(), r1)); 1076 UseFixed(instr->right(), r1));
1084 return MarkAsCall(DefineFixed(result, r0), instr); 1077 return MarkAsCall(DefineFixed(result, r0), instr);
1085 } 1078 }
1086 1079
1087 1080
1088 LInstruction* LChunkBuilder::DoInstanceOfKnownGlobal( 1081 LInstruction* LChunkBuilder::DoInstanceOfKnownGlobal(
1089 HInstanceOfKnownGlobal* instr) { 1082 HInstanceOfKnownGlobal* instr) {
1090 LInstruction* result = 1083 LInstanceOfKnownGlobal* result =
1091 new LInstanceOfKnownGlobal(UseFixed(instr->value(), r0), FixedTemp(r4)); 1084 new LInstanceOfKnownGlobal(UseFixed(instr->value(), r0), FixedTemp(r4));
1092 MarkAsSaveDoubles(result); 1085 MarkAsSaveDoubles(result);
1093 return AssignEnvironment(AssignPointerMap(DefineFixed(result, r0))); 1086 return AssignEnvironment(AssignPointerMap(DefineFixed(result, r0)));
1094 } 1087 }
1095 1088
1096 1089
1097 LInstruction* LChunkBuilder::DoApplyArguments(HApplyArguments* instr) { 1090 LInstruction* LChunkBuilder::DoApplyArguments(HApplyArguments* instr) {
1098 LOperand* function = UseFixed(instr->function(), r1); 1091 LOperand* function = UseFixed(instr->function(), r1);
1099 LOperand* receiver = UseFixed(instr->receiver(), r0); 1092 LOperand* receiver = UseFixed(instr->receiver(), r0);
1100 LOperand* length = UseRegisterAtStart(instr->length()); 1093 LOperand* length = UseRegisterAtStart(instr->length());
1101 LOperand* elements = UseRegisterAtStart(instr->elements()); 1094 LOperand* elements = UseRegisterAtStart(instr->elements());
1102 LInstruction* result = new LApplyArguments(function, 1095 LApplyArguments* result = new LApplyArguments(function,
1103 receiver, 1096 receiver,
1104 length, 1097 length,
1105 elements); 1098 elements);
1106 return MarkAsCall(DefineFixed(result, r0), instr, CAN_DEOPTIMIZE_EAGERLY); 1099 return MarkAsCall(DefineFixed(result, r0), instr, CAN_DEOPTIMIZE_EAGERLY);
1107 } 1100 }
1108 1101
1109 1102
1110 LInstruction* LChunkBuilder::DoPushArgument(HPushArgument* instr) { 1103 LInstruction* LChunkBuilder::DoPushArgument(HPushArgument* instr) {
1111 ++argument_count_; 1104 ++argument_count_;
1112 LOperand* argument = Use(instr->argument()); 1105 LOperand* argument = Use(instr->argument());
1113 return new LPushArgument(argument); 1106 return new LPushArgument(argument);
1114 } 1107 }
1115 1108
(...skipping 12 matching lines...) Expand all
1128 HCallConstantFunction* instr) { 1121 HCallConstantFunction* instr) {
1129 argument_count_ -= instr->argument_count(); 1122 argument_count_ -= instr->argument_count();
1130 return MarkAsCall(DefineFixed(new LCallConstantFunction, r0), instr); 1123 return MarkAsCall(DefineFixed(new LCallConstantFunction, r0), instr);
1131 } 1124 }
1132 1125
1133 1126
1134 LInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) { 1127 LInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) {
1135 BuiltinFunctionId op = instr->op(); 1128 BuiltinFunctionId op = instr->op();
1136 LOperand* input = UseRegisterAtStart(instr->value()); 1129 LOperand* input = UseRegisterAtStart(instr->value());
1137 LOperand* temp = (op == kMathFloor) ? TempRegister() : NULL; 1130 LOperand* temp = (op == kMathFloor) ? TempRegister() : NULL;
1138 LInstruction* result = new LUnaryMathOperation(input, temp); 1131 LUnaryMathOperation* result = new LUnaryMathOperation(input, temp);
1139 switch (op) { 1132 switch (op) {
1140 case kMathAbs: 1133 case kMathAbs:
1141 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); 1134 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result)));
1142 case kMathFloor: 1135 case kMathFloor:
1143 return AssignEnvironment(DefineAsRegister(result)); 1136 return AssignEnvironment(DefineAsRegister(result));
1144 case kMathSqrt: 1137 case kMathSqrt:
1145 return DefineSameAsFirst(result); 1138 return DefineSameAsFirst(result);
1146 case kMathRound: 1139 case kMathRound:
1147 Abort("MathRound LUnaryMathOperation not implemented"); 1140 Abort("MathRound LUnaryMathOperation not implemented");
1148 return NULL; 1141 return NULL;
(...skipping 12 matching lines...) Expand all
1161 default: 1154 default:
1162 UNREACHABLE(); 1155 UNREACHABLE();
1163 return NULL; 1156 return NULL;
1164 } 1157 }
1165 } 1158 }
1166 1159
1167 1160
1168 LInstruction* LChunkBuilder::DoCallKeyed(HCallKeyed* instr) { 1161 LInstruction* LChunkBuilder::DoCallKeyed(HCallKeyed* instr) {
1169 ASSERT(instr->key()->representation().IsTagged()); 1162 ASSERT(instr->key()->representation().IsTagged());
1170 argument_count_ -= instr->argument_count(); 1163 argument_count_ -= instr->argument_count();
1171 UseFixed(instr->key(), r2); 1164 LOperand* key = UseFixed(instr->key(), r2);
1172 return MarkAsCall(DefineFixed(new LCallKeyed, r0), instr); 1165 return MarkAsCall(DefineFixed(new LCallKeyed(key), r0), instr);
1173 } 1166 }
1174 1167
1175 1168
1176 LInstruction* LChunkBuilder::DoCallNamed(HCallNamed* instr) { 1169 LInstruction* LChunkBuilder::DoCallNamed(HCallNamed* instr) {
1177 argument_count_ -= instr->argument_count(); 1170 argument_count_ -= instr->argument_count();
1178 return MarkAsCall(DefineFixed(new LCallNamed, r0), instr); 1171 return MarkAsCall(DefineFixed(new LCallNamed, r0), instr);
1179 } 1172 }
1180 1173
1181 1174
1182 LInstruction* LChunkBuilder::DoCallGlobal(HCallGlobal* instr) { 1175 LInstruction* LChunkBuilder::DoCallGlobal(HCallGlobal* instr) {
1183 argument_count_ -= instr->argument_count(); 1176 argument_count_ -= instr->argument_count();
1184 return MarkAsCall(DefineFixed(new LCallGlobal, r0), instr); 1177 return MarkAsCall(DefineFixed(new LCallGlobal, r0), instr);
1185 } 1178 }
1186 1179
1187 1180
1188 LInstruction* LChunkBuilder::DoCallKnownGlobal(HCallKnownGlobal* instr) { 1181 LInstruction* LChunkBuilder::DoCallKnownGlobal(HCallKnownGlobal* instr) {
1189 argument_count_ -= instr->argument_count(); 1182 argument_count_ -= instr->argument_count();
1190 return MarkAsCall(DefineFixed(new LCallKnownGlobal, r0), instr); 1183 return MarkAsCall(DefineFixed(new LCallKnownGlobal, r0), instr);
1191 } 1184 }
1192 1185
1193 1186
1194 LInstruction* LChunkBuilder::DoCallNew(HCallNew* instr) { 1187 LInstruction* LChunkBuilder::DoCallNew(HCallNew* instr) {
1195 LOperand* constructor = UseFixed(instr->constructor(), r1); 1188 LOperand* constructor = UseFixed(instr->constructor(), r1);
1196 argument_count_ -= instr->argument_count(); 1189 argument_count_ -= instr->argument_count();
1197 LInstruction* result = new LCallNew(constructor); 1190 LCallNew* result = new LCallNew(constructor);
1198 return MarkAsCall(DefineFixed(result, r0), instr); 1191 return MarkAsCall(DefineFixed(result, r0), instr);
1199 } 1192 }
1200 1193
1201 1194
1202 LInstruction* LChunkBuilder::DoCallFunction(HCallFunction* instr) { 1195 LInstruction* LChunkBuilder::DoCallFunction(HCallFunction* instr) {
1203 argument_count_ -= instr->argument_count(); 1196 argument_count_ -= instr->argument_count();
1204 return MarkAsCall(DefineFixed(new LCallFunction, r0), instr); 1197 return MarkAsCall(DefineFixed(new LCallFunction, r0), instr);
1205 } 1198 }
1206 1199
1207 1200
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1377 ASSERT(instr->right()->representation().IsDouble()); 1370 ASSERT(instr->right()->representation().IsDouble());
1378 LOperand* left = UseRegisterAtStart(instr->left()); 1371 LOperand* left = UseRegisterAtStart(instr->left());
1379 LOperand* right = UseRegisterAtStart(instr->right()); 1372 LOperand* right = UseRegisterAtStart(instr->right());
1380 return DefineAsRegister(new LCmpID(left, right)); 1373 return DefineAsRegister(new LCmpID(left, right));
1381 } else { 1374 } else {
1382 ASSERT(instr->left()->representation().IsTagged()); 1375 ASSERT(instr->left()->representation().IsTagged());
1383 ASSERT(instr->right()->representation().IsTagged()); 1376 ASSERT(instr->right()->representation().IsTagged());
1384 bool reversed = (op == Token::GT || op == Token::LTE); 1377 bool reversed = (op == Token::GT || op == Token::LTE);
1385 LOperand* left = UseFixed(instr->left(), reversed ? r0 : r1); 1378 LOperand* left = UseFixed(instr->left(), reversed ? r0 : r1);
1386 LOperand* right = UseFixed(instr->right(), reversed ? r1 : r0); 1379 LOperand* right = UseFixed(instr->right(), reversed ? r1 : r0);
1387 LInstruction* result = new LCmpT(left, right); 1380 LCmpT* result = new LCmpT(left, right);
1388 return MarkAsCall(DefineFixed(result, r0), instr); 1381 return MarkAsCall(DefineFixed(result, r0), instr);
1389 } 1382 }
1390 } 1383 }
1391 1384
1392 1385
1393 LInstruction* LChunkBuilder::DoCompareJSObjectEq( 1386 LInstruction* LChunkBuilder::DoCompareJSObjectEq(
1394 HCompareJSObjectEq* instr) { 1387 HCompareJSObjectEq* instr) {
1395 LOperand* left = UseRegisterAtStart(instr->left()); 1388 LOperand* left = UseRegisterAtStart(instr->left());
1396 LOperand* right = UseRegisterAtStart(instr->right()); 1389 LOperand* right = UseRegisterAtStart(instr->right());
1397 LInstruction* result = new LCmpJSObjectEq(left, right); 1390 LCmpJSObjectEq* result = new LCmpJSObjectEq(left, right);
1398 return DefineAsRegister(result); 1391 return DefineAsRegister(result);
1399 } 1392 }
1400 1393
1401 1394
1402 LInstruction* LChunkBuilder::DoIsNull(HIsNull* instr) { 1395 LInstruction* LChunkBuilder::DoIsNull(HIsNull* instr) {
1403 ASSERT(instr->value()->representation().IsTagged()); 1396 ASSERT(instr->value()->representation().IsTagged());
1404 LOperand* value = UseRegisterAtStart(instr->value()); 1397 LOperand* value = UseRegisterAtStart(instr->value());
1405 1398
1406 return DefineAsRegister(new LIsNull(value)); 1399 return DefineAsRegister(new LIsNull(value));
1407 } 1400 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1454 1447
1455 1448
1456 LInstruction* LChunkBuilder::DoFixedArrayLength(HFixedArrayLength* instr) { 1449 LInstruction* LChunkBuilder::DoFixedArrayLength(HFixedArrayLength* instr) {
1457 LOperand* array = UseRegisterAtStart(instr->value()); 1450 LOperand* array = UseRegisterAtStart(instr->value());
1458 return DefineAsRegister(new LFixedArrayLength(array)); 1451 return DefineAsRegister(new LFixedArrayLength(array));
1459 } 1452 }
1460 1453
1461 1454
1462 LInstruction* LChunkBuilder::DoValueOf(HValueOf* instr) { 1455 LInstruction* LChunkBuilder::DoValueOf(HValueOf* instr) {
1463 LOperand* object = UseRegister(instr->value()); 1456 LOperand* object = UseRegister(instr->value());
1464 LInstruction* result = new LValueOf(object, TempRegister()); 1457 LValueOf* result = new LValueOf(object, TempRegister());
1465 return AssignEnvironment(DefineSameAsFirst(result)); 1458 return AssignEnvironment(DefineSameAsFirst(result));
1466 } 1459 }
1467 1460
1468 1461
1469 LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) { 1462 LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) {
1470 return AssignEnvironment(new LBoundsCheck(UseRegisterAtStart(instr->index()), 1463 return AssignEnvironment(new LBoundsCheck(UseRegisterAtStart(instr->index()),
1471 UseRegister(instr->length()))); 1464 UseRegister(instr->length())));
1472 } 1465 }
1473 1466
1474 1467
1475 LInstruction* LChunkBuilder::DoThrow(HThrow* instr) { 1468 LInstruction* LChunkBuilder::DoThrow(HThrow* instr) {
1476 LOperand* value = UseFixed(instr->value(), r0); 1469 LOperand* value = UseFixed(instr->value(), r0);
1477 return MarkAsCall(new LThrow(value), instr); 1470 return MarkAsCall(new LThrow(value), instr);
1478 } 1471 }
1479 1472
1480 1473
1481 LInstruction* LChunkBuilder::DoChange(HChange* instr) { 1474 LInstruction* LChunkBuilder::DoChange(HChange* instr) {
1482 Representation from = instr->from(); 1475 Representation from = instr->from();
1483 Representation to = instr->to(); 1476 Representation to = instr->to();
1484 if (from.IsTagged()) { 1477 if (from.IsTagged()) {
1485 if (to.IsDouble()) { 1478 if (to.IsDouble()) {
1486 LOperand* value = UseRegister(instr->value()); 1479 LOperand* value = UseRegister(instr->value());
1487 LInstruction* res = new LNumberUntagD(value); 1480 LNumberUntagD* res = new LNumberUntagD(value);
1488 return AssignEnvironment(DefineAsRegister(res)); 1481 return AssignEnvironment(DefineAsRegister(res));
1489 } else { 1482 } else {
1490 ASSERT(to.IsInteger32()); 1483 ASSERT(to.IsInteger32());
1491 LOperand* value = UseRegister(instr->value()); 1484 LOperand* value = UseRegister(instr->value());
1492 bool needs_check = !instr->value()->type().IsSmi(); 1485 bool needs_check = !instr->value()->type().IsSmi();
1493 LInstruction* res = NULL; 1486 LInstruction* res = NULL;
1494 if (needs_check) { 1487 if (needs_check) {
1495 res = DefineSameAsFirst(new LTaggedToI(value, FixedTemp(d1))); 1488 res = DefineSameAsFirst(new LTaggedToI(value, FixedTemp(d1)));
1496 } else { 1489 } else {
1497 res = DefineSameAsFirst(new LSmiUntag(value, needs_check)); 1490 res = DefineSameAsFirst(new LSmiUntag(value, needs_check));
1498 } 1491 }
1499 if (needs_check) { 1492 if (needs_check) {
1500 res = AssignEnvironment(res); 1493 res = AssignEnvironment(res);
1501 } 1494 }
1502 return res; 1495 return res;
1503 } 1496 }
1504 } else if (from.IsDouble()) { 1497 } else if (from.IsDouble()) {
1505 if (to.IsTagged()) { 1498 if (to.IsTagged()) {
1506 LOperand* value = UseRegister(instr->value()); 1499 LOperand* value = UseRegister(instr->value());
1507 LOperand* temp1 = TempRegister(); 1500 LOperand* temp1 = TempRegister();
1508 LOperand* temp2 = TempRegister(); 1501 LOperand* temp2 = TempRegister();
1509 1502
1510 // Make sure that the temp and result_temp registers are 1503 // Make sure that the temp and result_temp registers are
1511 // different. 1504 // different.
1512 LUnallocated* result_temp = TempRegister(); 1505 LUnallocated* result_temp = TempRegister();
1513 LInstruction* result = new LNumberTagD(value, temp1, temp2); 1506 LNumberTagD* result = new LNumberTagD(value, temp1, temp2);
1514 Define(result, result_temp); 1507 Define(result, result_temp);
1515 return AssignPointerMap(result); 1508 return AssignPointerMap(result);
1516 } else { 1509 } else {
1517 ASSERT(to.IsInteger32()); 1510 ASSERT(to.IsInteger32());
1518 LOperand* value = UseRegister(instr->value()); 1511 LOperand* value = UseRegister(instr->value());
1519 LInstruction* res = new LDoubleToI(value); 1512 LDoubleToI* res = new LDoubleToI(value);
1520 return AssignEnvironment(DefineAsRegister(res)); 1513 return AssignEnvironment(DefineAsRegister(res));
1521 } 1514 }
1522 } else if (from.IsInteger32()) { 1515 } else if (from.IsInteger32()) {
1523 if (to.IsTagged()) { 1516 if (to.IsTagged()) {
1524 HValue* val = instr->value(); 1517 HValue* val = instr->value();
1525 LOperand* value = UseRegister(val); 1518 LOperand* value = UseRegister(val);
1526 if (val->HasRange() && val->range()->IsInSmiRange()) { 1519 if (val->HasRange() && val->range()->IsInSmiRange()) {
1527 return DefineSameAsFirst(new LSmiTag(value)); 1520 return DefineSameAsFirst(new LSmiTag(value));
1528 } else { 1521 } else {
1529 LInstruction* result = new LNumberTagI(value); 1522 LNumberTagI* result = new LNumberTagI(value);
1530 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); 1523 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result)));
1531 } 1524 }
1532 } else { 1525 } else {
1533 ASSERT(to.IsDouble()); 1526 ASSERT(to.IsDouble());
1534 LOperand* value = Use(instr->value()); 1527 LOperand* value = Use(instr->value());
1535 return DefineAsRegister(new LInteger32ToDouble(value)); 1528 return DefineAsRegister(new LInteger32ToDouble(value));
1536 } 1529 }
1537 } 1530 }
1538 UNREACHABLE(); 1531 UNREACHABLE();
1539 return NULL; 1532 return NULL;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1596 } else if (r.IsTagged()) { 1589 } else if (r.IsTagged()) {
1597 return DefineAsRegister(new LConstantT(instr->handle())); 1590 return DefineAsRegister(new LConstantT(instr->handle()));
1598 } else { 1591 } else {
1599 UNREACHABLE(); 1592 UNREACHABLE();
1600 return NULL; 1593 return NULL;
1601 } 1594 }
1602 } 1595 }
1603 1596
1604 1597
1605 LInstruction* LChunkBuilder::DoLoadGlobal(HLoadGlobal* instr) { 1598 LInstruction* LChunkBuilder::DoLoadGlobal(HLoadGlobal* instr) {
1606 LInstruction* result = new LLoadGlobal(); 1599 LLoadGlobal* result = new LLoadGlobal();
1607 return instr->check_hole_value() 1600 return instr->check_hole_value()
1608 ? AssignEnvironment(DefineAsRegister(result)) 1601 ? AssignEnvironment(DefineAsRegister(result))
1609 : DefineAsRegister(result); 1602 : DefineAsRegister(result);
1610 } 1603 }
1611 1604
1612 1605
1613 LInstruction* LChunkBuilder::DoStoreGlobal(HStoreGlobal* instr) { 1606 LInstruction* LChunkBuilder::DoStoreGlobal(HStoreGlobal* instr) {
1614 return new LStoreGlobal(UseRegisterAtStart(instr->value())); 1607 return new LStoreGlobal(UseRegisterAtStart(instr->value()));
1615 } 1608 }
1616 1609
(...skipping 28 matching lines...) Expand all
1645 return DefineSameAsFirst(new LLoadElements(input)); 1638 return DefineSameAsFirst(new LLoadElements(input));
1646 } 1639 }
1647 1640
1648 1641
1649 LInstruction* LChunkBuilder::DoLoadKeyedFastElement( 1642 LInstruction* LChunkBuilder::DoLoadKeyedFastElement(
1650 HLoadKeyedFastElement* instr) { 1643 HLoadKeyedFastElement* instr) {
1651 ASSERT(instr->representation().IsTagged()); 1644 ASSERT(instr->representation().IsTagged());
1652 ASSERT(instr->key()->representation().IsInteger32()); 1645 ASSERT(instr->key()->representation().IsInteger32());
1653 LOperand* obj = UseRegisterAtStart(instr->object()); 1646 LOperand* obj = UseRegisterAtStart(instr->object());
1654 LOperand* key = UseRegisterAtStart(instr->key()); 1647 LOperand* key = UseRegisterAtStart(instr->key());
1655 LInstruction* result = new LLoadKeyedFastElement(obj, key); 1648 LLoadKeyedFastElement* result = new LLoadKeyedFastElement(obj, key);
1656 return AssignEnvironment(DefineSameAsFirst(result)); 1649 return AssignEnvironment(DefineSameAsFirst(result));
1657 } 1650 }
1658 1651
1659 1652
1660 LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) { 1653 LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) {
1661 LOperand* object = UseFixed(instr->object(), r1); 1654 LOperand* object = UseFixed(instr->object(), r1);
1662 LOperand* key = UseFixed(instr->key(), r0); 1655 LOperand* key = UseFixed(instr->key(), r0);
1663 1656
1664 LInstruction* result = 1657 LInstruction* result =
1665 DefineFixed(new LLoadKeyedGeneric(object, key), r0); 1658 DefineFixed(new LLoadKeyedGeneric(object, key), r0);
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after
1719 LOperand* val = UseFixed(instr->value(), r0); 1712 LOperand* val = UseFixed(instr->value(), r0);
1720 1713
1721 LInstruction* result = new LStoreNamedGeneric(obj, val); 1714 LInstruction* result = new LStoreNamedGeneric(obj, val);
1722 return MarkAsCall(result, instr); 1715 return MarkAsCall(result, instr);
1723 } 1716 }
1724 1717
1725 1718
1726 LInstruction* LChunkBuilder::DoStringCharCodeAt(HStringCharCodeAt* instr) { 1719 LInstruction* LChunkBuilder::DoStringCharCodeAt(HStringCharCodeAt* instr) {
1727 LOperand* string = UseRegister(instr->string()); 1720 LOperand* string = UseRegister(instr->string());
1728 LOperand* index = UseRegisterOrConstant(instr->index()); 1721 LOperand* index = UseRegisterOrConstant(instr->index());
1729 LInstruction* result = new LStringCharCodeAt(string, index); 1722 LStringCharCodeAt* result = new LStringCharCodeAt(string, index);
1730 return AssignEnvironment(AssignPointerMap(DefineAsRegister(result))); 1723 return AssignEnvironment(AssignPointerMap(DefineAsRegister(result)));
1731 } 1724 }
1732 1725
1733 1726
1734 LInstruction* LChunkBuilder::DoStringLength(HStringLength* instr) { 1727 LInstruction* LChunkBuilder::DoStringLength(HStringLength* instr) {
1735 LOperand* string = UseRegisterAtStart(instr->value()); 1728 LOperand* string = UseRegisterAtStart(instr->value());
1736 return DefineAsRegister(new LStringLength(string)); 1729 return DefineAsRegister(new LStringLength(string));
1737 } 1730 }
1738 1731
1739 1732
(...skipping 13 matching lines...) Expand all
1753 1746
1754 1747
1755 LInstruction* LChunkBuilder::DoFunctionLiteral(HFunctionLiteral* instr) { 1748 LInstruction* LChunkBuilder::DoFunctionLiteral(HFunctionLiteral* instr) {
1756 return MarkAsCall(DefineFixed(new LFunctionLiteral, r0), instr); 1749 return MarkAsCall(DefineFixed(new LFunctionLiteral, r0), instr);
1757 } 1750 }
1758 1751
1759 1752
1760 LInstruction* LChunkBuilder::DoDeleteProperty(HDeleteProperty* instr) { 1753 LInstruction* LChunkBuilder::DoDeleteProperty(HDeleteProperty* instr) {
1761 LOperand* object = UseRegisterAtStart(instr->object()); 1754 LOperand* object = UseRegisterAtStart(instr->object());
1762 LOperand* key = UseRegisterAtStart(instr->key()); 1755 LOperand* key = UseRegisterAtStart(instr->key());
1763 LInstruction* result = new LDeleteProperty(object, key); 1756 LDeleteProperty* result = new LDeleteProperty(object, key);
1764 return MarkAsCall(DefineFixed(result, r0), instr); 1757 return MarkAsCall(DefineFixed(result, r0), instr);
1765 } 1758 }
1766 1759
1767 1760
1768 LInstruction* LChunkBuilder::DoOsrEntry(HOsrEntry* instr) { 1761 LInstruction* LChunkBuilder::DoOsrEntry(HOsrEntry* instr) {
1769 allocator_->MarkAsOsrEntry(); 1762 allocator_->MarkAsOsrEntry();
1770 current_block_->last_environment()->set_ast_id(instr->ast_id()); 1763 current_block_->last_environment()->set_ast_id(instr->ast_id());
1771 return AssignEnvironment(new LOsrEntry); 1764 return AssignEnvironment(new LOsrEntry);
1772 } 1765 }
1773 1766
(...skipping 20 matching lines...) Expand all
1794 // There are no real uses of the arguments object (we bail out in all other 1787 // There are no real uses of the arguments object (we bail out in all other
1795 // cases). 1788 // cases).
1796 return NULL; 1789 return NULL;
1797 } 1790 }
1798 1791
1799 1792
1800 LInstruction* LChunkBuilder::DoAccessArgumentsAt(HAccessArgumentsAt* instr) { 1793 LInstruction* LChunkBuilder::DoAccessArgumentsAt(HAccessArgumentsAt* instr) {
1801 LOperand* arguments = UseRegister(instr->arguments()); 1794 LOperand* arguments = UseRegister(instr->arguments());
1802 LOperand* length = UseTempRegister(instr->length()); 1795 LOperand* length = UseTempRegister(instr->length());
1803 LOperand* index = UseRegister(instr->index()); 1796 LOperand* index = UseRegister(instr->index());
1804 LInstruction* result = new LAccessArgumentsAt(arguments, length, index); 1797 LAccessArgumentsAt* result = new LAccessArgumentsAt(arguments, length, index);
1805 return DefineAsRegister(AssignEnvironment(result)); 1798 return AssignEnvironment(DefineAsRegister(result));
1806 } 1799 }
1807 1800
1808 1801
1809 LInstruction* LChunkBuilder::DoTypeof(HTypeof* instr) { 1802 LInstruction* LChunkBuilder::DoTypeof(HTypeof* instr) {
1810 LInstruction* result = new LTypeof(UseRegisterAtStart(instr->value())); 1803 LTypeof* result = new LTypeof(UseRegisterAtStart(instr->value()));
1811 return MarkAsCall(DefineFixed(result, r0), instr); 1804 return MarkAsCall(DefineFixed(result, r0), instr);
1812 } 1805 }
1813 1806
1814 1807
1815 LInstruction* LChunkBuilder::DoTypeofIs(HTypeofIs* instr) { 1808 LInstruction* LChunkBuilder::DoTypeofIs(HTypeofIs* instr) {
1816 return DefineSameAsFirst(new LTypeofIs(UseRegister(instr->value()))); 1809 return DefineSameAsFirst(new LTypeofIs(UseRegister(instr->value())));
1817 } 1810 }
1818 1811
1819 LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) { 1812 LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) {
1820 HEnvironment* env = current_block_->last_environment(); 1813 HEnvironment* env = current_block_->last_environment();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1868 1861
1869 1862
1870 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) { 1863 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) {
1871 HEnvironment* outer = current_block_->last_environment()->outer(); 1864 HEnvironment* outer = current_block_->last_environment()->outer();
1872 current_block_->UpdateEnvironment(outer); 1865 current_block_->UpdateEnvironment(outer);
1873 return NULL; 1866 return NULL;
1874 } 1867 }
1875 1868
1876 1869
1877 } } // namespace v8::internal 1870 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/arm/lithium-arm.h ('k') | src/arm/lithium-codegen-arm.h » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698