OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 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 393 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
404 void LTransitionElementsKind::PrintDataTo(StringStream* stream) { | 404 void LTransitionElementsKind::PrintDataTo(StringStream* stream) { |
405 object()->PrintTo(stream); | 405 object()->PrintTo(stream); |
406 stream->Add(" %p -> %p", *original_map(), *transitioned_map()); | 406 stream->Add(" %p -> %p", *original_map(), *transitioned_map()); |
407 } | 407 } |
408 | 408 |
409 | 409 |
410 LChunk::LChunk(CompilationInfo* info, HGraph* graph) | 410 LChunk::LChunk(CompilationInfo* info, HGraph* graph) |
411 : spill_slot_count_(0), | 411 : spill_slot_count_(0), |
412 info_(info), | 412 info_(info), |
413 graph_(graph), | 413 graph_(graph), |
414 instructions_(32), | 414 instructions_(32, graph->zone()), |
415 pointer_maps_(8), | 415 pointer_maps_(8, graph->zone()), |
416 inlined_closures_(1) { | 416 inlined_closures_(1, graph->zone()) { |
417 } | 417 } |
418 | 418 |
419 | 419 |
420 int LChunk::GetNextSpillIndex(bool is_double) { | 420 int LChunk::GetNextSpillIndex(bool is_double) { |
421 // Skip a slot if for a double-width slot. | 421 // Skip a slot if for a double-width slot. |
422 if (is_double) spill_slot_count_++; | 422 if (is_double) spill_slot_count_++; |
423 return spill_slot_count_++; | 423 return spill_slot_count_++; |
424 } | 424 } |
425 | 425 |
426 | 426 |
427 LOperand* LChunk::GetNextSpillSlot(bool is_double) { | 427 LOperand* LChunk::GetNextSpillSlot(bool is_double) { |
428 int index = GetNextSpillIndex(is_double); | 428 int index = GetNextSpillIndex(is_double); |
429 if (is_double) { | 429 if (is_double) { |
430 return LDoubleStackSlot::Create(index); | 430 return LDoubleStackSlot::Create(index, zone()); |
431 } else { | 431 } else { |
432 return LStackSlot::Create(index); | 432 return LStackSlot::Create(index, zone()); |
433 } | 433 } |
434 } | 434 } |
435 | 435 |
436 | 436 |
437 void LChunk::MarkEmptyBlocks() { | 437 void LChunk::MarkEmptyBlocks() { |
438 HPhase phase("L_Mark empty blocks", this); | 438 HPhase phase("L_Mark empty blocks", this); |
439 for (int i = 0; i < graph()->blocks()->length(); ++i) { | 439 for (int i = 0; i < graph()->blocks()->length(); ++i) { |
440 HBasicBlock* block = graph()->blocks()->at(i); | 440 HBasicBlock* block = graph()->blocks()->at(i); |
441 int first = block->first_instruction_index(); | 441 int first = block->first_instruction_index(); |
442 int last = block->last_instruction_index(); | 442 int last = block->last_instruction_index(); |
(...skipping 24 matching lines...) Expand all Loading... |
467 } | 467 } |
468 } | 468 } |
469 } | 469 } |
470 } | 470 } |
471 | 471 |
472 | 472 |
473 void LChunk::AddInstruction(LInstruction* instr, HBasicBlock* block) { | 473 void LChunk::AddInstruction(LInstruction* instr, HBasicBlock* block) { |
474 LInstructionGap* gap = new(graph_->zone()) LInstructionGap(block); | 474 LInstructionGap* gap = new(graph_->zone()) LInstructionGap(block); |
475 int index = -1; | 475 int index = -1; |
476 if (instr->IsControl()) { | 476 if (instr->IsControl()) { |
477 instructions_.Add(gap); | 477 instructions_.Add(gap, zone()); |
478 index = instructions_.length(); | 478 index = instructions_.length(); |
479 instructions_.Add(instr); | 479 instructions_.Add(instr, zone()); |
480 } else { | 480 } else { |
481 index = instructions_.length(); | 481 index = instructions_.length(); |
482 instructions_.Add(instr); | 482 instructions_.Add(instr, zone()); |
483 instructions_.Add(gap); | 483 instructions_.Add(gap, zone()); |
484 } | 484 } |
485 if (instr->HasPointerMap()) { | 485 if (instr->HasPointerMap()) { |
486 pointer_maps_.Add(instr->pointer_map()); | 486 pointer_maps_.Add(instr->pointer_map(), zone()); |
487 instr->pointer_map()->set_lithium_position(index); | 487 instr->pointer_map()->set_lithium_position(index); |
488 } | 488 } |
489 } | 489 } |
490 | 490 |
491 | 491 |
492 LConstantOperand* LChunk::DefineConstantOperand(HConstant* constant) { | 492 LConstantOperand* LChunk::DefineConstantOperand(HConstant* constant) { |
493 return LConstantOperand::Create(constant->id()); | 493 return LConstantOperand::Create(constant->id(), zone()); |
494 } | 494 } |
495 | 495 |
496 | 496 |
497 int LChunk::GetParameterStackSlot(int index) const { | 497 int LChunk::GetParameterStackSlot(int index) const { |
498 // The receiver is at index 0, the first parameter at index 1, so we | 498 // The receiver is at index 0, the first parameter at index 1, so we |
499 // shift all parameter indexes down by the number of parameters, and | 499 // shift all parameter indexes down by the number of parameters, and |
500 // make sure they end up negative so they are distinguishable from | 500 // make sure they end up negative so they are distinguishable from |
501 // spill slots. | 501 // spill slots. |
502 int result = index - info()->scope()->num_parameters() - 1; | 502 int result = index - info()->scope()->num_parameters() - 1; |
503 ASSERT(result < 0); | 503 ASSERT(result < 0); |
(...skipping 18 matching lines...) Expand all Loading... |
522 } | 522 } |
523 | 523 |
524 | 524 |
525 int LChunk::NearestGapPos(int index) const { | 525 int LChunk::NearestGapPos(int index) const { |
526 while (!IsGapAt(index)) index--; | 526 while (!IsGapAt(index)) index--; |
527 return index; | 527 return index; |
528 } | 528 } |
529 | 529 |
530 | 530 |
531 void LChunk::AddGapMove(int index, LOperand* from, LOperand* to) { | 531 void LChunk::AddGapMove(int index, LOperand* from, LOperand* to) { |
532 GetGapAt(index)->GetOrCreateParallelMove(LGap::START)->AddMove(from, to); | 532 GetGapAt(index)->GetOrCreateParallelMove( |
| 533 LGap::START, zone())->AddMove(from, to, zone()); |
533 } | 534 } |
534 | 535 |
535 | 536 |
536 Handle<Object> LChunk::LookupLiteral(LConstantOperand* operand) const { | 537 Handle<Object> LChunk::LookupLiteral(LConstantOperand* operand) const { |
537 return HConstant::cast(graph_->LookupValue(operand->index()))->handle(); | 538 return HConstant::cast(graph_->LookupValue(operand->index()))->handle(); |
538 } | 539 } |
539 | 540 |
540 | 541 |
541 Representation LChunk::LookupLiteralRepresentation( | 542 Representation LChunk::LookupLiteralRepresentation( |
542 LConstantOperand* operand) const { | 543 LConstantOperand* operand) const { |
(...skipping 212 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
755 if (needs_environment && !instr->HasEnvironment()) { | 756 if (needs_environment && !instr->HasEnvironment()) { |
756 instr = AssignEnvironment(instr); | 757 instr = AssignEnvironment(instr); |
757 } | 758 } |
758 | 759 |
759 return instr; | 760 return instr; |
760 } | 761 } |
761 | 762 |
762 | 763 |
763 LInstruction* LChunkBuilder::AssignPointerMap(LInstruction* instr) { | 764 LInstruction* LChunkBuilder::AssignPointerMap(LInstruction* instr) { |
764 ASSERT(!instr->HasPointerMap()); | 765 ASSERT(!instr->HasPointerMap()); |
765 instr->set_pointer_map(new(zone()) LPointerMap(position_)); | 766 instr->set_pointer_map(new(zone()) LPointerMap(position_, zone())); |
766 return instr; | 767 return instr; |
767 } | 768 } |
768 | 769 |
769 | 770 |
770 LUnallocated* LChunkBuilder::TempRegister() { | 771 LUnallocated* LChunkBuilder::TempRegister() { |
771 LUnallocated* operand = | 772 LUnallocated* operand = |
772 new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER); | 773 new(zone()) LUnallocated(LUnallocated::MUST_HAVE_REGISTER); |
773 operand->set_virtual_register(allocator_->GetVirtualRegister()); | 774 operand->set_virtual_register(allocator_->GetVirtualRegister()); |
774 if (!allocator_->AllocationOk()) Abort("Not enough virtual registers."); | 775 if (!allocator_->AllocationOk()) Abort("Not enough virtual registers."); |
775 return operand; | 776 return operand; |
(...skipping 813 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1589 | 1590 |
1590 LInstruction* LChunkBuilder::DoValueOf(HValueOf* instr) { | 1591 LInstruction* LChunkBuilder::DoValueOf(HValueOf* instr) { |
1591 LOperand* object = UseRegister(instr->value()); | 1592 LOperand* object = UseRegister(instr->value()); |
1592 LValueOf* result = new(zone()) LValueOf(object, TempRegister()); | 1593 LValueOf* result = new(zone()) LValueOf(object, TempRegister()); |
1593 return DefineAsRegister(result); | 1594 return DefineAsRegister(result); |
1594 } | 1595 } |
1595 | 1596 |
1596 | 1597 |
1597 LInstruction* LChunkBuilder::DoDateField(HDateField* instr) { | 1598 LInstruction* LChunkBuilder::DoDateField(HDateField* instr) { |
1598 LOperand* object = UseFixed(instr->value(), a0); | 1599 LOperand* object = UseFixed(instr->value(), a0); |
1599 LDateField* result = new LDateField(object, FixedTemp(a1), instr->index()); | 1600 LDateField* result = |
| 1601 new(zone()) LDateField(object, FixedTemp(a1), instr->index()); |
1600 return MarkAsCall(DefineFixed(result, v0), instr); | 1602 return MarkAsCall(DefineFixed(result, v0), instr); |
1601 } | 1603 } |
1602 | 1604 |
1603 | 1605 |
1604 LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) { | 1606 LInstruction* LChunkBuilder::DoBoundsCheck(HBoundsCheck* instr) { |
1605 LOperand* value = UseRegisterAtStart(instr->index()); | 1607 LOperand* value = UseRegisterAtStart(instr->index()); |
1606 LOperand* length = UseRegister(instr->length()); | 1608 LOperand* length = UseRegister(instr->length()); |
1607 return AssignEnvironment(new(zone()) LBoundsCheck(value, length)); | 1609 return AssignEnvironment(new(zone()) LBoundsCheck(value, length)); |
1608 } | 1610 } |
1609 | 1611 |
(...skipping 494 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2104 } | 2106 } |
2105 | 2107 |
2106 | 2108 |
2107 LInstruction* LChunkBuilder::DoStringLength(HStringLength* instr) { | 2109 LInstruction* LChunkBuilder::DoStringLength(HStringLength* instr) { |
2108 LOperand* string = UseRegisterAtStart(instr->value()); | 2110 LOperand* string = UseRegisterAtStart(instr->value()); |
2109 return DefineAsRegister(new(zone()) LStringLength(string)); | 2111 return DefineAsRegister(new(zone()) LStringLength(string)); |
2110 } | 2112 } |
2111 | 2113 |
2112 | 2114 |
2113 LInstruction* LChunkBuilder::DoAllocateObject(HAllocateObject* instr) { | 2115 LInstruction* LChunkBuilder::DoAllocateObject(HAllocateObject* instr) { |
2114 LAllocateObject* result = new(zone()) LAllocateObject( | 2116 LAllocateObject* result = |
2115 TempRegister(), TempRegister()); | 2117 new(zone()) LAllocateObject(TempRegister(), TempRegister()); |
2116 return AssignPointerMap(DefineAsRegister(result)); | 2118 return AssignPointerMap(DefineAsRegister(result)); |
2117 } | 2119 } |
2118 | 2120 |
2119 | 2121 |
2120 LInstruction* LChunkBuilder::DoFastLiteral(HFastLiteral* instr) { | 2122 LInstruction* LChunkBuilder::DoFastLiteral(HFastLiteral* instr) { |
2121 return MarkAsCall(DefineFixed(new(zone()) LFastLiteral, v0), instr); | 2123 return MarkAsCall(DefineFixed(new(zone()) LFastLiteral, v0), instr); |
2122 } | 2124 } |
2123 | 2125 |
2124 | 2126 |
2125 LInstruction* LChunkBuilder::DoArrayLiteral(HArrayLiteral* instr) { | 2127 LInstruction* LChunkBuilder::DoArrayLiteral(HArrayLiteral* instr) { |
(...skipping 207 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2333 | 2335 |
2334 | 2336 |
2335 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2337 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2336 LOperand* object = UseRegister(instr->object()); | 2338 LOperand* object = UseRegister(instr->object()); |
2337 LOperand* index = UseRegister(instr->index()); | 2339 LOperand* index = UseRegister(instr->index()); |
2338 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2340 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
2339 } | 2341 } |
2340 | 2342 |
2341 | 2343 |
2342 } } // namespace v8::internal | 2344 } } // namespace v8::internal |
OLD | NEW |