| 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 692 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 703 } | 703 } |
| 704 | 704 |
| 705 | 705 |
| 706 LInstruction* LChunkBuilder::DoDeoptimize(HDeoptimize* instr) { | 706 LInstruction* LChunkBuilder::DoDeoptimize(HDeoptimize* instr) { |
| 707 return AssignEnvironment(new(zone()) LDeoptimize); | 707 return AssignEnvironment(new(zone()) LDeoptimize); |
| 708 } | 708 } |
| 709 | 709 |
| 710 | 710 |
| 711 LInstruction* LChunkBuilder::DoShift(Token::Value op, | 711 LInstruction* LChunkBuilder::DoShift(Token::Value op, |
| 712 HBitwiseBinaryOperation* instr) { | 712 HBitwiseBinaryOperation* instr) { |
| 713 if (instr->representation().IsTagged()) { | 713 if (instr->representation().IsSmiOrTagged()) { |
| 714 ASSERT(instr->left()->representation().IsTagged()); | 714 ASSERT(instr->left()->representation().IsSmiOrTagged()); |
| 715 ASSERT(instr->right()->representation().IsTagged()); | 715 ASSERT(instr->right()->representation().IsSmiOrTagged()); |
| 716 | 716 |
| 717 LOperand* left = UseFixed(instr->left(), r1); | 717 LOperand* left = UseFixed(instr->left(), r1); |
| 718 LOperand* right = UseFixed(instr->right(), r0); | 718 LOperand* right = UseFixed(instr->right(), r0); |
| 719 LArithmeticT* result = new(zone()) LArithmeticT(op, left, right); | 719 LArithmeticT* result = new(zone()) LArithmeticT(op, left, right); |
| 720 return MarkAsCall(DefineFixed(result, r0), instr); | 720 return MarkAsCall(DefineFixed(result, r0), instr); |
| 721 } | 721 } |
| 722 | 722 |
| 723 ASSERT(instr->representation().IsInteger32()); | 723 ASSERT(instr->representation().IsInteger32()); |
| 724 ASSERT(instr->left()->representation().IsInteger32()); | 724 ASSERT(instr->left()->representation().IsInteger32()); |
| 725 ASSERT(instr->right()->representation().IsInteger32()); | 725 ASSERT(instr->right()->representation().IsInteger32()); |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 773 | 773 |
| 774 LInstruction* LChunkBuilder::DoArithmeticT(Token::Value op, | 774 LInstruction* LChunkBuilder::DoArithmeticT(Token::Value op, |
| 775 HArithmeticBinaryOperation* instr) { | 775 HArithmeticBinaryOperation* instr) { |
| 776 ASSERT(op == Token::ADD || | 776 ASSERT(op == Token::ADD || |
| 777 op == Token::DIV || | 777 op == Token::DIV || |
| 778 op == Token::MOD || | 778 op == Token::MOD || |
| 779 op == Token::MUL || | 779 op == Token::MUL || |
| 780 op == Token::SUB); | 780 op == Token::SUB); |
| 781 HValue* left = instr->left(); | 781 HValue* left = instr->left(); |
| 782 HValue* right = instr->right(); | 782 HValue* right = instr->right(); |
| 783 ASSERT(left->representation().IsTagged()); | 783 ASSERT(left->representation().IsSmiOrTagged()); |
| 784 ASSERT(right->representation().IsTagged()); | 784 ASSERT(right->representation().IsSmiOrTagged()); |
| 785 LOperand* left_operand = UseFixed(left, r1); | 785 LOperand* left_operand = UseFixed(left, r1); |
| 786 LOperand* right_operand = UseFixed(right, r0); | 786 LOperand* right_operand = UseFixed(right, r0); |
| 787 LArithmeticT* result = | 787 LArithmeticT* result = |
| 788 new(zone()) LArithmeticT(op, left_operand, right_operand); | 788 new(zone()) LArithmeticT(op, left_operand, right_operand); |
| 789 return MarkAsCall(DefineFixed(result, r0), instr); | 789 return MarkAsCall(DefineFixed(result, r0), instr); |
| 790 } | 790 } |
| 791 | 791 |
| 792 | 792 |
| 793 void LChunkBuilder::DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block) { | 793 void LChunkBuilder::DoBasicBlock(HBasicBlock* block, HBasicBlock* next_block) { |
| 794 ASSERT(is_building()); | 794 ASSERT(is_building()); |
| (...skipping 501 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1296 | 1296 |
| 1297 LInstruction* LChunkBuilder::DoBitwise(HBitwise* instr) { | 1297 LInstruction* LChunkBuilder::DoBitwise(HBitwise* instr) { |
| 1298 if (instr->representation().IsInteger32()) { | 1298 if (instr->representation().IsInteger32()) { |
| 1299 ASSERT(instr->left()->representation().IsInteger32()); | 1299 ASSERT(instr->left()->representation().IsInteger32()); |
| 1300 ASSERT(instr->right()->representation().IsInteger32()); | 1300 ASSERT(instr->right()->representation().IsInteger32()); |
| 1301 | 1301 |
| 1302 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); | 1302 LOperand* left = UseRegisterAtStart(instr->BetterLeftOperand()); |
| 1303 LOperand* right = UseOrConstantAtStart(instr->BetterRightOperand()); | 1303 LOperand* right = UseOrConstantAtStart(instr->BetterRightOperand()); |
| 1304 return DefineAsRegister(new(zone()) LBitI(left, right)); | 1304 return DefineAsRegister(new(zone()) LBitI(left, right)); |
| 1305 } else { | 1305 } else { |
| 1306 ASSERT(instr->representation().IsTagged()); | 1306 ASSERT(instr->representation().IsSmiOrTagged()); |
| 1307 ASSERT(instr->left()->representation().IsTagged()); | 1307 ASSERT(instr->left()->representation().IsSmiOrTagged()); |
| 1308 ASSERT(instr->right()->representation().IsTagged()); | 1308 ASSERT(instr->right()->representation().IsSmiOrTagged()); |
| 1309 | 1309 |
| 1310 LOperand* left = UseFixed(instr->left(), r1); | 1310 LOperand* left = UseFixed(instr->left(), r1); |
| 1311 LOperand* right = UseFixed(instr->right(), r0); | 1311 LOperand* right = UseFixed(instr->right(), r0); |
| 1312 LArithmeticT* result = new(zone()) LArithmeticT(instr->op(), left, right); | 1312 LArithmeticT* result = new(zone()) LArithmeticT(instr->op(), left, right); |
| 1313 return MarkAsCall(DefineFixed(result, r0), instr); | 1313 return MarkAsCall(DefineFixed(result, r0), instr); |
| 1314 } | 1314 } |
| 1315 } | 1315 } |
| 1316 | 1316 |
| 1317 | 1317 |
| 1318 LInstruction* LChunkBuilder::DoBitNot(HBitNot* instr) { | 1318 LInstruction* LChunkBuilder::DoBitNot(HBitNot* instr) { |
| (...skipping 133 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1452 FixedTemp(d11)); | 1452 FixedTemp(d11)); |
| 1453 } | 1453 } |
| 1454 | 1454 |
| 1455 if (instr->CheckFlag(HValue::kBailoutOnMinusZero) || | 1455 if (instr->CheckFlag(HValue::kBailoutOnMinusZero) || |
| 1456 instr->CheckFlag(HValue::kCanBeDivByZero) || | 1456 instr->CheckFlag(HValue::kCanBeDivByZero) || |
| 1457 instr->CheckFlag(HValue::kCanOverflow)) { | 1457 instr->CheckFlag(HValue::kCanOverflow)) { |
| 1458 return AssignEnvironment(DefineAsRegister(mod)); | 1458 return AssignEnvironment(DefineAsRegister(mod)); |
| 1459 } else { | 1459 } else { |
| 1460 return DefineAsRegister(mod); | 1460 return DefineAsRegister(mod); |
| 1461 } | 1461 } |
| 1462 } else if (instr->representation().IsTagged()) { | 1462 } else if (instr->representation().IsSmiOrTagged()) { |
| 1463 return DoArithmeticT(Token::MOD, instr); | 1463 return DoArithmeticT(Token::MOD, instr); |
| 1464 } else { | 1464 } else { |
| 1465 ASSERT(instr->representation().IsDouble()); | 1465 ASSERT(instr->representation().IsDouble()); |
| 1466 // We call a C function for double modulo. It can't trigger a GC. | 1466 // We call a C function for double modulo. It can't trigger a GC. |
| 1467 // We need to use fixed result register for the call. | 1467 // We need to use fixed result register for the call. |
| 1468 // TODO(fschneider): Allow any register as input registers. | 1468 // TODO(fschneider): Allow any register as input registers. |
| 1469 LOperand* left = UseFixedDouble(instr->left(), d1); | 1469 LOperand* left = UseFixedDouble(instr->left(), d1); |
| 1470 LOperand* right = UseFixedDouble(instr->right(), d2); | 1470 LOperand* right = UseFixedDouble(instr->right(), d2); |
| 1471 LArithmeticD* result = new(zone()) LArithmeticD(Token::MOD, left, right); | 1471 LArithmeticD* result = new(zone()) LArithmeticD(Token::MOD, left, right); |
| 1472 return MarkAsCall(DefineFixedDouble(result, d1), instr); | 1472 return MarkAsCall(DefineFixedDouble(result, d1), instr); |
| (...skipping 137 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1610 return DoMultiplyAdd(HMul::cast(instr->left()), instr->right()); | 1610 return DoMultiplyAdd(HMul::cast(instr->left()), instr->right()); |
| 1611 } | 1611 } |
| 1612 | 1612 |
| 1613 if (instr->right()->IsMul()) { | 1613 if (instr->right()->IsMul()) { |
| 1614 ASSERT(!instr->left()->IsMul()); | 1614 ASSERT(!instr->left()->IsMul()); |
| 1615 return DoMultiplyAdd(HMul::cast(instr->right()), instr->left()); | 1615 return DoMultiplyAdd(HMul::cast(instr->right()), instr->left()); |
| 1616 } | 1616 } |
| 1617 | 1617 |
| 1618 return DoArithmeticD(Token::ADD, instr); | 1618 return DoArithmeticD(Token::ADD, instr); |
| 1619 } else { | 1619 } else { |
| 1620 ASSERT(instr->representation().IsTagged()); | 1620 ASSERT(instr->representation().IsSmiOrTagged()); |
| 1621 return DoArithmeticT(Token::ADD, instr); | 1621 return DoArithmeticT(Token::ADD, instr); |
| 1622 } | 1622 } |
| 1623 } | 1623 } |
| 1624 | 1624 |
| 1625 | 1625 |
| 1626 LInstruction* LChunkBuilder::DoMathMinMax(HMathMinMax* instr) { | 1626 LInstruction* LChunkBuilder::DoMathMinMax(HMathMinMax* instr) { |
| 1627 LOperand* left = NULL; | 1627 LOperand* left = NULL; |
| 1628 LOperand* right = NULL; | 1628 LOperand* right = NULL; |
| 1629 if (instr->representation().IsInteger32()) { | 1629 if (instr->representation().IsInteger32()) { |
| 1630 ASSERT(instr->left()->representation().IsInteger32()); | 1630 ASSERT(instr->left()->representation().IsInteger32()); |
| (...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1882 return NULL; | 1882 return NULL; |
| 1883 } | 1883 } |
| 1884 | 1884 |
| 1885 | 1885 |
| 1886 LInstruction* LChunkBuilder::DoChange(HChange* instr) { | 1886 LInstruction* LChunkBuilder::DoChange(HChange* instr) { |
| 1887 Representation from = instr->from(); | 1887 Representation from = instr->from(); |
| 1888 Representation to = instr->to(); | 1888 Representation to = instr->to(); |
| 1889 if (from.IsSmi()) { | 1889 if (from.IsSmi()) { |
| 1890 if (to.IsTagged()) { | 1890 if (to.IsTagged()) { |
| 1891 LOperand* value = UseRegister(instr->value()); | 1891 LOperand* value = UseRegister(instr->value()); |
| 1892 // For now, always deopt on hole. | |
| 1893 if (instr->value()->IsLoadKeyed() && | |
| 1894 HLoadKeyed::cast(instr->value())->UsesMustHandleHole()) { | |
| 1895 return AssignEnvironment( | |
| 1896 DefineSameAsFirst(new(zone()) LCheckSmiAndReturn(value))); | |
| 1897 } | |
| 1898 return DefineSameAsFirst(new(zone()) LDummyUse(value)); | 1892 return DefineSameAsFirst(new(zone()) LDummyUse(value)); |
| 1899 } | 1893 } |
| 1900 from = Representation::Tagged(); | 1894 from = Representation::Tagged(); |
| 1901 } | 1895 } |
| 1902 if (from.IsTagged()) { | 1896 if (from.IsTagged()) { |
| 1903 if (to.IsDouble()) { | 1897 if (to.IsDouble()) { |
| 1904 info()->MarkAsDeferredCalling(); | 1898 info()->MarkAsDeferredCalling(); |
| 1905 LOperand* value = UseRegister(instr->value()); | 1899 LOperand* value = UseRegister(instr->value()); |
| 1906 LNumberUntagD* res = new(zone()) LNumberUntagD(value); | 1900 LNumberUntagD* res = new(zone()) LNumberUntagD(value); |
| 1907 return AssignEnvironment(DefineAsRegister(res)); | 1901 return AssignEnvironment(DefineAsRegister(res)); |
| 1908 } else if (to.IsSmi()) { | 1902 } else if (to.IsSmi()) { |
| 1909 HValue* val = instr->value(); | 1903 HValue* val = instr->value(); |
| 1910 LOperand* value = UseRegister(val); | 1904 LOperand* value = UseRegister(val); |
| 1911 if (val->type().IsSmi()) { | 1905 if (val->type().IsSmi()) { |
| 1912 return DefineSameAsFirst(new(zone()) LDummyUse(value)); | 1906 return DefineSameAsFirst(new(zone()) LDummyUse(value)); |
| 1913 } | 1907 } |
| 1914 return AssignEnvironment( | 1908 return AssignEnvironment( |
| 1915 DefineSameAsFirst(new(zone()) LCheckSmiAndReturn(value))); | 1909 DefineSameAsFirst(new(zone()) LCheckSmiAndReturn(value))); |
| 1916 } else { | 1910 } else { |
| 1917 ASSERT(to.IsInteger32()); | 1911 ASSERT(to.IsInteger32()); |
| 1918 LOperand* value = NULL; | 1912 LOperand* value = NULL; |
| 1919 LInstruction* res = NULL; | 1913 LInstruction* res = NULL; |
| 1920 if (instr->value()->type().IsSmi()) { | 1914 if (instr->value()->type().IsSmi()) { |
| 1921 value = UseRegisterAtStart(instr->value()); | 1915 value = UseRegisterAtStart(instr->value()); |
| 1922 res = DefineAsRegister(new(zone()) LSmiUntag(value, false)); | 1916 res = DefineAsRegister(new(zone()) LSmiUntag(value, false)); |
| 1923 if (instr->value()->IsLoadKeyed()) { | |
| 1924 HLoadKeyed* load_keyed = HLoadKeyed::cast(instr->value()); | |
| 1925 if (load_keyed->UsesMustHandleHole() && | |
| 1926 load_keyed->hole_mode() == NEVER_RETURN_HOLE) { | |
| 1927 res = AssignEnvironment(res); | |
| 1928 } | |
| 1929 } | |
| 1930 } else { | 1917 } else { |
| 1931 value = UseRegister(instr->value()); | 1918 value = UseRegister(instr->value()); |
| 1932 LOperand* temp1 = TempRegister(); | 1919 LOperand* temp1 = TempRegister(); |
| 1933 LOperand* temp2 = instr->CanTruncateToInt32() ? TempRegister() | 1920 LOperand* temp2 = instr->CanTruncateToInt32() ? TempRegister() |
| 1934 : NULL; | 1921 : NULL; |
| 1935 LOperand* temp3 = FixedTemp(d11); | 1922 LOperand* temp3 = FixedTemp(d11); |
| 1936 res = DefineSameAsFirst(new(zone()) LTaggedToI(value, | 1923 res = DefineSameAsFirst(new(zone()) LTaggedToI(value, |
| 1937 temp1, | 1924 temp1, |
| 1938 temp2, | 1925 temp2, |
| 1939 temp3)); | 1926 temp3)); |
| (...skipping 702 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2642 | 2629 |
| 2643 | 2630 |
| 2644 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { | 2631 LInstruction* LChunkBuilder::DoLoadFieldByIndex(HLoadFieldByIndex* instr) { |
| 2645 LOperand* object = UseRegister(instr->object()); | 2632 LOperand* object = UseRegister(instr->object()); |
| 2646 LOperand* index = UseRegister(instr->index()); | 2633 LOperand* index = UseRegister(instr->index()); |
| 2647 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); | 2634 return DefineAsRegister(new(zone()) LLoadFieldByIndex(object, index)); |
| 2648 } | 2635 } |
| 2649 | 2636 |
| 2650 | 2637 |
| 2651 } } // namespace v8::internal | 2638 } } // namespace v8::internal |
| OLD | NEW |