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

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: fixed lintos 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
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 // TODO(fschneider): Handle test instructions uniformly like
Søren Thygesen Gjesse 2011/01/24 08:08:40 Username -> issue number
fschneider 2011/01/24 09:40:16 I removed the todo since it really is part of our
902 // other instructions. This requires us to generate the right
903 // branch instruction already at the HIR level.
904 ASSERT(instr->IsControl());
905 HTest* test = HTest::cast(current);
906 instr->set_hydrogen_value(test->value());
907 HBasicBlock* first = test->FirstSuccessor();
908 HBasicBlock* second = test->SecondSuccessor();
909 ASSERT(first != NULL && second != NULL);
910 instr->SetBranchTargets(first->block_id(), second->block_id());
887 } else { 911 } else {
888 instr->set_hydrogen_value(current); 912 instr->set_hydrogen_value(current);
889 } 913 }
890 914
891 int index = chunk_->AddInstruction(instr, current_block_); 915 int index = chunk_->AddInstruction(instr, current_block_);
892 allocator_->SummarizeInstruction(index); 916 allocator_->SummarizeInstruction(index);
893 } else { 917 } else {
894 // This instruction should be omitted. 918 // This instruction should be omitted.
895 allocator_->OmitInstruction(); 919 allocator_->OmitInstruction();
896 } 920 }
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after
932 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) { 956 LInstruction* LChunkBuilder::DoGoto(HGoto* instr) {
933 LInstruction* result = new LGoto(instr->FirstSuccessor()->block_id(), 957 LInstruction* result = new LGoto(instr->FirstSuccessor()->block_id(),
934 instr->include_stack_check()); 958 instr->include_stack_check());
935 if (instr->include_stack_check()) result = AssignPointerMap(result); 959 if (instr->include_stack_check()) result = AssignPointerMap(result);
936 return result; 960 return result;
937 } 961 }
938 962
939 963
940 LInstruction* LChunkBuilder::DoTest(HTest* instr) { 964 LInstruction* LChunkBuilder::DoTest(HTest* instr) {
941 HValue* v = instr->value(); 965 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()) { 966 if (v->EmitAtUses()) {
949 if (v->IsClassOfTest()) { 967 if (v->IsClassOfTest()) {
950 HClassOfTest* compare = HClassOfTest::cast(v); 968 HClassOfTest* compare = HClassOfTest::cast(v);
951 ASSERT(compare->value()->representation().IsTagged()); 969 ASSERT(compare->value()->representation().IsTagged());
952 970
953 return new LClassOfTestAndBranch(UseTempRegister(compare->value()), 971 return new LClassOfTestAndBranch(UseTempRegister(compare->value()),
954 TempRegister(), 972 TempRegister());
955 first_id,
956 second_id);
957 } else if (v->IsCompare()) { 973 } else if (v->IsCompare()) {
958 HCompare* compare = HCompare::cast(v); 974 HCompare* compare = HCompare::cast(v);
959 Token::Value op = compare->token(); 975 Token::Value op = compare->token();
960 HValue* left = compare->left(); 976 HValue* left = compare->left();
961 HValue* right = compare->right(); 977 HValue* right = compare->right();
962 Representation r = compare->GetInputRepresentation(); 978 Representation r = compare->GetInputRepresentation();
963 if (r.IsInteger32()) { 979 if (r.IsInteger32()) {
964 ASSERT(left->representation().IsInteger32()); 980 ASSERT(left->representation().IsInteger32());
965 ASSERT(right->representation().IsInteger32()); 981 ASSERT(right->representation().IsInteger32());
966 return new LCmpIDAndBranch(UseRegisterAtStart(left), 982 return new LCmpIDAndBranch(UseRegisterAtStart(left),
967 UseOrConstantAtStart(right), 983 UseOrConstantAtStart(right));
968 first_id,
969 second_id);
970 } else if (r.IsDouble()) { 984 } else if (r.IsDouble()) {
971 ASSERT(left->representation().IsDouble()); 985 ASSERT(left->representation().IsDouble());
972 ASSERT(right->representation().IsDouble()); 986 ASSERT(right->representation().IsDouble());
973 return new LCmpIDAndBranch(UseRegisterAtStart(left), 987 return new LCmpIDAndBranch(UseRegisterAtStart(left),
974 UseRegisterAtStart(right), 988 UseRegisterAtStart(right));
975 first_id,
976 second_id);
977 } else { 989 } else {
978 ASSERT(left->representation().IsTagged()); 990 ASSERT(left->representation().IsTagged());
979 ASSERT(right->representation().IsTagged()); 991 ASSERT(right->representation().IsTagged());
980 bool reversed = op == Token::GT || op == Token::LTE; 992 bool reversed = op == Token::GT || op == Token::LTE;
981 LOperand* left_operand = UseFixed(left, reversed ? r0 : r1); 993 LOperand* left_operand = UseFixed(left, reversed ? r0 : r1);
982 LOperand* right_operand = UseFixed(right, reversed ? r1 : r0); 994 LOperand* right_operand = UseFixed(right, reversed ? r1 : r0);
983 LInstruction* result = new LCmpTAndBranch(left_operand, 995 LInstruction* result = new LCmpTAndBranch(left_operand,
984 right_operand, 996 right_operand);
985 first_id,
986 second_id);
987 return MarkAsCall(result, instr); 997 return MarkAsCall(result, instr);
988 } 998 }
989 } else if (v->IsIsSmi()) { 999 } else if (v->IsIsSmi()) {
990 HIsSmi* compare = HIsSmi::cast(v); 1000 HIsSmi* compare = HIsSmi::cast(v);
991 ASSERT(compare->value()->representation().IsTagged()); 1001 ASSERT(compare->value()->representation().IsTagged());
992 1002
993 return new LIsSmiAndBranch(Use(compare->value()), 1003 return new LIsSmiAndBranch(Use(compare->value()));
994 first_id,
995 second_id);
996 } else if (v->IsHasInstanceType()) { 1004 } else if (v->IsHasInstanceType()) {
997 HHasInstanceType* compare = HHasInstanceType::cast(v); 1005 HHasInstanceType* compare = HHasInstanceType::cast(v);
998 ASSERT(compare->value()->representation().IsTagged()); 1006 ASSERT(compare->value()->representation().IsTagged());
999 1007 return new LHasInstanceTypeAndBranch(
1000 return new LHasInstanceTypeAndBranch(UseRegisterAtStart(compare->value()), 1008 UseRegisterAtStart(compare->value()));
1001 first_id,
1002 second_id);
1003 } else if (v->IsHasCachedArrayIndex()) { 1009 } else if (v->IsHasCachedArrayIndex()) {
1004 HHasCachedArrayIndex* compare = HHasCachedArrayIndex::cast(v); 1010 HHasCachedArrayIndex* compare = HHasCachedArrayIndex::cast(v);
1005 ASSERT(compare->value()->representation().IsTagged()); 1011 ASSERT(compare->value()->representation().IsTagged());
1006 1012
1007 return new LHasCachedArrayIndexAndBranch( 1013 return new LHasCachedArrayIndexAndBranch(
1008 UseRegisterAtStart(compare->value()), first_id, second_id); 1014 UseRegisterAtStart(compare->value()));
1009 } else if (v->IsIsNull()) { 1015 } else if (v->IsIsNull()) {
1010 HIsNull* compare = HIsNull::cast(v); 1016 HIsNull* compare = HIsNull::cast(v);
1011 ASSERT(compare->value()->representation().IsTagged()); 1017 ASSERT(compare->value()->representation().IsTagged());
1012 1018
1013 return new LIsNullAndBranch(UseRegisterAtStart(compare->value()), 1019 return new LIsNullAndBranch(UseRegisterAtStart(compare->value()));
1014 first_id,
1015 second_id);
1016 } else if (v->IsIsObject()) { 1020 } else if (v->IsIsObject()) {
1017 HIsObject* compare = HIsObject::cast(v); 1021 HIsObject* compare = HIsObject::cast(v);
1018 ASSERT(compare->value()->representation().IsTagged()); 1022 ASSERT(compare->value()->representation().IsTagged());
1019 1023
1020 LOperand* temp1 = TempRegister(); 1024 LOperand* temp1 = TempRegister();
1021 LOperand* temp2 = TempRegister(); 1025 LOperand* temp2 = TempRegister();
1022 return new LIsObjectAndBranch(UseRegisterAtStart(compare->value()), 1026 return new LIsObjectAndBranch(UseRegisterAtStart(compare->value()),
1023 temp1, 1027 temp1,
1024 temp2, 1028 temp2);
1025 first_id,
1026 second_id);
1027 } else if (v->IsCompareJSObjectEq()) { 1029 } else if (v->IsCompareJSObjectEq()) {
1028 HCompareJSObjectEq* compare = HCompareJSObjectEq::cast(v); 1030 HCompareJSObjectEq* compare = HCompareJSObjectEq::cast(v);
1029 return new LCmpJSObjectEqAndBranch(UseRegisterAtStart(compare->left()), 1031 return new LCmpJSObjectEqAndBranch(UseRegisterAtStart(compare->left()),
1030 UseRegisterAtStart(compare->right()), 1032 UseRegisterAtStart(compare->right()));
1031 first_id,
1032 second_id);
1033 } else if (v->IsInstanceOf()) { 1033 } else if (v->IsInstanceOf()) {
1034 HInstanceOf* instance_of = HInstanceOf::cast(v); 1034 HInstanceOf* instance_of = HInstanceOf::cast(v);
1035 LInstruction* result = 1035 LInstruction* result =
1036 new LInstanceOfAndBranch(Use(instance_of->left()), 1036 new LInstanceOfAndBranch(Use(instance_of->left()),
1037 Use(instance_of->right()), 1037 Use(instance_of->right()));
1038 first_id,
1039 second_id);
1040 return MarkAsCall(result, instr); 1038 return MarkAsCall(result, instr);
1041 } else if (v->IsTypeofIs()) { 1039 } else if (v->IsTypeofIs()) {
1042 HTypeofIs* typeof_is = HTypeofIs::cast(v); 1040 HTypeofIs* typeof_is = HTypeofIs::cast(v);
1043 return new LTypeofIsAndBranch(UseTempRegister(typeof_is->value()), 1041 return new LTypeofIsAndBranch(UseTempRegister(typeof_is->value()));
1044 first_id,
1045 second_id);
1046 } else { 1042 } else {
1047 if (v->IsConstant()) { 1043 if (v->IsConstant()) {
1048 if (HConstant::cast(v)->handle()->IsTrue()) { 1044 if (HConstant::cast(v)->handle()->IsTrue()) {
1049 return new LGoto(first_id); 1045 return new LGoto(instr->FirstSuccessor()->block_id());
1050 } else if (HConstant::cast(v)->handle()->IsFalse()) { 1046 } else if (HConstant::cast(v)->handle()->IsFalse()) {
1051 return new LGoto(second_id); 1047 return new LGoto(instr->SecondSuccessor()->block_id());
1052 } 1048 }
1053 } 1049 }
1054 Abort("Undefined compare before branch"); 1050 Abort("Undefined compare before branch");
1055 return NULL; 1051 return NULL;
1056 } 1052 }
1057 } 1053 }
1058 return new LBranch(UseRegisterAtStart(v), first_id, second_id); 1054 return new LBranch(UseRegisterAtStart(v));
1059 } 1055 }
1060 1056
1061 1057
1062 LInstruction* LChunkBuilder::DoCompareMap(HCompareMap* instr) { 1058 LInstruction* LChunkBuilder::DoCompareMap(HCompareMap* instr) {
1063 ASSERT(instr->value()->representation().IsTagged()); 1059 ASSERT(instr->value()->representation().IsTagged());
1064 LOperand* value = UseRegisterAtStart(instr->value()); 1060 LOperand* value = UseRegisterAtStart(instr->value());
1065 LOperand* temp = TempRegister(); 1061 LOperand* temp = TempRegister();
1066 return new LCmpMapAndBranch(value, temp); 1062 return new LCmpMapAndBranch(value, temp);
1067 } 1063 }
1068 1064
1069 1065
1070 LInstruction* LChunkBuilder::DoArgumentsLength(HArgumentsLength* length) { 1066 LInstruction* LChunkBuilder::DoArgumentsLength(HArgumentsLength* length) {
1071 return DefineAsRegister(new LArgumentsLength(UseRegister(length->value()))); 1067 return DefineAsRegister(new LArgumentsLength(UseRegister(length->value())));
1072 } 1068 }
1073 1069
1074 1070
1075 LInstruction* LChunkBuilder::DoArgumentsElements(HArgumentsElements* elems) { 1071 LInstruction* LChunkBuilder::DoArgumentsElements(HArgumentsElements* elems) {
1076 return DefineAsRegister(new LArgumentsElements); 1072 return DefineAsRegister(new LArgumentsElements);
1077 } 1073 }
1078 1074
1079 1075
1080 LInstruction* LChunkBuilder::DoInstanceOf(HInstanceOf* instr) { 1076 LInstruction* LChunkBuilder::DoInstanceOf(HInstanceOf* instr) {
1081 LInstruction* result = 1077 LInstanceOf* result =
1082 new LInstanceOf(UseFixed(instr->left(), r0), 1078 new LInstanceOf(UseFixed(instr->left(), r0),
1083 UseFixed(instr->right(), r1)); 1079 UseFixed(instr->right(), r1));
1084 return MarkAsCall(DefineFixed(result, r0), instr); 1080 return MarkAsCall(DefineFixed(result, r0), instr);
1085 } 1081 }
1086 1082
1087 1083
1088 LInstruction* LChunkBuilder::DoInstanceOfKnownGlobal( 1084 LInstruction* LChunkBuilder::DoInstanceOfKnownGlobal(
1089 HInstanceOfKnownGlobal* instr) { 1085 HInstanceOfKnownGlobal* instr) {
1090 LInstruction* result = 1086 LInstanceOfKnownGlobal* result =
1091 new LInstanceOfKnownGlobal(UseFixed(instr->value(), r0), FixedTemp(r4)); 1087 new LInstanceOfKnownGlobal(UseFixed(instr->value(), r0), FixedTemp(r4));
1092 MarkAsSaveDoubles(result); 1088 MarkAsSaveDoubles(result);
1093 return AssignEnvironment(AssignPointerMap(DefineFixed(result, r0))); 1089 return AssignEnvironment(AssignPointerMap(DefineFixed(result, r0)));
1094 } 1090 }
1095 1091
1096 1092
1097 LInstruction* LChunkBuilder::DoApplyArguments(HApplyArguments* instr) { 1093 LInstruction* LChunkBuilder::DoApplyArguments(HApplyArguments* instr) {
1098 LOperand* function = UseFixed(instr->function(), r1); 1094 LOperand* function = UseFixed(instr->function(), r1);
1099 LOperand* receiver = UseFixed(instr->receiver(), r0); 1095 LOperand* receiver = UseFixed(instr->receiver(), r0);
1100 LOperand* length = UseRegisterAtStart(instr->length()); 1096 LOperand* length = UseRegisterAtStart(instr->length());
1101 LOperand* elements = UseRegisterAtStart(instr->elements()); 1097 LOperand* elements = UseRegisterAtStart(instr->elements());
1102 LInstruction* result = new LApplyArguments(function, 1098 LApplyArguments* result = new LApplyArguments(function,
1103 receiver, 1099 receiver,
1104 length, 1100 length,
1105 elements); 1101 elements);
1106 return MarkAsCall(DefineFixed(result, r0), instr, CAN_DEOPTIMIZE_EAGERLY); 1102 return MarkAsCall(DefineFixed(result, r0), instr, CAN_DEOPTIMIZE_EAGERLY);
1107 } 1103 }
1108 1104
1109 1105
1110 LInstruction* LChunkBuilder::DoPushArgument(HPushArgument* instr) { 1106 LInstruction* LChunkBuilder::DoPushArgument(HPushArgument* instr) {
1111 ++argument_count_; 1107 ++argument_count_;
1112 LOperand* argument = Use(instr->argument()); 1108 LOperand* argument = Use(instr->argument());
1113 return new LPushArgument(argument); 1109 return new LPushArgument(argument);
1114 } 1110 }
1115 1111
(...skipping 12 matching lines...) Expand all
1128 HCallConstantFunction* instr) { 1124 HCallConstantFunction* instr) {
1129 argument_count_ -= instr->argument_count(); 1125 argument_count_ -= instr->argument_count();
1130 return MarkAsCall(DefineFixed(new LCallConstantFunction, r0), instr); 1126 return MarkAsCall(DefineFixed(new LCallConstantFunction, r0), instr);
1131 } 1127 }
1132 1128
1133 1129
1134 LInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) { 1130 LInstruction* LChunkBuilder::DoUnaryMathOperation(HUnaryMathOperation* instr) {
1135 BuiltinFunctionId op = instr->op(); 1131 BuiltinFunctionId op = instr->op();
1136 LOperand* input = UseRegisterAtStart(instr->value()); 1132 LOperand* input = UseRegisterAtStart(instr->value());
1137 LOperand* temp = (op == kMathFloor) ? TempRegister() : NULL; 1133 LOperand* temp = (op == kMathFloor) ? TempRegister() : NULL;
1138 LInstruction* result = new LUnaryMathOperation(input, temp); 1134 LUnaryMathOperation* result = new LUnaryMathOperation(input, temp);
1139 switch (op) { 1135 switch (op) {
1140 case kMathAbs: 1136 case kMathAbs:
1141 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); 1137 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result)));
1142 case kMathFloor: 1138 case kMathFloor:
1143 return AssignEnvironment(DefineAsRegister(result)); 1139 return AssignEnvironment(DefineAsRegister(result));
1144 case kMathSqrt: 1140 case kMathSqrt:
1145 return DefineSameAsFirst(result); 1141 return DefineSameAsFirst(result);
1146 case kMathRound: 1142 case kMathRound:
1147 Abort("MathRound LUnaryMathOperation not implemented"); 1143 Abort("MathRound LUnaryMathOperation not implemented");
1148 return NULL; 1144 return NULL;
(...skipping 12 matching lines...) Expand all
1161 default: 1157 default:
1162 UNREACHABLE(); 1158 UNREACHABLE();
1163 return NULL; 1159 return NULL;
1164 } 1160 }
1165 } 1161 }
1166 1162
1167 1163
1168 LInstruction* LChunkBuilder::DoCallKeyed(HCallKeyed* instr) { 1164 LInstruction* LChunkBuilder::DoCallKeyed(HCallKeyed* instr) {
1169 ASSERT(instr->key()->representation().IsTagged()); 1165 ASSERT(instr->key()->representation().IsTagged());
1170 argument_count_ -= instr->argument_count(); 1166 argument_count_ -= instr->argument_count();
1171 UseFixed(instr->key(), r2); 1167 LOperand* key = UseFixed(instr->key(), r2);
1172 return MarkAsCall(DefineFixed(new LCallKeyed, r0), instr); 1168 return MarkAsCall(DefineFixed(new LCallKeyed(key), r0), instr);
1173 } 1169 }
1174 1170
1175 1171
1176 LInstruction* LChunkBuilder::DoCallNamed(HCallNamed* instr) { 1172 LInstruction* LChunkBuilder::DoCallNamed(HCallNamed* instr) {
1177 argument_count_ -= instr->argument_count(); 1173 argument_count_ -= instr->argument_count();
1178 return MarkAsCall(DefineFixed(new LCallNamed, r0), instr); 1174 return MarkAsCall(DefineFixed(new LCallNamed, r0), instr);
1179 } 1175 }
1180 1176
1181 1177
1182 LInstruction* LChunkBuilder::DoCallGlobal(HCallGlobal* instr) { 1178 LInstruction* LChunkBuilder::DoCallGlobal(HCallGlobal* instr) {
1183 argument_count_ -= instr->argument_count(); 1179 argument_count_ -= instr->argument_count();
1184 return MarkAsCall(DefineFixed(new LCallGlobal, r0), instr); 1180 return MarkAsCall(DefineFixed(new LCallGlobal, r0), instr);
1185 } 1181 }
1186 1182
1187 1183
1188 LInstruction* LChunkBuilder::DoCallKnownGlobal(HCallKnownGlobal* instr) { 1184 LInstruction* LChunkBuilder::DoCallKnownGlobal(HCallKnownGlobal* instr) {
1189 argument_count_ -= instr->argument_count(); 1185 argument_count_ -= instr->argument_count();
1190 return MarkAsCall(DefineFixed(new LCallKnownGlobal, r0), instr); 1186 return MarkAsCall(DefineFixed(new LCallKnownGlobal, r0), instr);
1191 } 1187 }
1192 1188
1193 1189
1194 LInstruction* LChunkBuilder::DoCallNew(HCallNew* instr) { 1190 LInstruction* LChunkBuilder::DoCallNew(HCallNew* instr) {
1195 LOperand* constructor = UseFixed(instr->constructor(), r1); 1191 LOperand* constructor = UseFixed(instr->constructor(), r1);
1196 argument_count_ -= instr->argument_count(); 1192 argument_count_ -= instr->argument_count();
1197 LInstruction* result = new LCallNew(constructor); 1193 LCallNew* result = new LCallNew(constructor);
1198 return MarkAsCall(DefineFixed(result, r0), instr); 1194 return MarkAsCall(DefineFixed(result, r0), instr);
1199 } 1195 }
1200 1196
1201 1197
1202 LInstruction* LChunkBuilder::DoCallFunction(HCallFunction* instr) { 1198 LInstruction* LChunkBuilder::DoCallFunction(HCallFunction* instr) {
1203 argument_count_ -= instr->argument_count(); 1199 argument_count_ -= instr->argument_count();
1204 return MarkAsCall(DefineFixed(new LCallFunction, r0), instr); 1200 return MarkAsCall(DefineFixed(new LCallFunction, r0), instr);
1205 } 1201 }
1206 1202
1207 1203
(...skipping 169 matching lines...) Expand 10 before | Expand all | Expand 10 after
1377 ASSERT(instr->right()->representation().IsDouble()); 1373 ASSERT(instr->right()->representation().IsDouble());
1378 LOperand* left = UseRegisterAtStart(instr->left()); 1374 LOperand* left = UseRegisterAtStart(instr->left());
1379 LOperand* right = UseRegisterAtStart(instr->right()); 1375 LOperand* right = UseRegisterAtStart(instr->right());
1380 return DefineAsRegister(new LCmpID(left, right)); 1376 return DefineAsRegister(new LCmpID(left, right));
1381 } else { 1377 } else {
1382 ASSERT(instr->left()->representation().IsTagged()); 1378 ASSERT(instr->left()->representation().IsTagged());
1383 ASSERT(instr->right()->representation().IsTagged()); 1379 ASSERT(instr->right()->representation().IsTagged());
1384 bool reversed = (op == Token::GT || op == Token::LTE); 1380 bool reversed = (op == Token::GT || op == Token::LTE);
1385 LOperand* left = UseFixed(instr->left(), reversed ? r0 : r1); 1381 LOperand* left = UseFixed(instr->left(), reversed ? r0 : r1);
1386 LOperand* right = UseFixed(instr->right(), reversed ? r1 : r0); 1382 LOperand* right = UseFixed(instr->right(), reversed ? r1 : r0);
1387 LInstruction* result = new LCmpT(left, right); 1383 LCmpT* result = new LCmpT(left, right);
1388 return MarkAsCall(DefineFixed(result, r0), instr); 1384 return MarkAsCall(DefineFixed(result, r0), instr);
1389 } 1385 }
1390 } 1386 }
1391 1387
1392 1388
1393 LInstruction* LChunkBuilder::DoCompareJSObjectEq( 1389 LInstruction* LChunkBuilder::DoCompareJSObjectEq(
1394 HCompareJSObjectEq* instr) { 1390 HCompareJSObjectEq* instr) {
1395 LOperand* left = UseRegisterAtStart(instr->left()); 1391 LOperand* left = UseRegisterAtStart(instr->left());
1396 LOperand* right = UseRegisterAtStart(instr->right()); 1392 LOperand* right = UseRegisterAtStart(instr->right());
1397 LInstruction* result = new LCmpJSObjectEq(left, right); 1393 LCmpJSObjectEq* result = new LCmpJSObjectEq(left, right);
1398 return DefineAsRegister(result); 1394 return DefineAsRegister(result);
1399 } 1395 }
1400 1396
1401 1397
1402 LInstruction* LChunkBuilder::DoIsNull(HIsNull* instr) { 1398 LInstruction* LChunkBuilder::DoIsNull(HIsNull* instr) {
1403 ASSERT(instr->value()->representation().IsTagged()); 1399 ASSERT(instr->value()->representation().IsTagged());
1404 LOperand* value = UseRegisterAtStart(instr->value()); 1400 LOperand* value = UseRegisterAtStart(instr->value());
1405 1401
1406 return DefineAsRegister(new LIsNull(value)); 1402 return DefineAsRegister(new LIsNull(value));
1407 } 1403 }
(...skipping 46 matching lines...) Expand 10 before | Expand all | Expand 10 after
1454 1450
1455 1451
1456 LInstruction* LChunkBuilder::DoFixedArrayLength(HFixedArrayLength* instr) { 1452 LInstruction* LChunkBuilder::DoFixedArrayLength(HFixedArrayLength* instr) {
1457 LOperand* array = UseRegisterAtStart(instr->value()); 1453 LOperand* array = UseRegisterAtStart(instr->value());
1458 return DefineAsRegister(new LFixedArrayLength(array)); 1454 return DefineAsRegister(new LFixedArrayLength(array));
1459 } 1455 }
1460 1456
1461 1457
1462 LInstruction* LChunkBuilder::DoValueOf(HValueOf* instr) { 1458 LInstruction* LChunkBuilder::DoValueOf(HValueOf* instr) {
1463 LOperand* object = UseRegister(instr->value()); 1459 LOperand* object = UseRegister(instr->value());
1464 LInstruction* result = new LValueOf(object, TempRegister()); 1460 LValueOf* result = new LValueOf(object, TempRegister());
1465 return AssignEnvironment(DefineSameAsFirst(result)); 1461 return AssignEnvironment(DefineSameAsFirst(result));
1466 } 1462 }
1467 1463
1468 1464
1469 LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) { 1465 LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) {
1470 return AssignEnvironment(new LBoundsCheck(UseRegisterAtStart(instr->index()), 1466 return AssignEnvironment(new LBoundsCheck(UseRegisterAtStart(instr->index()),
1471 UseRegister(instr->length()))); 1467 UseRegister(instr->length())));
1472 } 1468 }
1473 1469
1474 1470
1475 LInstruction* LChunkBuilder::DoThrow(HThrow* instr) { 1471 LInstruction* LChunkBuilder::DoThrow(HThrow* instr) {
1476 LOperand* value = UseFixed(instr->value(), r0); 1472 LOperand* value = UseFixed(instr->value(), r0);
1477 return MarkAsCall(new LThrow(value), instr); 1473 return MarkAsCall(new LThrow(value), instr);
1478 } 1474 }
1479 1475
1480 1476
1481 LInstruction* LChunkBuilder::DoChange(HChange* instr) { 1477 LInstruction* LChunkBuilder::DoChange(HChange* instr) {
1482 Representation from = instr->from(); 1478 Representation from = instr->from();
1483 Representation to = instr->to(); 1479 Representation to = instr->to();
1484 if (from.IsTagged()) { 1480 if (from.IsTagged()) {
1485 if (to.IsDouble()) { 1481 if (to.IsDouble()) {
1486 LOperand* value = UseRegister(instr->value()); 1482 LOperand* value = UseRegister(instr->value());
1487 LInstruction* res = new LNumberUntagD(value); 1483 LNumberUntagD* res = new LNumberUntagD(value);
1488 return AssignEnvironment(DefineAsRegister(res)); 1484 return AssignEnvironment(DefineAsRegister(res));
1489 } else { 1485 } else {
1490 ASSERT(to.IsInteger32()); 1486 ASSERT(to.IsInteger32());
1491 LOperand* value = UseRegister(instr->value()); 1487 LOperand* value = UseRegister(instr->value());
1492 bool needs_check = !instr->value()->type().IsSmi(); 1488 bool needs_check = !instr->value()->type().IsSmi();
1493 LInstruction* res = NULL; 1489 LInstruction* res = NULL;
1494 if (needs_check) { 1490 if (needs_check) {
1495 res = DefineSameAsFirst(new LTaggedToI(value, FixedTemp(d1))); 1491 res = DefineSameAsFirst(new LTaggedToI(value, FixedTemp(d1)));
1496 } else { 1492 } else {
1497 res = DefineSameAsFirst(new LSmiUntag(value, needs_check)); 1493 res = DefineSameAsFirst(new LSmiUntag(value, needs_check));
1498 } 1494 }
1499 if (needs_check) { 1495 if (needs_check) {
1500 res = AssignEnvironment(res); 1496 res = AssignEnvironment(res);
1501 } 1497 }
1502 return res; 1498 return res;
1503 } 1499 }
1504 } else if (from.IsDouble()) { 1500 } else if (from.IsDouble()) {
1505 if (to.IsTagged()) { 1501 if (to.IsTagged()) {
1506 LOperand* value = UseRegister(instr->value()); 1502 LOperand* value = UseRegister(instr->value());
1507 LOperand* temp1 = TempRegister(); 1503 LOperand* temp1 = TempRegister();
1508 LOperand* temp2 = TempRegister(); 1504 LOperand* temp2 = TempRegister();
1509 1505
1510 // Make sure that the temp and result_temp registers are 1506 // Make sure that the temp and result_temp registers are
1511 // different. 1507 // different.
1512 LUnallocated* result_temp = TempRegister(); 1508 LUnallocated* result_temp = TempRegister();
1513 LInstruction* result = new LNumberTagD(value, temp1, temp2); 1509 LNumberTagD* result = new LNumberTagD(value, temp1, temp2);
1514 Define(result, result_temp); 1510 Define(result, result_temp);
1515 return AssignPointerMap(result); 1511 return AssignPointerMap(result);
1516 } else { 1512 } else {
1517 ASSERT(to.IsInteger32()); 1513 ASSERT(to.IsInteger32());
1518 LOperand* value = UseRegister(instr->value()); 1514 LOperand* value = UseRegister(instr->value());
1519 LInstruction* res = new LDoubleToI(value); 1515 LDoubleToI* res = new LDoubleToI(value);
1520 return AssignEnvironment(DefineAsRegister(res)); 1516 return AssignEnvironment(DefineAsRegister(res));
1521 } 1517 }
1522 } else if (from.IsInteger32()) { 1518 } else if (from.IsInteger32()) {
1523 if (to.IsTagged()) { 1519 if (to.IsTagged()) {
1524 HValue* val = instr->value(); 1520 HValue* val = instr->value();
1525 LOperand* value = UseRegister(val); 1521 LOperand* value = UseRegister(val);
1526 if (val->HasRange() && val->range()->IsInSmiRange()) { 1522 if (val->HasRange() && val->range()->IsInSmiRange()) {
1527 return DefineSameAsFirst(new LSmiTag(value)); 1523 return DefineSameAsFirst(new LSmiTag(value));
1528 } else { 1524 } else {
1529 LInstruction* result = new LNumberTagI(value); 1525 LNumberTagI* result = new LNumberTagI(value);
1530 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); 1526 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result)));
1531 } 1527 }
1532 } else { 1528 } else {
1533 ASSERT(to.IsDouble()); 1529 ASSERT(to.IsDouble());
1534 LOperand* value = Use(instr->value()); 1530 LOperand* value = Use(instr->value());
1535 return DefineAsRegister(new LInteger32ToDouble(value)); 1531 return DefineAsRegister(new LInteger32ToDouble(value));
1536 } 1532 }
1537 } 1533 }
1538 UNREACHABLE(); 1534 UNREACHABLE();
1539 return NULL; 1535 return NULL;
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
1596 } else if (r.IsTagged()) { 1592 } else if (r.IsTagged()) {
1597 return DefineAsRegister(new LConstantT(instr->handle())); 1593 return DefineAsRegister(new LConstantT(instr->handle()));
1598 } else { 1594 } else {
1599 UNREACHABLE(); 1595 UNREACHABLE();
1600 return NULL; 1596 return NULL;
1601 } 1597 }
1602 } 1598 }
1603 1599
1604 1600
1605 LInstruction* LChunkBuilder::DoLoadGlobal(HLoadGlobal* instr) { 1601 LInstruction* LChunkBuilder::DoLoadGlobal(HLoadGlobal* instr) {
1606 LInstruction* result = new LLoadGlobal(); 1602 LLoadGlobal* result = new LLoadGlobal();
1607 return instr->check_hole_value() 1603 return instr->check_hole_value()
1608 ? AssignEnvironment(DefineAsRegister(result)) 1604 ? AssignEnvironment(DefineAsRegister(result))
1609 : DefineAsRegister(result); 1605 : DefineAsRegister(result);
1610 } 1606 }
1611 1607
1612 1608
1613 LInstruction* LChunkBuilder::DoStoreGlobal(HStoreGlobal* instr) { 1609 LInstruction* LChunkBuilder::DoStoreGlobal(HStoreGlobal* instr) {
1614 return new LStoreGlobal(UseRegisterAtStart(instr->value())); 1610 return new LStoreGlobal(UseRegisterAtStart(instr->value()));
1615 } 1611 }
1616 1612
(...skipping 28 matching lines...) Expand all
1645 return DefineSameAsFirst(new LLoadElements(input)); 1641 return DefineSameAsFirst(new LLoadElements(input));
1646 } 1642 }
1647 1643
1648 1644
1649 LInstruction* LChunkBuilder::DoLoadKeyedFastElement( 1645 LInstruction* LChunkBuilder::DoLoadKeyedFastElement(
1650 HLoadKeyedFastElement* instr) { 1646 HLoadKeyedFastElement* instr) {
1651 ASSERT(instr->representation().IsTagged()); 1647 ASSERT(instr->representation().IsTagged());
1652 ASSERT(instr->key()->representation().IsInteger32()); 1648 ASSERT(instr->key()->representation().IsInteger32());
1653 LOperand* obj = UseRegisterAtStart(instr->object()); 1649 LOperand* obj = UseRegisterAtStart(instr->object());
1654 LOperand* key = UseRegisterAtStart(instr->key()); 1650 LOperand* key = UseRegisterAtStart(instr->key());
1655 LInstruction* result = new LLoadKeyedFastElement(obj, key); 1651 LLoadKeyedFastElement* result = new LLoadKeyedFastElement(obj, key);
1656 return AssignEnvironment(DefineSameAsFirst(result)); 1652 return AssignEnvironment(DefineSameAsFirst(result));
1657 } 1653 }
1658 1654
1659 1655
1660 LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) { 1656 LInstruction* LChunkBuilder::DoLoadKeyedGeneric(HLoadKeyedGeneric* instr) {
1661 LOperand* object = UseFixed(instr->object(), r1); 1657 LOperand* object = UseFixed(instr->object(), r1);
1662 LOperand* key = UseFixed(instr->key(), r0); 1658 LOperand* key = UseFixed(instr->key(), r0);
1663 1659
1664 LInstruction* result = 1660 LInstruction* result =
1665 DefineFixed(new LLoadKeyedGeneric(object, key), r0); 1661 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); 1715 LOperand* val = UseFixed(instr->value(), r0);
1720 1716
1721 LInstruction* result = new LStoreNamedGeneric(obj, val); 1717 LInstruction* result = new LStoreNamedGeneric(obj, val);
1722 return MarkAsCall(result, instr); 1718 return MarkAsCall(result, instr);
1723 } 1719 }
1724 1720
1725 1721
1726 LInstruction* LChunkBuilder::DoStringCharCodeAt(HStringCharCodeAt* instr) { 1722 LInstruction* LChunkBuilder::DoStringCharCodeAt(HStringCharCodeAt* instr) {
1727 LOperand* string = UseRegister(instr->string()); 1723 LOperand* string = UseRegister(instr->string());
1728 LOperand* index = UseRegisterOrConstant(instr->index()); 1724 LOperand* index = UseRegisterOrConstant(instr->index());
1729 LInstruction* result = new LStringCharCodeAt(string, index); 1725 LStringCharCodeAt* result = new LStringCharCodeAt(string, index);
1730 return AssignEnvironment(AssignPointerMap(DefineAsRegister(result))); 1726 return AssignEnvironment(AssignPointerMap(DefineAsRegister(result)));
1731 } 1727 }
1732 1728
1733 1729
1734 LInstruction* LChunkBuilder::DoStringLength(HStringLength* instr) { 1730 LInstruction* LChunkBuilder::DoStringLength(HStringLength* instr) {
1735 LOperand* string = UseRegisterAtStart(instr->value()); 1731 LOperand* string = UseRegisterAtStart(instr->value());
1736 return DefineAsRegister(new LStringLength(string)); 1732 return DefineAsRegister(new LStringLength(string));
1737 } 1733 }
1738 1734
1739 1735
(...skipping 13 matching lines...) Expand all
1753 1749
1754 1750
1755 LInstruction* LChunkBuilder::DoFunctionLiteral(HFunctionLiteral* instr) { 1751 LInstruction* LChunkBuilder::DoFunctionLiteral(HFunctionLiteral* instr) {
1756 return MarkAsCall(DefineFixed(new LFunctionLiteral, r0), instr); 1752 return MarkAsCall(DefineFixed(new LFunctionLiteral, r0), instr);
1757 } 1753 }
1758 1754
1759 1755
1760 LInstruction* LChunkBuilder::DoDeleteProperty(HDeleteProperty* instr) { 1756 LInstruction* LChunkBuilder::DoDeleteProperty(HDeleteProperty* instr) {
1761 LOperand* object = UseRegisterAtStart(instr->object()); 1757 LOperand* object = UseRegisterAtStart(instr->object());
1762 LOperand* key = UseRegisterAtStart(instr->key()); 1758 LOperand* key = UseRegisterAtStart(instr->key());
1763 LInstruction* result = new LDeleteProperty(object, key); 1759 LDeleteProperty* result = new LDeleteProperty(object, key);
1764 return MarkAsCall(DefineFixed(result, r0), instr); 1760 return MarkAsCall(DefineFixed(result, r0), instr);
1765 } 1761 }
1766 1762
1767 1763
1768 LInstruction* LChunkBuilder::DoOsrEntry(HOsrEntry* instr) { 1764 LInstruction* LChunkBuilder::DoOsrEntry(HOsrEntry* instr) {
1769 allocator_->MarkAsOsrEntry(); 1765 allocator_->MarkAsOsrEntry();
1770 current_block_->last_environment()->set_ast_id(instr->ast_id()); 1766 current_block_->last_environment()->set_ast_id(instr->ast_id());
1771 return AssignEnvironment(new LOsrEntry); 1767 return AssignEnvironment(new LOsrEntry);
1772 } 1768 }
1773 1769
(...skipping 20 matching lines...) Expand all
1794 // There are no real uses of the arguments object (we bail out in all other 1790 // There are no real uses of the arguments object (we bail out in all other
1795 // cases). 1791 // cases).
1796 return NULL; 1792 return NULL;
1797 } 1793 }
1798 1794
1799 1795
1800 LInstruction* LChunkBuilder::DoAccessArgumentsAt(HAccessArgumentsAt* instr) { 1796 LInstruction* LChunkBuilder::DoAccessArgumentsAt(HAccessArgumentsAt* instr) {
1801 LOperand* arguments = UseRegister(instr->arguments()); 1797 LOperand* arguments = UseRegister(instr->arguments());
1802 LOperand* length = UseTempRegister(instr->length()); 1798 LOperand* length = UseTempRegister(instr->length());
1803 LOperand* index = UseRegister(instr->index()); 1799 LOperand* index = UseRegister(instr->index());
1804 LInstruction* result = new LAccessArgumentsAt(arguments, length, index); 1800 LAccessArgumentsAt* result = new LAccessArgumentsAt(arguments, length, index);
1805 return DefineAsRegister(AssignEnvironment(result)); 1801 return AssignEnvironment(DefineAsRegister(result));
1806 } 1802 }
1807 1803
1808 1804
1809 LInstruction* LChunkBuilder::DoTypeof(HTypeof* instr) { 1805 LInstruction* LChunkBuilder::DoTypeof(HTypeof* instr) {
1810 LInstruction* result = new LTypeof(UseRegisterAtStart(instr->value())); 1806 LTypeof* result = new LTypeof(UseRegisterAtStart(instr->value()));
1811 return MarkAsCall(DefineFixed(result, r0), instr); 1807 return MarkAsCall(DefineFixed(result, r0), instr);
1812 } 1808 }
1813 1809
1814 1810
1815 LInstruction* LChunkBuilder::DoTypeofIs(HTypeofIs* instr) { 1811 LInstruction* LChunkBuilder::DoTypeofIs(HTypeofIs* instr) {
1816 return DefineSameAsFirst(new LTypeofIs(UseRegister(instr->value()))); 1812 return DefineSameAsFirst(new LTypeofIs(UseRegister(instr->value())));
1817 } 1813 }
1818 1814
1819 LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) { 1815 LInstruction* LChunkBuilder::DoSimulate(HSimulate* instr) {
1820 HEnvironment* env = current_block_->last_environment(); 1816 HEnvironment* env = current_block_->last_environment();
(...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after
1868 1864
1869 1865
1870 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) { 1866 LInstruction* LChunkBuilder::DoLeaveInlined(HLeaveInlined* instr) {
1871 HEnvironment* outer = current_block_->last_environment()->outer(); 1867 HEnvironment* outer = current_block_->last_environment()->outer();
1872 current_block_->UpdateEnvironment(outer); 1868 current_block_->UpdateEnvironment(outer);
1873 return NULL; 1869 return NULL;
1874 } 1870 }
1875 1871
1876 1872
1877 } } // namespace v8::internal 1873 } } // namespace v8::internal
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698