OLD | NEW |
1 // Copyright 2013 the V8 project authors. All rights reserved. | 1 // Copyright 2013 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_X64 | 7 #if V8_TARGET_ARCH_X64 |
8 | 8 |
9 #include "src/x64/lithium-codegen-x64.h" | 9 #include "src/x64/lithium-codegen-x64.h" |
10 #include "src/code-stubs.h" | 10 #include "src/code-stubs.h" |
(...skipping 1116 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
1127 __ sarl(dividend, Immediate(shift)); | 1127 __ sarl(dividend, Immediate(shift)); |
1128 return; | 1128 return; |
1129 } | 1129 } |
1130 | 1130 |
1131 // If the divisor is negative, we have to negate and handle edge cases. | 1131 // If the divisor is negative, we have to negate and handle edge cases. |
1132 __ negl(dividend); | 1132 __ negl(dividend); |
1133 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { | 1133 if (instr->hydrogen()->CheckFlag(HValue::kBailoutOnMinusZero)) { |
1134 DeoptimizeIf(zero, instr->environment()); | 1134 DeoptimizeIf(zero, instr->environment()); |
1135 } | 1135 } |
1136 | 1136 |
| 1137 // Dividing by -1 is basically negation, unless we overflow. |
| 1138 if (divisor == -1) { |
| 1139 if (instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) { |
| 1140 DeoptimizeIf(overflow, instr->environment()); |
| 1141 } |
| 1142 return; |
| 1143 } |
| 1144 |
1137 // If the negation could not overflow, simply shifting is OK. | 1145 // If the negation could not overflow, simply shifting is OK. |
1138 if (!instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) { | 1146 if (!instr->hydrogen()->CheckFlag(HValue::kLeftCanBeMinInt)) { |
1139 __ sarl(dividend, Immediate(shift)); | 1147 __ sarl(dividend, Immediate(shift)); |
1140 return; | 1148 return; |
1141 } | 1149 } |
1142 | 1150 |
1143 // Note that we could emit branch-free code, but that would need one more | |
1144 // register. | |
1145 if (divisor == -1) { | |
1146 DeoptimizeIf(overflow, instr->environment()); | |
1147 return; | |
1148 } | |
1149 | |
1150 Label not_kmin_int, done; | 1151 Label not_kmin_int, done; |
1151 __ j(no_overflow, ¬_kmin_int, Label::kNear); | 1152 __ j(no_overflow, ¬_kmin_int, Label::kNear); |
1152 __ movl(dividend, Immediate(kMinInt / divisor)); | 1153 __ movl(dividend, Immediate(kMinInt / divisor)); |
1153 __ jmp(&done, Label::kNear); | 1154 __ jmp(&done, Label::kNear); |
1154 __ bind(¬_kmin_int); | 1155 __ bind(¬_kmin_int); |
1155 __ sarl(dividend, Immediate(shift)); | 1156 __ sarl(dividend, Immediate(shift)); |
1156 __ bind(&done); | 1157 __ bind(&done); |
1157 } | 1158 } |
1158 | 1159 |
1159 | 1160 |
(...skipping 4577 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
5737 CallRuntime(Runtime::kHiddenPushBlockContext, 2, instr); | 5738 CallRuntime(Runtime::kHiddenPushBlockContext, 2, instr); |
5738 RecordSafepoint(Safepoint::kNoLazyDeopt); | 5739 RecordSafepoint(Safepoint::kNoLazyDeopt); |
5739 } | 5740 } |
5740 | 5741 |
5741 | 5742 |
5742 #undef __ | 5743 #undef __ |
5743 | 5744 |
5744 } } // namespace v8::internal | 5745 } } // namespace v8::internal |
5745 | 5746 |
5746 #endif // V8_TARGET_ARCH_X64 | 5747 #endif // V8_TARGET_ARCH_X64 |
OLD | NEW |