| OLD | NEW |
| 1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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 1835 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 1846 | 1846 |
| 1847 } else if (hmod->representation().IsSmiOrTagged()) { | 1847 } else if (hmod->representation().IsSmiOrTagged()) { |
| 1848 return DoArithmeticT(Token::MOD, hmod); | 1848 return DoArithmeticT(Token::MOD, hmod); |
| 1849 } else { | 1849 } else { |
| 1850 return DoArithmeticD(Token::MOD, hmod); | 1850 return DoArithmeticD(Token::MOD, hmod); |
| 1851 } | 1851 } |
| 1852 } | 1852 } |
| 1853 | 1853 |
| 1854 | 1854 |
| 1855 LInstruction* LChunkBuilder::DoMul(HMul* instr) { | 1855 LInstruction* LChunkBuilder::DoMul(HMul* instr) { |
| 1856 if (instr->representation().IsSmi()) { | 1856 if (instr->representation().IsSmiOrInteger32()) { |
| 1857 // TODO(jbramley): Implement LMulConstS, then merge this into the Integer32 | |
| 1858 // case. | |
| 1859 ASSERT(instr->left()->representation().Equals(instr->representation())); | 1857 ASSERT(instr->left()->representation().Equals(instr->representation())); |
| 1860 ASSERT(instr->right()->representation().Equals(instr->representation())); | 1858 ASSERT(instr->right()->representation().Equals(instr->representation())); |
| 1861 | 1859 |
| 1862 bool can_overflow = instr->CheckFlag(HValue::kCanOverflow); | |
| 1863 bool bailout_on_minus_zero = instr->CheckFlag(HValue::kBailoutOnMinusZero); | |
| 1864 bool needs_environment = can_overflow || bailout_on_minus_zero; | |
| 1865 | |
| 1866 LOperand* left = UseRegister(instr->BetterLeftOperand()); | |
| 1867 LOperand* right = UseRegister(instr->BetterRightOperand()); | |
| 1868 | |
| 1869 LMulS* mul = new(zone()) LMulS(left, right); | |
| 1870 if (needs_environment) AssignEnvironment(mul); | |
| 1871 return DefineAsRegister(mul); | |
| 1872 } else if (instr->representation().IsSmiOrInteger32()) { | |
| 1873 ASSERT(instr->left()->representation().Equals(instr->representation())); | |
| 1874 ASSERT(instr->right()->representation().Equals(instr->representation())); | |
| 1875 | |
| 1876 bool can_overflow = instr->CheckFlag(HValue::kCanOverflow); | 1860 bool can_overflow = instr->CheckFlag(HValue::kCanOverflow); |
| 1877 bool bailout_on_minus_zero = instr->CheckFlag(HValue::kBailoutOnMinusZero); | 1861 bool bailout_on_minus_zero = instr->CheckFlag(HValue::kBailoutOnMinusZero); |
| 1878 bool needs_environment = can_overflow || bailout_on_minus_zero; | 1862 bool needs_environment = can_overflow || bailout_on_minus_zero; |
| 1879 | 1863 |
| 1880 HValue* least_const = instr->BetterLeftOperand(); | 1864 HValue* least_const = instr->BetterLeftOperand(); |
| 1881 HValue* most_const = instr->BetterRightOperand(); | 1865 HValue* most_const = instr->BetterRightOperand(); |
| 1882 | 1866 |
| 1883 LOperand* left = UseRegisterAtStart(least_const); | 1867 LOperand* left = UseRegisterAtStart(least_const); |
| 1884 | 1868 |
| 1885 // LMulConstI can handle a subset of constants: | 1869 // LMulConstI can handle a subset of constants: |
| (...skipping 10 matching lines...) Expand all Loading... |
| 1896 (!can_overflow && (IsPowerOf2(constant_abs) || | 1880 (!can_overflow && (IsPowerOf2(constant_abs) || |
| 1897 IsPowerOf2(constant_abs + 1) || | 1881 IsPowerOf2(constant_abs + 1) || |
| 1898 IsPowerOf2(constant_abs - 1)))) { | 1882 IsPowerOf2(constant_abs - 1)))) { |
| 1899 LConstantOperand* right = UseConstant(most_const); | 1883 LConstantOperand* right = UseConstant(most_const); |
| 1900 LMulConstI* mul = new(zone()) LMulConstI(left, right); | 1884 LMulConstI* mul = new(zone()) LMulConstI(left, right); |
| 1901 if (needs_environment) AssignEnvironment(mul); | 1885 if (needs_environment) AssignEnvironment(mul); |
| 1902 return DefineAsRegister(mul); | 1886 return DefineAsRegister(mul); |
| 1903 } | 1887 } |
| 1904 } | 1888 } |
| 1905 | 1889 |
| 1906 // LMulI can handle all cases, but it requires that a register is allocated | 1890 // LMulI/S can handle all cases, but it requires that a register is |
| 1907 // for the second operand. | 1891 // allocated for the second operand. |
| 1908 LOperand* right = UseRegisterAtStart(most_const); | 1892 LInstruction* result; |
| 1909 LMulI* mul = new(zone()) LMulI(left, right); | 1893 if (instr->representation().IsSmi()) { |
| 1910 if (needs_environment) AssignEnvironment(mul); | 1894 // TODO(jbramley/rmcilroy): Fix LMulS so we can UseRegisterAtStart here. |
| 1911 return DefineAsRegister(mul); | 1895 LOperand* right = UseRegister(most_const); |
| 1896 result = DefineAsRegister(new(zone()) LMulS(left, right)); |
| 1897 } else { |
| 1898 LOperand* right = UseRegisterAtStart(most_const); |
| 1899 result = DefineAsRegister(new(zone()) LMulI(left, right)); |
| 1900 } |
| 1901 if (needs_environment) AssignEnvironment(result); |
| 1902 return result; |
| 1912 } else if (instr->representation().IsDouble()) { | 1903 } else if (instr->representation().IsDouble()) { |
| 1913 return DoArithmeticD(Token::MUL, instr); | 1904 return DoArithmeticD(Token::MUL, instr); |
| 1914 } else { | 1905 } else { |
| 1915 return DoArithmeticT(Token::MUL, instr); | 1906 return DoArithmeticT(Token::MUL, instr); |
| 1916 } | 1907 } |
| 1917 } | 1908 } |
| 1918 | 1909 |
| 1919 | 1910 |
| 1920 LInstruction* LChunkBuilder::DoOsrEntry(HOsrEntry* instr) { | 1911 LInstruction* LChunkBuilder::DoOsrEntry(HOsrEntry* instr) { |
| 1921 ASSERT(argument_count_ == 0); | 1912 ASSERT(argument_count_ == 0); |
| (...skipping 614 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 2536 LInstruction* LChunkBuilder::DoWrapReceiver(HWrapReceiver* instr) { | 2527 LInstruction* LChunkBuilder::DoWrapReceiver(HWrapReceiver* instr) { |
| 2537 LOperand* receiver = UseRegister(instr->receiver()); | 2528 LOperand* receiver = UseRegister(instr->receiver()); |
| 2538 LOperand* function = UseRegisterAtStart(instr->function()); | 2529 LOperand* function = UseRegisterAtStart(instr->function()); |
| 2539 LOperand* temp = TempRegister(); | 2530 LOperand* temp = TempRegister(); |
| 2540 LWrapReceiver* result = new(zone()) LWrapReceiver(receiver, function, temp); | 2531 LWrapReceiver* result = new(zone()) LWrapReceiver(receiver, function, temp); |
| 2541 return AssignEnvironment(DefineAsRegister(result)); | 2532 return AssignEnvironment(DefineAsRegister(result)); |
| 2542 } | 2533 } |
| 2543 | 2534 |
| 2544 | 2535 |
| 2545 } } // namespace v8::internal | 2536 } } // namespace v8::internal |
| OLD | NEW |