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 |
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 "v8.h" | 28 #include "v8.h" |
29 | 29 |
30 #if defined(V8_TARGET_ARCH_X64) | 30 #if V8_TARGET_ARCH_X64 |
31 | 31 |
32 #include "lithium-allocator-inl.h" | 32 #include "lithium-allocator-inl.h" |
33 #include "x64/lithium-x64.h" | 33 #include "x64/lithium-x64.h" |
34 #include "x64/lithium-codegen-x64.h" | 34 #include "x64/lithium-codegen-x64.h" |
35 | 35 |
36 namespace v8 { | 36 namespace v8 { |
37 namespace internal { | 37 namespace internal { |
38 | 38 |
39 #define DEFINE_COMPILE(type) \ | 39 #define DEFINE_COMPILE(type) \ |
40 void L##type::CompileToNative(LCodeGen* generator) { \ | 40 void L##type::CompileToNative(LCodeGen* generator) { \ |
(...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
178 stream->Add("B%d", block_id()); | 178 stream->Add("B%d", block_id()); |
179 } | 179 } |
180 | 180 |
181 | 181 |
182 void LBranch::PrintDataTo(StringStream* stream) { | 182 void LBranch::PrintDataTo(StringStream* stream) { |
183 stream->Add("B%d | B%d on ", true_block_id(), false_block_id()); | 183 stream->Add("B%d | B%d on ", true_block_id(), false_block_id()); |
184 value()->PrintTo(stream); | 184 value()->PrintTo(stream); |
185 } | 185 } |
186 | 186 |
187 | 187 |
188 void LCmpIDAndBranch::PrintDataTo(StringStream* stream) { | 188 void LCompareNumericAndBranch::PrintDataTo(StringStream* stream) { |
189 stream->Add("if "); | 189 stream->Add("if "); |
190 left()->PrintTo(stream); | 190 left()->PrintTo(stream); |
191 stream->Add(" %s ", Token::String(op())); | 191 stream->Add(" %s ", Token::String(op())); |
192 right()->PrintTo(stream); | 192 right()->PrintTo(stream); |
193 stream->Add(" then B%d else B%d", true_block_id(), false_block_id()); | 193 stream->Add(" then B%d else B%d", true_block_id(), false_block_id()); |
194 } | 194 } |
195 | 195 |
196 | 196 |
197 void LIsObjectAndBranch::PrintDataTo(StringStream* stream) { | 197 void LIsObjectAndBranch::PrintDataTo(StringStream* stream) { |
198 stream->Add("if is_object("); | 198 stream->Add("if is_object("); |
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
322 constructor()->PrintTo(stream); | 322 constructor()->PrintTo(stream); |
323 stream->Add(" #%d / ", arity()); | 323 stream->Add(" #%d / ", arity()); |
324 } | 324 } |
325 | 325 |
326 | 326 |
327 void LCallNewArray::PrintDataTo(StringStream* stream) { | 327 void LCallNewArray::PrintDataTo(StringStream* stream) { |
328 stream->Add("= "); | 328 stream->Add("= "); |
329 constructor()->PrintTo(stream); | 329 constructor()->PrintTo(stream); |
330 stream->Add(" #%d / ", arity()); | 330 stream->Add(" #%d / ", arity()); |
331 ASSERT(hydrogen()->property_cell()->value()->IsSmi()); | 331 ASSERT(hydrogen()->property_cell()->value()->IsSmi()); |
332 ElementsKind kind = static_cast<ElementsKind>( | 332 ElementsKind kind = hydrogen()->elements_kind(); |
333 Smi::cast(hydrogen()->property_cell()->value())->value()); | |
334 stream->Add(" (%s) ", ElementsKindToString(kind)); | 333 stream->Add(" (%s) ", ElementsKindToString(kind)); |
335 } | 334 } |
336 | 335 |
337 | 336 |
338 void LAccessArgumentsAt::PrintDataTo(StringStream* stream) { | 337 void LAccessArgumentsAt::PrintDataTo(StringStream* stream) { |
339 arguments()->PrintTo(stream); | 338 arguments()->PrintTo(stream); |
340 | 339 |
341 stream->Add(" length "); | 340 stream->Add(" length "); |
342 length()->PrintTo(stream); | 341 length()->PrintTo(stream); |
343 | 342 |
(...skipping 818 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1162 return AssignEnvironment(DefineAsRegister(result)); | 1161 return AssignEnvironment(DefineAsRegister(result)); |
1163 } | 1162 } |
1164 | 1163 |
1165 | 1164 |
1166 LInstruction* LChunkBuilder::DoMathRound(HUnaryMathOperation* instr) { | 1165 LInstruction* LChunkBuilder::DoMathRound(HUnaryMathOperation* instr) { |
1167 LOperand* input = UseRegisterAtStart(instr->value()); | 1166 LOperand* input = UseRegisterAtStart(instr->value()); |
1168 LMathRound* result = new(zone()) LMathRound(input); | 1167 LMathRound* result = new(zone()) LMathRound(input); |
1169 return AssignEnvironment(DefineAsRegister(result)); | 1168 return AssignEnvironment(DefineAsRegister(result)); |
1170 } | 1169 } |
1171 | 1170 |
| 1171 |
1172 LInstruction* LChunkBuilder::DoMathAbs(HUnaryMathOperation* instr) { | 1172 LInstruction* LChunkBuilder::DoMathAbs(HUnaryMathOperation* instr) { |
1173 LOperand* input = UseRegisterAtStart(instr->value()); | 1173 LOperand* input = UseRegisterAtStart(instr->value()); |
1174 LMathAbs* result = new(zone()) LMathAbs(input); | 1174 LMathAbs* result = new(zone()) LMathAbs(input); |
1175 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); | 1175 return AssignEnvironment(AssignPointerMap(DefineSameAsFirst(result))); |
1176 } | 1176 } |
1177 | 1177 |
1178 | 1178 |
1179 LInstruction* LChunkBuilder::DoMathLog(HUnaryMathOperation* instr) { | 1179 LInstruction* LChunkBuilder::DoMathLog(HUnaryMathOperation* instr) { |
1180 LOperand* input = UseFixedDouble(instr->value(), xmm1); | 1180 LOperand* input = UseFixedDouble(instr->value(), xmm1); |
1181 LMathLog* result = new(zone()) LMathLog(input); | 1181 LMathLog* result = new(zone()) LMathLog(input); |
(...skipping 410 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1592 LInstruction* LChunkBuilder::DoCompareGeneric(HCompareGeneric* instr) { | 1592 LInstruction* LChunkBuilder::DoCompareGeneric(HCompareGeneric* instr) { |
1593 ASSERT(instr->left()->representation().IsTagged()); | 1593 ASSERT(instr->left()->representation().IsTagged()); |
1594 ASSERT(instr->right()->representation().IsTagged()); | 1594 ASSERT(instr->right()->representation().IsTagged()); |
1595 LOperand* left = UseFixed(instr->left(), rdx); | 1595 LOperand* left = UseFixed(instr->left(), rdx); |
1596 LOperand* right = UseFixed(instr->right(), rax); | 1596 LOperand* right = UseFixed(instr->right(), rax); |
1597 LCmpT* result = new(zone()) LCmpT(left, right); | 1597 LCmpT* result = new(zone()) LCmpT(left, right); |
1598 return MarkAsCall(DefineFixed(result, rax), instr); | 1598 return MarkAsCall(DefineFixed(result, rax), instr); |
1599 } | 1599 } |
1600 | 1600 |
1601 | 1601 |
1602 LInstruction* LChunkBuilder::DoCompareIDAndBranch( | 1602 LInstruction* LChunkBuilder::DoCompareNumericAndBranch( |
1603 HCompareIDAndBranch* instr) { | 1603 HCompareNumericAndBranch* instr) { |
1604 Representation r = instr->representation(); | 1604 Representation r = instr->representation(); |
1605 if (r.IsSmiOrInteger32()) { | 1605 if (r.IsSmiOrInteger32()) { |
1606 ASSERT(instr->left()->representation().IsSmiOrInteger32()); | 1606 ASSERT(instr->left()->representation().IsSmiOrInteger32()); |
1607 ASSERT(instr->left()->representation().Equals( | 1607 ASSERT(instr->left()->representation().Equals( |
1608 instr->right()->representation())); | 1608 instr->right()->representation())); |
1609 LOperand* left = UseRegisterOrConstantAtStart(instr->left()); | 1609 LOperand* left = UseRegisterOrConstantAtStart(instr->left()); |
1610 LOperand* right = UseOrConstantAtStart(instr->right()); | 1610 LOperand* right = UseOrConstantAtStart(instr->right()); |
1611 return new(zone()) LCmpIDAndBranch(left, right); | 1611 return new(zone()) LCompareNumericAndBranch(left, right); |
1612 } else { | 1612 } else { |
1613 ASSERT(r.IsDouble()); | 1613 ASSERT(r.IsDouble()); |
1614 ASSERT(instr->left()->representation().IsDouble()); | 1614 ASSERT(instr->left()->representation().IsDouble()); |
1615 ASSERT(instr->right()->representation().IsDouble()); | 1615 ASSERT(instr->right()->representation().IsDouble()); |
1616 LOperand* left; | 1616 LOperand* left; |
1617 LOperand* right; | 1617 LOperand* right; |
1618 if (instr->left()->IsConstant() && instr->right()->IsConstant()) { | 1618 if (instr->left()->IsConstant() && instr->right()->IsConstant()) { |
1619 left = UseRegisterOrConstantAtStart(instr->left()); | 1619 left = UseRegisterOrConstantAtStart(instr->left()); |
1620 right = UseRegisterOrConstantAtStart(instr->right()); | 1620 right = UseRegisterOrConstantAtStart(instr->right()); |
1621 } else { | 1621 } else { |
1622 left = UseRegisterAtStart(instr->left()); | 1622 left = UseRegisterAtStart(instr->left()); |
1623 right = UseRegisterAtStart(instr->right()); | 1623 right = UseRegisterAtStart(instr->right()); |
1624 } | 1624 } |
1625 return new(zone()) LCmpIDAndBranch(left, right); | 1625 return new(zone()) LCompareNumericAndBranch(left, right); |
1626 } | 1626 } |
1627 } | 1627 } |
1628 | 1628 |
1629 | 1629 |
1630 LInstruction* LChunkBuilder::DoCompareObjectEqAndBranch( | 1630 LInstruction* LChunkBuilder::DoCompareObjectEqAndBranch( |
1631 HCompareObjectEqAndBranch* instr) { | 1631 HCompareObjectEqAndBranch* instr) { |
1632 LOperand* left = UseRegisterAtStart(instr->left()); | 1632 LOperand* left = UseRegisterAtStart(instr->left()); |
1633 LOperand* right = UseRegisterOrConstantAtStart(instr->right()); | 1633 LOperand* right = UseRegisterOrConstantAtStart(instr->right()); |
1634 return new(zone()) LCmpObjectEqAndBranch(left, right); | 1634 return new(zone()) LCmpObjectEqAndBranch(left, right); |
1635 } | 1635 } |
(...skipping 76 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1712 | 1712 |
1713 LInstruction* LChunkBuilder::DoClassOfTestAndBranch( | 1713 LInstruction* LChunkBuilder::DoClassOfTestAndBranch( |
1714 HClassOfTestAndBranch* instr) { | 1714 HClassOfTestAndBranch* instr) { |
1715 LOperand* value = UseRegister(instr->value()); | 1715 LOperand* value = UseRegister(instr->value()); |
1716 return new(zone()) LClassOfTestAndBranch(value, | 1716 return new(zone()) LClassOfTestAndBranch(value, |
1717 TempRegister(), | 1717 TempRegister(), |
1718 TempRegister()); | 1718 TempRegister()); |
1719 } | 1719 } |
1720 | 1720 |
1721 | 1721 |
1722 LInstruction* LChunkBuilder::DoFixedArrayBaseLength( | |
1723 HFixedArrayBaseLength* instr) { | |
1724 LOperand* array = UseRegisterAtStart(instr->value()); | |
1725 return DefineAsRegister(new(zone()) LFixedArrayBaseLength(array)); | |
1726 } | |
1727 | |
1728 | |
1729 LInstruction* LChunkBuilder::DoMapEnumLength(HMapEnumLength* instr) { | 1722 LInstruction* LChunkBuilder::DoMapEnumLength(HMapEnumLength* instr) { |
1730 LOperand* map = UseRegisterAtStart(instr->value()); | 1723 LOperand* map = UseRegisterAtStart(instr->value()); |
1731 return DefineAsRegister(new(zone()) LMapEnumLength(map)); | 1724 return DefineAsRegister(new(zone()) LMapEnumLength(map)); |
1732 } | 1725 } |
1733 | 1726 |
1734 | 1727 |
1735 LInstruction* LChunkBuilder::DoElementsKind(HElementsKind* instr) { | 1728 LInstruction* LChunkBuilder::DoElementsKind(HElementsKind* instr) { |
1736 LOperand* object = UseRegisterAtStart(instr->value()); | 1729 LOperand* object = UseRegisterAtStart(instr->value()); |
1737 return DefineAsRegister(new(zone()) LElementsKind(object)); | 1730 return DefineAsRegister(new(zone()) LElementsKind(object)); |
1738 } | 1731 } |
(...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1912 return NULL; | 1905 return NULL; |
1913 } | 1906 } |
1914 | 1907 |
1915 | 1908 |
1916 LInstruction* LChunkBuilder::DoCheckHeapObject(HCheckHeapObject* instr) { | 1909 LInstruction* LChunkBuilder::DoCheckHeapObject(HCheckHeapObject* instr) { |
1917 LOperand* value = UseRegisterAtStart(instr->value()); | 1910 LOperand* value = UseRegisterAtStart(instr->value()); |
1918 return AssignEnvironment(new(zone()) LCheckNonSmi(value)); | 1911 return AssignEnvironment(new(zone()) LCheckNonSmi(value)); |
1919 } | 1912 } |
1920 | 1913 |
1921 | 1914 |
| 1915 LInstruction* LChunkBuilder::DoCheckSmi(HCheckSmi* instr) { |
| 1916 LOperand* value = UseRegisterAtStart(instr->value()); |
| 1917 return AssignEnvironment(new(zone()) LCheckSmi(value)); |
| 1918 } |
| 1919 |
| 1920 |
| 1921 LInstruction* LChunkBuilder::DoIsNumberAndBranch(HIsNumberAndBranch* instr) { |
| 1922 return new(zone()) LIsNumberAndBranch( |
| 1923 UseRegisterOrConstantAtStart(instr->value())); |
| 1924 } |
| 1925 |
| 1926 |
1922 LInstruction* LChunkBuilder::DoCheckInstanceType(HCheckInstanceType* instr) { | 1927 LInstruction* LChunkBuilder::DoCheckInstanceType(HCheckInstanceType* instr) { |
1923 LOperand* value = UseRegisterAtStart(instr->value()); | 1928 LOperand* value = UseRegisterAtStart(instr->value()); |
1924 LCheckInstanceType* result = new(zone()) LCheckInstanceType(value); | 1929 LCheckInstanceType* result = new(zone()) LCheckInstanceType(value); |
1925 return AssignEnvironment(result); | 1930 return AssignEnvironment(result); |
1926 } | 1931 } |
1927 | 1932 |
1928 | 1933 |
1929 LInstruction* LChunkBuilder::DoCheckPrototypeMaps(HCheckPrototypeMaps* instr) { | 1934 LInstruction* LChunkBuilder::DoCheckPrototypeMaps(HCheckPrototypeMaps* instr) { |
1930 LUnallocated* temp = TempRegister(); | 1935 LUnallocated* temp = TempRegister(); |
1931 LCheckPrototypeMaps* result = new(zone()) LCheckPrototypeMaps(temp); | 1936 LCheckPrototypeMaps* result = new(zone()) LCheckPrototypeMaps(temp); |
(...skipping 643 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
2575 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2580 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
2576 LOperand* object = UseRegister(instr->object()); | 2581 LOperand* object = UseRegister(instr->object()); |
2577 LOperand* index = UseTempRegister(instr->index()); | 2582 LOperand* index = UseTempRegister(instr->index()); |
2578 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); | 2583 return DefineSameAsFirst(new(zone()) LLoadFieldByIndex(object, index)); |
2579 } | 2584 } |
2580 | 2585 |
2581 | 2586 |
2582 } } // namespace v8::internal | 2587 } } // namespace v8::internal |
2583 | 2588 |
2584 #endif // V8_TARGET_ARCH_X64 | 2589 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |