OLD | NEW |
1 // Copyright 2012 the V8 project authors. All rights reserved. | 1 // Copyright 2012 the V8 project authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
4 | 4 |
5 #include "src/v8.h" | 5 #include "src/v8.h" |
6 | 6 |
7 #if V8_TARGET_ARCH_IA32 | 7 #if V8_TARGET_ARCH_IA32 |
8 | 8 |
9 #include "src/ia32/lithium-codegen-ia32.h" | 9 #include "src/ia32/lithium-codegen-ia32.h" |
10 #include "src/ic.h" | 10 #include "src/ic.h" |
(...skipping 1335 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1346 __ sar(dividend, shift); | 1346 __ sar(dividend, shift); |
1347 return; | 1347 return; |
1348 } | 1348 } |
1349 | 1349 |
1350 // If the divisor is negative, we have to negate and handle edge cases. | 1350 // If the divisor is negative, we have to negate and handle edge cases. |
1351 __ neg(dividend); | 1351 __ neg(dividend); |
1352 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 1352 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
1353 DeoptimizeIf(zero, instr->environment()); | 1353 DeoptimizeIf(zero, instr->environment()); |
1354 } | 1354 } |
1355 | 1355 |
| 1356 // Dividing by -1 is basically negation, unless we overflow. |
| 1357 if (divisor == -1) { |
| 1358 if (instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) { |
| 1359 DeoptimizeIf(overflow, instr->environment()); |
| 1360 } |
| 1361 return; |
| 1362 } |
| 1363 |
| 1364 // If the negation could not overflow, simply shifting is OK. |
1356 if (!instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) { | 1365 if (!instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) { |
1357 __ sar(dividend, shift); | 1366 __ sar(dividend, shift); |
1358 return; | 1367 return; |
1359 } | 1368 } |
1360 | 1369 |
1361 // Dividing by -1 is basically negation, unless we overflow. | |
1362 if (divisor == -1) { | |
1363 DeoptimizeIf(overflow, instr->environment()); | |
1364 return; | |
1365 } | |
1366 | |
1367 Label not_kmin_int, done; | 1370 Label not_kmin_int, done; |
1368 __ j(no_overflow, ¬_kmin_int, Label::kNear); | 1371 __ j(no_overflow, ¬_kmin_int, Label::kNear); |
1369 __ mov(dividend, Immediate(kMinInt / divisor)); | 1372 __ mov(dividend, Immediate(kMinInt / divisor)); |
1370 __ jmp(&done, Label::kNear); | 1373 __ jmp(&done, Label::kNear); |
1371 __ bind(¬_kmin_int); | 1374 __ bind(¬_kmin_int); |
1372 __ sar(dividend, shift); | 1375 __ sar(dividend, shift); |
1373 __ bind(&done); | 1376 __ bind(&done); |
1374 } | 1377 } |
1375 | 1378 |
1376 | 1379 |
(...skipping 4282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5659 CallRuntime(Runtime::kHiddenPushBlockContext, 2, instr); | 5662 CallRuntime(Runtime::kHiddenPushBlockContext, 2, instr); |
5660 RecordSafepoint(Safepoint::kNoLazyDeopt); | 5663 RecordSafepoint(Safepoint::kNoLazyDeopt); |
5661 } | 5664 } |
5662 | 5665 |
5663 | 5666 |
5664 #undef __ | 5667 #undef __ |
5665 | 5668 |
5666 } } // namespace v8::internal | 5669 } } // namespace v8::internal |
5667 | 5670 |
5668 #endif // V8_TARGET_ARCH_IA32 | 5671 #endif // V8_TARGET_ARCH_IA32 |
OLD | NEW |