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

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

Issue 6066010: Merge 6095:6198 from bleeding_edge to experimental/gc. (Closed) Base URL: http://v8.googlecode.com/svn/branches/experimental/gc/
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/lithium-allocator.h ('k') | src/liveedit-debugger.js » ('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 2010 the V8 project authors. All rights reserved. 1 // Copyright 2010 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
11 // with the distribution. 11 // with the distribution.
12 // * Neither the name of Google Inc. nor the names of its 12 // * Neither the name of Google Inc. nor the names of its
13 // contributors may be used to endorse or promote products derived 13 // contributors may be used to endorse or promote products derived
14 // from this software without specific prior written permission. 14 // from this software without specific prior written permission.
15 // 15 //
16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 16 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 17 // "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 18 // LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 19 // A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 20 // OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 21 // SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 22 // LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 23 // DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 // THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 25 // (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 27
28 #include "lithium-allocator.h" 28 #include "lithium-allocator.h"
29 29
30 #include "data-flow.h"
31 #include "hydrogen.h" 30 #include "hydrogen.h"
32 #include "string-stream.h" 31 #include "string-stream.h"
33 32
34 #if V8_TARGET_ARCH_IA32 33 #if V8_TARGET_ARCH_IA32
35 #include "ia32/lithium-ia32.h" 34 #include "ia32/lithium-ia32.h"
36 #elif V8_TARGET_ARCH_X64 35 #elif V8_TARGET_ARCH_X64
37 #include "x64/lithium-x64.h" 36 #include "x64/lithium-x64.h"
38 #elif V8_TARGET_ARCH_ARM 37 #elif V8_TARGET_ARCH_ARM
39 #include "arm/lithium-arm.h" 38 #include "arm/lithium-arm.h"
40 #else 39 #else
(...skipping 59 matching lines...) Expand 10 before | Expand all | Expand 10 after
100 break; 99 break;
101 case LUnallocated::MUST_HAVE_REGISTER: 100 case LUnallocated::MUST_HAVE_REGISTER:
102 stream->Add("(R)"); 101 stream->Add("(R)");
103 break; 102 break;
104 case LUnallocated::WRITABLE_REGISTER: 103 case LUnallocated::WRITABLE_REGISTER:
105 stream->Add("(WR)"); 104 stream->Add("(WR)");
106 break; 105 break;
107 case LUnallocated::SAME_AS_FIRST_INPUT: 106 case LUnallocated::SAME_AS_FIRST_INPUT:
108 stream->Add("(1)"); 107 stream->Add("(1)");
109 break; 108 break;
110 case LUnallocated::SAME_AS_ANY_INPUT:
111 stream->Add("(A)");
112 break;
113 case LUnallocated::ANY: 109 case LUnallocated::ANY:
114 stream->Add("(-)"); 110 stream->Add("(-)");
115 break; 111 break;
116 case LUnallocated::IGNORE: 112 case LUnallocated::IGNORE:
117 stream->Add("(0)"); 113 stream->Add("(0)");
118 break; 114 break;
119 } 115 }
120 break; 116 break;
121 case CONSTANT_OPERAND: 117 case CONSTANT_OPERAND:
122 stream->Add("[constant:%d]", index()); 118 stream->Add("[constant:%d]", index());
(...skipping 704 matching lines...) Expand 10 before | Expand all | Expand 10 after
827 for (int i = 0; i < second->InputCount(); ++i) { 823 for (int i = 0; i < second->InputCount(); ++i) {
828 LUnallocated* cur_input = LUnallocated::cast(second->InputAt(i)); 824 LUnallocated* cur_input = LUnallocated::cast(second->InputAt(i));
829 if (cur_input->HasFixedPolicy()) { 825 if (cur_input->HasFixedPolicy()) {
830 LUnallocated* input_copy = cur_input->CopyUnconstrained(); 826 LUnallocated* input_copy = cur_input->CopyUnconstrained();
831 bool is_tagged = HasTaggedValue(cur_input->VirtualRegister()); 827 bool is_tagged = HasTaggedValue(cur_input->VirtualRegister());
832 AllocateFixed(cur_input, gap_index + 1, is_tagged); 828 AllocateFixed(cur_input, gap_index + 1, is_tagged);
833 AddConstraintsGapMove(gap_index, input_copy, cur_input); 829 AddConstraintsGapMove(gap_index, input_copy, cur_input);
834 } else if (cur_input->policy() == LUnallocated::WRITABLE_REGISTER) { 830 } else if (cur_input->policy() == LUnallocated::WRITABLE_REGISTER) {
835 LUnallocated* input_copy = cur_input->CopyUnconstrained(); 831 LUnallocated* input_copy = cur_input->CopyUnconstrained();
836 cur_input->set_virtual_register(next_virtual_register_++); 832 cur_input->set_virtual_register(next_virtual_register_++);
833
834 if (RequiredRegisterKind(input_copy->virtual_register()) ==
835 DOUBLE_REGISTERS) {
836 double_artificial_registers_.Add(
837 cur_input->virtual_register() - first_artificial_register_);
838 }
839
837 second->AddTemp(cur_input); 840 second->AddTemp(cur_input);
838 AddConstraintsGapMove(gap_index, input_copy, cur_input); 841 AddConstraintsGapMove(gap_index, input_copy, cur_input);
839 } 842 }
840 } 843 }
841 } 844 }
842 845
843 // Handle "output same as input" for second instruction. 846 // Handle "output same as input" for second instruction.
844 if (second != NULL && second->Output() != NULL) { 847 if (second != NULL && second->Output() != NULL) {
845 LUnallocated* second_output = LUnallocated::cast(second->Output()); 848 LUnallocated* second_output = LUnallocated::cast(second->Output());
846 if (second_output->HasSameAsInputPolicy()) { 849 if (second_output->HasSameAsInputPolicy()) {
(...skipping 182 matching lines...) Expand 10 before | Expand all | Expand 10 after
1029 AllocateDoubleRegisters(); 1032 AllocateDoubleRegisters();
1030 PopulatePointerMaps(); 1033 PopulatePointerMaps();
1031 if (has_osr_entry_) ProcessOsrEntry(); 1034 if (has_osr_entry_) ProcessOsrEntry();
1032 ConnectRanges(); 1035 ConnectRanges();
1033 ResolveControlFlow(); 1036 ResolveControlFlow();
1034 } 1037 }
1035 1038
1036 1039
1037 void LAllocator::MeetRegisterConstraints() { 1040 void LAllocator::MeetRegisterConstraints() {
1038 HPhase phase("Register constraints", chunk()); 1041 HPhase phase("Register constraints", chunk());
1042 first_artificial_register_ = next_virtual_register_;
1039 const ZoneList<HBasicBlock*>* blocks = graph()->blocks(); 1043 const ZoneList<HBasicBlock*>* blocks = graph()->blocks();
1040 for (int i = 0; i < blocks->length(); ++i) { 1044 for (int i = 0; i < blocks->length(); ++i) {
1041 HBasicBlock* block = blocks->at(i); 1045 HBasicBlock* block = blocks->at(i);
1042 MeetRegisterConstraints(block); 1046 MeetRegisterConstraints(block);
1043 } 1047 }
1044 } 1048 }
1045 1049
1046 1050
1047 void LAllocator::ResolvePhis() { 1051 void LAllocator::ResolvePhis() {
1048 HPhase phase("Resolve phis", chunk()); 1052 HPhase phase("Resolve phis", chunk());
(...skipping 508 matching lines...) Expand 10 before | Expand all | Expand 10 after
1557 1561
1558 1562
1559 bool LAllocator::HasTaggedValue(int virtual_register) const { 1563 bool LAllocator::HasTaggedValue(int virtual_register) const {
1560 HValue* value = graph()->LookupValue(virtual_register); 1564 HValue* value = graph()->LookupValue(virtual_register);
1561 if (value == NULL) return false; 1565 if (value == NULL) return false;
1562 return value->representation().IsTagged(); 1566 return value->representation().IsTagged();
1563 } 1567 }
1564 1568
1565 1569
1566 RegisterKind LAllocator::RequiredRegisterKind(int virtual_register) const { 1570 RegisterKind LAllocator::RequiredRegisterKind(int virtual_register) const {
1567 HValue* value = graph()->LookupValue(virtual_register); 1571 if (virtual_register < first_artificial_register_) {
1568 if (value != NULL && value->representation().IsDouble()) { 1572 HValue* value = graph()->LookupValue(virtual_register);
1573 if (value != NULL && value->representation().IsDouble()) {
1574 return DOUBLE_REGISTERS;
1575 }
1576 } else if (double_artificial_registers_.Contains(
1577 virtual_register - first_artificial_register_)) {
1569 return DOUBLE_REGISTERS; 1578 return DOUBLE_REGISTERS;
1570 } 1579 }
1580
1571 return GENERAL_REGISTERS; 1581 return GENERAL_REGISTERS;
1572 } 1582 }
1573 1583
1574 1584
1575 void LAllocator::MarkAsCall() { 1585 void LAllocator::MarkAsCall() {
1576 current_summary()->MarkAsCall(); 1586 // Call instructions can use only fixed registers as
1587 // temporaries and outputs because all registers
1588 // are blocked by the calling convention.
1589 // Inputs can use either fixed register or have a short lifetime (be
1590 // used at start of the instruction).
1591 InstructionSummary* summary = current_summary();
1592 #ifdef DEBUG
1593 ASSERT(summary->Output() == NULL ||
1594 LUnallocated::cast(summary->Output())->HasFixedPolicy() ||
1595 !LUnallocated::cast(summary->Output())->HasRegisterPolicy());
1596 for (int i = 0; i < summary->InputCount(); i++) {
1597 ASSERT(LUnallocated::cast(summary->InputAt(i))->HasFixedPolicy() ||
1598 LUnallocated::cast(summary->InputAt(i))->IsUsedAtStart() ||
1599 !LUnallocated::cast(summary->InputAt(i))->HasRegisterPolicy());
1600 }
1601 for (int i = 0; i < summary->TempCount(); i++) {
1602 ASSERT(LUnallocated::cast(summary->TempAt(i))->HasFixedPolicy() ||
1603 !LUnallocated::cast(summary->TempAt(i))->HasRegisterPolicy());
1604 }
1605 #endif
1606 summary->MarkAsCall();
1577 } 1607 }
1578 1608
1579 1609
1580 void LAllocator::RecordDefinition(HInstruction* instr, LUnallocated* operand) { 1610 void LAllocator::RecordDefinition(HInstruction* instr, LUnallocated* operand) {
1581 operand->set_virtual_register(instr->id()); 1611 operand->set_virtual_register(instr->id());
1582 current_summary()->SetOutput(operand); 1612 current_summary()->SetOutput(operand);
1583 } 1613 }
1584 1614
1585 1615
1586 void LAllocator::RecordTemporary(LUnallocated* operand) { 1616 void LAllocator::RecordTemporary(LUnallocated* operand) {
(...skipping 520 matching lines...) Expand 10 before | Expand all | Expand 10 after
2107 LiveRange* current = live_ranges()->at(i); 2137 LiveRange* current = live_ranges()->at(i);
2108 if (current != NULL) current->Verify(); 2138 if (current != NULL) current->Verify();
2109 } 2139 }
2110 } 2140 }
2111 2141
2112 2142
2113 #endif 2143 #endif
2114 2144
2115 2145
2116 } } // namespace v8::internal 2146 } } // namespace v8::internal
OLDNEW
« no previous file with comments | « src/lithium-allocator.h ('k') | src/liveedit-debugger.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698