| OLD | NEW | 
|---|
| 1 // Copyright 2012 the V8 project authors. All rights reserved.7 | 1 // Copyright 2012 the V8 project authors. All rights reserved.7 | 
| 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 "src/v8.h" | 28 #include "src/v8.h" | 
| 29 | 29 | 
|  | 30 #include "src/base/bits.h" | 
| 30 #include "src/code-stubs.h" | 31 #include "src/code-stubs.h" | 
| 31 #include "src/hydrogen-osr.h" | 32 #include "src/hydrogen-osr.h" | 
| 32 #include "src/mips/lithium-codegen-mips.h" | 33 #include "src/mips/lithium-codegen-mips.h" | 
| 33 #include "src/mips/lithium-gap-resolver-mips.h" | 34 #include "src/mips/lithium-gap-resolver-mips.h" | 
| 34 | 35 | 
| 35 | 36 | 
| 36 namespace v8 { | 37 namespace v8 { | 
| 37 namespace internal { | 38 namespace internal { | 
| 38 | 39 | 
| 39 | 40 | 
| (...skipping 1154 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1194     DeoptimizeIf(eq, instr->environment(), result_reg, Operand(zero_reg)); | 1195     DeoptimizeIf(eq, instr->environment(), result_reg, Operand(zero_reg)); | 
| 1195   } | 1196   } | 
| 1196   __ bind(&done); | 1197   __ bind(&done); | 
| 1197 } | 1198 } | 
| 1198 | 1199 | 
| 1199 | 1200 | 
| 1200 void LCodeGen::DoDivByPowerOf2I(LDivByPowerOf2I* instr) { | 1201 void LCodeGen::DoDivByPowerOf2I(LDivByPowerOf2I* instr) { | 
| 1201   Register dividend = ToRegister(instr->dividend()); | 1202   Register dividend = ToRegister(instr->dividend()); | 
| 1202   int32_t divisor = instr->divisor(); | 1203   int32_t divisor = instr->divisor(); | 
| 1203   Register result = ToRegister(instr->result()); | 1204   Register result = ToRegister(instr->result()); | 
| 1204   DCHECK(divisor == kMinInt || IsPowerOf2(Abs(divisor))); | 1205   DCHECK(divisor == kMinInt || base::bits::IsPowerOfTwo32(Abs(divisor))); | 
| 1205   DCHECK(!result.is(dividend)); | 1206   DCHECK(!result.is(dividend)); | 
| 1206 | 1207 | 
| 1207   // Check for (0 / -x) that will produce negative zero. | 1208   // Check for (0 / -x) that will produce negative zero. | 
| 1208   HDiv* hdiv = instr->hydrogen(); | 1209   HDiv* hdiv = instr->hydrogen(); | 
| 1209   if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) { | 1210   if (hdiv->CheckFlag(HValue::kBailoutOnMinusZero) && divisor < 0) { | 
| 1210     DeoptimizeIf(eq, instr->environment(), dividend, Operand(zero_reg)); | 1211     DeoptimizeIf(eq, instr->environment(), dividend, Operand(zero_reg)); | 
| 1211   } | 1212   } | 
| 1212   // Check for (kMinInt / -1). | 1213   // Check for (kMinInt / -1). | 
| 1213   if (hdiv->CheckFlag(HValue::kCanOverflow) && divisor == -1) { | 1214   if (hdiv->CheckFlag(HValue::kCanOverflow) && divisor == -1) { | 
| 1214     DeoptimizeIf(eq, instr->environment(), dividend, Operand(kMinInt)); | 1215     DeoptimizeIf(eq, instr->environment(), dividend, Operand(kMinInt)); | 
| (...skipping 292 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 1507         // Nothing to do. | 1508         // Nothing to do. | 
| 1508         __ Move(result, left); | 1509         __ Move(result, left); | 
| 1509         break; | 1510         break; | 
| 1510       default: | 1511       default: | 
| 1511         // Multiplying by powers of two and powers of two plus or minus | 1512         // Multiplying by powers of two and powers of two plus or minus | 
| 1512         // one can be done faster with shifted operands. | 1513         // one can be done faster with shifted operands. | 
| 1513         // For other constants we emit standard code. | 1514         // For other constants we emit standard code. | 
| 1514         int32_t mask = constant >> 31; | 1515         int32_t mask = constant >> 31; | 
| 1515         uint32_t constant_abs = (constant + mask) ^ mask; | 1516         uint32_t constant_abs = (constant + mask) ^ mask; | 
| 1516 | 1517 | 
| 1517         if (IsPowerOf2(constant_abs)) { | 1518         if (base::bits::IsPowerOfTwo32(constant_abs)) { | 
| 1518           int32_t shift = WhichPowerOf2(constant_abs); | 1519           int32_t shift = WhichPowerOf2(constant_abs); | 
| 1519           __ sll(result, left, shift); | 1520           __ sll(result, left, shift); | 
| 1520           // Correct the sign of the result if the constant is negative. | 1521           // Correct the sign of the result if the constant is negative. | 
| 1521           if (constant < 0)  __ Subu(result, zero_reg, result); | 1522           if (constant < 0)  __ Subu(result, zero_reg, result); | 
| 1522         } else if (IsPowerOf2(constant_abs - 1)) { | 1523         } else if (base::bits::IsPowerOfTwo32(constant_abs - 1)) { | 
| 1523           int32_t shift = WhichPowerOf2(constant_abs - 1); | 1524           int32_t shift = WhichPowerOf2(constant_abs - 1); | 
| 1524           __ sll(scratch, left, shift); | 1525           __ sll(scratch, left, shift); | 
| 1525           __ Addu(result, scratch, left); | 1526           __ Addu(result, scratch, left); | 
| 1526           // Correct the sign of the result if the constant is negative. | 1527           // Correct the sign of the result if the constant is negative. | 
| 1527           if (constant < 0)  __ Subu(result, zero_reg, result); | 1528           if (constant < 0)  __ Subu(result, zero_reg, result); | 
| 1528         } else if (IsPowerOf2(constant_abs + 1)) { | 1529         } else if (base::bits::IsPowerOfTwo32(constant_abs + 1)) { | 
| 1529           int32_t shift = WhichPowerOf2(constant_abs + 1); | 1530           int32_t shift = WhichPowerOf2(constant_abs + 1); | 
| 1530           __ sll(scratch, left, shift); | 1531           __ sll(scratch, left, shift); | 
| 1531           __ Subu(result, scratch, left); | 1532           __ Subu(result, scratch, left); | 
| 1532           // Correct the sign of the result if the constant is negative. | 1533           // Correct the sign of the result if the constant is negative. | 
| 1533           if (constant < 0)  __ Subu(result, zero_reg, result); | 1534           if (constant < 0)  __ Subu(result, zero_reg, result); | 
| 1534         } else { | 1535         } else { | 
| 1535           // Generate standard code. | 1536           // Generate standard code. | 
| 1536           __ li(at, constant); | 1537           __ li(at, constant); | 
| 1537           __ Mul(result, left, at); | 1538           __ Mul(result, left, at); | 
| 1538         } | 1539         } | 
| (...skipping 3554 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 5093       // Omit check for the last type. | 5094       // Omit check for the last type. | 
| 5094       if (last != LAST_TYPE) { | 5095       if (last != LAST_TYPE) { | 
| 5095         DeoptimizeIf(hi, instr->environment(), scratch, Operand(last)); | 5096         DeoptimizeIf(hi, instr->environment(), scratch, Operand(last)); | 
| 5096       } | 5097       } | 
| 5097     } | 5098     } | 
| 5098   } else { | 5099   } else { | 
| 5099     uint8_t mask; | 5100     uint8_t mask; | 
| 5100     uint8_t tag; | 5101     uint8_t tag; | 
| 5101     instr->hydrogen()->GetCheckMaskAndTag(&mask, &tag); | 5102     instr->hydrogen()->GetCheckMaskAndTag(&mask, &tag); | 
| 5102 | 5103 | 
| 5103     if (IsPowerOf2(mask)) { | 5104     if (base::bits::IsPowerOfTwo32(mask)) { | 
| 5104       DCHECK(tag == 0 || IsPowerOf2(tag)); | 5105       DCHECK(tag == 0 || base::bits::IsPowerOfTwo32(tag)); | 
| 5105       __ And(at, scratch, mask); | 5106       __ And(at, scratch, mask); | 
| 5106       DeoptimizeIf(tag == 0 ? ne : eq, instr->environment(), | 5107       DeoptimizeIf(tag == 0 ? ne : eq, instr->environment(), | 
| 5107           at, Operand(zero_reg)); | 5108           at, Operand(zero_reg)); | 
| 5108     } else { | 5109     } else { | 
| 5109       __ And(scratch, scratch, Operand(mask)); | 5110       __ And(scratch, scratch, Operand(mask)); | 
| 5110       DeoptimizeIf(ne, instr->environment(), scratch, Operand(tag)); | 5111       DeoptimizeIf(ne, instr->environment(), scratch, Operand(tag)); | 
| 5111     } | 5112     } | 
| 5112   } | 5113   } | 
| 5113 } | 5114 } | 
| 5114 | 5115 | 
| (...skipping 782 matching lines...) Expand 10 before | Expand all | Expand 10 after  Loading... | 
| 5897   __ li(at, scope_info); | 5898   __ li(at, scope_info); | 
| 5898   __ Push(at, ToRegister(instr->function())); | 5899   __ Push(at, ToRegister(instr->function())); | 
| 5899   CallRuntime(Runtime::kPushBlockContext, 2, instr); | 5900   CallRuntime(Runtime::kPushBlockContext, 2, instr); | 
| 5900   RecordSafepoint(Safepoint::kNoLazyDeopt); | 5901   RecordSafepoint(Safepoint::kNoLazyDeopt); | 
| 5901 } | 5902 } | 
| 5902 | 5903 | 
| 5903 | 5904 | 
| 5904 #undef __ | 5905 #undef __ | 
| 5905 | 5906 | 
| 5906 } }  // namespace v8::internal | 5907 } }  // namespace v8::internal | 
| OLD | NEW | 
|---|