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