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 |
(...skipping 1280 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1291 } | 1291 } |
1292 | 1292 |
1293 | 1293 |
1294 void LCodeGen::DoFlooringDivByPowerOf2I(LFlooringDivByPowerOf2I* instr) { | 1294 void LCodeGen::DoFlooringDivByPowerOf2I(LFlooringDivByPowerOf2I* instr) { |
1295 Register dividend = ToRegister(instr->dividend()); | 1295 Register dividend = ToRegister(instr->dividend()); |
1296 Register result = ToRegister(instr->result()); | 1296 Register result = ToRegister(instr->result()); |
1297 int32_t divisor = instr->divisor(); | 1297 int32_t divisor = instr->divisor(); |
1298 Register scratch = scratch0(); | 1298 Register scratch = scratch0(); |
1299 ASSERT(!scratch.is(dividend)); | 1299 ASSERT(!scratch.is(dividend)); |
1300 | 1300 |
| 1301 // If the divisor is 1, return the dividend. |
| 1302 if (divisor == 1) { |
| 1303 __ Move(result, dividend); |
| 1304 return; |
| 1305 } |
| 1306 |
1301 // If the divisor is positive, things are easy: There can be no deopts and we | 1307 // If the divisor is positive, things are easy: There can be no deopts and we |
1302 // can simply do an arithmetic right shift. | 1308 // can simply do an arithmetic right shift. |
1303 if (divisor == 1) return; | |
1304 uint16_t shift = WhichPowerOf2Abs(divisor); | 1309 uint16_t shift = WhichPowerOf2Abs(divisor); |
1305 if (divisor > 1) { | 1310 if (divisor > 1) { |
1306 __ sra(result, dividend, shift); | 1311 __ sra(result, dividend, shift); |
1307 return; | 1312 return; |
1308 } | 1313 } |
1309 | 1314 |
1310 // If the divisor is negative, we have to negate and handle edge cases. | 1315 // If the divisor is negative, we have to negate and handle edge cases. |
1311 if (instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) { | 1316 if (instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) { |
1312 __ Move(scratch, dividend); | 1317 __ Move(scratch, dividend); |
1313 } | 1318 } |
(...skipping 4600 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5914 __ lw(result, FieldMemOperand(scratch, | 5919 __ lw(result, FieldMemOperand(scratch, |
5915 FixedArray::kHeaderSize - kPointerSize)); | 5920 FixedArray::kHeaderSize - kPointerSize)); |
5916 __ bind(deferred->exit()); | 5921 __ bind(deferred->exit()); |
5917 __ bind(&done); | 5922 __ bind(&done); |
5918 } | 5923 } |
5919 | 5924 |
5920 | 5925 |
5921 #undef __ | 5926 #undef __ |
5922 | 5927 |
5923 } } // namespace v8::internal | 5928 } } // namespace v8::internal |
OLD | NEW |